3
* Copyright (C) 2009 Matthew Gates
4
* Copyright (C) 2007 Fabien Chereau
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#include "StelMainScriptAPI.hpp"
22
#include "StelMainScriptAPIProxy.hpp"
23
#include "StelScriptMgr.hpp"
25
#include "ConstellationMgr.hpp"
26
#include "GridLinesMgr.hpp"
27
#include "LandscapeMgr.hpp"
28
#include "MeteorMgr.hpp"
29
#include "NebulaMgr.hpp"
31
#include "SolarSystem.hpp"
32
#include "StarMgr.hpp"
33
#include "StelApp.hpp"
34
#include "StelAudioMgr.hpp"
35
#include "StelCore.hpp"
36
#include "StelFileMgr.hpp"
37
#include "StelLocation.hpp"
38
#include "StelLocationMgr.hpp"
39
#include "StelMainGraphicsView.hpp"
40
#include "StelModuleMgr.hpp"
41
#include "StelMovementMgr.hpp"
42
#include "StelNavigator.hpp"
43
#include "StelObject.hpp"
44
#include "StelObjectMgr.hpp"
45
#include "StelProjector.hpp"
46
#include "StelSkyCultureMgr.hpp"
47
#include "StelSkyDrawer.hpp"
48
#include "StelSkyLayerMgr.hpp"
49
#include "StelUtils.hpp"
50
#include "StelGuiBase.hpp"
60
#include <QStringList>
61
#include <QTemporaryFile>
65
StelMainScriptAPI::StelMainScriptAPI(QObject *parent) : QObject(parent)
67
if(StelSkyLayerMgr* smgr = GETSTELMODULE(StelSkyLayerMgr))
69
connect(this, SIGNAL(requestLoadSkyImage(const QString&, const QString&, double, double, double, double, double, double, double, double, double, double, bool)), smgr, SLOT(loadSkyImage(const QString&, const QString&, double, double, double, double, double, double, double, double, double, double, bool)));
70
connect(this, SIGNAL(requestRemoveSkyImage(const QString&)), smgr, SLOT(removeSkyLayer(const QString&)));
73
connect(this, SIGNAL(requestLoadSound(const QString&, const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(loadSound(const QString&, const QString&)));
74
connect(this, SIGNAL(requestPlaySound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(playSound(const QString&)));
75
connect(this, SIGNAL(requestPauseSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(pauseSound(const QString&)));
76
connect(this, SIGNAL(requestStopSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(stopSound(const QString&)));
77
connect(this, SIGNAL(requestDropSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(dropSound(const QString&)));
78
connect(this, SIGNAL(requestExit()), this->parent(), SLOT(stopScript()));
79
connect(this, SIGNAL(requestSetNightMode(bool)), &StelApp::getInstance(), SLOT(setVisionModeNight(bool)));
80
connect(this, SIGNAL(requestSetProjectionMode(QString)), StelApp::getInstance().getCore(), SLOT(setCurrentProjectionTypeKey(QString)));
81
connect(this, SIGNAL(requestSetSkyCulture(QString)), &StelApp::getInstance().getSkyCultureMgr(), SLOT(setCurrentSkyCultureID(QString)));
82
connect(this, SIGNAL(requestSetDiskViewport(bool)), StelMainGraphicsView::getInstance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool)));
85
StelMainScriptAPI::~StelMainScriptAPI()
89
ScriptSleeper& StelMainScriptAPI::getScriptSleeper(void)
94
//! Set the current date in Julian Day
95
//! @param JD the Julian Date
96
void StelMainScriptAPI::setJDay(double JD)
98
StelApp::getInstance().getCore()->getNavigator()->setJDay(JD);
101
//! Get the current date in Julian Day
102
//! @return the Julian Date
103
double StelMainScriptAPI::getJDay(void) const
105
return StelApp::getInstance().getCore()->getNavigator()->getJDay();
108
void StelMainScriptAPI::setDate(const QString& dt, const QString& spec)
110
StelApp::getInstance().getCore()->getNavigator()->setJDay(jdFromDateString(dt, spec));
113
QString StelMainScriptAPI::getDate(const QString& spec)
115
return StelUtils::jdToIsoString(getJDay());
118
//! Set time speed in JDay/sec
119
//! @param ts time speed in JDay/sec
120
void StelMainScriptAPI::setTimeRate(double ts)
122
// 1 second = .00001157407407407407 JDay
123
StelApp::getInstance().getCore()->getNavigator()->setTimeRate(ts * 0.00001157407407407407 * scriptSleeper.getRate());
126
//! Get time speed in JDay/sec
127
//! @return time speed in JDay/sec
128
double StelMainScriptAPI::getTimeRate(void) const
130
return StelApp::getInstance().getCore()->getNavigator()->getTimeRate() / (0.00001157407407407407 * scriptSleeper.getRate());
133
bool StelMainScriptAPI::isRealTime()
135
return StelApp::getInstance().getCore()->getNavigator()->getIsTimeNow();
138
void StelMainScriptAPI::setRealTime()
141
StelApp::getInstance().getCore()->getNavigator()->setTimeNow();
144
void StelMainScriptAPI::wait(double t)
146
scriptSleeper.sleep(t*1000);
149
void StelMainScriptAPI::waitFor(const QString& dt, const QString& spec)
151
double JD = jdFromDateString(dt, spec);
152
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator();
154
double timeSpeed = nav->getTimeRate();
158
qWarning() << "waitFor called with no time passing - would be infinite. not waiting!";
161
else if (timeSpeed > 0)
163
while(nav->getJDay() < JD)
164
scriptSleeper.sleep(200);
168
while(nav->getJDay() > JD)
169
scriptSleeper.sleep(200);
173
void StelMainScriptAPI::setObserverLocation(double longitude, double latitude, double altitude, double duration, const QString& name, const QString& planet)
175
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator();
177
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
180
StelLocation loc = nav->getCurrentLocation();
181
if (longitude < 180 || longitude > 180)
182
loc.longitude = longitude;
183
if (latitude < 180 || latitude > 180)
184
loc.latitude = latitude;
185
if (altitude < -1000)
186
loc.altitude = altitude;
187
if (ssmgr->searchByName(planet))
188
loc.planetName = planet;
191
nav->moveObserverTo(loc, duration);
194
void StelMainScriptAPI::setObserverLocation(const QString id, double duration)
196
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator();
198
StelLocation loc = StelApp::getInstance().getLocationMgr().locationForSmallString(id);
199
// How best to test to see if the lookup of the name was a success?
200
// On failure, it returns Paris, but maybe we _want_ Paris.
202
if (id!="Paris, France" && (loc.name=="Paris" && loc.country=="France"))
203
return; // location find fail
205
nav->moveObserverTo(loc, duration);
208
QString StelMainScriptAPI::getObserverLocation()
210
return StelApp::getInstance().getCore()->getNavigator()->getCurrentLocation().getID();
213
void StelMainScriptAPI::screenshot(const QString& prefix, bool invert, const QString& dir)
215
bool oldInvertSetting = StelMainGraphicsView::getInstance().getFlagInvertScreenShotColors();
216
StelMainGraphicsView::getInstance().setFlagInvertScreenShotColors(invert);
217
StelMainGraphicsView::getInstance().saveScreenShot(prefix, dir);
218
StelMainGraphicsView::getInstance().setFlagInvertScreenShotColors(oldInvertSetting);
221
void StelMainScriptAPI::setGuiVisible(bool b)
223
StelApp::getInstance().getGui()->setVisible(b);
226
void StelMainScriptAPI::setMinFps(float m)
228
StelMainGraphicsView::getInstance().setMinFps(m);
231
float StelMainScriptAPI::getMinFps()
233
return StelMainGraphicsView::getInstance().getMinFps();
236
void StelMainScriptAPI::setMaxFps(float m)
238
StelMainGraphicsView::getInstance().setMaxFps(m);
241
float StelMainScriptAPI::getMaxFps()
243
return StelMainGraphicsView::getInstance().getMaxFps();
246
QString StelMainScriptAPI::getMountMode()
248
if (GETSTELMODULE(StelMovementMgr)->getMountMode() == StelMovementMgr::MountEquinoxEquatorial)
254
void StelMainScriptAPI::setMountMode(const QString& mode)
256
if (mode=="equatorial")
257
GETSTELMODULE(StelMovementMgr)->setMountMode(StelMovementMgr::MountEquinoxEquatorial);
258
else if (mode=="azimuthal")
259
GETSTELMODULE(StelMovementMgr)->setMountMode(StelMovementMgr::MountAltAzimuthal);
262
bool StelMainScriptAPI::getNightMode()
264
return StelApp::getInstance().getVisionModeNight();
267
void StelMainScriptAPI::setNightMode(bool b)
269
emit(requestSetNightMode(b));
272
QString StelMainScriptAPI::getProjectionMode()
274
return StelApp::getInstance().getCore()->getCurrentProjectionTypeKey();
277
void StelMainScriptAPI::setProjectionMode(const QString& id)
279
emit(requestSetProjectionMode(id));
282
QStringList StelMainScriptAPI::getAllSkyCultureIDs(void)
284
return StelApp::getInstance().getSkyCultureMgr().getSkyCultureListIDs();
287
QString StelMainScriptAPI::getSkyCulture()
289
return StelApp::getInstance().getSkyCultureMgr().getCurrentSkyCultureID();
292
void StelMainScriptAPI::setSkyCulture(const QString& id)
294
emit(requestSetSkyCulture(id));
297
bool StelMainScriptAPI::getFlagGravityLabels()
299
return StelApp::getInstance().getCore()->getProjection(Mat4d())->getFlagGravityLabels();
302
void StelMainScriptAPI::setFlagGravityLabels(bool b)
304
StelApp::getInstance().getCore()->setFlagGravityLabels(b);
307
bool StelMainScriptAPI::getDiskViewport()
309
return StelApp::getInstance().getCore()->getProjection(Mat4d())->getMaskType() == StelProjector::MaskDisk;
312
void StelMainScriptAPI::setDiskViewport(bool b)
314
emit(requestSetDiskViewport(b));
317
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& filename,
318
double ra0, double dec0,
319
double ra1, double dec1,
320
double ra2, double dec2,
321
double ra3, double dec3,
322
double minRes, double maxBright, bool visible)
324
QString path = "scripts/" + filename;
325
emit(requestLoadSkyImage(id, path, ra0, dec0, ra1, dec1, ra2, dec2, ra3, dec3, minRes, maxBright, visible));
328
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& filename,
329
const QString& ra0, const QString& dec0,
330
const QString& ra1, const QString& dec1,
331
const QString& ra2, const QString& dec2,
332
const QString& ra3, const QString& dec3,
333
double minRes, double maxBright, bool visible)
335
loadSkyImage(id, filename,
336
StelUtils::getDecAngle(ra0) *180./M_PI, StelUtils::getDecAngle(dec0)*180./M_PI,
337
StelUtils::getDecAngle(ra1) *180./M_PI, StelUtils::getDecAngle(dec1)*180./M_PI,
338
StelUtils::getDecAngle(ra2) *180./M_PI, StelUtils::getDecAngle(dec2)*180./M_PI,
339
StelUtils::getDecAngle(ra3) *180./M_PI, StelUtils::getDecAngle(dec3)*180./M_PI,
340
minRes, maxBright, visible);
343
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& filename,
344
double ra, double dec, double angSize, double rotation,
345
double minRes, double maxBright, bool visible)
348
const double RADIUS_NEB = 1.;
349
StelUtils::spheToRect(ra*M_PI/180., dec*M_PI/180., XYZ);
351
double texSize = RADIUS_NEB * sin(angSize/2/60*M_PI/180);
352
Mat4f matPrecomp = Mat4f::translation(XYZ) *
353
Mat4f::zrotation(ra*M_PI/180.) *
354
Mat4f::yrotation(-dec*M_PI/180.) *
355
Mat4f::xrotation(rotation*M_PI/180.);
358
corners[0] = matPrecomp * Vec3d(0.,-texSize,-texSize);
359
corners[1] = matPrecomp * Vec3d(0., texSize,-texSize);
360
corners[2] = matPrecomp * Vec3d(0.,-texSize, texSize);
361
corners[3] = matPrecomp * Vec3d(0., texSize, texSize);
363
// convert back to ra/dec (radians)
364
Vec3d cornersRaDec[4];
365
for(int i=0; i<4; i++)
366
StelUtils::rectToSphe(&cornersRaDec[i][0], &cornersRaDec[i][1], corners[i]);
368
loadSkyImage(id, filename,
369
cornersRaDec[0][0]*180./M_PI, cornersRaDec[0][1]*180./M_PI,
370
cornersRaDec[1][0]*180./M_PI, cornersRaDec[1][1]*180./M_PI,
371
cornersRaDec[3][0]*180./M_PI, cornersRaDec[3][1]*180./M_PI,
372
cornersRaDec[2][0]*180./M_PI, cornersRaDec[2][1]*180./M_PI,
373
minRes, maxBright, visible);
376
void StelMainScriptAPI::loadSkyImage(const QString& id, const QString& filename,
377
const QString& ra, const QString& dec, double angSize, double rotation,
378
double minRes, double maxBright, bool visible)
380
loadSkyImage(id, filename, StelUtils::getDecAngle(ra)*180./M_PI,
381
StelUtils::getDecAngle(dec)*180./M_PI, angSize,
382
rotation, minRes, maxBright, visible);
385
void StelMainScriptAPI::removeSkyImage(const QString& id)
387
emit(requestRemoveSkyImage(id));
390
void StelMainScriptAPI::loadSound(const QString& filename, const QString& id)
395
path = StelFileMgr::findFile("scripts/" + filename);
397
catch(std::runtime_error& e)
399
qWarning() << "cannot play sound" << filename << ":" << e.what();
403
emit(requestLoadSound(path, id));
406
void StelMainScriptAPI::playSound(const QString& id)
408
emit(requestPlaySound(id));
411
void StelMainScriptAPI::pauseSound(const QString& id)
413
emit(requestPauseSound(id));
416
void StelMainScriptAPI::stopSound(const QString& id)
418
emit(requestStopSound(id));
421
void StelMainScriptAPI::dropSound(const QString& id)
423
emit(requestDropSound(id));
426
int StelMainScriptAPI::getScreenWidth(void)
428
return StelMainGraphicsView::getInstance().size().width();
431
int StelMainScriptAPI::getScreenHeight(void)
433
return StelMainGraphicsView::getInstance().size().height();
436
double StelMainScriptAPI::getScriptRate(void)
438
return scriptSleeper.getRate();
441
void StelMainScriptAPI::setScriptRate(double r)
443
return scriptSleeper.setRate(r);
446
void StelMainScriptAPI::setSelectedObjectInfo(const QString& level)
448
if (level == "AllInfo")
449
StelApp::getInstance().getGui()->setInfoTextFilters(StelObject::InfoStringGroup(StelObject::AllInfo));
450
else if (level == "ShortInfo")
451
StelApp::getInstance().getGui()->setInfoTextFilters(StelObject::InfoStringGroup(StelObject::ShortInfo));
452
else if (level == "None")
453
StelApp::getInstance().getGui()->setInfoTextFilters((StelObject::InfoStringGroup)0);
455
qWarning() << "setSelectedObjectInfo unknown level string \"" << level << "\"";
458
void StelMainScriptAPI::exit(void)
463
void StelMainScriptAPI::quitStellarium(void)
465
QCoreApplication::exit();
468
void StelMainScriptAPI::debug(const QString& s)
470
qDebug() << "script: " << s;
471
StelMainGraphicsView::getInstance().getScriptMgr().debug(s);
474
double StelMainScriptAPI::jdFromDateString(const QString& dt, const QString& spec)
479
// 2008-03-24T13:21:01
480
QRegExp isoRe("^\\d{4}[:\\-]\\d\\d[:\\-]\\d\\dT\\d?\\d:\\d\\d:\\d\\d$");
481
QRegExp nowRe("^(now)?(\\s*([+\\-])\\s*(\\d+(\\.\\d+)?)\\s*(second|seconds|minute|minutes|hour|hours|day|days|week|weeks))(\\s+(sidereal)?)?");
484
return StelUtils::getJDFromSystem();
485
else if (isoRe.exactMatch(dt))
487
qdt = QDateTime::fromString(dt, Qt::ISODate);
490
JD = StelUtils::qDateTimeToJd(qdt.toUTC());
492
JD = StelUtils::qDateTimeToJd(qdt);
496
else if (nowRe.exactMatch(dt))
500
double dayLength = 1.0;
502
if (nowRe.capturedTexts().at(1)=="now")
503
JD = StelUtils::getJDFromSystem();
505
JD = StelApp::getInstance().getCore()->getNavigator()->getJDay();
507
if (nowRe.capturedTexts().at(8) == "sidereal")
508
dayLength = StelApp::getInstance().getCore()->getNavigator()->getLocalSideralDayLength();
510
QString unitString = nowRe.capturedTexts().at(6);
511
if (unitString == "seconds" || unitString == "second")
512
unit = dayLength / (24*3600.);
513
else if (unitString == "minutes" || unitString == "minute")
514
unit = dayLength / (24*60.);
515
else if (unitString == "hours" || unitString == "hour")
516
unit = dayLength / (24.);
517
else if (unitString == "days" || unitString == "day")
519
else if (unitString == "weeks" || unitString == "week")
520
unit = dayLength * 7.;
523
qWarning() << "StelMainScriptAPI::setDate - unknown time unit:" << nowRe.capturedTexts().at(4);
527
delta = nowRe.capturedTexts().at(4).toDouble();
529
if (nowRe.capturedTexts().at(3) == "+")
530
JD += (unit * delta);
531
else if (nowRe.capturedTexts().at(3) == "-")
532
JD -= (unit * delta);
538
qWarning() << "StelMainScriptAPI::jdFromDateString error - date string" << dt << "not recognised, returning \"now\"";
539
return StelUtils::getJDFromSystem();
543
void StelMainScriptAPI::selectObjectByName(const QString& name, bool pointer)
545
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
546
omgr->setFlagSelectedObjectPointer(pointer);
550
omgr->findAndSelect(name);
553
QVariantMap StelMainScriptAPI::getObjectPosition(const QString& name)
555
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
556
StelObjectP obj = omgr->searchByName(name);
561
debug("getObjectData WARNING - object not found: " + name);
562
map.insert("found", false);
567
map.insert("found", true);
570
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator();
572
double ra, dec, alt, azi;
575
pos = obj->getEquinoxEquatorialPos(nav);
576
StelUtils::rectToSphe(&ra, &dec, pos);
577
map.insert("ra", ra*180./M_PI);
578
map.insert("dec", dec*180./M_PI);
581
pos = obj->getJ2000EquatorialPos(nav);
582
StelUtils::rectToSphe(&ra, &dec, pos);
583
map.insert("raJ2000", ra*180./M_PI);
584
map.insert("decJ2000", dec*180./M_PI);
587
pos = obj->getAltAzPos(nav);
588
StelUtils::rectToSphe(&azi, &alt, pos);
589
map.insert("altitude", alt*180./M_PI);
590
map.insert("azimuth", azi*180./M_PI);
595
void StelMainScriptAPI::clear(const QString& state)
597
LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
598
SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
599
MeteorMgr* mmgr = GETSTELMODULE(MeteorMgr);
600
StelSkyDrawer* skyd = StelApp::getInstance().getCore()->getSkyDrawer();
601
ConstellationMgr* cmgr = GETSTELMODULE(ConstellationMgr);
602
StarMgr* smgr = GETSTELMODULE(StarMgr);
603
NebulaMgr* nmgr = GETSTELMODULE(NebulaMgr);
604
GridLinesMgr* glmgr = GETSTELMODULE(GridLinesMgr);
605
StelMovementMgr* movmgr = GETSTELMODULE(StelMovementMgr);
607
if (state.toLower() == "natural")
609
movmgr->setMountMode(StelMovementMgr::MountAltAzimuthal);
610
skyd->setFlagTwinkle(true);
611
skyd->setFlagLuminanceAdaptation(true);
612
ssmgr->setFlagPlanets(true);
613
ssmgr->setFlagHints(false);
614
ssmgr->setFlagOrbits(false);
615
ssmgr->setFlagMoonScale(false);
616
ssmgr->setFlagTrails(false);
618
glmgr->setFlagAzimuthalGrid(false);
619
glmgr->setFlagEquatorGrid(false);
620
glmgr->setFlagEquatorLine(false);
621
glmgr->setFlagEclipticLine(false);
622
glmgr->setFlagMeridianLine(false);
623
glmgr->setFlagEquatorJ2000Grid(false);
624
lmgr->setFlagCardinalsPoints(false);
625
cmgr->setFlagLines(false);
626
cmgr->setFlagLabels(false);
627
cmgr->setFlagBoundaries(false);
628
cmgr->setFlagArt(false);
629
smgr->setFlagLabels(false);
630
ssmgr->setFlagLabels(false);
631
nmgr->setFlagHints(false);
632
lmgr->setFlagLandscape(true);
633
lmgr->setFlagAtmosphere(true);
634
lmgr->setFlagFog(true);
636
else if (state.toLower() == "starchart")
638
movmgr->setMountMode(StelMovementMgr::MountEquinoxEquatorial);
639
skyd->setFlagTwinkle(false);
640
skyd->setFlagLuminanceAdaptation(false);
641
ssmgr->setFlagPlanets(true);
642
ssmgr->setFlagHints(false);
643
ssmgr->setFlagOrbits(false);
644
ssmgr->setFlagMoonScale(false);
645
ssmgr->setFlagTrails(false);
647
glmgr->setFlagAzimuthalGrid(false);
648
glmgr->setFlagEquatorGrid(true);
649
glmgr->setFlagEquatorLine(false);
650
glmgr->setFlagEclipticLine(false);
651
glmgr->setFlagMeridianLine(false);
652
glmgr->setFlagEquatorJ2000Grid(false);
653
lmgr->setFlagCardinalsPoints(false);
654
cmgr->setFlagLines(true);
655
cmgr->setFlagLabels(true);
656
cmgr->setFlagBoundaries(true);
657
cmgr->setFlagArt(false);
658
smgr->setFlagLabels(true);
659
ssmgr->setFlagLabels(true);
660
nmgr->setFlagHints(true);
661
lmgr->setFlagLandscape(false);
662
lmgr->setFlagAtmosphere(false);
663
lmgr->setFlagFog(false);
665
else if (state.toLower() == "deepspace")
667
movmgr->setMountMode(StelMovementMgr::MountEquinoxEquatorial);
668
skyd->setFlagTwinkle(false);
669
skyd->setFlagLuminanceAdaptation(false);
670
ssmgr->setFlagPlanets(false);
671
ssmgr->setFlagHints(false);
672
ssmgr->setFlagOrbits(false);
673
ssmgr->setFlagMoonScale(false);
674
ssmgr->setFlagTrails(false);
676
glmgr->setFlagAzimuthalGrid(false);
677
glmgr->setFlagEquatorGrid(false);
678
glmgr->setFlagEquatorLine(false);
679
glmgr->setFlagEclipticLine(false);
680
glmgr->setFlagMeridianLine(false);
681
glmgr->setFlagEquatorJ2000Grid(false);
682
lmgr->setFlagCardinalsPoints(false);
683
cmgr->setFlagLines(false);
684
cmgr->setFlagLabels(false);
685
cmgr->setFlagBoundaries(false);
686
cmgr->setFlagArt(false);
687
smgr->setFlagLabels(false);
688
ssmgr->setFlagLabels(false);
689
nmgr->setFlagHints(false);
690
lmgr->setFlagLandscape(false);
691
lmgr->setFlagAtmosphere(false);
692
lmgr->setFlagFog(false);
696
qWarning() << "WARNING clear(" << state << ") - state not known";
700
double StelMainScriptAPI::getViewAltitudeAngle()
702
const Vec3d& current = StelApp::getInstance().getCore()->getNavigator()->j2000ToAltAz(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000());
704
StelUtils::rectToSphe(&azi, &alt, current);
705
return alt*180/M_PI; // convert to degrees from radians
708
double StelMainScriptAPI::getViewAzimuthAngle()
710
const Vec3d& current = StelApp::getInstance().getCore()->getNavigator()->j2000ToAltAz(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000());
712
StelUtils::rectToSphe(&azi, &alt, current);
713
// The returned azimuth angle is in radians and set up such that:
714
// N=+/-PI; E=PI/2; S=0; W=-PI/2;
715
// But we want compass bearings, i.e. N=0, E=90, S=180, W=270
716
return std::fmod(((azi*180/M_PI)*-1)+180., 360.);
719
double StelMainScriptAPI::getViewRaAngle()
721
const Vec3d& current = StelApp::getInstance().getCore()->getNavigator()->j2000ToEquinoxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000());
723
StelUtils::rectToSphe(&ra, &dec, current);
724
// returned RA angle is in range -PI .. PI, but we want 0 .. 360
725
return std::fmod((ra*180/M_PI)+360., 360.); // convert to degrees from radians
728
double StelMainScriptAPI::getViewDecAngle()
730
const Vec3d& current = StelApp::getInstance().getCore()->getNavigator()->j2000ToEquinoxEqu(GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000());
732
StelUtils::rectToSphe(&ra, &dec, current);
733
return dec*180/M_PI; // convert to degrees from radians
736
double StelMainScriptAPI::getViewRaJ2000Angle()
738
Vec3d current = GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000();
740
StelUtils::rectToSphe(&ra, &dec, current);
741
// returned RA angle is in range -PI .. PI, but we want 0 .. 360
742
return std::fmod((ra*180/M_PI)+360., 360.); // convert to degrees from radians
745
double StelMainScriptAPI::getViewDecJ2000Angle()
747
Vec3d current = GETSTELMODULE(StelMovementMgr)->getViewDirectionJ2000();
749
StelUtils::rectToSphe(&ra, &dec, current);
750
return dec*180/M_PI; // convert to degrees from radians
753
void StelMainScriptAPI::moveToAltAzi(const QString& alt, const QString& azi, float duration)
755
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
758
GETSTELMODULE(StelObjectMgr)->unSelect();
761
double dAlt = StelUtils::getDecAngle(alt);
762
double dAzi = M_PI - StelUtils::getDecAngle(azi);
764
StelUtils::spheToRect(dAzi,dAlt,aim);
765
mvmgr->moveToJ2000(StelApp::getInstance().getCore()->getNavigator()->altAzToJ2000(aim), duration);
768
void StelMainScriptAPI::moveToRaDec(const QString& ra, const QString& dec, float duration)
770
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
773
GETSTELMODULE(StelObjectMgr)->unSelect();
776
double dRa = StelUtils::getDecAngle(ra);
777
double dDec = StelUtils::getDecAngle(dec);
779
StelUtils::spheToRect(dRa,dDec,aim);
780
mvmgr->moveToJ2000(StelApp::getInstance().getCore()->getNavigator()->equinoxEquToJ2000(aim), duration);
783
void StelMainScriptAPI::moveToRaDecJ2000(const QString& ra, const QString& dec, float duration)
785
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
788
GETSTELMODULE(StelObjectMgr)->unSelect();
790
Vec3d aimJ2000, aimEquofDate;
791
double dRa = StelUtils::getDecAngle(ra);
792
double dDec = StelUtils::getDecAngle(dec);
794
StelUtils::spheToRect(dRa,dDec,aimJ2000);
795
aimEquofDate = StelApp::getInstance().getCore()->getNavigator()->j2000ToEquinoxEqu(aimJ2000);
796
mvmgr->moveToJ2000(aimEquofDate, duration);