StelMainScriptAPI.cpp   StelMainScriptAPI.cpp 
skipping to change at line 29 skipping to change at line 29
*/ */
#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 "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "MeteorMgr.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"
skipping to change at line 107 skipping to change at line 107
connect(this, SIGNAL(requestSetSkyCulture(QString)), &StelApp::getIn stance().getSkyCultureMgr(), SLOT(setCurrentSkyCultureID(QString))); connect(this, SIGNAL(requestSetSkyCulture(QString)), &StelApp::getIn stance().getSkyCultureMgr(), SLOT(setCurrentSkyCultureID(QString)));
connect(this, SIGNAL(requestSetDiskViewport(bool)), StelApp::getInst ance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool))); connect(this, SIGNAL(requestSetDiskViewport(bool)), StelApp::getInst ance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool)));
connect(this, SIGNAL(requestSetHomePosition()), StelApp::getInstance ().getCore(), SLOT(returnToHome())); connect(this, SIGNAL(requestSetHomePosition()), StelApp::getInstance ().getCore(), SLOT(returnToHome()));
} }
StelMainScriptAPI::~StelMainScriptAPI() StelMainScriptAPI::~StelMainScriptAPI()
{ {
} }
//! Set the current date in Julian Day //! Set the current date in Julian Day
//! @param JD the Julian Date //! @param JD the Julian Date (UT)
void StelMainScriptAPI::setJDay(double JD) void StelMainScriptAPI::setJDay(double JD)
{ {
StelApp::getInstance().getCore()->setJDay(JD); StelApp::getInstance().getCore()->setJD(JD);
} }
//! Get the current date in Julian Day //! Get the current date in Julian Day
//! @return the Julian Date //! @return the Julian Date (UT)
double StelMainScriptAPI::getJDay() const double StelMainScriptAPI::getJDay() const
{ {
return StelApp::getInstance().getCore()->getJDay(); return StelApp::getInstance().getCore()->getJD();
} }
//! Set the current date in Modified Julian Day //! Set the current date in Modified Julian Day
//! @param MJD the Modified Julian Date //! @param MJD the Modified Julian Date
void StelMainScriptAPI::setMJDay(double MJD) void StelMainScriptAPI::setMJDay(double MJD)
{ {
StelApp::getInstance().getCore()->setMJDay(MJD); StelApp::getInstance().getCore()->setMJDay(MJD);
} }
//! Get the current date in Modified Julian Day //! Get the current date in Modified Julian Day
//! @return the Modified Julian Date //! @return the Modified Julian Date
double StelMainScriptAPI::getMJDay() const double StelMainScriptAPI::getMJDay() const
{ {
return StelApp::getInstance().getCore()->getMJDay(); return StelApp::getInstance().getCore()->getMJDay();
} }
void StelMainScriptAPI::setDate(const QString& dt, const QString& spec, con st bool &enableDeltaT) void StelMainScriptAPI::setDate(const QString& dateStr, const QString& spec , const bool &dateIsDT)
{ {
bool relativeTime = false;
if (dt.startsWith("+") || dt.startsWith("-") || (dt.startsWith("now"
) && (dt.startsWith("+") || dt.startsWith("-"))))
relativeTime = true;
double JD = jdFromDateString(dt, spec);
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
if (relativeTime) double JD = jdFromDateString(dateStr, spec);
if (dateIsDT)
{ {
core->setJDay(JD); qWarning() << "StelMainScriptAPI::setDate() called with fina
l Boolean set to indicate Dynamical Time. This is new in 0.14, make sure yo
u did this intentionally.";
qWarning() << "This warning will go away in Stellarium 0.16,
please update the script by then to be sure.";
core->setJDE(JD);
} }
else else
{ core->setJD(JD);
if (enableDeltaT)
{ // bool relativeTime = false;
// add Delta-T correction for date // if (dateStr.startsWith("+") || dateStr.startsWith("-") || (dateStr.s
core->setJDay(JD + core->getDeltaT(JD)/86400); tartsWith("now") && (dateStr.startsWith("+") || dateStr.startsWith("-"))))
} // relativeTime = true;
else // double JD = jdFromDateString(dateStr, spec);
{ // StelCore* core = StelApp::getInstance().getCore();
// set date without Delta-T correction // if (relativeTime)
// compatible with 0.11 // {
core->setJDay(JD); // core->setJDay(JD);
} // }
} // else
// {
// if (dateIsDT)
// {
// // add Delta-T correction for date
// core->setJDay(JD + core->getDeltaT(JD)/86400);
// }
// else
// {
// // set date without Delta-T correction
// // compatible with 0.11
// core->setJDay(JD);
// }
// }
} }
QString StelMainScriptAPI::getDate(const QString& spec) QString StelMainScriptAPI::getDate(const QString& spec)
{ {
if (spec=="utc") if (spec=="utc")
return StelUtils::julianDayToISO8601String(getJDay()); return StelUtils::julianDayToISO8601String(getJDay());
else else
return StelUtils::julianDayToISO8601String(getJDay()+StelUti ls::getGMTShiftFromQT(getJDay())/24); return StelUtils::julianDayToISO8601String(getJDay()+StelUti ls::getGMTShiftFromQT(getJDay())/24);
} }
QString StelMainScriptAPI::getDeltaT() const QString StelMainScriptAPI::getDeltaT() const
{ {
return StelUtils::hoursToHmsStr(StelApp::getInstance().getCore()->ge tDeltaT(getJDay())/3600.); return StelUtils::hoursToHmsStr(StelApp::getInstance().getCore()->ge tDeltaT()/3600.);
} }
QString StelMainScriptAPI::getDeltaTAlgorithm() const QString StelMainScriptAPI::getDeltaTAlgorithm() const
{ {
return StelApp::getInstance().getCore()->getCurrentDeltaTAlgorithmKe y(); return StelApp::getInstance().getCore()->getCurrentDeltaTAlgorithmKe y();
} }
void StelMainScriptAPI::setDeltaTAlgorithm(QString algorithmName) void StelMainScriptAPI::setDeltaTAlgorithm(QString algorithmName)
{ {
StelApp::getInstance().getCore()->setCurrentDeltaTAlgorithmKey(algor ithmName); StelApp::getInstance().getCore()->setCurrentDeltaTAlgorithmKey(algor ithmName);
skipping to change at line 692 skipping to change at line 703
{ {
double delta; double delta;
double unit; double unit;
double dayLength = 1.0; double dayLength = 1.0;
double yearLength = 365.242190419; // duration of Earth's me an tropical year double yearLength = 365.242190419; // duration of Earth's me an tropical year
double monthLength = 27.321582241; // duration of Earth's me an tropical month double monthLength = 27.321582241; // duration of Earth's me an tropical month
if (nowRe.capturedTexts().at(1)=="now") if (nowRe.capturedTexts().at(1)=="now")
jd = StelUtils::getJDFromSystem(); jd = StelUtils::getJDFromSystem();
else else
jd = core->getJDay(); jd = core->getJD();
if (nowRe.capturedTexts().at(8) == "sidereal") if (nowRe.capturedTexts().at(8) == "sidereal")
{ {
dayLength = core->getLocalSiderealDayLength(); dayLength = core->getLocalSiderealDayLength();
yearLength = core->getLocalSiderealYearLength(); yearLength = core->getLocalSiderealYearLength();
monthLength = 27.321661; // duration of Earth's side real month monthLength = 27.321661; // duration of Earth's side real month
} }
QString unitString = nowRe.capturedTexts().at(6); QString unitString = nowRe.capturedTexts().at(6);
if (unitString == "seconds" || unitString == "second") if (unitString == "seconds" || unitString == "second")
skipping to change at line 739 skipping to change at line 750
} }
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::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=="") if (name.isEmpty() || !omgr->findAndSelect(name))
{
omgr->unSelect(); omgr->unSelect();
else }
omgr->findAndSelect(name);
} }
//DEPRECATED: Use getObjectInfo() //DEPRECATED: Use getObjectInfo()
QVariantMap StelMainScriptAPI::getObjectPosition(const QString& name) QVariantMap StelMainScriptAPI::getObjectPosition(const QString& name)
{ {
return getObjectInfo(name); return getObjectInfo(name);
} }
QVariantMap StelMainScriptAPI::getObjectInfo(const QString& name) QVariantMap StelMainScriptAPI::getObjectInfo(const QString& name)
{ {
skipping to change at line 771 skipping to change at line 782
return map; return map;
} }
else else
{ {
map.insert("found", true); map.insert("found", true);
} }
Vec3d pos; Vec3d pos;
double ra, dec, alt, az, glong, glat; double ra, dec, alt, az, glong, glat;
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
bool useOldAzimuth = StelApp::getInstance().getFlagOldAzimuthUsage() ;
// ra/dec // ra/dec
pos = obj->getEquinoxEquatorialPos(core); pos = obj->getEquinoxEquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos); StelUtils::rectToSphe(&ra, &dec, pos);
map.insert("ra", ra*180./M_PI); map.insert("ra", ra*180./M_PI);
map.insert("dec", dec*180./M_PI); map.insert("dec", dec*180./M_PI);
// ra/dec in J2000 // ra/dec in J2000
pos = obj->getJ2000EquatorialPos(core); pos = obj->getJ2000EquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos); StelUtils::rectToSphe(&ra, &dec, pos);
map.insert("raJ2000", ra*180./M_PI); map.insert("raJ2000", ra*180./M_PI);
map.insert("decJ2000", dec*180./M_PI); map.insert("decJ2000", dec*180./M_PI);
// apparent altitude/azimuth // apparent altitude/azimuth
pos = obj->getAltAzPosApparent(core); pos = obj->getAltAzPosApparent(core);
StelUtils::rectToSphe(&az, &alt, pos); StelUtils::rectToSphe(&az, &alt, pos);
az = 3.*M_PI - az; // N is zero, E is 90 degrees float direction = 3.; // N is zero, E is 90 degrees
if (useOldAzimuth)
direction = 2.;
az = direction*M_PI - az;
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
map.insert("altitude", alt*180./M_PI); map.insert("altitude", alt*180./M_PI);
map.insert("azimuth", az*180./M_PI); map.insert("azimuth", az*180./M_PI);
// geometric altitude/azimuth // geometric altitude/azimuth
pos = obj->getAltAzPosGeometric(core); pos = obj->getAltAzPosGeometric(core);
StelUtils::rectToSphe(&az, &alt, pos); StelUtils::rectToSphe(&az, &alt, pos);
az = 3.*M_PI - az; // N is zero, E is 90 degrees az = direction*M_PI - az;
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
map.insert("altitude-geometric", alt*180./M_PI); map.insert("altitude-geometric", alt*180./M_PI);
map.insert("azimuth-geometric", az*180./M_PI); map.insert("azimuth-geometric", az*180./M_PI);
// galactic long/lat // galactic long/lat
pos = obj->getGalacticPos(core); pos = obj->getGalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos); StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("glong", glong*180./M_PI); map.insert("glong", glong*180./M_PI);
skipping to change at line 877 skipping to change at line 892
} }
else else
{ {
map.insert("found", true); map.insert("found", true);
} }
// OK, object found. Let's go. // OK, object found. Let's go.
Vec3d pos; Vec3d pos;
double ra, dec, alt, az, glong, glat; double ra, dec, alt, az, glong, glat;
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
bool useOldAzimuth = StelApp::getInstance().getFlagOldAzimuthUsage() ;
// ra/dec // ra/dec
pos = obj->getEquinoxEquatorialPos(core); pos = obj->getEquinoxEquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos); StelUtils::rectToSphe(&ra, &dec, pos);
map.insert("ra", ra*180./M_PI); map.insert("ra", ra*180./M_PI);
map.insert("dec", dec*180./M_PI); map.insert("dec", dec*180./M_PI);
// ra/dec in J2000 // ra/dec in J2000
pos = obj->getJ2000EquatorialPos(core); pos = obj->getJ2000EquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos); StelUtils::rectToSphe(&ra, &dec, pos);
map.insert("raJ2000", ra*180./M_PI); map.insert("raJ2000", ra*180./M_PI);
map.insert("decJ2000", dec*180./M_PI); map.insert("decJ2000", dec*180./M_PI);
// apparent altitude/azimuth // apparent altitude/azimuth
pos = obj->getAltAzPosApparent(core); pos = obj->getAltAzPosApparent(core);
StelUtils::rectToSphe(&az, &alt, pos); StelUtils::rectToSphe(&az, &alt, pos);
az = 3.*M_PI - az; // N is zero, E is 90 degrees float direction = 3.; // N is zero, E is 90 degrees
if (useOldAzimuth)
direction = 2.;
az = direction*M_PI - az;
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
map.insert("altitude", alt*180./M_PI); map.insert("altitude", alt*180./M_PI);
map.insert("azimuth", az*180./M_PI); map.insert("azimuth", az*180./M_PI);
// geometric altitude/azimuth // geometric altitude/azimuth
pos = obj->getAltAzPosGeometric(core); pos = obj->getAltAzPosGeometric(core);
StelUtils::rectToSphe(&az, &alt, pos); StelUtils::rectToSphe(&az, &alt, pos);
az = 3.*M_PI - az; // N is zero, E is 90 degrees az = direction*M_PI - az;
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
map.insert("altitude-geometric", alt*180./M_PI); map.insert("altitude-geometric", alt*180./M_PI);
map.insert("azimuth-geometric", az*180./M_PI); map.insert("azimuth-geometric", az*180./M_PI);
// galactic long/lat // galactic long/lat
pos = obj->getGalacticPos(core); pos = obj->getGalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos); StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("glong", glong*180./M_PI); map.insert("glong", glong*180./M_PI);
skipping to change at line 960 skipping to change at line 979
map.insert("name", obj->getEnglishName()); map.insert("name", obj->getEnglishName());
map.insert("localized-name", obj->getNameI18n()); map.insert("localized-name", obj->getNameI18n());
return map; return map;
} }
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);
MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr); SporadicMeteorMgr* mmgr = GETSTELMODULE(SporadicMeteorMgr);
StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer (); StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer ();
ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr); ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr);
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")
{ {
skipping to change at line 1071 skipping to change at line 1090
cmgr->setFlagBoundaries(false); cmgr->setFlagBoundaries(false);
cmgr->setFlagArt(false); cmgr->setFlagArt(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")
{
movmgr->setMountMode(StelMovementMgr::MountGalactic);
skyd->setFlagTwinkle(false);
skyd->setFlagLuminanceAdaptation(false);
ssmgr->setFlagPlanets(false);
ssmgr->setFlagHints(false);
ssmgr->setFlagOrbits(false);
ssmgr->setFlagMoonScale(false);
ssmgr->setFlagTrails(false);
mmgr->setZHR(0);
glmgr->setFlagAzimuthalGrid(false);
glmgr->setFlagGalacticGrid(false);
glmgr->setFlagEquatorGrid(false);
glmgr->setFlagEquatorLine(false);
glmgr->setFlagEclipticLine(false);
glmgr->setFlagMeridianLine(false);
glmgr->setFlagLongitudeLine(false);
glmgr->setFlagHorizonLine(false);
glmgr->setFlagGalacticEquatorLine(false);
glmgr->setFlagEquatorJ2000Grid(false);
lmgr->setFlagCardinalsPoints(false);
cmgr->setFlagLines(false);
cmgr->setFlagLabels(false);
cmgr->setFlagBoundaries(false);
cmgr->setFlagArt(false);
smgr->setFlagLabels(false);
ssmgr->setFlagLabels(false);
nmgr->setFlagHints(false);
lmgr->setFlagLandscape(false);
lmgr->setFlagAtmosphere(false);
lmgr->setFlagFog(false);
zl->setFlagShow(false);
}
else else
{ {
qWarning() << "WARNING clear(" << state << ") - state not kn own"; qWarning() << "WARNING clear(" << state << ") - state not kn own";
} }
} }
double StelMainScriptAPI::getViewAltitudeAngle() double StelMainScriptAPI::getViewAltitudeAngle()
{ {
const Vec3d& current = StelApp::getInstance().getCore()->j2000ToAltA z(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000(), StelCore::Refrac tionOff); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToAltA z(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000(), StelCore::Refrac tionOff);
double alt, azi; double alt, azi;
skipping to change at line 1141 skipping to change at line 1194
{ {
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mvmgr); Q_ASSERT(mvmgr);
GETSTELMODULE(StelObjectMgr)->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);
if (StelApp::getInstance().getFlagOldAzimuthUsage())
dAzi -= M_PI;
StelUtils::spheToRect(dAzi,dAlt,aim); StelUtils::spheToRect(dAzi,dAlt,aim);
mvmgr->moveToJ2000(StelApp::getInstance().getCore()->altAzToJ2000(ai m, StelCore::RefractionOff), duration); mvmgr->moveToJ2000(StelApp::getInstance().getCore()->altAzToJ2000(ai m, StelCore::RefractionOff), duration);
} }
void StelMainScriptAPI::moveToRaDec(const QString& ra, const QString& dec, float duration) void StelMainScriptAPI::moveToRaDec(const QString& ra, const QString& dec, float duration)
{ {
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mvmgr); Q_ASSERT(mvmgr);
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
 End of changes. 23 change blocks. 
36 lines changed or deleted 95 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/