Stellarium 0.90.0
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 
76  // TODO: This calls for implementing "sol" days (planets's solar days)!
87  // GZ JDfix for 0.14: I estimate 99.7% of users will want to set UT-based dates here. We could use an awkward name like dateIsUTbased=true to keep default value true.
88  //void setDate(const QString& dt, const QString& spec="utc", const bool& enableDeltaT=true);
89  void setDate(const QString& dateStr, const QString& spec="utc", const bool& dateIsDT=false);
90 
96  QString getDate(const QString& spec="utc");
97 
101  QString getDeltaT() const;
102 
105  QString getDeltaTAlgorithm() const;
106 
115  void setDeltaTAlgorithm(QString algorithmName);
116 
122  void setTimeRate(double ts);
125  double getTimeRate() const;
126 
130  bool isRealTime();
131 
133  void setRealTime();
134 
140  void selectObjectByName(const QString& name, bool pointer=false);
141 
155  QVariantMap getObjectPosition(const QString& name);
156 
194  QVariantMap getObjectInfo(const QString& name);
195 
232  QVariantMap getSelectedObjectInfo();
233 
243  void clear(const QString& state="natural");
244 
248  double getViewAltitudeAngle();
249 
253  double getViewAzimuthAngle();
254 
258  double getViewRaAngle();
259 
263  double getViewDecAngle();
264 
267  double getViewRaJ2000Angle();
268 
271  double getViewDecJ2000Angle();
272 
279  void moveToAltAzi(const QString& alt, const QString& azi, float duration=1.);
280 
287  void moveToRaDec(const QString& ra, const QString& dec, float duration=1.);
288 
294  void moveToRaDecJ2000(const QString& ra, const QString& dec, float duration=1.);
295 
313  void setObserverLocation(double longitude, double latitude, double altitude, double duration=1., const QString& name="", const QString& planet="");
314 
320  void setObserverLocation(const QString id, float duration=1.);
321 
323  QString getObserverLocation();
324 
337  QVariantMap getObserverLocationInfo();
338 
345  void screenshot(const QString& prefix, bool invert=false, const QString& dir="", const bool overwrite=false);
346 
350  void setGuiVisible(bool b);
351 
357  void setMinFps(float m);
358 
361  float getMinFps();
362 
365  void setMaxFps(float m);
366 
369  float getMaxFps();
370 
373  QString getMountMode();
374 
377  void setMountMode(const QString& mode);
378 
381  bool getNightMode();
382 
385  void setNightMode(bool b);
386 
390  QString getProjectionMode();
391 
403  void setProjectionMode(const QString& id);
404 
407  bool getDiskViewport();
408 
411  void setDiskViewport(bool b);
412 
415  void setSphericMirror(bool b);
416 
422  void setViewportOffset(const float x, const float y);
423 
428  void setViewportStretch(const float stretch);
429 
432  QStringList getAllSkyCultureIDs();
433 
437  QString getSkyCulture();
438 
441  void setSkyCulture(const QString& id);
442 
445  QString getSkyCultureName();
446 
449  QString getSkyCultureNameI18n();
450 
453  bool getFlagGravityLabels();
454 
457  void setFlagGravityLabels(bool b);
458 
477  void loadSkyImage(const QString& id, const QString& filename,
478  double ra0, double dec0,
479  double ra1, double dec1,
480  double ra2, double dec2,
481  double ra3, double dec3,
482  double minRes=2.5, double maxBright=14, bool visible=true);
483 
484 
488  void loadSkyImage(const QString& id, const QString& filename,
489  const QString& ra0, const QString& dec0,
490  const QString& ra1, const QString& dec1,
491  const QString& ra2, const QString& dec2,
492  const QString& ra3, const QString& dec3,
493  double minRes=2.5, double maxBright=14, bool visible=true);
494 
509  void loadSkyImage(const QString& id, const QString& filename,
510  double ra, double dec, double angSize, double rotation,
511  double minRes=2.5, double maxBright=14, bool visible=true);
512 
517  void loadSkyImage(const QString& id, const QString& filename,
518  const QString& ra, const QString& dec, double angSize, double rotation,
519  double minRes=2.5, double maxBright=14, bool visible=true);
520 
539  void loadSkyImageAltAz(const QString& id, const QString& filename,
540  double azi0, double alt0,
541  double azi1, double alt1,
542  double azi2, double alt2,
543  double azi3, double alt3,
544  double minRes=2.5, double maxBright=14, bool visible=true);
545 
560  void loadSkyImageAltAz(const QString& id, const QString& filename,
561  double alt, double azi, double angSize, double rotation,
562  double minRes=2.5, double maxBright=14, bool visible=true);
563 
566  void removeSkyImage(const QString& id);
567 
575  QVariantMap getScreenXYFromAltAzi(const QString& alt, const QString& azi);
576 
581  void loadSound(const QString& filename, const QString& id);
582 
585  void playSound(const QString& id);
586 
590  void pauseSound(const QString& id);
591 
596  void stopSound(const QString& id);
597 
601  void dropSound(const QString& id);
602 
606  qint64 getSoundPosition(const QString& id);
607 
611  qint64 getSoundDuration(const QString& id);
612 
613 
626  void loadVideo(const QString& filename, const QString& id, float x, float y, bool show=true, float alpha=1.0f);
627 
630  void playVideo(const QString& id, bool keepVisibleAtEnd=false);
631 
645  void playVideoPopout(const QString& id, float fromX, float fromY, float atCenterX, float atCenterY, float finalSizeX, float finalSizeY, float popupDuration, bool frozenInTransition);
646 
650  void pauseVideo(const QString& id);
651 
656  void stopVideo(const QString& id);
657 
661  void dropVideo(const QString& id);
662 
667  void seekVideo(const QString& id, qint64 ms, bool pause=false);
668 
674  void setVideoXY(const QString& id, float x, float y, bool relative=false);
675 
680  void setVideoAlpha(const QString& id, float alpha);
681 
686  void resizeVideo(const QString& id, float w, float h);
687 
692  void showVideo(const QString& id, bool show=true);
693 
696  qint64 getVideoDuration(const QString& id);
697 
700  qint64 getVideoPosition(const QString& id);
701 
704  int getScreenWidth();
707  int getScreenHeight();
708 
711  double getScriptRate();
716  void setScriptRate(double r);
717 
720  void pauseScript();
721 
724  void setSelectedObjectInfo(const QString& level);
725 
727  void exit();
728 
730  void quitStellarium();
731 
734  void debug(const QString& s);
735 
738  void output(const QString& s);
739 
741  void resetOutput(void);
742 
745  void saveOutputAs(const QString &filename);
746 
749  QString getAppLanguage();
750 
753  void setAppLanguage(QString langCode);
754 
757  QString getSkyLanguage();
758 
761  void setSkyLanguage(QString langCode);
762 
764  void goHome();
765 
768  void setMilkyWayVisible(bool b);
769 
772  void setMilkyWayIntensity(double i);
773 
776  double getMilkyWayIntensity();
777 
780  void setZodiacalLightVisible(bool b);
781 
784  void setZodiacalLightIntensity(double i);
785 
788  double getZodiacalLightIntensity();
789 
794  int getBortleScaleIndex() const;
795 
801  void setBortleScaleIndex(int index);
802 
806  double jdFromDateString(const QString& dt, const QString& spec);
807 
808  // Methods wait() and waitFor() was added for documentation.
809  // Details: https://bugs.launchpad.net/stellarium/+bug/1402200
810 
813  void wait(double t);
814 
823  void waitFor(const QString& dt, const QString& spec="utc");
824 
825 signals:
826  void requestLoadSkyImage(const QString& id, const QString& filename,
827  double c1, double c2,
828  double c3, double c4,
829  double c5, double c6,
830  double c7, double c8,
831  double minRes, double maxBright, bool visible);
832  void requestLoadSkyImageAltAz(const QString& id, const QString& filename,
833  double c1, double c2,
834  double c3, double c4,
835  double c5, double c6,
836  double c7, double c8,
837  double minRes, double maxBright, bool visible);
838 
839 
840  void requestRemoveSkyImage(const QString& id);
841 
842  void requestLoadSound(const QString& filename, const QString& id);
843  void requestPlaySound(const QString& id);
844  void requestPauseSound(const QString& id);
845  void requestStopSound(const QString& id);
846  void requestDropSound(const QString& id);
847  void requestLoadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
848  void requestPlayVideo(const QString& id, const bool keepVisibleAtEnd);
849  void requestPlayVideoPopout(const QString& id, float fromX, float fromY, float atCenterX, float atCenterY, float finalSizeX, float finalSizeY, float popupDuration, bool frozenInTransition);
850  void requestPauseVideo(const QString& id);
851  void requestStopVideo(const QString& id);
852  void requestDropVideo(const QString& id);
853  void requestSeekVideo(const QString& id, qint64 ms, bool pause=false);
854  void requestSetVideoXY(const QString& id, float x, float y, bool relative=false);
855  void requestSetVideoAlpha(const QString& id, float alpha);
856  void requestResizeVideo(const QString& id, float w, float h);
857  void requestShowVideo(const QString& id, bool show);
858 
859  void requestSetNightMode(bool b);
860  void requestSetProjectionMode(QString id);
861  void requestSetSkyCulture(QString id);
862  void requestSetDiskViewport(bool b);
863  void requestExit();
864  void requestSetHomePosition();
865 };
866 
867 #endif // _STELMAINSCRIPTAPI_HPP_
868 
void setBortleScaleIndex(int index)
Changes the Bortle scale index, which is used to simulate light pollution.
void setMinFps(float m)
Set the minimum frames per second.
double getViewDecAngle()
Get the current viewing direction Declination angle at center of view.
double getMJDay() const
Get the current date as Modified Julian Day.
bool getNightMode()
Get the current status of Night Mode.
QVariantMap getObjectInfo(const QString &name)
Fetch a map with data about an object&#39;s position, magnitude and so on.
void selectObjectByName(const QString &name, bool pointer=false)
Select an object by name.
void clear(const QString &state="natural")
Clear the display options, setting a "standard" view.
double jdFromDateString(const QString &dt, const QString &spec)
For use in setDate and waitFor For parameter descriptions see setDate().
void saveOutputAs(const QString &filename)
Save output file to new file (in same directory as output.txt).
void pauseVideo(const QString &id)
Pause a video which is playing.
void moveToAltAzi(const QString &alt, const QString &azi, float duration=1.)
move the current viewing direction to some specified altitude and azimuth.
int getScreenHeight()
Get the screen height (actually, height of Stellarium main view) in pixels.
QString getAppLanguage()
Get the current application language.
void setProjectionMode(const QString &id)
Set the current projection mode.
void setDiskViewport(bool b)
Set the disk viewport.
bool isRealTime()
Get the simulation time and rate state - is it "real time".
void playSound(const QString &id)
Play a sound which has previously been loaded with loadSound.
void moveToRaDec(const QString &ra, const QString &dec, float duration=1.)
move the current viewing direction to some specified right ascension and declination.
void playVideo(const QString &id, bool keepVisibleAtEnd=false)
Play a video which has previously been loaded with loadVideo.
QString getDeltaTAlgorithm() const
get the DeltaT equation name for the simulation date and time as a string
double getTimeRate() const
Get simulation time rate.
double getViewDecJ2000Angle()
Get the current viewing direction Declination angle in J2000 frame at center of view.
double getViewRaJ2000Angle()
Get the current viewing direction Right Ascension in J2000 frame at center of view.
QString getProjectionMode()
Get the current projection mode ID string.
void setRealTime()
Set the simulation time to the current system time, and the time rate to 1.
void exit()
Stop the script.
QVariantMap getObserverLocationInfo()
Get the info of the current observer location.
void wait(double t)
Pauses the script for t seconds.
int getScreenWidth()
Get the screen width in pixels.
void setMilkyWayVisible(bool b)
Show or hide the Milky Way.
void resizeVideo(const QString &id, float w, float h)
Resize the video widget to the specified width, height.
void setVideoAlpha(const QString &id, float alpha)
Set the alpha value of a video when visible.
void playVideoPopout(const QString &id, float fromX, float fromY, float atCenterX, float atCenterY, float finalSizeX, float finalSizeY, float popupDuration, bool frozenInTransition)
Play a video which has previously been loaded with loadVideo with a complex effect.
void setNightMode(bool b)
Set the status of Night Mode.
void setViewportStretch(const float stretch)
Set a lateral width distortion.
void setSphericMirror(bool b)
Set the viewport distortion effect.
void setSelectedObjectInfo(const QString &level)
Set the amount of selected object information to display.
QString getSkyCultureName()
Find out the current sky culture and get it English name.
QString getSkyCultureNameI18n()
Find out the current sky culture and get it localized name.
void dropSound(const QString &id)
Drop a sound from memory.
void removeSkyImage(const QString &id)
Remove a SkyImage.
void setFlagGravityLabels(bool b)
Turn on/off gravity labels.
int getBortleScaleIndex() const
Returns the currently set Bortle scale index, which is used to simulate light pollution.
void setZodiacalLightVisible(bool b)
Show or hide the Zodiacal Light.
void setMountMode(const QString &mode)
Set the mount mode.
qint64 getSoundPosition(const QString &id)
Get position in a playing sound.
double getViewAltitudeAngle()
Get the current viewing direction altitude angle at center of view.
void debug(const QString &s)
print a debugging message to the console
QString getDate(const QString &spec="utc")
get the simulation date and time as a string in ISO format, e.g.
Provide script API for Stellarium global functions.
QVariantMap getSelectedObjectInfo()
Fetch a map with data about an latest selected object&#39;s position, magnitude and so on...
void setJDay(double JD)
Set the current date as Julian Day number.
void loadSkyImageAltAz(const QString &id, const QString &filename, double azi0, double alt0, double azi1, double alt1, double azi2, double alt2, double azi3, double alt3, double minRes=2.5, double maxBright=14, bool visible=true)
Load an image which will have a sky location given in alt-azimuthal coordinates.
float getMinFps()
Get the current minimum frames per second.
QVariantMap getScreenXYFromAltAzi(const QString &alt, const QString &azi)
Get screen coordinates from some specified altitude and azimuth angles may be specified in a format r...
void setViewportOffset(const float x, const float y)
Set viewport offset This can be used e.g.
void setScriptRate(double r)
Set the script execution rate as a multiple of normal execution speed.
void moveToRaDecJ2000(const QString &ra, const QString &dec, float duration=1.)
move the current viewing direction to some specified right ascension and declination in the J2000 fra...
void loadSkyImage(const QString &id, const QString &filename, double ra0, double dec0, double ra1, double dec1, double ra2, double dec2, double ra3, double dec3, double minRes=2.5, double maxBright=14, bool visible=true)
Load an image which will have sky coordinates.
void setMaxFps(float m)
Set the maximum frames per second.
QStringList getAllSkyCultureIDs()
Get a list of Sky Culture IDs.
void setSkyLanguage(QString langCode)
Set the current sky language.
void loadVideo(const QString &filename, const QString &id, float x, float y, bool show=true, float alpha=1.0f)
Load a video from a file.
void goHome()
Go to defaults position and direction of view.
void waitFor(const QString &dt, const QString &spec="utc")
Waits until a specified simulation date/time.
void loadSound(const QString &filename, const QString &id)
Load a sound from a file.
void setDate(const QString &dateStr, const QString &spec="utc", const bool &dateIsDT=false)
set the date in ISO format, e.g.
void setAppLanguage(QString langCode)
Set the current application language.
qint64 getVideoDuration(const QString &id)
Get the duration of a loaded video, or -1.
QString getMountMode()
Get the mount mode as a string.
void setGuiVisible(bool b)
Show or hide the GUI (toolbars).
void output(const QString &s)
print an output message from script
void pauseScript()
Pause the currently running script.
bool getDiskViewport()
Get the status of the disk viewport.
void dropVideo(const QString &id)
Drop a video from memory.
QString getDeltaT() const
get the DeltaT for the simulation date and time as a string in HMS format, e.g.
void showVideo(const QString &id, bool show=true)
Set the visibility state of a video.
void resetOutput(void)
Reset (clear) output file.
double getMilkyWayIntensity()
Get Milky Way intensity.
double getViewAzimuthAngle()
Get the current viewing direction azimuth angle at center of view.
void seekVideo(const QString &id, qint64 ms, bool pause=false)
Seeks a video to the requested time and either start playing or freeze there.
QString getObserverLocation()
Get the ID of the current observer location.
float getMaxFps()
Get the current maximum frames per second.
void screenshot(const QString &prefix, bool invert=false, const QString &dir="", const bool overwrite=false)
Save a screenshot.
QString getSkyLanguage()
Get the current sky language.
void quitStellarium()
Close Stellarium.
void setDeltaTAlgorithm(QString algorithmName)
set equation of the DeltaT for the simulation date and time
double getScriptRate()
Get the script execution rate as a multiple of normal execution speed.
void setMJDay(double MJD)
Set the current date as Modified Julian Day.
qint64 getSoundDuration(const QString &id)
Get duration of a sound object (if possible).
void setTimeRate(double ts)
Set time speed in JDay/sec.
void pauseSound(const QString &id)
Pause a sound which is playing.
qint64 getVideoPosition(const QString &id)
Get the current position of a loaded video, or -1.
void setVideoXY(const QString &id, float x, float y, bool relative=false)
Sets the position of the video widget.
void setMilkyWayIntensity(double i)
Set Milky Way intensity.
bool getFlagGravityLabels()
Get the current status of the gravity labels option.
void setSkyCulture(const QString &id)
Set the current sky culture.
QString getSkyCulture()
Find out the current sky culture.
double getViewRaAngle()
Get the current viewing direction Right Ascension at center of view.
void setZodiacalLightIntensity(double i)
Set Zodiacal Light intensity.
void stopSound(const QString &id)
Stop a sound from playing.
double getZodiacalLightIntensity()
Get Zodiacal Light intensity.
double getJDay() const
Get the current date as Julian Day number.
QVariantMap getObjectPosition(const QString &name)
Fetch a map with data about an object&#39;s position, magnitude and so on.
void stopVideo(const QString &id)
Stop a video from playing.
void setObserverLocation(double longitude, double latitude, double altitude, double duration=1., const QString &name="", const QString &planet="")
Set the observer location.