StelMainScriptAPI.cpp   StelMainScriptAPI.cpp 
skipping to change at line 43 skipping to change at line 43
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelAudioMgr.hpp" #include "StelAudioMgr.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 "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelNavigator.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 <QAction> #include <QAction>
skipping to change at line 94 skipping to change at line 94
} }
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
void StelMainScriptAPI::setJDay(double JD) void StelMainScriptAPI::setJDay(double JD)
{ {
StelApp::getInstance().getCore()->getNavigator()->setJDay(JD); StelApp::getInstance().getCore()->setJDay(JD);
} }
//! Get the current date in Julian Day //! Get the current date in Julian Day
//! @return the Julian Date //! @return the Julian Date
double StelMainScriptAPI::getJDay() const double StelMainScriptAPI::getJDay() const
{ {
return StelApp::getInstance().getCore()->getNavigator()->getJDay(); return StelApp::getInstance().getCore()->getJDay();
} }
void StelMainScriptAPI::setDate(const QString& dt, const QString& spec) void StelMainScriptAPI::setDate(const QString& dt, const QString& spec)
{ {
StelApp::getInstance().getCore()->getNavigator()->setJDay(jdFromDate String(dt, spec)); StelApp::getInstance().getCore()->setJDay(jdFromDateString(dt, spec) );
} }
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);
} }
//! Set time speed in JDay/sec //! Set time speed in JDay/sec
//! @param ts time speed in JDay/sec //! @param ts time speed in JDay/sec
void StelMainScriptAPI::setTimeRate(double ts) void StelMainScriptAPI::setTimeRate(double ts)
{ {
// 1 second = .00001157407407407407 JDay // 1 second = .00001157407407407407 JDay
StelApp::getInstance().getCore()->getNavigator()->setTimeRate(ts * 0 .00001157407407407407 * StelMainGraphicsView::getInstance().getScriptMgr(). getScriptRate()); StelApp::getInstance().getCore()->setTimeRate(ts * 0.000011574074074 07407 * StelMainGraphicsView::getInstance().getScriptMgr().getScriptRate()) ;
} }
//! Get time speed in JDay/sec //! Get time speed in JDay/sec
//! @return time speed in JDay/sec //! @return time speed in JDay/sec
double StelMainScriptAPI::getTimeRate() const double StelMainScriptAPI::getTimeRate() const
{ {
return StelApp::getInstance().getCore()->getNavigator()->getTimeRate () / (0.00001157407407407407 * StelMainGraphicsView::getInstance().getScrip tMgr().getScriptRate()); return StelApp::getInstance().getCore()->getTimeRate() / (0.00001157 407407407407 * StelMainGraphicsView::getInstance().getScriptMgr().getScript Rate());
} }
bool StelMainScriptAPI::isRealTime() bool StelMainScriptAPI::isRealTime()
{ {
return StelApp::getInstance().getCore()->getNavigator()->getIsTimeNo w(); return StelApp::getInstance().getCore()->getIsTimeNow();
} }
void StelMainScriptAPI::setRealTime() void StelMainScriptAPI::setRealTime()
{ {
setTimeRate(1.0); setTimeRate(1.0);
StelApp::getInstance().getCore()->getNavigator()->setTimeNow(); StelApp::getInstance().getCore()->setTimeNow();
} }
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( StelCore* core = StelApp::getInstance().getCore();
);
Q_ASSERT(nav);
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem); SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
Q_ASSERT(ssmgr); Q_ASSERT(ssmgr);
StelLocation loc = nav->getCurrentLocation(); StelLocation loc = core->getCurrentLocation();
loc.longitude = longitude; loc.longitude = longitude;
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))
loc.planetName = planet; loc.planetName = planet;
loc.name = name; loc.name = name;
nav->moveObserverTo(loc, duration); core->moveObserverTo(loc, duration);
} }
void StelMainScriptAPI::setObserverLocation(const QString id, float duratio n) void StelMainScriptAPI::setObserverLocation(const QString id, float duratio n)
{ {
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( StelCore* core = StelApp::getInstance().getCore();
);
Q_ASSERT(nav);
bool ok; bool ok;
StelLocation loc = StelApp::getInstance().getLocationMgr().locationF orSmallString(id, &ok); StelLocation loc = StelApp::getInstance().getLocationMgr().locationF orSmallString(id, &ok);
if (!ok) if (!ok)
return; // location find failed return; // location find failed
nav->moveObserverTo(loc, duration); core->moveObserverTo(loc, duration);
} }
QString StelMainScriptAPI::getObserverLocation() QString StelMainScriptAPI::getObserverLocation()
{ {
return StelApp::getInstance().getCore()->getNavigator()->getCurrentL ocation().getID(); return StelApp::getInstance().getCore()->getCurrentLocation().getID( );
} }
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);
} }
skipping to change at line 466 skipping to change at line 464
QRegExp nowRe("^(now)?(\\s*([+\\-])\\s*(\\d+(\\.\\d+)?)\\s*(second|s econds|minute|minutes|hour|hours|day|days|week|weeks))(\\s+(sidereal)?)?"); QRegExp nowRe("^(now)?(\\s*([+\\-])\\s*(\\d+(\\.\\d+)?)\\s*(second|s econds|minute|minutes|hour|hours|day|days|week|weeks))(\\s+(sidereal)?)?");
if (nowRe.exactMatch(dt)) if (nowRe.exactMatch(dt))
{ {
double delta; double delta;
double unit; double unit;
double dayLength = 1.0; double dayLength = 1.0;
if (nowRe.capturedTexts().at(1)=="now") if (nowRe.capturedTexts().at(1)=="now")
jd = StelUtils::getJDFromSystem(); jd = StelUtils::getJDFromSystem();
else else
jd = StelApp::getInstance().getCore()->getNavigator( )->getJDay(); jd = StelApp::getInstance().getCore()->getJDay();
if (nowRe.capturedTexts().at(8) == "sidereal") if (nowRe.capturedTexts().at(8) == "sidereal")
dayLength = StelApp::getInstance().getCore()->getNav igator()->getLocalSideralDayLength(); dayLength = StelApp::getInstance().getCore()->getLoc alSideralDayLength();
QString unitString = nowRe.capturedTexts().at(6); QString unitString = nowRe.capturedTexts().at(6);
if (unitString == "seconds" || unitString == "second") if (unitString == "seconds" || unitString == "second")
unit = dayLength / (24*3600.); unit = dayLength / (24*3600.);
else if (unitString == "minutes" || unitString == "minute") else if (unitString == "minutes" || unitString == "minute")
unit = dayLength / (24*60.); unit = dayLength / (24*60.);
else if (unitString == "hours" || unitString == "hour") else if (unitString == "hours" || unitString == "hour")
unit = dayLength / (24.); unit = dayLength / (24.);
else if (unitString == "days" || unitString == "day") else if (unitString == "days" || unitString == "day")
unit = dayLength; unit = dayLength;
skipping to change at line 528 skipping to change at line 526
{ {
debug("getObjectData WARNING - object not found: " + name); debug("getObjectData WARNING - object not found: " + name);
map.insert("found", false); map.insert("found", false);
return map; return map;
} }
else else
{ {
map.insert("found", true); map.insert("found", true);
} }
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
Vec3d pos; Vec3d pos;
double ra, dec, alt, azi; double ra, dec, alt, azi;
// ra/dec // ra/dec
pos = obj->getEquinoxEquatorialPos(nav); pos = obj->getEquinoxEquatorialPos(StelApp::getInstance().getCore()) ;
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(nav); pos = obj->getJ2000EquatorialPos(StelApp::getInstance().getCore());
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);
// altitude/azimuth // altitude/azimuth
pos = obj->getAltAzPos(nav); pos = obj->getAltAzPosApparent(StelApp::getInstance().getCore());
StelUtils::rectToSphe(&azi, &alt, pos); StelUtils::rectToSphe(&azi, &alt, pos);
map.insert("altitude", alt*180./M_PI); map.insert("altitude", alt*180./M_PI);
map.insert("azimuth", azi*180./M_PI); map.insert("azimuth", azi*180./M_PI);
return map; return map;
} }
void StelMainScriptAPI::clear(const QString& state) void StelMainScriptAPI::clear(const QString& state)
{ {
LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
skipping to change at line 660 skipping to change at line 657
lmgr->setFlagFog(false); lmgr->setFlagFog(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()->getNavigato r()->j2000ToAltAz(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000()); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToAltA z(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000(), StelCore::Refrac tionOff);
double alt, azi; double alt, azi;
StelUtils::rectToSphe(&azi, &alt, current); StelUtils::rectToSphe(&azi, &alt, current);
return alt*180/M_PI; // convert to degrees from radians return alt*180/M_PI; // convert to degrees from radians
} }
double StelMainScriptAPI::getViewAzimuthAngle() double StelMainScriptAPI::getViewAzimuthAngle()
{ {
const Vec3d& current = StelApp::getInstance().getCore()->getNavigato r()->j2000ToAltAz(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000()); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToAltA z(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000(), StelCore::Refrac tionOff);
double alt, azi; double alt, azi;
StelUtils::rectToSphe(&azi, &alt, current); StelUtils::rectToSphe(&azi, &alt, current);
// The returned azimuth angle is in radians and set up such that: // The returned azimuth angle is in radians and set up such that:
// N=+/-PI; E=PI/2; S=0; W=-PI/2; // N=+/-PI; E=PI/2; S=0; W=-PI/2;
// But we want compass bearings, i.e. N=0, E=90, S=180, W=270 // But we want compass bearings, i.e. N=0, E=90, S=180, W=270
return std::fmod(((azi*180/M_PI)*-1)+180., 360.); return std::fmod(((azi*180/M_PI)*-1)+180., 360.);
} }
double StelMainScriptAPI::getViewRaAngle() double StelMainScriptAPI::getViewRaAngle()
{ {
const Vec3d& current = StelApp::getInstance().getCore()->getNavigato r()->j2000ToEquinoxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ200 0()); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToEqui noxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000());
double ra, dec; double ra, dec;
StelUtils::rectToSphe(&ra, &dec, current); StelUtils::rectToSphe(&ra, &dec, current);
// returned RA angle is in range -PI .. PI, but we want 0 .. 360 // returned RA angle is in range -PI .. PI, but we want 0 .. 360
return std::fmod((ra*180/M_PI)+360., 360.); // convert to degrees fr om radians return std::fmod((ra*180/M_PI)+360., 360.); // convert to degrees fr om radians
} }
double StelMainScriptAPI::getViewDecAngle() double StelMainScriptAPI::getViewDecAngle()
{ {
const Vec3d& current = StelApp::getInstance().getCore()->getNavigato r()->j2000ToEquinoxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ200 0()); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToEqui noxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000());
double ra, dec; double ra, dec;
StelUtils::rectToSphe(&ra, &dec, current); StelUtils::rectToSphe(&ra, &dec, current);
return dec*180/M_PI; // convert to degrees from radians return dec*180/M_PI; // convert to degrees from radians
} }
double StelMainScriptAPI::getViewRaJ2000Angle() double StelMainScriptAPI::getViewRaJ2000Angle()
{ {
Vec3d current = GETSTELMODULE(StelMovementMgr)->getViewDirectionJ200 0(); Vec3d current = GETSTELMODULE(StelMovementMgr)->getViewDirectionJ200 0();
double ra, dec; double ra, dec;
StelUtils::rectToSphe(&ra, &dec, current); StelUtils::rectToSphe(&ra, &dec, current);
skipping to change at line 723 skipping to change at line 720
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);
StelUtils::spheToRect(dAzi,dAlt,aim); StelUtils::spheToRect(dAzi,dAlt,aim);
mvmgr->moveToJ2000(StelApp::getInstance().getCore()->getNavigator()- >altAzToJ2000(aim), 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();
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->moveToJ2000(StelApp::getInstance().getCore()->getNavigator()- >equinoxEquToJ2000(aim), duration); mvmgr->moveToJ2000(StelApp::getInstance().getCore()->equinoxEquToJ20 00(aim), duration);
} }
void StelMainScriptAPI::moveToRaDecJ2000(const QString& ra, const QString& dec, float duration) void StelMainScriptAPI::moveToRaDecJ2000(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();
Vec3d aimJ2000, aimEquofDate; Vec3d aimJ2000, aimEquofDate;
double dRa = StelUtils::getDecAngle(ra); double dRa = StelUtils::getDecAngle(ra);
double dDec = StelUtils::getDecAngle(dec); double dDec = StelUtils::getDecAngle(dec);
StelUtils::spheToRect(dRa,dDec,aimJ2000); StelUtils::spheToRect(dRa,dDec,aimJ2000);
aimEquofDate = StelApp::getInstance().getCore()->getNavigator()->j20 00ToEquinoxEqu(aimJ2000); aimEquofDate = StelApp::getInstance().getCore()->j2000ToEquinoxEqu(a imJ2000);
mvmgr->moveToJ2000(aimEquofDate, duration); mvmgr->moveToJ2000(aimEquofDate, duration);
} }
QString StelMainScriptAPI::getAppLanguage() QString StelMainScriptAPI::getAppLanguage()
{ {
return StelApp::getInstance().getLocaleMgr().getAppLanguage(); return StelApp::getInstance().getLocaleMgr().getAppLanguage();
} }
void StelMainScriptAPI::setAppLanguage(QString langCode) void StelMainScriptAPI::setAppLanguage(QString langCode)
{ {
 End of changes. 27 change blocks. 
31 lines changed or deleted 26 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/