Stellarium 0.12.4
StelMainScriptAPI.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2009 Matthew Gates
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELMAINSCRIPTAPI_HPP_
21 #define _STELMAINSCRIPTAPI_HPP_
22 
23 #include <QObject>
24 #include <QVariant>
25 #include <QStringList>
26 
27 class QScriptEngine;
28 
35 class StelMainScriptAPI : public QObject
36 {
37  Q_OBJECT
38  Q_PROPERTY(double JDay READ getJDay WRITE setJDay)
39  Q_PROPERTY(double timeSpeed READ getTimeRate WRITE setTimeRate)
40 
41 public:
42  StelMainScriptAPI(QObject *parent = 0);
44 
45 // These functions will be available in scripts
46 public slots:
49  void setJDay(double JD);
52  double getJDay() const;
53 
56  void setMJDay(double MJD);
59  double getMJDay() const;
60 
83  void setDate(const QString& dt, const QString& spec="utc", const bool& enableDeltaT=true);
84 
90  QString getDate(const QString& spec="utc");
91 
95  QString getDeltaT() const;
96 
99  QString getDeltaTAlgorithm() const;
100 
109  void setDeltaTAlgorithm(QString algorithmName);
110 
116  void setTimeRate(double ts);
119  double getTimeRate() const;
120 
124  bool isRealTime();
125 
127  void setRealTime();
128 
134  void selectObjectByName(const QString& name, bool pointer=false);
135 
149  QVariantMap getObjectPosition(const QString& name);
150 
169  QVariantMap getObjectInfo(const QString& name);
170 
188  QVariantMap getSelectedObjectInfo();
189 
197  void clear(const QString& state="natural");
198 
202  double getViewAltitudeAngle();
203 
207  double getViewAzimuthAngle();
208 
212  double getViewRaAngle();
213 
217  double getViewDecAngle();
218 
221  double getViewRaJ2000Angle();
222 
225  double getViewDecJ2000Angle();
226 
232  void moveToAltAzi(const QString& alt, const QString& azi, float duration=1.);
233 
239  void moveToRaDec(const QString& ra, const QString& dec, float duration=1.);
240 
246  void moveToRaDecJ2000(const QString& ra, const QString& dec, float duration=1.);
247 
265  void setObserverLocation(double longitude, double latitude, double altitude, double duration=1., const QString& name="", const QString& planet="");
266 
272  void setObserverLocation(const QString id, float duration=1.);
273 
275  QString getObserverLocation();
276 
287  QVariantMap getObserverLocationInfo();
288 
294  void screenshot(const QString& prefix, bool invert=false, const QString& dir="");
295 
299  void setGuiVisible(bool b);
300 
306  void setMinFps(float m);
307 
310  float getMinFps();
311 
314  void setMaxFps(float m);
315 
318  float getMaxFps();
319 
322  QString getMountMode();
323 
326  void setMountMode(const QString& mode);
327 
330  bool getNightMode();
331 
334  void setNightMode(bool b);
335 
339  QString getProjectionMode();
340 
352  void setProjectionMode(const QString& id);
353 
356  bool getDiskViewport();
357 
360  void setDiskViewport(bool b);
361 
364  QStringList getAllSkyCultureIDs();
365 
369  QString getSkyCulture();
370 
373  void setSkyCulture(const QString& id);
374 
377  QString getSkyCultureName();
378 
381  QString getSkyCultureNameI18n();
382 
385  bool getFlagGravityLabels();
386 
389  void setFlagGravityLabels(bool b);
390 
409  void loadSkyImage(const QString& id, const QString& filename,
410  double ra0, double dec0,
411  double ra1, double dec1,
412  double ra2, double dec2,
413  double ra3, double dec3,
414  double minRes=2.5, double maxBright=14, bool visible=true);
415 
416 
420  void loadSkyImage(const QString& id, const QString& filename,
421  const QString& ra0, const QString& dec0,
422  const QString& ra1, const QString& dec1,
423  const QString& ra2, const QString& dec2,
424  const QString& ra3, const QString& dec3,
425  double minRes=2.5, double maxBright=14, bool visible=true);
426 
441  void loadSkyImage(const QString& id, const QString& filename,
442  double ra, double dec, double angSize, double rotation,
443  double minRes=2.5, double maxBright=14, bool visible=true);
444 
449  void loadSkyImage(const QString& id, const QString& filename,
450  const QString& ra, const QString& dec, double angSize, double rotation,
451  double minRes=2.5, double maxBright=14, bool visible=true);
452 
471  void loadSkyImageAltAz(const QString& id, const QString& filename,
472  double alt0, double azi0,
473  double alt1, double azi1,
474  double alt2, double azi2,
475  double alt3, double azi3,
476  double minRes=2.5, double maxBright=14, bool visible=true);
477 
492  void loadSkyImageAltAz(const QString& id, const QString& filename,
493  double alt, double azi, double angSize, double rotation,
494  double minRes=2.5, double maxBright=14, bool visible=true);
495 
498  void removeSkyImage(const QString& id);
499 
504  void loadSound(const QString& filename, const QString& id);
505 
508  void playSound(const QString& id);
509 
513  void pauseSound(const QString& id);
514 
519  void stopSound(const QString& id);
520 
524  void dropSound(const QString& id);
525 
534  void loadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
535 
538  void playVideo(const QString& id);
539 
543  void pauseVideo(const QString& id);
544 
549  void stopVideo(const QString& id);
550 
554  void dropVideo(const QString& id);
555 
559  void seekVideo(const QString& id, qint64 ms);
560 
565  void setVideoXY(const QString& id, float x, float y);
566 
570  void setVideoAlpha(const QString& id, float alpha);
571 
576  void resizeVideo(const QString& id, float w, float h);
577 
581  void showVideo(const QString& id, bool show);
582 
585  int getScreenWidth();
588  int getScreenHeight();
589 
592  double getScriptRate();
597  void setScriptRate(double r);
598 
601  void pauseScript();
602 
605  void setSelectedObjectInfo(const QString& level);
606 
608  void exit();
609 
611  void quitStellarium();
612 
615  void debug(const QString& s);
616 
619  QString getAppLanguage();
620 
623  void setAppLanguage(QString langCode);
624 
627  QString getSkyLanguage();
628 
631  void setSkyLanguage(QString langCode);
632 
634  void goHome();
635 
638  void setMilkyWayVisible(bool b);
639 
642  void setMilkyWayIntensity(double i);
643 
646  double getMilkyWayIntensity();
647 
651  double jdFromDateString(const QString& dt, const QString& spec);
652 
653 signals:
654  void requestLoadSkyImage(const QString& id, const QString& filename,
655  double c1, double c2,
656  double c3, double c4,
657  double c5, double c6,
658  double c7, double c8,
659  double minRes, double maxBright, bool visible);
660  void requestLoadSkyImageAltAz(const QString& id, const QString& filename,
661  double c1, double c2,
662  double c3, double c4,
663  double c5, double c6,
664  double c7, double c8,
665  double minRes, double maxBright, bool visible);
666 
667 
668  void requestRemoveSkyImage(const QString& id);
669 
670  void requestLoadSound(const QString& filename, const QString& id);
671  void requestPlaySound(const QString& id);
672  void requestPauseSound(const QString& id);
673  void requestStopSound(const QString& id);
674  void requestDropSound(const QString& id);
675  void requestLoadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
676  void requestPlayVideo(const QString& id);
677  void requestPauseVideo(const QString& id);
678  void requestStopVideo(const QString& id);
679  void requestDropVideo(const QString& id);
680  void requestSeekVideo(const QString& id, qint64 ms);
681  void requestSetVideoXY(const QString& id, float x, float y);
682  void requestSetVideoAlpha(const QString& id, float alpha);
683  void requestResizeVideo(const QString& id, float w, float h);
684  void requestShowVideo(const QString& id, bool show);
685 
686  void requestSetNightMode(bool b);
687  void requestSetProjectionMode(QString id);
688  void requestSetSkyCulture(QString id);
689  void requestSetDiskViewport(bool b);
690  void requestExit();
691  void requestSetHomePosition();
692 };
693 
694 #endif // _STELMAINSCRIPTAPI_HPP_
695