StelMainScriptAPI.cpp   StelMainScriptAPI.cpp 
skipping to change at line 164 skipping to change at line 164
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(getJDay())/3600.);
} }
QString StelMainScriptAPI::getDeltaTAlgorithm() const
{
return StelApp::getInstance().getCore()->getCurrentDeltaTAlgorithmKe
y();
}
void StelMainScriptAPI::setDeltaTAlgorithm(QString algorithmName)
{
StelApp::getInstance().getCore()->setCurrentDeltaTAlgorithmKey(algor
ithmName);
}
//! 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()->setTimeRate(ts * 0.000011574074074 07407 * 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
skipping to change at line 482 skipping to change at line 492
void StelMainScriptAPI::loadSound(const QString& filename, const QString& i d) void StelMainScriptAPI::loadSound(const QString& filename, const QString& i d)
{ {
QString path; QString path;
try try
{ {
path = StelFileMgr::findFile("scripts/" + filename); path = StelFileMgr::findFile("scripts/" + filename);
} }
catch(std::runtime_error& e) catch(std::runtime_error& e)
{ {
qWarning() << "cannot play sound" << filename << ":" << e.wh at(); qWarning() << "cannot play sound" << QDir::toNativeSeparator s(filename) << ":" << e.what();
return; return;
} }
emit(requestLoadSound(path, id)); emit(requestLoadSound(path, id));
} }
void StelMainScriptAPI::playSound(const QString& id) void StelMainScriptAPI::playSound(const QString& id)
{ {
emit(requestPlaySound(id)); emit(requestPlaySound(id));
} }
skipping to change at line 518 skipping to change at line 528
void StelMainScriptAPI::loadVideo(const QString& filename, const QString& i d, float x, float y, bool show, float alpha) void StelMainScriptAPI::loadVideo(const QString& filename, const QString& i d, float x, float y, bool show, float alpha)
{ {
QString path; QString path;
try try
{ {
path = StelFileMgr::findFile("scripts/" + filename); path = StelFileMgr::findFile("scripts/" + filename);
} }
catch(std::runtime_error& e) catch(std::runtime_error& e)
{ {
qWarning() << "cannot play video" << filename << ":" << e.wh at(); qWarning() << "cannot play video" << QDir::toNativeSeparator s(filename) << ":" << e.what();
return; return;
} }
emit(requestLoadVideo(path, id, x, y, show, alpha)); emit(requestLoadVideo(path, id, x, y, show, alpha));
} }
void StelMainScriptAPI::playVideo(const QString& id) void StelMainScriptAPI::playVideo(const QString& id)
{ {
emit(requestPlayVideo(id)); emit(requestPlayVideo(id));
} }
skipping to change at line 625 skipping to change at line 635
} }
void StelMainScriptAPI::debug(const QString& s) void StelMainScriptAPI::debug(const QString& s)
{ {
qDebug() << "script: " << s; qDebug() << "script: " << s;
StelMainGraphicsView::getInstance().getScriptMgr().debug(s); StelMainGraphicsView::getInstance().getScriptMgr().debug(s);
} }
double StelMainScriptAPI::jdFromDateString(const QString& dt, const QString & spec) double StelMainScriptAPI::jdFromDateString(const QString& dt, const QString & spec)
{ {
StelCore *core = StelApp::getInstance().getCore();
if (dt == "now") if (dt == "now")
return StelUtils::getJDFromSystem(); return StelUtils::getJDFromSystem();
bool ok; bool ok;
double jd; double jd;
if (spec=="local") if (spec=="local")
{ {
jd = StelApp::getInstance().getLocaleMgr().getJdFromISO8601T imeLocal(dt, &ok); jd = StelApp::getInstance().getLocaleMgr().getJdFromISO8601T imeLocal(dt, &ok);
} }
else else
{ {
jd = StelUtils::getJulianDayFromISO8601String(dt, &ok); jd = StelUtils::getJulianDayFromISO8601String(dt, &ok);
} }
if (ok) if (ok)
return jd; return jd;
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|month|months|year|year s))(\\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;
double yearLength = 365.242190419; // duration of Earth's me
an tropical year
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 = StelApp::getInstance().getCore()->getJDay(); jd = core->getJDay();
if (nowRe.capturedTexts().at(8) == "sidereal") if (nowRe.capturedTexts().at(8) == "sidereal")
dayLength = StelApp::getInstance().getCore()->getLoc {
alSideralDayLength(); dayLength = core->getLocalSideralDayLength();
yearLength = core->getLocalSideralYearLength();
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")
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;
else if (unitString == "weeks" || unitString == "week") else if (unitString == "weeks" || unitString == "week")
unit = dayLength * 7.; unit = dayLength * 7.;
else if (unitString == "months" || unitString == "month")
unit = monthLength;
else if (unitString == "years" || unitString == "year")
unit = yearLength;
else else
{ {
qWarning() << "StelMainScriptAPI::setDate - unknown time unit:" << nowRe.capturedTexts().at(4); qWarning() << "StelMainScriptAPI::setDate - unknown time unit:" << nowRe.capturedTexts().at(4);
unit = 0; unit = 0;
} }
delta = nowRe.capturedTexts().at(4).toDouble(); delta = nowRe.capturedTexts().at(4).toDouble();
if (nowRe.capturedTexts().at(3) == "+") if (nowRe.capturedTexts().at(3) == "+")
jd += (unit * delta); jd += (unit * delta);
skipping to change at line 766 skipping to change at line 787
// angular size // angular size
map.insert("size", obj->getAngularSize(core)); map.insert("size", obj->getAngularSize(core));
// localized name // localized name
map.insert("localized-name", obj->getNameI18n()); map.insert("localized-name", obj->getNameI18n());
return map; return map;
} }
QVariantMap StelMainScriptAPI::getSelectedObjectInfo()
{
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
QVariantMap map;
if (omgr->getSelectedObject().isEmpty())
{
debug("getObjectData WARNING - object not selected");
map.insert("found", false);
return map;
}
StelObjectP obj = omgr->getSelectedObject()[0];
if (!obj)
{
debug("getObjectData WARNING - object not found");
map.insert("found", false);
return map;
}
else
{
map.insert("found", true);
}
// OK, object found. Let's go.
Vec3d pos;
double ra, dec, alt, azi, glong, glat;
StelCore* core = StelApp::getInstance().getCore();
// ra/dec
pos = obj->getEquinoxEquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos);
map.insert("ra", ra*180./M_PI);
map.insert("dec", dec*180./M_PI);
// ra/dec in J2000
pos = obj->getJ2000EquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos);
map.insert("raJ2000", ra*180./M_PI);
map.insert("decJ2000", dec*180./M_PI);
// apparent altitude/azimuth
pos = obj->getAltAzPosApparent(core);
StelUtils::rectToSphe(&azi, &alt, pos);
map.insert("altitude", alt*180./M_PI);
map.insert("azimuth", azi*180./M_PI);
// geometric altitude/azimuth
pos = obj->getAltAzPosGeometric(core);
StelUtils::rectToSphe(&azi, &alt, pos);
map.insert("altitude-geometric", alt*180./M_PI);
map.insert("azimuth-geometric", azi*180./M_PI);
// galactic long/lat in J2000
pos = obj->getJ2000GalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("glong", alt*180./M_PI);
map.insert("glat", azi*180./M_PI);
// magnitude
map.insert("vmag", obj->getVMagnitude(core, false));
map.insert("vmage", obj->getVMagnitude(core, true));
// angular size
map.insert("size", obj->getAngularSize(core));
// english name or designation & localized name
map.insert("name", obj->getEnglishName());
map.insert("localized-name", obj->getNameI18n());
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); MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr);
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);
 End of changes. 10 change blocks. 
6 lines changed or deleted 104 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/