StelMainScriptAPI.cpp   StelMainScriptAPI.cpp 
skipping to change at line 27 skipping to change at line 27
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelMainScriptAPI.hpp" #include "StelMainScriptAPI.hpp"
#include "StelMainScriptAPIProxy.hpp" #include "StelMainScriptAPIProxy.hpp"
#include "StelScriptMgr.hpp" #include "StelScriptMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "AsterismMgr.hpp"
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "SporadicMeteorMgr.hpp" #include "SporadicMeteorMgr.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelAudioMgr.hpp" #include "StelAudioMgr.hpp"
#include "StelVideoMgr.hpp" #include "StelVideoMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelLocationMgr.hpp" #include "StelLocationMgr.hpp"
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelPropertyMgr.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelSkyLayerMgr.hpp" #include "StelSkyLayerMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelGuiBase.hpp" #include "StelGuiBase.hpp"
#include "MilkyWay.hpp" #include "MilkyWay.hpp"
#include "ZodiacalLight.hpp" #include "ZodiacalLight.hpp"
#include "ToastMgr.hpp"
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QRegExp> #include <QRegExp>
#include <QSet> #include <QSet>
#include <QStringList> #include <QStringList>
#include <QTemporaryFile> #include <QTemporaryFile>
skipping to change at line 731 skipping to change at line 734
void StelMainScriptAPI::exit() void StelMainScriptAPI::exit()
{ {
emit(requestExit()); emit(requestExit());
} }
void StelMainScriptAPI::quitStellarium() void StelMainScriptAPI::quitStellarium()
{ {
QCoreApplication::exit(); QCoreApplication::exit();
} }
QStringList StelMainScriptAPI::getPropertyList() const
{
return StelApp::getInstance().getStelPropertyManager()->getPropertyL
ist();
}
void StelMainScriptAPI::debug(const QString& s) void StelMainScriptAPI::debug(const QString& s)
{ {
qDebug() << "script: " << s; qDebug() << "script: " << s;
StelApp::getInstance().getScriptMgr().debug(s); StelApp::getInstance().getScriptMgr().debug(s);
} }
void StelMainScriptAPI::output(const QString &s) const void StelMainScriptAPI::output(const QString &s) const
{ {
StelApp::getInstance().getScriptMgr().output(s); StelApp::getInstance().getScriptMgr().output(s);
} }
skipping to change at line 756 skipping to change at line 764
QString res = QString("[\n"); QString res = QString("[\n");
QList<QVariant::Type> simpleTypeList; QList<QVariant::Type> simpleTypeList;
simpleTypeList.push_back(QVariant::Bool); simpleTypeList.push_back(QVariant::Bool);
simpleTypeList.push_back(QVariant::Int); simpleTypeList.push_back(QVariant::Int);
simpleTypeList.push_back(QVariant::UInt); simpleTypeList.push_back(QVariant::UInt);
simpleTypeList.push_back(QVariant::Double); simpleTypeList.push_back(QVariant::Double);
QVariantMap::const_iterator i=map.constBegin(); QVariantMap::const_iterator i=map.constBegin();
while (i != map.constEnd()){ while (i != map.constEnd()){
if (i.value().type()==QMetaType::QString) if (i.value().type()==QVariant::String)
{ {
res.append(QString("[ \"%1\" = \"%2\" ]\n").arg(i.ke y()).arg(i.value().toString())); res.append(QString("[ \"%1\" = \"%2\" ]\n").arg(i.ke y()).arg(i.value().toString()));
} }
else if (simpleTypeList.contains(i.value().type())) else if (simpleTypeList.contains(i.value().type()))
{ {
res.append(QString("[ \"%1\" = %2 ]\n").arg(i.key()) .arg(i.value().toString())); res.append(QString("[ \"%1\" = %2 ]\n").arg(i.key()) .arg(i.value().toString()));
} }
else else
{ {
res.append(QString("[ \"%1\" = \"<%2>:%3\" ]\n").arg (i.key()).arg(i.value().typeName()).arg(i.value().toString())); res.append(QString("[ \"%1\" = \"<%2>:%3\" ]\n").arg (i.key()).arg(i.value().typeName()).arg(i.value().toString()));
skipping to change at line 861 skipping to change at line 869
jd -= (unit * delta); jd -= (unit * delta);
return jd; return jd;
} }
qWarning() << "StelMainScriptAPI::jdFromDateString error: date strin g" << dt << "not recognised, returning \"now\""; qWarning() << "StelMainScriptAPI::jdFromDateString error: date strin g" << dt << "not recognised, returning \"now\"";
return StelUtils::getJDFromSystem(); return StelUtils::getJDFromSystem();
} }
void StelMainScriptAPI::wait(double t) { void StelMainScriptAPI::wait(double t) {
QEventLoop loop; QEventLoop loop;
QTimer timer; QTimer::singleShot(1000*t, &loop, SLOT(quit()));
timer.setInterval(1000*t);
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
timer.start();
loop.exec(); loop.exec();
} }
void StelMainScriptAPI::waitFor(const QString& dt, const QString& spec) void StelMainScriptAPI::waitFor(const QString& dt, const QString& spec)
{ {
double deltaJD = jdFromDateString(dt, spec) - getJDay(); double deltaJD = jdFromDateString(dt, spec) - getJDay();
double timeSpeed = getTimeRate(); double timeRate = getTimeRate();
if (timeSpeed == 0.) { qDebug() << "waitFor() called with no time pa if (timeRate == 0.) { qDebug() << "waitFor() called with no time pas
ssing - would be infinite. not waiting!"; return;} sing - would be infinite. Not waiting!"; return;}
QEventLoop loop; int interval=1000*deltaJD*86400/timeRate;
QTimer timer; if (interval<=0){ qDebug() << "waitFor() called, but negative interv
int interval=1000*deltaJD*86400/timeSpeed; al. (time exceeded before starting timer). Not waiting!"; return; }
//qDebug() << "timeSpeed is" << timeSpeed << " interval:" << interva l; //qDebug() << "timeSpeed is" << timeSpeed << " interval:" << interva l;
timer.setInterval(interval); QEventLoop loop;
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); QTimer::singleShot(interval, &loop, SLOT(quit()));
timer.start();
loop.exec(); loop.exec();
} }
void StelMainScriptAPI::selectObjectByName(const QString& name, bool pointe r) void StelMainScriptAPI::selectObjectByName(const QString& name, bool pointe r)
{ {
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
omgr->setFlagSelectedObjectPointer(pointer); omgr->setFlagSelectedObjectPointer(pointer);
if (name.isEmpty() || !omgr->findAndSelect(name)) if (name.isEmpty() || !omgr->findAndSelect(name))
{ {
omgr->unSelect(); omgr->unSelect();
skipping to change at line 930 skipping to change at line 933
return StelObjectMgr::getObjectInfo(obj); return StelObjectMgr::getObjectInfo(obj);
} }
void StelMainScriptAPI::clear(const QString& state) void StelMainScriptAPI::clear(const QString& state)
{ {
LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
SporadicMeteorMgr* mmgr = GETSTELMODULE(SporadicMeteorMgr); SporadicMeteorMgr* mmgr = GETSTELMODULE(SporadicMeteorMgr);
StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer (); StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer ();
ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr);
AsterismMgr* amgr = GETSTELMODULE(AsterismMgr);
StarMgr* smgr = GETSTELMODULE(StarMgr); StarMgr* smgr = GETSTELMODULE(StarMgr);
NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr); NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr);
GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr); GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr);
StelMovementMgr* movmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* movmgr = GETSTELMODULE(StelMovementMgr);
ZodiacalLight* zl = GETSTELMODULE(ZodiacalLight); ZodiacalLight* zl = GETSTELMODULE(ZodiacalLight);
if (state.toLower() == "natural") if (state.toLower() == "natural")
{ {
movmgr->setMountMode(StelMovementMgr::MountAltAzimuthal); movmgr->setMountMode(StelMovementMgr::MountAltAzimuthal);
skyd->setFlagTwinkle(true); skyd->setFlagTwinkle(true);
skipping to change at line 981 skipping to change at line 985
glmgr->setFlagEclipticPoles(false); glmgr->setFlagEclipticPoles(false);
glmgr->setFlagGalacticPoles(false); glmgr->setFlagGalacticPoles(false);
glmgr->setFlagSupergalacticPoles(false); glmgr->setFlagSupergalacticPoles(false);
glmgr->setFlagEquinoxJ2000Points(false); glmgr->setFlagEquinoxJ2000Points(false);
glmgr->setFlagEquinoxPoints(false); glmgr->setFlagEquinoxPoints(false);
lmgr->setFlagCardinalsPoints(false); lmgr->setFlagCardinalsPoints(false);
cmgr->setFlagLines(false); cmgr->setFlagLines(false);
cmgr->setFlagLabels(false); cmgr->setFlagLabels(false);
cmgr->setFlagBoundaries(false); cmgr->setFlagBoundaries(false);
cmgr->setFlagArt(false); cmgr->setFlagArt(false);
amgr->setFlagLines(false);
amgr->setFlagLabels(false);
smgr->setFlagLabels(false); smgr->setFlagLabels(false);
ssmgr->setFlagLabels(false); ssmgr->setFlagLabels(false);
nmgr->setFlagHints(false); nmgr->setFlagHints(false);
lmgr->setFlagLandscape(true); lmgr->setFlagLandscape(true);
lmgr->setFlagAtmosphere(true); lmgr->setFlagAtmosphere(true);
lmgr->setFlagFog(true); lmgr->setFlagFog(true);
zl->setFlagShow(true); zl->setFlagShow(true);
} }
else if (state.toLower() == "starchart") else if (state.toLower() == "starchart")
{ {
skipping to change at line 1029 skipping to change at line 1035
glmgr->setFlagEclipticPoles(false); glmgr->setFlagEclipticPoles(false);
glmgr->setFlagGalacticPoles(false); glmgr->setFlagGalacticPoles(false);
glmgr->setFlagSupergalacticPoles(false); glmgr->setFlagSupergalacticPoles(false);
glmgr->setFlagEquinoxJ2000Points(false); glmgr->setFlagEquinoxJ2000Points(false);
glmgr->setFlagEquinoxPoints(false); glmgr->setFlagEquinoxPoints(false);
lmgr->setFlagCardinalsPoints(false); lmgr->setFlagCardinalsPoints(false);
cmgr->setFlagLines(true); cmgr->setFlagLines(true);
cmgr->setFlagLabels(true); cmgr->setFlagLabels(true);
cmgr->setFlagBoundaries(true); cmgr->setFlagBoundaries(true);
cmgr->setFlagArt(false); cmgr->setFlagArt(false);
amgr->setFlagLines(false);
amgr->setFlagLabels(false);
smgr->setFlagLabels(true); smgr->setFlagLabels(true);
ssmgr->setFlagLabels(true); ssmgr->setFlagLabels(true);
nmgr->setFlagHints(true); nmgr->setFlagHints(true);
lmgr->setFlagLandscape(false); lmgr->setFlagLandscape(false);
lmgr->setFlagAtmosphere(false); lmgr->setFlagAtmosphere(false);
lmgr->setFlagFog(false); lmgr->setFlagFog(false);
zl->setFlagShow(false); zl->setFlagShow(false);
} }
else if (state.toLower() == "deepspace") else if (state.toLower() == "deepspace")
{ {
skipping to change at line 1077 skipping to change at line 1085
glmgr->setFlagEclipticPoles(false); glmgr->setFlagEclipticPoles(false);
glmgr->setFlagGalacticPoles(false); glmgr->setFlagGalacticPoles(false);
glmgr->setFlagSupergalacticPoles(false); glmgr->setFlagSupergalacticPoles(false);
glmgr->setFlagEquinoxJ2000Points(false); glmgr->setFlagEquinoxJ2000Points(false);
glmgr->setFlagEquinoxPoints(false); glmgr->setFlagEquinoxPoints(false);
lmgr->setFlagCardinalsPoints(false); lmgr->setFlagCardinalsPoints(false);
cmgr->setFlagLines(false); cmgr->setFlagLines(false);
cmgr->setFlagLabels(false); cmgr->setFlagLabels(false);
cmgr->setFlagBoundaries(false); cmgr->setFlagBoundaries(false);
cmgr->setFlagArt(false); cmgr->setFlagArt(false);
amgr->setFlagLines(false);
amgr->setFlagLabels(false);
smgr->setFlagLabels(false); smgr->setFlagLabels(false);
ssmgr->setFlagLabels(false); ssmgr->setFlagLabels(false);
nmgr->setFlagHints(false); nmgr->setFlagHints(false);
lmgr->setFlagLandscape(false); lmgr->setFlagLandscape(false);
lmgr->setFlagAtmosphere(false); lmgr->setFlagAtmosphere(false);
lmgr->setFlagFog(false); lmgr->setFlagFog(false);
zl->setFlagShow(false); zl->setFlagShow(false);
} }
else if (state.toLower() == "galactic") else if (state.toLower() == "galactic")
{ {
skipping to change at line 1125 skipping to change at line 1135
glmgr->setFlagEclipticPoles(false); glmgr->setFlagEclipticPoles(false);
glmgr->setFlagGalacticPoles(false); glmgr->setFlagGalacticPoles(false);
glmgr->setFlagSupergalacticPoles(false); glmgr->setFlagSupergalacticPoles(false);
glmgr->setFlagEquinoxJ2000Points(false); glmgr->setFlagEquinoxJ2000Points(false);
glmgr->setFlagEquinoxPoints(false); glmgr->setFlagEquinoxPoints(false);
lmgr->setFlagCardinalsPoints(false); lmgr->setFlagCardinalsPoints(false);
cmgr->setFlagLines(false); cmgr->setFlagLines(false);
cmgr->setFlagLabels(false); cmgr->setFlagLabels(false);
cmgr->setFlagBoundaries(false); cmgr->setFlagBoundaries(false);
cmgr->setFlagArt(false); cmgr->setFlagArt(false);
amgr->setFlagLines(false);
amgr->setFlagLabels(false);
smgr->setFlagLabels(false); smgr->setFlagLabels(false);
ssmgr->setFlagLabels(false); ssmgr->setFlagLabels(false);
nmgr->setFlagHints(false); nmgr->setFlagHints(false);
lmgr->setFlagLandscape(false); lmgr->setFlagLandscape(false);
lmgr->setFlagAtmosphere(false); lmgr->setFlagAtmosphere(false);
lmgr->setFlagFog(false); lmgr->setFlagFog(false);
zl->setFlagShow(false); zl->setFlagShow(false);
} }
else if (state.toLower() == "supergalactic") else if (state.toLower() == "supergalactic")
{ {
skipping to change at line 1173 skipping to change at line 1185
glmgr->setFlagEclipticPoles(false); glmgr->setFlagEclipticPoles(false);
glmgr->setFlagGalacticPoles(false); glmgr->setFlagGalacticPoles(false);
glmgr->setFlagSupergalacticPoles(false); glmgr->setFlagSupergalacticPoles(false);
glmgr->setFlagEquinoxJ2000Points(false); glmgr->setFlagEquinoxJ2000Points(false);
glmgr->setFlagEquinoxPoints(false); glmgr->setFlagEquinoxPoints(false);
lmgr->setFlagCardinalsPoints(false); lmgr->setFlagCardinalsPoints(false);
cmgr->setFlagLines(false); cmgr->setFlagLines(false);
cmgr->setFlagLabels(false); cmgr->setFlagLabels(false);
cmgr->setFlagBoundaries(false); cmgr->setFlagBoundaries(false);
cmgr->setFlagArt(false); cmgr->setFlagArt(false);
amgr->setFlagLines(false);
amgr->setFlagLabels(false);
smgr->setFlagLabels(false); smgr->setFlagLabels(false);
ssmgr->setFlagLabels(false); ssmgr->setFlagLabels(false);
nmgr->setFlagHints(false); nmgr->setFlagHints(false);
lmgr->setFlagLandscape(false); lmgr->setFlagLandscape(false);
lmgr->setFlagAtmosphere(false); lmgr->setFlagAtmosphere(false);
lmgr->setFlagFog(false); lmgr->setFlagFog(false);
zl->setFlagShow(false); zl->setFlagShow(false);
} }
else else
skipping to change at line 1380 skipping to change at line 1394
int StelMainScriptAPI::getBortleScaleIndex() const int StelMainScriptAPI::getBortleScaleIndex() const
{ {
return StelApp::getInstance().getCore()->getSkyDrawer()->getBortleSc aleIndex(); return StelApp::getInstance().getCore()->getSkyDrawer()->getBortleSc aleIndex();
} }
void StelMainScriptAPI::setBortleScaleIndex(int index) void StelMainScriptAPI::setBortleScaleIndex(int index)
{ {
StelApp::getInstance().getCore()->getSkyDrawer()->setBortleScaleInde x(index); StelApp::getInstance().getCore()->getSkyDrawer()->setBortleScaleInde x(index);
} }
void StelMainScriptAPI::setDSSMode(bool b)
{
GETSTELMODULE(ToastMgr)->setFlagSurveyShow(b);
}
bool StelMainScriptAPI::isDSSModeEnabled() const
{
return GETSTELMODULE(ToastMgr)->getFlagSurveyShow();
}
QVariantMap StelMainScriptAPI::getScreenXYFromAltAzi(const QString &alt, co nst QString &azi) QVariantMap StelMainScriptAPI::getScreenXYFromAltAzi(const QString &alt, co nst QString &azi)
{ {
Vec3d aim, v; Vec3d aim, v;
double dAlt = StelUtils::getDecAngle(alt); double dAlt = StelUtils::getDecAngle(alt);
double dAzi = M_PI - StelUtils::getDecAngle(azi); double dAzi = M_PI - StelUtils::getDecAngle(azi);
if (StelApp::getInstance().getFlagSouthAzimuthUsage()) if (StelApp::getInstance().getFlagSouthAzimuthUsage())
dAzi -= M_PI; dAzi -= M_PI;
StelUtils::spheToRect(dAzi,dAlt,aim); StelUtils::spheToRect(dAzi,dAlt,aim);
 End of changes. 15 change blocks. 
14 lines changed or deleted 40 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/