MainService.cpp   MainService.cpp 
skipping to change at line 38 skipping to change at line 38
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelPropertyMgr.hpp" #include "StelPropertyMgr.hpp"
#include "StelScriptMgr.hpp" #include "StelScriptMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
MainService::MainService(const QByteArray &serviceName, QObject *parent) MainService::MainService(const QByteArray &serviceName, QObject *parent)
: AbstractAPIService(serviceName,parent), : AbstractAPIService(serviceName,parent),
moveX(0),moveY(0),lastMoveUpdateTime(0) moveX(0),moveY(0),lastMoveUpdateTime(0),
//100 should be more than enough
//this only has to emcompass events that occur between 2 status up
dates
actionCache(100), propCache(100)
{ {
//100 should be more than enough
//this only has to emcompass events that occur between 2 status upda
tes
actionCache.setCapacity(100);
propCache.setCapacity(100);
//this is run in the main thread //this is run in the main thread
core = StelApp::getInstance().getCore(); core = StelApp::getInstance().getCore();
actionMgr = StelApp::getInstance().getStelActionManager(); actionMgr = StelApp::getInstance().getStelActionManager();
lsMgr = GETSTELMODULE(LandscapeMgr); lsMgr = GETSTELMODULE(LandscapeMgr);
localeMgr = &StelApp::getInstance().getLocaleMgr(); localeMgr = &StelApp::getInstance().getLocaleMgr();
objMgr = &StelApp::getInstance().getStelObjectMgr(); objMgr = &StelApp::getInstance().getStelObjectMgr();
mvmgr = GETSTELMODULE(StelMovementMgr); mvmgr = GETSTELMODULE(StelMovementMgr);
propMgr = StelApp::getInstance().getStelPropertyManager(); propMgr = StelApp::getInstance().getStelPropertyManager();
scriptMgr = &StelApp::getInstance().getScriptMgr(); scriptMgr = &StelApp::getInstance().getScriptMgr();
skyCulMgr = &StelApp::getInstance().getSkyCultureMgr(); skyCulMgr = &StelApp::getInstance().getSkyCultureMgr();
skipping to change at line 372 skipping to change at line 372
Q_ARG(float,x), Q_ARG(float,x),
Q_ARG(float,y), Q_ARG(float,y),
Q_ARG(bool,xOk), Q_ARG(bool,xOk),
Q_ARG(bool,yOk)); Q_ARG(bool,yOk));
response.setData("ok"); response.setData("ok");
} }
else else
response.writeRequestError("requires x or y paramete r"); response.writeRequestError("requires x or y paramete r");
} }
else if(operation == "view")
{
QString azs = QString::fromUtf8(parameters.value("az"));
QString alts = QString::fromUtf8(parameters.value("alt"));
bool azOk,altOk;
double az = azs.toDouble(&azOk);
double alt = alts.toDouble(&altOk);
if(azOk || altOk)
{
QMetaObject::invokeMethod(this,"updateView", SERVICE
_DEFAULT_INVOKETYPE,
Q_ARG(double,az),
Q_ARG(double,alt),
Q_ARG(bool,azOk),
Q_ARG(bool,altOk));
response.setData("ok");
}
else
response.writeRequestError("requires x or y paramete
r");
}
else if (operation == "fov") else if (operation == "fov")
{ {
QString fov = QString::fromUtf8(parameters.value("fov")); QString fov = QString::fromUtf8(parameters.value("fov"));
bool ok; bool ok;
double dFov = fov.toDouble(&ok); double dFov = fov.toDouble(&ok);
if(fov.isEmpty() || !ok) if(fov.isEmpty() || !ok)
{ {
response.writeRequestError("requires fov parameter") ; response.writeRequestError("requires fov parameter") ;
return; return;
skipping to change at line 466 skipping to change at line 489
} }
if(yUpdated) if(yUpdated)
{ {
this->moveY = y; this->moveY = y;
} }
qint64 curTime = QDateTime::currentMSecsSinceEpoch(); qint64 curTime = QDateTime::currentMSecsSinceEpoch();
//qDebug()<<"updateMove"<<x<<y<<(curTime-lastMoveUpdateTime); //qDebug()<<"updateMove"<<x<<y<<(curTime-lastMoveUpdateTime);
lastMoveUpdateTime = curTime; lastMoveUpdateTime = curTime;
} }
void MainService::updateView(double az, double alt, bool azUpdated, bool al
tUpdated)
{
Vec3d viewDirJ2000=mvmgr->getViewDirectionJ2000();
Vec3d viewDirAltAz=core->j2000ToAltAz(viewDirJ2000, StelCore::Refrac
tionOff);
double anAz, anAlt;
StelUtils::rectToSphe(&anAz, &anAlt, viewDirAltAz);
if (azUpdated)
{
anAz=az;
}
if (altUpdated)
{
anAlt=alt;
}
StelUtils::spheToRect(anAz, anAlt, viewDirAltAz);
mvmgr->setViewDirectionJ2000(core->altAzToJ2000(viewDirAltAz, StelCo
re::RefractionOff));
}
void MainService::setFov(double fov) void MainService::setFov(double fov)
{ {
//TODO calculate a better move duration here //TODO calculate a better move duration here
mvmgr->zoomTo(fov,0.25f); mvmgr->zoomTo(fov,0.25f);
} }
void MainService::actionToggled(const QString &id, bool val) void MainService::actionToggled(const QString &id, bool val)
{ {
actionMutex.lock(); actionMutex.lock();
actionCache.append(ActionCacheEntry(id,val)); actionCache.append(ActionCacheEntry(id,val));
 End of changes. 5 change blocks. 
7 lines changed or deleted 53 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/