StelMainScriptAPI.cpp   StelMainScriptAPI.cpp 
skipping to change at line 74 skipping to change at line 74
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QTimer> #include <QTimer>
#include <QEventLoop> #include <QEventLoop>
#include <cmath> #include <cmath>
StelMainScriptAPI::StelMainScriptAPI(QObject *parent) : QObject(parent) StelMainScriptAPI::StelMainScriptAPI(QObject *parent) : QObject(parent)
{ {
if(StelSkyLayerMgr* smgr = GETSTELMODULE(StelSkyLayerMgr)) if(StelSkyLayerMgr* smgr = GETSTELMODULE(StelSkyLayerMgr))
{ {
connect(this, SIGNAL(requestLoadSkyImage(const QString&, con connect(this, SIGNAL(requestLoadSkyImage(const QString&, con
st QString&, double, double, double, double, double, double, double, double st QString&, double, double, double, double, double, double, double, double
, double, double, bool)), smgr, SLOT(loadSkyImage(const QString&, const QSt , double, double, bool, StelCore::FrameType)),
ring&, double, double, double, double, double, double, double, double, doub smgr, SLOT( loadSkyImage(const QString&, con
le, double, bool))); st QString&, double, double, double, double, double, double, double, double
connect(this, SIGNAL(requestLoadSkyImageAltAz(const QString& , double, double, bool, StelCore::FrameType)));
, const QString&, double, double, double, double, double, double, double, d // The next is deprecated and should be removed in V0.16.
ouble, double, double, bool)), smgr, SLOT(loadSkyImageAltAz(const QString&, connect(this, SIGNAL(requestLoadSkyImageAltAz(const QString&
const QString&, double, double, double, double, double, double, double, do , const QString&, double, double, double, double, double, double, double, d
uble, double, double, bool))); ouble, double, double, bool)),
smgr, SLOT( loadSkyImageAltAz(const QString&
, const QString&, double, double, double, double, double, double, double, d
ouble, double, double, bool)));
connect(this, SIGNAL(requestRemoveSkyImage(const QString&)), smgr, SLOT(removeSkyLayer(const QString&))); connect(this, SIGNAL(requestRemoveSkyImage(const QString&)), smgr, SLOT(removeSkyLayer(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&)));
connect(this, SIGNAL(requestLoadVideo(const QString&, const QString& , float, float, bool, float)), StelApp::getInstance().getStelVideoMgr(), SL OT(loadVideo(const QString&, const QString&, float, float, bool, float))); connect(this, SIGNAL(requestLoadVideo(const QString&, const QString& , float, float, bool, float)), StelApp::getInstance().getStelVideoMgr(), SL OT(loadVideo(const QString&, const QString&, float, float, bool, float)));
skipping to change at line 421 skipping to change at line 425
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
core->getMovementMgr()->moveViewport(x,y); core->getMovementMgr()->moveViewport(x,y);
} }
void StelMainScriptAPI::setViewportStretch(const float stretch) void StelMainScriptAPI::setViewportStretch(const float stretch)
{ {
StelApp::getInstance().getCore()->setViewportStretch(stretch); StelApp::getInstance().getCore()->setViewportStretch(stretch);
} }
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name, void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name,
double ra0, double dec0, double lon0, double lat0,
double ra1, double dec1, double lon1, double lat1,
double ra2, double dec2, double lon2, double lat2,
double ra3, double dec3, double lon3, double lat3,
double minRes, double maxBright, bool v double minRes, double maxBright, bool v
isible) isible, const QString &frame)
{ {
QString path = "scripts/" + filename; QString path = "scripts/" + filename;
emit(requestLoadSkyImage(id, path, ra0, dec0, ra1, dec1, ra2, dec2, StelCore::FrameType frameType=StelCore::FrameJ2000;
ra3, dec3, minRes, maxBright, visible)); if (frame=="EqDate")
frameType=StelCore::FrameEquinoxEqu;
else if (frame=="EclJ2000")
frameType=StelCore::FrameObservercentricEclipticJ2000;
else if (frame=="EclDate")
frameType=StelCore::FrameObservercentricEclipticOfDate;
else if (frame.startsWith("Gal"))
frameType=StelCore::FrameGalactic;
else if (frame.startsWith("SuperG"))
frameType=StelCore::FrameSupergalactic;
else if (frame=="AzAlt")
frameType=StelCore::FrameAltAz;
else if (frame!="EqJ2000")
{
qDebug() << "StelMainScriptAPI::loadSkyImage(): unknown fram
e type " << frame << " requested -- Using Equatorial J2000";
}
emit(requestLoadSkyImage(id, path, lon0, lat0, lon1, lat1, lon2, lat
2, lon3, lat3, minRes, maxBright, visible, frameType));
} }
// Convenience method:
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name, void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name,
const QString& ra0, const QString& dec0 const QString& lon0, const QString& lat
, 0,
const QString& ra1, const QString& dec1 const QString& lon1, const QString& lat
, 1,
const QString& ra2, const QString& dec2 const QString& lon2, const QString& lat
, 2,
const QString& ra3, const QString& dec3 const QString& lon3, const QString& lat
, 3,
double minRes, double maxBright, bool v double minRes, double maxBright, bool v
isible) isible, const QString& frame)
{ {
loadSkyImage(id, filename, loadSkyImage(id, filename,
StelUtils::getDecAngle(ra0) *180./M_PI, StelUtils::getD StelUtils::getDecAngle(lon0) *180./M_PI, StelUtils::get
ecAngle(dec0)*180./M_PI, DecAngle(lat0)*180./M_PI,
StelUtils::getDecAngle(ra1) *180./M_PI, StelUtils::getD StelUtils::getDecAngle(lon1) *180./M_PI, StelUtils::get
ecAngle(dec1)*180./M_PI, DecAngle(lat1)*180./M_PI,
StelUtils::getDecAngle(ra2) *180./M_PI, StelUtils::getD StelUtils::getDecAngle(lon2) *180./M_PI, StelUtils::get
ecAngle(dec2)*180./M_PI, DecAngle(lat2)*180./M_PI,
StelUtils::getDecAngle(ra3) *180./M_PI, StelUtils::getD StelUtils::getDecAngle(lon3) *180./M_PI, StelUtils::get
ecAngle(dec3)*180./M_PI, DecAngle(lat3)*180./M_PI,
minRes, maxBright, visible); minRes, maxBright, visible, frame);
} }
// Convenience method: (Fixed 2017-03: rotation increased by 90deg, makes u pright images now!)
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name, void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name,
double ra, double dec, double angSize, double lon, double lat, double angSize,
double rotation, double rotation,
double minRes, double maxBright, bool v double minRes, double maxBright, bool v
isible) isible, const QString &frame)
{ {
Vec3f XYZ; Vec3f XYZ;
static const float RADIUS_NEB = 1.; static const float RADIUS_NEB = 1.f;
StelUtils::spheToRect(ra*M_PI/180., dec*M_PI/180., XYZ); StelUtils::spheToRect(lon*M_PI/180., lat*M_PI/180., XYZ);
XYZ*=RADIUS_NEB; XYZ*=RADIUS_NEB;
float texSize = RADIUS_NEB * sin(angSize/2/60*M_PI/180); float texSize = RADIUS_NEB * sin(angSize/2./60.*M_PI/180.);
Mat4f matPrecomp = Mat4f::translation(XYZ) * Mat4f matPrecomp = Mat4f::translation(XYZ) *
Mat4f::zrotation(ra*M_PI/180.) * Mat4f::zrotation(lon*M_PI/180.) *
Mat4f::yrotation(-dec*M_PI/180.) * Mat4f::yrotation(-lat*M_PI/180.) *
Mat4f::xrotation(rotation*M_PI/180.); Mat4f::xrotation((rotation+90.0)*M_PI/180.);
Vec3f corners[4]; Vec3f corners[4];
corners[0] = matPrecomp * Vec3f(0.f,-texSize,-texSize); corners[0] = matPrecomp * Vec3f(0.f,-texSize,-texSize);
corners[1] = matPrecomp * Vec3f(0.f,-texSize, texSize); corners[1] = matPrecomp * Vec3f(0.f,-texSize, texSize);
corners[2] = matPrecomp * Vec3f(0.f, texSize,-texSize); corners[2] = matPrecomp * Vec3f(0.f, texSize,-texSize);
corners[3] = matPrecomp * Vec3f(0.f, texSize, texSize); corners[3] = matPrecomp * Vec3f(0.f, texSize, texSize);
// convert back to ra/dec (radians) // convert back to ra/dec (radians)
Vec3f cornersRaDec[4]; Vec3f cornersRaDec[4];
for(int i=0; i<4; i++) for(int i=0; i<4; i++)
StelUtils::rectToSphe(&cornersRaDec[i][0], &cornersRaDec[i][ 1], corners[i]); StelUtils::rectToSphe(&cornersRaDec[i][0], &cornersRaDec[i][ 1], corners[i]);
loadSkyImage(id, filename, loadSkyImage(id, filename,
cornersRaDec[0][0]*180./M_PI, cornersRaDec[0][1]*180./M _PI, cornersRaDec[0][0]*180./M_PI, cornersRaDec[0][1]*180./M _PI,
cornersRaDec[1][0]*180./M_PI, cornersRaDec[1][1]*180./M _PI, cornersRaDec[1][0]*180./M_PI, cornersRaDec[1][1]*180./M _PI,
cornersRaDec[3][0]*180./M_PI, cornersRaDec[3][1]*180./M _PI, cornersRaDec[3][0]*180./M_PI, cornersRaDec[3][1]*180./M _PI,
cornersRaDec[2][0]*180./M_PI, cornersRaDec[2][1]*180./M _PI, cornersRaDec[2][0]*180./M_PI, cornersRaDec[2][1]*180./M _PI,
minRes, maxBright, visible); minRes, maxBright, visible, frame);
} }
// Convenience method:
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name, void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name,
const QString& ra, const QString& dec, const QString& lon, const QString& lat,
double angSize, double rotation, double angSize, double rotation,
double minRes, double maxBright, bool v isible) double minRes, double maxBright, bool v isible, const QString &frame)
{ {
loadSkyImage(id, filename, StelUtils::getDecAngle(ra)*180./M_PI, loadSkyImage(id, filename, StelUtils::getDecAngle(lon)*180./M_PI,
StelUtils::getDecAngle(dec)*180./M_PI, angSize, StelUtils::getDecAngle(lat)*180./M_PI, angSize,
rotation, minRes, maxBright, visible); rotation, minRes, maxBright, visible, frame);
} }
// DEPRECATED with old name
void StelMainScriptAPI::loadSkyImageAltAz(const QString& id, const QString& filename, void StelMainScriptAPI::loadSkyImageAltAz(const QString& id, const QString& filename,
double azi0, double alt0, double azi0, double alt0,
double azi1, double alt1, double azi1, double alt1,
double azi2, double alt2, double azi2, double alt2,
double azi3, double alt3, double azi3, double alt3,
double minRes, double maxBright, b ool visible) double minRes, double maxBright, b ool visible)
{ {
qDebug() << "StelMainScriptAPI::loadSkyImageAltAz() is deprecated an d will not be available in version 0.16! Please use loadSkyImageAzAlt()";
QString path = "scripts/" + filename; QString path = "scripts/" + filename;
emit(requestLoadSkyImageAltAz(id, path, alt0, azi0, alt1, azi1, alt2 , azi2, alt3, azi3, minRes, maxBright, visible)); emit(requestLoadSkyImageAltAz(id, path, alt0, azi0, alt1, azi1, alt2 , azi2, alt3, azi3, minRes, maxBright, visible));
} }
// DEPRECATED with old argument order and name.
void StelMainScriptAPI::loadSkyImageAltAz(const QString& id, const QString& filename, void StelMainScriptAPI::loadSkyImageAltAz(const QString& id, const QString& filename,
double alt, double azi, double alt, double azi,
double angSize, double rotation, double angSize, double rotation,
double minRes, double maxBright, b ool visible) double minRes, double maxBright, b ool visible)
{ {
qDebug() << "StelMainScriptAPI::loadSkyImageAltAz() is deprecated an
d will not be available in version 0.16! Please use loadSkyImageAzAlt()";
Vec3f XYZ; Vec3f XYZ;
static const float RADIUS_NEB = 1.; static const float RADIUS_NEB = 1.0f;
StelUtils::spheToRect((180-azi)*M_PI/180., alt*M_PI/180., XYZ); StelUtils::spheToRect((180.0-azi)*M_PI/180., alt*M_PI/180., XYZ);
XYZ*=RADIUS_NEB; XYZ*=RADIUS_NEB;
float texSize = RADIUS_NEB * sin(angSize/2/60*M_PI/180); float texSize = RADIUS_NEB * sin(angSize/2.0f/60.0f*M_PI/180.0f);
Mat4f matPrecomp = Mat4f::translation(XYZ) * Mat4f matPrecomp = Mat4f::translation(XYZ) *
Mat4f::zrotation((180.-azi)*M_PI/180.) * Mat4f::zrotation((180.-azi)*M_PI/180.) *
Mat4f::yrotation(-alt*M_PI/180.) * Mat4f::yrotation(-alt*M_PI/180.) *
Mat4f::xrotation((rotation+90.)*M_PI/180.); Mat4f::xrotation((rotation+90.)*M_PI/180.);
Vec3f corners[4]; Vec3f corners[4];
corners[0] = matPrecomp * Vec3f(0.f,-texSize,-texSize); corners[0] = matPrecomp * Vec3f(0.f,-texSize,-texSize);
corners[1] = matPrecomp * Vec3f(0.f,-texSize, texSize); corners[1] = matPrecomp * Vec3f(0.f,-texSize, texSize);
corners[2] = matPrecomp * Vec3f(0.f, texSize,-texSize); corners[2] = matPrecomp * Vec3f(0.f, texSize,-texSize);
corners[3] = matPrecomp * Vec3f(0.f, texSize, texSize); corners[3] = matPrecomp * Vec3f(0.f, texSize, texSize);
skipping to change at line 707 skipping to change at line 737
{ {
QCoreApplication::exit(); QCoreApplication::exit();
} }
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) void StelMainScriptAPI::output(const QString &s) const
{ {
StelApp::getInstance().getScriptMgr().output(s); StelApp::getInstance().getScriptMgr().output(s);
} }
void StelMainScriptAPI::resetOutput(void) //! print contents of a QVariantMap
//! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo()
QString StelMainScriptAPI::mapToString(const QVariantMap& map) const
{
QString res = QString("[\n");
QList<QVariant::Type> simpleTypeList;
simpleTypeList.push_back(QVariant::Bool);
simpleTypeList.push_back(QVariant::Int);
simpleTypeList.push_back(QVariant::UInt);
simpleTypeList.push_back(QVariant::Double);
QVariantMap::const_iterator i=map.constBegin();
while (i != map.constEnd()){
if (i.value().type()==QMetaType::QString)
{
res.append(QString("[ \"%1\" = \"%2\" ]\n").arg(i.ke
y()).arg(i.value().toString()));
}
else if (simpleTypeList.contains(i.value().type()))
{
res.append(QString("[ \"%1\" = %2 ]\n").arg(i.key())
.arg(i.value().toString()));
}
else
{
res.append(QString("[ \"%1\" = \"<%2>:%3\" ]\n").arg
(i.key()).arg(i.value().typeName()).arg(i.value().toString()));
}
++i;
}
res.append( QString("]\n"));
return res;
}
void StelMainScriptAPI::resetOutput(void) const
{ {
StelApp::getInstance().getScriptMgr().resetOutput(); StelApp::getInstance().getScriptMgr().resetOutput();
} }
void StelMainScriptAPI::saveOutputAs(const QString &filename) void StelMainScriptAPI::saveOutputAs(const QString &filename)
{ {
StelApp::getInstance().getScriptMgr().saveOutputAs(filename); StelApp::getInstance().getScriptMgr().saveOutputAs(filename);
} }
double StelMainScriptAPI::jdFromDateString(const QString& dt, const QString & spec) double StelMainScriptAPI::jdFromDateString(const QString& dt, const QString & spec)
skipping to change at line 840 skipping to change at line 903
//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)
{ {
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
StelObjectP obj = omgr->searchByName(name); StelObjectP obj = omgr->searchByName(name);
QVariantMap map;
if (!obj)
{
debug("getObjectData WARNING - object not found: " + name);
map.insert("found", false);
return map;
}
else
{
map.insert("found", true);
}
Vec3d pos;
double ra, dec, alt, az, glong, glat;
StelCore* core = StelApp::getInstance().getCore();
bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage
();
// 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(&az, &alt, pos);
float direction = 3.; // N is zero, E is 90 degrees
if (useOldAzimuth)
direction = 2.;
az = direction*M_PI - az;
if (az > M_PI*2)
az -= M_PI*2;
map.insert("altitude", alt*180./M_PI);
map.insert("azimuth", az*180./M_PI);
// geometric altitude/azimuth
pos = obj->getAltAzPosGeometric(core);
StelUtils::rectToSphe(&az, &alt, pos);
az = direction*M_PI - az;
if (az > M_PI*2)
az -= M_PI*2;
map.insert("altitude-geometric", alt*180./M_PI);
map.insert("azimuth-geometric", az*180./M_PI);
// galactic long/lat
pos = obj->getGalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("glong", glong*180./M_PI);
map.insert("glat", glat*180./M_PI);
// supergalactic long/lat
pos = obj->getSupergalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("sglong", glong*180./M_PI);
map.insert("sglat", glat*180./M_PI);
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
double ra_equ, dec_equ, lambda, beta;
// J2000
double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0);
double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE());
// ecliptic longitude/latitude (J2000 frame)
StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getJ2000EquatorialPos(c
ore));
StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta);
if (lambda<0) lambda+=2.0*M_PI;
map.insert("elongJ2000", lambda*180./M_PI);
map.insert("elatJ2000", beta*180./M_PI);
if (QString("Earth Sun").contains(core->getCurrentLocation().planetN return StelObjectMgr::getObjectInfo(obj);
ame))
{
// ecliptic longitude/latitude
StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getEquinoxEquat
orialPos(core));
StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta);
if (lambda<0) lambda+=2.0*M_PI;
map.insert("elong", lambda*180./M_PI);
map.insert("elat", beta*180./M_PI);
}
// magnitude
map.insert("vmag", obj->getVMagnitude(core));
map.insert("vmage", obj->getVMagnitudeWithExtinction(core));
// angular size
double angularSize = 2.*obj->getAngularSize(core)*M_PI/180.;
bool sign;
double deg;
StelUtils::radToDecDeg(angularSize, sign, deg);
if (!sign)
deg *= -1;
map.insert("size", angularSize);
map.insert("size-dd", deg);
map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5));
map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true));
if (obj->getType().toLower()=="planet" && name!="Sun")
{
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
map.insert("distance", obj->getJ2000EquatorialPos(core).leng
th());
double phase = ssmgr->getPhaseForPlanet(name);
map.insert("phase", phase);
map.insert("illumination", 100.*phase);
double phaseAngle = ssmgr->getPhaseAngleForPlanet(name);
map.insert("phase-angle", phaseAngle);
map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAn
gle));
map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phas
eAngle));
double elongation = ssmgr->getElongationForPlanet(name);
map.insert("elongation", elongation);
map.insert("elongation-dms", StelUtils::radToDmsStr(elongati
on));
map.insert("elongation-deg", StelUtils::radToDecDegStr(elong
ation));
map.insert("ptype", ssmgr->getPlanetType(name));
}
// localized name
map.insert("localized-name", obj->getNameI18n());
return map;
} }
QVariantMap StelMainScriptAPI::getSelectedObjectInfo() QVariantMap StelMainScriptAPI::getSelectedObjectInfo()
{ {
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
QVariantMap map; QVariantMap map;
if (omgr->getSelectedObject().isEmpty()) if (omgr->getSelectedObject().isEmpty())
{ {
debug("getObjectData WARNING - object not selected"); debug("getObjectData WARNING - object not selected");
map.insert("found", false); map.insert("found", false);
return map; return map;
} }
StelObjectP obj = omgr->getSelectedObject()[0]; StelObjectP obj = omgr->getSelectedObject()[0];
if (!obj) return StelObjectMgr::getObjectInfo(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, az, glong, glat;
StelCore* core = StelApp::getInstance().getCore();
bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage
();
// 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(&az, &alt, pos);
float direction = 3.; // N is zero, E is 90 degrees
if (useOldAzimuth)
direction = 2.;
az = direction*M_PI - az;
if (az > M_PI*2)
az -= M_PI*2;
map.insert("altitude", alt*180./M_PI);
map.insert("azimuth", az*180./M_PI);
// geometric altitude/azimuth
pos = obj->getAltAzPosGeometric(core);
StelUtils::rectToSphe(&az, &alt, pos);
az = direction*M_PI - az;
if (az > M_PI*2)
az -= M_PI*2;
map.insert("altitude-geometric", alt*180./M_PI);
map.insert("azimuth-geometric", az*180./M_PI);
// galactic long/lat
pos = obj->getGalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("glong", glong*180./M_PI);
map.insert("glat", glat*180./M_PI);
// supergalactic long/lat
pos = obj->getSupergalacticPos(core);
StelUtils::rectToSphe(&glong, &glat, pos);
map.insert("sglong", glong*180./M_PI);
map.insert("sglat", glat*180./M_PI);
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
double ra_equ, dec_equ, lambda, beta;
// J2000
double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0);
double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE());
// ecliptic longitude/latitude (J2000 frame)
StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getJ2000EquatorialPos(c
ore));
StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta);
if (lambda<0) lambda+=2.0*M_PI;
map.insert("elongJ2000", lambda*180./M_PI);
map.insert("elatJ2000", beta*180./M_PI);
if (QString("Earth Sun").contains(core->getCurrentLocation().planetN
ame))
{
// ecliptic longitude/latitude
StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getEquinoxEquat
orialPos(core));
StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta);
if (lambda<0) lambda+=2.0*M_PI;
map.insert("elong", lambda*180./M_PI);
map.insert("elat", beta*180./M_PI);
}
// magnitude
map.insert("vmag", obj->getVMagnitude(core));
map.insert("vmage", obj->getVMagnitudeWithExtinction(core));
// angular size
double angularSize = 2.*obj->getAngularSize(core)*M_PI/180.;
bool sign;
double deg;
StelUtils::radToDecDeg(angularSize, sign, deg);
if (!sign)
deg *= -1;
map.insert("size", angularSize);
map.insert("size-dd", deg);
map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5));
map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true));
if (obj->getType().toLower()=="planet" && obj->getEnglishName()!="Su
n")
{
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
map.insert("distance", obj->getJ2000EquatorialPos(core).leng
th());
double phase = ssmgr->getPhaseForPlanet(obj->getEnglishName(
));
map.insert("phase", phase);
map.insert("illumination", 100.*phase);
double phaseAngle = ssmgr->getPhaseAngleForPlanet(obj->getEn
glishName());
map.insert("phase-angle", phaseAngle);
map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAn
gle));
map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phas
eAngle));
double elongation = ssmgr->getElongationForPlanet(obj->getEn
glishName());
map.insert("elongation", elongation);
map.insert("elongation-dms", StelUtils::radToDmsStr(elongati
on));
map.insert("elongation-deg", StelUtils::radToDecDegStr(elong
ation));
map.insert("ptype", ssmgr->getPlanetType(obj->getEnglishName
()));
}
// 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);
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);
StarMgr* smgr = GETSTELMODULE(StarMgr); StarMgr* smgr = GETSTELMODULE(StarMgr);
skipping to change at line 1395 skipping to change at line 1209
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()->j2000ToEqui noxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000()); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToEqui noxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000(), StelCore::R efractionOff);
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()->j2000ToEqui noxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000()); const Vec3d& current = StelApp::getInstance().getCore()->j2000ToEqui noxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000(), StelCore::R efractionOff);
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 1471 skipping to change at line 1285
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);
// make up vector more stable: // make up vector more stable:
StelMovementMgr::MountMode mountMode=mvmgr->getMountMode(); StelMovementMgr::MountMode mountMode=mvmgr->getMountMode();
Vec3d aimUp; Vec3d aimUp;
if ( (mountMode==StelMovementMgr::MountEquinoxEquatorial) && (fabs(d Dec)> (0.9*M_PI/2.0)) ) if ( (mountMode==StelMovementMgr::MountEquinoxEquatorial) && (fabs(d Dec)> (0.9*M_PI/2.0)) )
aimUp=core->equinoxEquToJ2000(Vec3d(-cos(dRa), -sin(dRa), 0. ) * (dDec>0. ? 1. : -1. )); aimUp=core->equinoxEquToJ2000(Vec3d(-cos(dRa), -sin(dRa), 0. ) * (dDec>0. ? 1. : -1. ), StelCore::RefractionOff);
else else
aimUp=core->equinoxEquToJ2000(Vec3d(0., 0., 1.)); aimUp=core->equinoxEquToJ2000(Vec3d(0., 0., 1.), StelCore::R efractionOff);
mvmgr->moveToJ2000(StelApp::getInstance().getCore()->equinoxEquToJ20 00(aim), aimUp, duration); mvmgr->moveToJ2000(StelApp::getInstance().getCore()->equinoxEquToJ20 00(aim, StelCore::RefractionOff), aimUp, 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; Vec3d aimJ2000;
skipping to change at line 1501 skipping to change at line 1315
StelMovementMgr::MountMode mountMode=mvmgr->getMountMode(); StelMovementMgr::MountMode mountMode=mvmgr->getMountMode();
Vec3d aimUp; Vec3d aimUp;
if ( (mountMode==StelMovementMgr::MountEquinoxEquatorial) && (fabs(d Dec)> (0.9*M_PI/2.0)) ) if ( (mountMode==StelMovementMgr::MountEquinoxEquatorial) && (fabs(d Dec)> (0.9*M_PI/2.0)) )
aimUp=Vec3d(-cos(dRa), -sin(dRa), 0.) * (dDec>0. ? 1. : -1. ); aimUp=Vec3d(-cos(dRa), -sin(dRa), 0.) * (dDec>0. ? 1. : -1. );
else else
aimUp=Vec3d(0., 0., 1.); aimUp=Vec3d(0., 0., 1.);
mvmgr->moveToJ2000(aimJ2000, aimUp, duration); mvmgr->moveToJ2000(aimJ2000, aimUp, duration);
} }
QString StelMainScriptAPI::getAppLanguage() QString StelMainScriptAPI::getAppLanguage() const
{ {
return StelApp::getInstance().getLocaleMgr().getAppLanguage(); return StelApp::getInstance().getLocaleMgr().getAppLanguage();
} }
void StelMainScriptAPI::setAppLanguage(QString langCode) void StelMainScriptAPI::setAppLanguage(QString langCode)
{ {
StelApp::getInstance().getLocaleMgr().setAppLanguage(langCode); StelApp::getInstance().getLocaleMgr().setAppLanguage(langCode);
} }
QString StelMainScriptAPI::getSkyLanguage() QString StelMainScriptAPI::getSkyLanguage() const
{ {
return StelApp::getInstance().getLocaleMgr().getSkyLanguage(); return StelApp::getInstance().getLocaleMgr().getSkyLanguage();
} }
void StelMainScriptAPI::setSkyLanguage(QString langCode) void StelMainScriptAPI::setSkyLanguage(QString langCode)
{ {
StelApp::getInstance().getLocaleMgr().setSkyLanguage(langCode); StelApp::getInstance().getLocaleMgr().setSkyLanguage(langCode);
} }
void StelMainScriptAPI::goHome() void StelMainScriptAPI::goHome()
skipping to change at line 1536 skipping to change at line 1350
void StelMainScriptAPI::setMilkyWayVisible(bool b) void StelMainScriptAPI::setMilkyWayVisible(bool b)
{ {
GETSTELMODULE(MilkyWay)->setFlagShow(b); GETSTELMODULE(MilkyWay)->setFlagShow(b);
} }
void StelMainScriptAPI::setMilkyWayIntensity(double i) void StelMainScriptAPI::setMilkyWayIntensity(double i)
{ {
GETSTELMODULE(MilkyWay)->setIntensity(i); GETSTELMODULE(MilkyWay)->setIntensity(i);
} }
double StelMainScriptAPI::getMilkyWayIntensity() double StelMainScriptAPI::getMilkyWayIntensity() const
{ {
return GETSTELMODULE(MilkyWay)->getIntensity(); return GETSTELMODULE(MilkyWay)->getIntensity();
} }
void StelMainScriptAPI::setZodiacalLightVisible(bool b) void StelMainScriptAPI::setZodiacalLightVisible(bool b)
{ {
GETSTELMODULE(ZodiacalLight)->setFlagShow(b); GETSTELMODULE(ZodiacalLight)->setFlagShow(b);
} }
void StelMainScriptAPI::setZodiacalLightIntensity(double i) void StelMainScriptAPI::setZodiacalLightIntensity(double i)
{ {
GETSTELMODULE(ZodiacalLight)->setIntensity(i); GETSTELMODULE(ZodiacalLight)->setIntensity(i);
} }
double StelMainScriptAPI::getZodiacalLightIntensity() double StelMainScriptAPI::getZodiacalLightIntensity() const
{ {
return GETSTELMODULE(ZodiacalLight)->getIntensity(); return GETSTELMODULE(ZodiacalLight)->getIntensity();
} }
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)
 End of changes. 37 change blocks. 
341 lines changed or deleted 137 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/