Stellarium 0.12.2
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 
79  void setDate(const QString& dt, const QString& spec="utc", const bool& enableDeltaT=false);
80 
86  QString getDate(const QString& spec="utc");
87 
91  QString getDeltaT() const;
92 
98  void setTimeRate(double ts);
101  double getTimeRate() const;
102 
106  bool isRealTime();
107 
109  void setRealTime();
110 
116  void selectObjectByName(const QString& name, bool pointer=false);
117 
131  QVariantMap getObjectPosition(const QString& name);
132 
151  QVariantMap getObjectInfo(const QString& name);
152 
160  void clear(const QString& state="natural");
161 
165  double getViewAltitudeAngle();
166 
170  double getViewAzimuthAngle();
171 
175  double getViewRaAngle();
176 
180  double getViewDecAngle();
181 
184  double getViewRaJ2000Angle();
185 
188  double getViewDecJ2000Angle();
189 
195  void moveToAltAzi(const QString& alt, const QString& azi, float duration=1.);
196 
202  void moveToRaDec(const QString& ra, const QString& dec, float duration=1.);
203 
209  void moveToRaDecJ2000(const QString& ra, const QString& dec, float duration=1.);
210 
228  void setObserverLocation(double longitude, double latitude, double altitude, double duration=1., const QString& name="", const QString& planet="");
229 
235  void setObserverLocation(const QString id, float duration=1.);
236 
238  QString getObserverLocation();
239 
250  QVariantMap getObserverLocationInfo();
251 
257  void screenshot(const QString& prefix, bool invert=false, const QString& dir="");
258 
262  void setGuiVisible(bool b);
263 
269  void setMinFps(float m);
270 
273  float getMinFps();
274 
277  void setMaxFps(float m);
278 
281  float getMaxFps();
282 
285  QString getMountMode();
286 
289  void setMountMode(const QString& mode);
290 
293  bool getNightMode();
294 
297  void setNightMode(bool b);
298 
302  QString getProjectionMode();
303 
315  void setProjectionMode(const QString& id);
316 
319  bool getDiskViewport();
320 
323  void setDiskViewport(bool b);
324 
327  QStringList getAllSkyCultureIDs();
328 
332  QString getSkyCulture();
333 
336  void setSkyCulture(const QString& id);
337 
340  QString getSkyCultureName();
341 
344  QString getSkyCultureNameI18n();
345 
348  bool getFlagGravityLabels();
349 
352  void setFlagGravityLabels(bool b);
353 
372  void loadSkyImage(const QString& id, const QString& filename,
373  double ra0, double dec0,
374  double ra1, double dec1,
375  double ra2, double dec2,
376  double ra3, double dec3,
377  double minRes=2.5, double maxBright=14, bool visible=true);
378 
379 
383  void loadSkyImage(const QString& id, const QString& filename,
384  const QString& ra0, const QString& dec0,
385  const QString& ra1, const QString& dec1,
386  const QString& ra2, const QString& dec2,
387  const QString& ra3, const QString& dec3,
388  double minRes=2.5, double maxBright=14, bool visible=true);
389 
404  void loadSkyImage(const QString& id, const QString& filename,
405  double ra, double dec, double angSize, double rotation,
406  double minRes=2.5, double maxBright=14, bool visible=true);
407 
412  void loadSkyImage(const QString& id, const QString& filename,
413  const QString& ra, const QString& dec, double angSize, double rotation,
414  double minRes=2.5, double maxBright=14, bool visible=true);
415 
434  void loadSkyImageAltAz(const QString& id, const QString& filename,
435  double alt0, double azi0,
436  double alt1, double azi1,
437  double alt2, double azi2,
438  double alt3, double azi3,
439  double minRes=2.5, double maxBright=14, bool visible=true);
440 
455  void loadSkyImageAltAz(const QString& id, const QString& filename,
456  double alt, double azi, double angSize, double rotation,
457  double minRes=2.5, double maxBright=14, bool visible=true);
458 
461  void removeSkyImage(const QString& id);
462 
467  void loadSound(const QString& filename, const QString& id);
468 
471  void playSound(const QString& id);
472 
476  void pauseSound(const QString& id);
477 
482  void stopSound(const QString& id);
483 
487  void dropSound(const QString& id);
488 
497  void loadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
498 
501  void playVideo(const QString& id);
502 
506  void pauseVideo(const QString& id);
507 
512  void stopVideo(const QString& id);
513 
517  void dropVideo(const QString& id);
518 
522  void seekVideo(const QString& id, qint64 ms);
523 
528  void setVideoXY(const QString& id, float x, float y);
529 
533  void setVideoAlpha(const QString& id, float alpha);
534 
539  void resizeVideo(const QString& id, float w, float h);
540 
544  void showVideo(const QString& id, bool show);
545 
548  int getScreenWidth();
551  int getScreenHeight();
552 
555  double getScriptRate();
560  void setScriptRate(double r);
561 
564  void pauseScript();
565 
568  void setSelectedObjectInfo(const QString& level);
569 
571  void exit();
572 
574  void quitStellarium();
575 
578  void debug(const QString& s);
579 
582  QString getAppLanguage();
583 
586  void setAppLanguage(QString langCode);
587 
590  QString getSkyLanguage();
591 
594  void setSkyLanguage(QString langCode);
595 
597  void goHome();
598 
601  void setMilkyWayVisible(bool b);
602 
605  void setMilkyWayIntensity(double i);
606 
609  double getMilkyWayIntensity();
610 
614  double jdFromDateString(const QString& dt, const QString& spec);
615 
616 signals:
617  void requestLoadSkyImage(const QString& id, const QString& filename,
618  double c1, double c2,
619  double c3, double c4,
620  double c5, double c6,
621  double c7, double c8,
622  double minRes, double maxBright, bool visible);
623  void requestLoadSkyImageAltAz(const QString& id, const QString& filename,
624  double c1, double c2,
625  double c3, double c4,
626  double c5, double c6,
627  double c7, double c8,
628  double minRes, double maxBright, bool visible);
629 
630 
631  void requestRemoveSkyImage(const QString& id);
632 
633  void requestLoadSound(const QString& filename, const QString& id);
634  void requestPlaySound(const QString& id);
635  void requestPauseSound(const QString& id);
636  void requestStopSound(const QString& id);
637  void requestDropSound(const QString& id);
638  void requestLoadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
639  void requestPlayVideo(const QString& id);
640  void requestPauseVideo(const QString& id);
641  void requestStopVideo(const QString& id);
642  void requestDropVideo(const QString& id);
643  void requestSeekVideo(const QString& id, qint64 ms);
644  void requestSetVideoXY(const QString& id, float x, float y);
645  void requestSetVideoAlpha(const QString& id, float alpha);
646  void requestResizeVideo(const QString& id, float w, float h);
647  void requestShowVideo(const QString& id, bool show);
648 
649  void requestSetNightMode(bool b);
650  void requestSetProjectionMode(QString id);
651  void requestSetSkyCulture(QString id);
652  void requestSetDiskViewport(bool b);
653  void requestExit();
654  void requestSetHomePosition();
655 };
656 
657 #endif // _STELMAINSCRIPTAPI_HPP_
658