Stellarium 0.14.3
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 
191  QVariantMap getObjectInfo(const QString& name);
192 
226  QVariantMap getSelectedObjectInfo();
227 
237  void clear(const QString& state="natural");
238 
242  double getViewAltitudeAngle();
243 
247  double getViewAzimuthAngle();
248 
252  double getViewRaAngle();
253 
257  double getViewDecAngle();
258 
261  double getViewRaJ2000Angle();
262 
265  double getViewDecJ2000Angle();
266 
272  void moveToAltAzi(const QString& alt, const QString& azi, float duration=1.);
273 
279  void moveToRaDec(const QString& ra, const QString& dec, float duration=1.);
280 
286  void moveToRaDecJ2000(const QString& ra, const QString& dec, float duration=1.);
287 
305  void setObserverLocation(double longitude, double latitude, double altitude, double duration=1., const QString& name="", const QString& planet="");
306 
312  void setObserverLocation(const QString id, float duration=1.);
313 
315  QString getObserverLocation();
316 
329  QVariantMap getObserverLocationInfo();
330 
337  void screenshot(const QString& prefix, bool invert=false, const QString& dir="", const bool overwrite=false);
338 
342  void setGuiVisible(bool b);
343 
349  void setMinFps(float m);
350 
353  float getMinFps();
354 
357  void setMaxFps(float m);
358 
361  float getMaxFps();
362 
365  QString getMountMode();
366 
369  void setMountMode(const QString& mode);
370 
373  bool getNightMode();
374 
377  void setNightMode(bool b);
378 
382  QString getProjectionMode();
383 
395  void setProjectionMode(const QString& id);
396 
399  bool getDiskViewport();
400 
403  void setDiskViewport(bool b);
404 
407  void setSphericMirror(bool b);
408 
411  QStringList getAllSkyCultureIDs();
412 
416  QString getSkyCulture();
417 
420  void setSkyCulture(const QString& id);
421 
424  QString getSkyCultureName();
425 
428  QString getSkyCultureNameI18n();
429 
432  bool getFlagGravityLabels();
433 
436  void setFlagGravityLabels(bool b);
437 
456  void loadSkyImage(const QString& id, const QString& filename,
457  double ra0, double dec0,
458  double ra1, double dec1,
459  double ra2, double dec2,
460  double ra3, double dec3,
461  double minRes=2.5, double maxBright=14, bool visible=true);
462 
463 
467  void loadSkyImage(const QString& id, const QString& filename,
468  const QString& ra0, const QString& dec0,
469  const QString& ra1, const QString& dec1,
470  const QString& ra2, const QString& dec2,
471  const QString& ra3, const QString& dec3,
472  double minRes=2.5, double maxBright=14, bool visible=true);
473 
488  void loadSkyImage(const QString& id, const QString& filename,
489  double ra, double dec, double angSize, double rotation,
490  double minRes=2.5, double maxBright=14, bool visible=true);
491 
496  void loadSkyImage(const QString& id, const QString& filename,
497  const QString& ra, const QString& dec, double angSize, double rotation,
498  double minRes=2.5, double maxBright=14, bool visible=true);
499 
518  void loadSkyImageAltAz(const QString& id, const QString& filename,
519  double alt0, double azi0,
520  double alt1, double azi1,
521  double alt2, double azi2,
522  double alt3, double azi3,
523  double minRes=2.5, double maxBright=14, bool visible=true);
524 
539  void loadSkyImageAltAz(const QString& id, const QString& filename,
540  double alt, double azi, double angSize, double rotation,
541  double minRes=2.5, double maxBright=14, bool visible=true);
542 
545  void removeSkyImage(const QString& id);
546 
551  void loadSound(const QString& filename, const QString& id);
552 
555  void playSound(const QString& id);
556 
560  void pauseSound(const QString& id);
561 
566  void stopSound(const QString& id);
567 
571  void dropSound(const QString& id);
572 
581  void loadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
582 
585  void playVideo(const QString& id);
586 
590  void pauseVideo(const QString& id);
591 
596  void stopVideo(const QString& id);
597 
601  void dropVideo(const QString& id);
602 
606  void seekVideo(const QString& id, qint64 ms);
607 
612  void setVideoXY(const QString& id, float x, float y);
613 
617  void setVideoAlpha(const QString& id, float alpha);
618 
623  void resizeVideo(const QString& id, float w, float h);
624 
628  void showVideo(const QString& id, bool show);
629 
632  int getScreenWidth();
635  int getScreenHeight();
636 
639  double getScriptRate();
644  void setScriptRate(double r);
645 
648  void pauseScript();
649 
652  void setSelectedObjectInfo(const QString& level);
653 
655  void exit();
656 
658  void quitStellarium();
659 
662  void debug(const QString& s);
663 
666  void output(const QString& s);
667 
669  void resetOutput(void);
670 
673  QString getAppLanguage();
674 
677  void setAppLanguage(QString langCode);
678 
681  QString getSkyLanguage();
682 
685  void setSkyLanguage(QString langCode);
686 
688  void goHome();
689 
692  void setMilkyWayVisible(bool b);
693 
696  void setMilkyWayIntensity(double i);
697 
700  double getMilkyWayIntensity();
701 
704  void setZodiacalLightVisible(bool b);
705 
708  void setZodiacalLightIntensity(double i);
709 
712  double getZodiacalLightIntensity();
713 
717  double jdFromDateString(const QString& dt, const QString& spec);
718 
719  // Methods wait() and waitFor() was added for documentation.
720  // Details: https://bugs.launchpad.net/stellarium/+bug/1402200
721 
725  void wait(double t) { Q_UNUSED(t) }
726 
736  void waitFor(const QString& dt, const QString& spec="utc") { Q_UNUSED(dt); Q_UNUSED(spec) }
737 
738 signals:
739  void requestLoadSkyImage(const QString& id, const QString& filename,
740  double c1, double c2,
741  double c3, double c4,
742  double c5, double c6,
743  double c7, double c8,
744  double minRes, double maxBright, bool visible);
745  void requestLoadSkyImageAltAz(const QString& id, const QString& filename,
746  double c1, double c2,
747  double c3, double c4,
748  double c5, double c6,
749  double c7, double c8,
750  double minRes, double maxBright, bool visible);
751 
752 
753  void requestRemoveSkyImage(const QString& id);
754 
755  void requestLoadSound(const QString& filename, const QString& id);
756  void requestPlaySound(const QString& id);
757  void requestPauseSound(const QString& id);
758  void requestStopSound(const QString& id);
759  void requestDropSound(const QString& id);
760  void requestLoadVideo(const QString& filename, const QString& id, float x, float y, bool show, float alpha);
761  void requestPlayVideo(const QString& id);
762  void requestPauseVideo(const QString& id);
763  void requestStopVideo(const QString& id);
764  void requestDropVideo(const QString& id);
765  void requestSeekVideo(const QString& id, qint64 ms);
766  void requestSetVideoXY(const QString& id, float x, float y);
767  void requestSetVideoAlpha(const QString& id, float alpha);
768  void requestResizeVideo(const QString& id, float w, float h);
769  void requestShowVideo(const QString& id, bool show);
770 
771  void requestSetNightMode(bool b);
772  void requestSetProjectionMode(QString id);
773  void requestSetSkyCulture(QString id);
774  void requestSetDiskViewport(bool b);
775  void requestExit();
776  void requestSetHomePosition();
777 };
778 
779 #endif // _STELMAINSCRIPTAPI_HPP_
780 
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'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 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 angles may be specified in ...
int getScreenHeight()
Get the screen height 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 angles may be sp...
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 loadVideo(const QString &filename, const QString &id, float x, float y, bool show, float alpha)
Load a video from a file.
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 setNightMode(bool b)
Set the status of Night Mode.
void playVideo(const QString &id)
Play a video which has previously been loaded with loadVideo.
void loadSkyImageAltAz(const QString &id, const QString &filename, double alt0, double azi0, double alt1, double azi1, double alt2, double azi2, double alt3, double azi3, double minRes=2.5, double maxBright=14, bool visible=true)
Load an image which will have sky coordinates.
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.
void setZodiacalLightVisible(bool b)
Show or hide the Zodiacal Light.
void setMountMode(const QString &mode)
Set the mount mode.
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's position, magnitude and so on...
void setJDay(double JD)
Set the current date as Julian Day number.
void showVideo(const QString &id, bool show)
Set the visibility state of a video.
float getMinFps()
Get the current minimum frames per second.
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 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.
void seekVideo(const QString &id, qint64 ms)
Seeks a video to the requested time.
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 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.
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.
void setTimeRate(double ts)
Set time speed in JDay/sec.
void pauseSound(const QString &id)
Pause a sound which is playing.
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.
void setVideoXY(const QString &id, float x, float y)
Sets the position of the video widget.
double getJDay() const
Get the current date as Julian Day number.
QVariantMap getObjectPosition(const QString &name)
Fetch a map with data about an object'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.