StelMainScriptAPI.cpp   StelMainScriptAPI.cpp 
skipping to change at line 36 skipping to change at line 36
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "MeteorMgr.hpp" #include "MeteorMgr.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 "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 "StelObject.hpp" #include "StelObject.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
skipping to change at line 71 skipping to change at line 72
#include <QStringList> #include <QStringList>
#include <QTemporaryFile> #include <QTemporaryFile>
#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 st QString&, double, double, double, double, double, double, double, double , double, double, bool)), smgr, SLOT(loadSkyImage(const QString&, const QSt ring&, double, double, double, double, double, double, double, double, doub le, double, bool))); connect(this, SIGNAL(requestLoadSkyImage(const QString&, con st QString&, double, double, double, double, double, double, double, double , double, double, bool)), smgr, SLOT(loadSkyImage(const QString&, const QSt ring&, double, double, double, double, double, double, double, double, doub le, double, bool)));
connect(this, SIGNAL(requestLoadSkyImageAltAz(const QString& , const QString&, double, double, double, double, double, double, double, d ouble, double, double, bool)), smgr, SLOT(loadSkyImageAltAz(const QString&, const QString&, double, double, double, double, double, double, double, do uble, 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(requestPlayVideo(const QString&)), StelApp::get
Instance().getStelVideoMgr(), SLOT(playVideo(const QString&)));
connect(this, SIGNAL(requestPauseVideo(const QString&)), StelApp::ge
tInstance().getStelVideoMgr(), SLOT(pauseVideo(const QString&)));
connect(this, SIGNAL(requestStopVideo(const QString&)), StelApp::get
Instance().getStelVideoMgr(), SLOT(stopVideo(const QString&)));
connect(this, SIGNAL(requestDropVideo(const QString&)), StelApp::get
Instance().getStelVideoMgr(), SLOT(dropVideo(const QString&)));
connect(this, SIGNAL(requestSeekVideo(const QString&, qint64)), Stel
App::getInstance().getStelVideoMgr(), SLOT(seekVideo(const QString&, qint64
)));
connect(this, SIGNAL(requestSetVideoXY(const QString&, float, float)
), StelApp::getInstance().getStelVideoMgr(), SLOT(setVideoXY(const QString&
, float, float)));
connect(this, SIGNAL(requestSetVideoAlpha(const QString&, float)), S
telApp::getInstance().getStelVideoMgr(), SLOT(setVideoAlpha(const QString&,
float)));
connect(this, SIGNAL(requestResizeVideo(const QString&, float, float
)), StelApp::getInstance().getStelVideoMgr(), SLOT(resizeVideo(const QStrin
g&, float, float)));
connect(this, SIGNAL(requestShowVideo(const QString&, bool)), StelAp
p::getInstance().getStelVideoMgr(), SLOT(showVideo(const QString&, bool)));
connect(this, SIGNAL(requestExit()), this->parent(), SLOT(stopScript ())); connect(this, SIGNAL(requestExit()), this->parent(), SLOT(stopScript ()));
connect(this, SIGNAL(requestSetNightMode(bool)), &StelApp::getInstan ce(), SLOT(setVisionModeNight(bool))); connect(this, SIGNAL(requestSetNightMode(bool)), &StelApp::getInstan ce(), SLOT(setVisionModeNight(bool)));
connect(this, SIGNAL(requestSetProjectionMode(QString)), StelApp::ge tInstance().getCore(), SLOT(setCurrentProjectionTypeKey(QString))); connect(this, SIGNAL(requestSetProjectionMode(QString)), StelApp::ge tInstance().getCore(), SLOT(setCurrentProjectionTypeKey(QString)));
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)), StelMainGraphics View::getInstance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool))); connect(this, SIGNAL(requestSetDiskViewport(bool)), StelMainGraphics View::getInstance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool)));
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
void StelMainScriptAPI::setJDay(double JD) void StelMainScriptAPI::setJDay(double JD)
{ {
skipping to change at line 175 skipping to change at line 190
if (!ok) if (!ok)
return; // location find failed return; // location find failed
core->moveObserverTo(loc, duration); core->moveObserverTo(loc, duration);
} }
QString StelMainScriptAPI::getObserverLocation() QString StelMainScriptAPI::getObserverLocation()
{ {
return StelApp::getInstance().getCore()->getCurrentLocation().getID( ); return StelApp::getInstance().getCore()->getCurrentLocation().getID( );
} }
QVariantMap StelMainScriptAPI::getObserverLocationInfo()
{
StelCore* core = StelApp::getInstance().getCore();
QVariantMap map;
map.insert("longitude", core->getCurrentLocation().longitude);
map.insert("latitude", core->getCurrentLocation().latitude);
map.insert("planet", core->getCurrentLocation().planetName);
map.insert("altitude", core->getCurrentLocation().altitude);
map.insert("location", core->getCurrentLocation().getID());
return map;
}
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);
} }
void StelMainScriptAPI::setGuiVisible(bool b) void StelMainScriptAPI::setGuiVisible(bool b)
{ {
skipping to change at line 321 skipping to change at line 349
StelUtils::spheToRect(ra*M_PI/180., dec*M_PI/180., XYZ); StelUtils::spheToRect(ra*M_PI/180., dec*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(ra*M_PI/180.) *
Mat4f::yrotation(-dec*M_PI/180.) * Mat4f::yrotation(-dec*M_PI/180.) *
Mat4f::xrotation(rotation*M_PI/18 0.); Mat4f::xrotation(rotation*M_PI/18 0.);
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,
skipping to change at line 347 skipping to change at line 375
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name, void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& file name,
con st QString& ra, const QString& dec, double angSize, double rotation, con st QString& ra, const QString& dec, double angSize, double rotation,
dou ble minRes, double maxBright, bool visible) dou ble minRes, double maxBright, bool visible)
{ {
loadSkyImage(id, filename, StelUtils::getDecAngle(ra)*180./M_PI, loadSkyImage(id, filename, StelUtils::getDecAngle(ra)*180./M_PI,
StelUtils::getDecAngle(dec)*180./M_PI, angS ize, StelUtils::getDecAngle(dec)*180./M_PI, angS ize,
rotation, minRes, maxBright, visible); rotation, minRes, maxBright, visible);
} }
void StelMainScriptAPI::loadSkyImageAltAz(const QString& id, const QString&
filename,
double alt0, double azi0,
double alt1, double azi1,
double alt2, double azi2,
double alt3, double azi3,
double minR
es, double maxBright, bool visible)
{
QString path = "scripts/" + filename;
emit(requestLoadSkyImageAltAz(id, path, alt0, azi0, alt1, azi1, alt2
, azi2, alt3, azi3, minRes, maxBright, visible));
}
void StelMainScriptAPI::loadSkyImageAltAz(const QString& id, const QString&
filename,
dou
ble alt, double azi, double angSize, double rotation,
dou
ble minRes, double maxBright, bool visible)
{
Vec3f XYZ;
static const float RADIUS_NEB = 1.;
StelUtils::spheToRect((180-azi)*M_PI/180., alt*M_PI/180., XYZ);
XYZ*=RADIUS_NEB;
float texSize = RADIUS_NEB * sin(angSize/2/60*M_PI/180);
Mat4f matPrecomp = Mat4f::translation(XYZ) *
Mat4f::zrotation((180-azi)*M_PI/1
80.) *
Mat4f::yrotation(-alt*M_PI/180.)
*
Mat4f::xrotation((rotation+90)*M_
PI/180.);
Vec3f corners[4];
corners[0] = matPrecomp * Vec3f(0.f,-texSize,-texSize);
corners[1] = matPrecomp * Vec3f(0.f,-texSize, texSize);
corners[2] = matPrecomp * Vec3f(0.f, texSize,-texSize);
corners[3] = matPrecomp * Vec3f(0.f, texSize, texSize);
// convert back to alt/azi (radians)
Vec3f cornersAltAz[4];
for(int i=0; i<4; i++)
StelUtils::rectToSphe(&cornersAltAz[i][0], &cornersAltAz[i][
1], corners[i]);
loadSkyImageAltAz(id, filename,
cornersAltAz[0][0]*180./M_PI, cornersAltAz[
0][1]*180./M_PI,
cornersAltAz[1][0]*180./M_PI, cornersAltAz[
1][1]*180./M_PI,
cornersAltAz[3][0]*180./M_PI, cornersAltAz[
3][1]*180./M_PI,
cornersAltAz[2][0]*180./M_PI, cornersAltAz[
2][1]*180./M_PI,
minRes, maxBright, visible);
}
void StelMainScriptAPI::removeSkyImage(const QString& id) void StelMainScriptAPI::removeSkyImage(const QString& id)
{ {
emit(requestRemoveSkyImage(id)); emit(requestRemoveSkyImage(id));
} }
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
{ {
skipping to change at line 388 skipping to change at line 461
void StelMainScriptAPI::stopSound(const QString& id) void StelMainScriptAPI::stopSound(const QString& id)
{ {
emit(requestStopSound(id)); emit(requestStopSound(id));
} }
void StelMainScriptAPI::dropSound(const QString& id) void StelMainScriptAPI::dropSound(const QString& id)
{ {
emit(requestDropSound(id)); emit(requestDropSound(id));
} }
void StelMainScriptAPI::loadVideo(const QString& filename, const QString& i
d, float x, float y, bool show, float alpha)
{
QString path;
try
{
path = StelFileMgr::findFile("scripts/" + filename);
}
catch(std::runtime_error& e)
{
qWarning() << "cannot play video" << filename << ":" << e.wh
at();
return;
}
emit(requestLoadVideo(path, id, x, y, show, alpha));
}
void StelMainScriptAPI::playVideo(const QString& id)
{
emit(requestPlayVideo(id));
}
void StelMainScriptAPI::pauseVideo(const QString& id)
{
emit(requestPauseVideo(id));
}
void StelMainScriptAPI::stopVideo(const QString& id)
{
emit(requestStopVideo(id));
}
void StelMainScriptAPI::dropVideo(const QString& id)
{
emit(requestDropVideo(id));
}
void StelMainScriptAPI::seekVideo(const QString& id, qint64 ms)
{
emit(requestSeekVideo(id, ms));
}
void StelMainScriptAPI::setVideoXY(const QString& id, float x, float y)
{
emit(requestSetVideoXY(id, x, y));
}
void StelMainScriptAPI::setVideoAlpha(const QString& id, float alpha)
{
emit(requestSetVideoAlpha(id, alpha));
}
void StelMainScriptAPI::resizeVideo(const QString& id, float w, float h)
{
emit(requestResizeVideo(id, w, h));
}
void StelMainScriptAPI::showVideo(const QString& id, bool show)
{
emit(requestShowVideo(id, show));
}
int StelMainScriptAPI::getScreenWidth() int StelMainScriptAPI::getScreenWidth()
{ {
return StelMainGraphicsView::getInstance().size().width(); return StelMainGraphicsView::getInstance().size().width();
} }
int StelMainScriptAPI::getScreenHeight() int StelMainScriptAPI::getScreenHeight()
{ {
return StelMainGraphicsView::getInstance().size().height(); return StelMainGraphicsView::getInstance().size().height();
} }
double StelMainScriptAPI::getScriptRate() double StelMainScriptAPI::getScriptRate()
{ {
return StelMainGraphicsView::getInstance().getScriptMgr().getScript Rate(); return StelMainGraphicsView::getInstance().getScriptMgr().getScript Rate();
} }
void StelMainScriptAPI::setScriptRate(double r) void StelMainScriptAPI::setScriptRate(double r)
{ {
return StelMainGraphicsView::getInstance().getScriptMgr().setScript Rate(r); return StelMainGraphicsView::getInstance().getScriptMgr().setScript Rate(r);
} }
void StelMainScriptAPI::pauseScript()
{
return StelMainGraphicsView::getInstance().getScriptMgr().pauseScrip
t();
}
void StelMainScriptAPI::setSelectedObjectInfo(const QString& level) void StelMainScriptAPI::setSelectedObjectInfo(const QString& level)
{ {
if (level == "AllInfo") if (level == "AllInfo")
StelApp::getInstance().getGui()->setInfoTextFilters(StelObje ct::InfoStringGroup(StelObject::AllInfo)); StelApp::getInstance().getGui()->setInfoTextFilters(StelObje ct::InfoStringGroup(StelObject::AllInfo));
else if (level == "ShortInfo") else if (level == "ShortInfo")
StelApp::getInstance().getGui()->setInfoTextFilters(StelObje ct::InfoStringGroup(StelObject::ShortInfo)); StelApp::getInstance().getGui()->setInfoTextFilters(StelObje ct::InfoStringGroup(StelObject::ShortInfo));
else if (level == "None") else if (level == "None")
StelApp::getInstance().getGui()->setInfoTextFilters((StelObj ect::InfoStringGroup)0); StelApp::getInstance().getGui()->setInfoTextFilters((StelObj ect::InfoStringGroup)0);
else else
qWarning() << "setSelectedObjectInfo unknown level string \" " << level << "\""; qWarning() << "setSelectedObjectInfo unknown level string \" " << level << "\"";
skipping to change at line 547 skipping to change at line 686
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->getAltAzPosApparent(StelApp::getInstance().getCore()); 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);
pos = obj->getAltAzPosGeometric(StelApp::getInstance().getCore());
StelUtils::rectToSphe(&azi, &alt, pos);
map.insert("altitude-geometric", alt*180./M_PI);
map.insert("azimuth-geometric", 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);
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);
skipping to change at line 782 skipping to change at line 926
QString StelMainScriptAPI::getSkyLanguage() QString StelMainScriptAPI::getSkyLanguage()
{ {
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()
{
emit(requestSetHomePosition());
}
 End of changes. 11 change blocks. 
2 lines changed or deleted 178 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/