StelScriptMgr.cpp   StelScriptMgr.cpp 
skipping to change at line 48 skipping to change at line 48
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelSkyImageMgr.hpp" #include "StelSkyImageMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelLocationMgr.hpp" #include "StelLocationMgr.hpp"
#include <QAction>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QSet> #include <QSet>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#include <QDateTime> #include <QDateTime>
#include <QRegExp> #include <QRegExp>
#include <QDir> #include <QDir>
#include <QTemporaryFile> #include <QTemporaryFile>
skipping to change at line 74 skipping to change at line 75
QString getFileName() {return fname;} QString getFileName() {return fname;}
protected: protected:
void run() void run()
{ {
// seed the QT PRNG // seed the QT PRNG
qsrand(QDateTime::currentDateTime().toTime_t()); qsrand(QDateTime::currentDateTime().toTime_t());
// For startup scripts, the gui object might not // For startup scripts, the gui object might not
// have completed init when we run. Wait for that. // have completed init when we run. Wait for that.
StelGui* gui = (StelGui*)GETSTELMODULE("StelGui"); StelGui* gui = GETSTELMODULE(StelGui);
while(!gui) while(!gui)
{ {
msleep(200); msleep(200);
gui = (StelGui*)GETSTELMODULE("StelGui"); gui = GETSTELMODULE(StelGui);
} }
while(!gui->initComplete()) while(!gui->initComplete())
msleep(200); msleep(200);
engine->evaluate(scriptCode); engine->evaluate(scriptCode);
} }
private: private:
QString scriptCode; QString scriptCode;
QScriptEngine* engine; QScriptEngine* engine;
skipping to change at line 119 skipping to change at line 120
{ {
Vec3f c; Vec3f c;
c[0] = context->argument(0).toNumber(); c[0] = context->argument(0).toNumber();
c[1] = context->argument(1).toNumber(); c[1] = context->argument(1).toNumber();
c[2] = context->argument(2).toNumber(); c[2] = context->argument(2).toNumber();
return vec3fToScriptValue(engine, c); return vec3fToScriptValue(engine, c);
} }
StelMainScriptAPI::StelMainScriptAPI(QObject *parent) : QObject(parent) StelMainScriptAPI::StelMainScriptAPI(QObject *parent) : QObject(parent)
{ {
connect(this, SIGNAL(requestLoadSkyImage(const QString&, const QStri if(StelSkyImageMgr* smgr = GETSTELMODULE(StelSkyImageMgr))
ng&, double, double, double, double, double, double, double, double, double {
, double, bool)), &StelApp::getInstance().getSkyImageMgr(), SLOT(loadSkyIma connect(this, SIGNAL(requestLoadSkyImage(const QString&, con
ge(const QString&, const QString&, double, double, double, double, double, st QString&, double, double, double, double, double, double, double, double
double, double, double, double, double, bool))); , double, double, bool)), smgr, SLOT(loadSkyImage(const QString&, const QSt
ring&, double, double, double, double, double, double, double, double, doub
connect(this, SIGNAL(requestRemoveSkyImage(const QString&)), &StelAp le, double, bool)));
p::getInstance().getSkyImageMgr(), SLOT(removeSkyImage(const QString&))); connect(this, SIGNAL(requestRemoveSkyImage(const QString&)),
smgr, SLOT(removeSkyImage(const QString&)));
}
connect(this, SIGNAL(requestLoadSound(const QString&, const QString& )), StelApp::getInstance().getStelAudioMgr(), SLOT(loadSound(const QString& , const QString&))); connect(this, SIGNAL(requestLoadSound(const QString&, const QString& )), StelApp::getInstance().getStelAudioMgr(), SLOT(loadSound(const QString& , const QString&)));
connect(this, SIGNAL(requestPlaySound(const QString&)), StelApp::get Instance().getStelAudioMgr(), SLOT(playSound(const QString&))); connect(this, SIGNAL(requestPlaySound(const QString&)), StelApp::get Instance().getStelAudioMgr(), SLOT(playSound(const QString&)));
connect(this, SIGNAL(requestPauseSound(const QString&)), StelApp::ge tInstance().getStelAudioMgr(), SLOT(pauseSound(const QString&))); connect(this, SIGNAL(requestPauseSound(const QString&)), StelApp::ge tInstance().getStelAudioMgr(), SLOT(pauseSound(const QString&)));
connect(this, SIGNAL(requestStopSound(const QString&)), StelApp::get Instance().getStelAudioMgr(), SLOT(stopSound(const QString&))); connect(this, SIGNAL(requestStopSound(const QString&)), StelApp::get Instance().getStelAudioMgr(), SLOT(stopSound(const QString&)));
connect(this, SIGNAL(requestDropSound(const QString&)), StelApp::get Instance().getStelAudioMgr(), SLOT(dropSound(const QString&))); connect(this, SIGNAL(requestDropSound(const QString&)), StelApp::get Instance().getStelAudioMgr(), SLOT(dropSound(const QString&)));
} }
StelMainScriptAPI::~StelMainScriptAPI() StelMainScriptAPI::~StelMainScriptAPI()
{ {
skipping to change at line 211 skipping to change at line 214
{ {
while(nav->getJDay() > JD) while(nav->getJDay() > JD)
MySleep::msleep(50); MySleep::msleep(50);
} }
} }
void StelMainScriptAPI::setObserverLocation(double longitude, double latitu de, double altitude, double duration, const QString& name, const QString& p lanet) void StelMainScriptAPI::setObserverLocation(double longitude, double latitu de, double altitude, double duration, const QString& name, const QString& p lanet)
{ {
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( ); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Q_ASSERT(nav); Q_ASSERT(nav);
SolarSystem* ssmgr = (SolarSystem*)GETSTELMODULE("SolarSystem"); SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
Q_ASSERT(ssmgr); Q_ASSERT(ssmgr);
StelLocation loc = nav->getCurrentLocation(); StelLocation loc = nav->getCurrentLocation();
if (longitude < 180 || longitude > 180) if (longitude < 180 || longitude > 180)
loc.longitude = longitude; loc.longitude = longitude;
if (latitude < 180 || latitude > 180) if (latitude < 180 || latitude > 180)
loc.latitude = latitude; loc.latitude = latitude;
if (altitude < -1000) if (altitude < -1000)
loc.altitude = altitude; loc.altitude = altitude;
if (ssmgr->searchByName(planet)) if (ssmgr->searchByName(planet))
skipping to change at line 252 skipping to change at line 255
void StelMainScriptAPI::screenshot(const QString& prefix, bool invert, cons t QString& dir) void StelMainScriptAPI::screenshot(const QString& prefix, bool invert, cons t QString& dir)
{ {
bool oldInvertSetting = StelMainGraphicsView::getInstance().getFlagI nvertScreenShotColors(); bool oldInvertSetting = StelMainGraphicsView::getInstance().getFlagI nvertScreenShotColors();
StelMainGraphicsView::getInstance().setFlagInvertScreenShotColors(in vert); StelMainGraphicsView::getInstance().setFlagInvertScreenShotColors(in vert);
StelMainGraphicsView::getInstance().saveScreenShot(prefix, dir); StelMainGraphicsView::getInstance().saveScreenShot(prefix, dir);
StelMainGraphicsView::getInstance().setFlagInvertScreenShotColors(ol dInvertSetting); StelMainGraphicsView::getInstance().setFlagInvertScreenShotColors(ol dInvertSetting);
} }
void StelMainScriptAPI::setHideGui(bool b) void StelMainScriptAPI::setHideGui(bool b)
{ {
StelGui* gui = (StelGui*)GETSTELMODULE("StelGui"); GETSTELMODULE(StelGui)->getGuiActions("actionToggle_GuiHidden_Global
Q_ASSERT(gui); ")->setChecked(b);
gui->setHideGui(b);
} }
void StelMainScriptAPI::setMinFps(float m) void StelMainScriptAPI::setMinFps(float m)
{ {
StelApp::getInstance().setMinFps(m); StelApp::getInstance().setMinFps(m);
} }
float StelMainScriptAPI::getMinFps() float StelMainScriptAPI::getMinFps()
{ {
return StelApp::getInstance().getMinFps(); return StelApp::getInstance().getMinFps();
skipping to change at line 466 skipping to change at line 467
} }
else else
{ {
qWarning() << "StelMainScriptAPI::jdFromDateString error - d ate string" << dt << "not recognised, returning \"now\""; qWarning() << "StelMainScriptAPI::jdFromDateString error - d ate string" << dt << "not recognised, returning \"now\"";
return StelUtils::getJDFromSystem(); return StelUtils::getJDFromSystem();
} }
} }
void StelMainScriptAPI::selectObjectByName(const QString& name, bool pointe r) void StelMainScriptAPI::selectObjectByName(const QString& name, bool pointe r)
{ {
StelApp::getInstance().getStelObjectMgr().setFlagSelectedObjectPoint StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
er(pointer); omgr->setFlagSelectedObjectPointer(pointer);
if (name=="") if (name=="")
StelApp::getInstance().getStelObjectMgr().unSelect(); omgr->unSelect();
else else
StelApp::getInstance().getStelObjectMgr().findAndSelect(name ); omgr->findAndSelect(name);
} }
void StelMainScriptAPI::clear(const QString& state) void StelMainScriptAPI::clear(const QString& state)
{ {
LandscapeMgr* lmgr = (LandscapeMgr*)GETSTELMODULE("LandscapeMgr"); LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
Q_ASSERT(lmgr); Q_ASSERT(lmgr);
SolarSystem* ssmgr = (SolarSystem*)GETSTELMODULE("SolarSystem"); SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
Q_ASSERT(ssmgr); Q_ASSERT(ssmgr);
MeteorMgr* mmgr = (MeteorMgr*)GETSTELMODULE("MeteorMgr"); MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr);
Q_ASSERT(mmgr); Q_ASSERT(mmgr);
StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer (); StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer ();
Q_ASSERT(skyd); Q_ASSERT(skyd);
ConstellationMgr* cmgr = (ConstellationMgr*)GETSTELMODULE("Constella tionMgr"); ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr);
Q_ASSERT(cmgr); Q_ASSERT(cmgr);
StarMgr* smgr = (StarMgr*)GETSTELMODULE("StarMgr"); StarMgr* smgr = GETSTELMODULE(StarMgr);
Q_ASSERT(smgr); Q_ASSERT(smgr);
NebulaMgr* nmgr = (NebulaMgr*)GETSTELMODULE("NebulaMgr"); NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr);
Q_ASSERT(nmgr); Q_ASSERT(nmgr);
GridLinesMgr* glmgr = (GridLinesMgr*)GETSTELMODULE("GridLinesMgr"); GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr);
Q_ASSERT(glmgr); Q_ASSERT(glmgr);
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( ); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Q_ASSERT(nav); Q_ASSERT(nav);
if (state.toLower() == "natural") if (state.toLower() == "natural")
{ {
nav->setEquatorialMount(false); nav->setEquatorialMount(false);
skyd->setFlagTwinkle(true); skyd->setFlagTwinkle(true);
skyd->setFlagLuminanceAdaptation(true); skyd->setFlagLuminanceAdaptation(true);
ssmgr->setFlagPlanets(true); ssmgr->setFlagPlanets(true);
skipping to change at line 589 skipping to change at line 591
lmgr->setFlagFog(false); lmgr->setFlagFog(false);
} }
else else
{ {
qWarning() << "WARNING clear(" << state << ") - state not kn own"; qWarning() << "WARNING clear(" << state << ") - state not kn own";
} }
} }
void StelMainScriptAPI::moveToAltAzi(const QString& alt, const QString& azi , float duration) void StelMainScriptAPI::moveToAltAzi(const QString& alt, const QString& azi , float duration)
{ {
StelMovementMgr* mvmgr = (StelMovementMgr*)GETSTELMODULE("StelMoveme ntMgr"); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mvmgr); Q_ASSERT(mvmgr);
StelApp::getInstance().getStelObjectMgr().unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
Vec3d aim; Vec3d aim;
double dAlt = StelUtils::getDecAngle(alt); double dAlt = StelUtils::getDecAngle(alt);
double dAzi = M_PI - StelUtils::getDecAngle(azi); double dAzi = M_PI - StelUtils::getDecAngle(azi);
StelUtils::spheToRect(dAzi,dAlt,aim); StelUtils::spheToRect(dAzi,dAlt,aim);
mvmgr->moveTo(aim, duration, true); mvmgr->moveTo(aim, duration, true);
} }
void StelMainScriptAPI::moveToRaDec(const QString& ra, const QString& dec, float duration) void StelMainScriptAPI::moveToRaDec(const QString& ra, const QString& dec, float duration)
{ {
StelMovementMgr* mvmgr = (StelMovementMgr*)GETSTELMODULE("StelMoveme ntMgr"); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mvmgr); Q_ASSERT(mvmgr);
StelApp::getInstance().getStelObjectMgr().unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
Vec3d aim; Vec3d aim;
double dRa = StelUtils::getDecAngle(ra); double dRa = StelUtils::getDecAngle(ra);
double dDec = StelUtils::getDecAngle(dec); double dDec = StelUtils::getDecAngle(dec);
StelUtils::spheToRect(dRa,dDec,aim); StelUtils::spheToRect(dRa,dDec,aim);
mvmgr->moveTo(aim, duration, false); mvmgr->moveTo(aim, duration, false);
} }
StelScriptMgr::StelScriptMgr(QObject *parent) StelScriptMgr::StelScriptMgr(QObject *parent)
skipping to change at line 641 skipping to change at line 643
// Add all the StelModules into the script engine // Add all the StelModules into the script engine
StelModuleMgr* mmgr = &StelApp::getInstance().getModuleMgr(); StelModuleMgr* mmgr = &StelApp::getInstance().getModuleMgr();
foreach (StelModule* m, mmgr->getAllModules()) foreach (StelModule* m, mmgr->getAllModules())
{ {
objectValue = engine.newQObject(m); objectValue = engine.newQObject(m);
engine.globalObject().setProperty(m->objectName(), objectVal ue); engine.globalObject().setProperty(m->objectName(), objectVal ue);
} }
// Add other classes which we want to be directly accessible from sc ripts // Add other classes which we want to be directly accessible from sc ripts
objectValue = engine.newQObject(&StelApp::getInstance().getSkyImageM if(StelSkyImageMgr* smgr = GETSTELMODULE(StelSkyImageMgr))
gr()); objectValue = engine.newQObject(smgr);
} }
StelScriptMgr::~StelScriptMgr() StelScriptMgr::~StelScriptMgr()
{ {
} }
QStringList StelScriptMgr::getScriptList(void) QStringList StelScriptMgr::getScriptList(void)
{ {
QStringList scriptFiles; QStringList scriptFiles;
try try
 End of changes. 21 change blocks. 
31 lines changed or deleted 33 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/