Stellarium 0.11.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

scripting/StelMainScriptAPI.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2009 Matthew Gates
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELMAINSCRIPTAPI_HPP_
00021 #define _STELMAINSCRIPTAPI_HPP_
00022 
00023 #include <QObject>
00024 #include <QVariant>
00025 #include <QStringList>
00026 
00027 class QScriptEngine;
00028 
00035 class StelMainScriptAPI : public QObject
00036 {
00037     Q_OBJECT
00038     Q_PROPERTY(double JDay READ getJDay WRITE setJDay)
00039     Q_PROPERTY(double timeSpeed READ getTimeRate WRITE setTimeRate)
00040 
00041 public:
00042     StelMainScriptAPI(QObject *parent = 0);
00043     ~StelMainScriptAPI();
00044 
00045 // These functions will be available in scripts
00046 public slots:
00049     void setJDay(double JD);
00052     double getJDay() const;
00053 
00071     void setDate(const QString& dt, const QString& spec="utc");
00072 
00078     QString getDate(const QString& spec="utc");
00079 
00085     void setTimeRate(double ts);
00088     double getTimeRate() const;
00089 
00093     bool isRealTime();
00094 
00096     void setRealTime();
00097 
00103     void selectObjectByName(const QString& name, bool pointer=false);
00104 
00115     QVariantMap getObjectPosition(const QString& name);
00116 
00124     void clear(const QString& state="natural");
00125 
00129     double getViewAltitudeAngle();
00130 
00134     double getViewAzimuthAngle();
00135 
00139     double getViewRaAngle();
00140 
00144     double getViewDecAngle();
00145 
00148     double getViewRaJ2000Angle();
00149 
00152     double getViewDecJ2000Angle();
00153 
00159     void moveToAltAzi(const QString& alt, const QString& azi, float duration=1.);
00160 
00166     void moveToRaDec(const QString& ra, const QString& dec, float duration=1.);
00167 
00173     void moveToRaDecJ2000(const QString& ra, const QString& dec, float duration=1.);
00174 
00192     void setObserverLocation(double longitude, double latitude, double altitude, double duration=1., const QString& name="", const QString& planet="");
00193 
00199     void setObserverLocation(const QString id, float duration=1.);
00200 
00202     QString getObserverLocation();
00203 
00209     void screenshot(const QString& prefix, bool invert=false, const QString& dir="");
00210 
00214     void setGuiVisible(bool b);
00215 
00221     void setMinFps(float m);
00222 
00225     float getMinFps();
00226 
00229     void setMaxFps(float m);
00230 
00233     float getMaxFps();
00234 
00237     QString getMountMode();
00238 
00241     void setMountMode(const QString& mode);
00242 
00245     bool getNightMode();
00246 
00249     void setNightMode(bool b);
00250 
00254     QString getProjectionMode();
00255 
00267     void setProjectionMode(const QString& id);
00268 
00271     bool getDiskViewport();
00272 
00275     void setDiskViewport(bool b);
00276 
00279     QStringList getAllSkyCultureIDs();
00280 
00284     QString getSkyCulture();
00285 
00288     void setSkyCulture(const QString& id);
00289 
00292     bool getFlagGravityLabels();
00293 
00296     void setFlagGravityLabels(bool b);
00297 
00316     void loadSkyImage(const QString& id, const QString& filename,
00317                       double ra0, double dec0,
00318                       double ra1, double dec1,
00319                       double ra2, double dec2,
00320                       double ra3, double dec3,
00321                       double minRes=2.5, double maxBright=14, bool visible=true);
00322 
00326     void loadSkyImage(const QString& id, const QString& filename,
00327                       const QString& ra0, const QString& dec0,
00328                       const QString& ra1, const QString& dec1,
00329                       const QString& ra2, const QString& dec2,
00330                       const QString& ra3, const QString& dec3,
00331                       double minRes=2.5, double maxBright=14, bool visible=true);
00332 
00347     void loadSkyImage(const QString& id, const QString& filename,
00348                       double ra, double dec, double angSize, double rotation,
00349                       double minRes=2.5, double maxBright=14, bool visible=true);
00350 
00355     void loadSkyImage(const QString& id, const QString& filename,
00356                       const QString& ra, const QString& dec, double angSize, double rotation,
00357                       double minRes=2.5, double maxBright=14, bool visible=true);
00358 
00361     void removeSkyImage(const QString& id);
00362 
00367     void loadSound(const QString& filename, const QString& id);
00368 
00371     void playSound(const QString& id);
00372 
00376     void pauseSound(const QString& id);
00377 
00382     void stopSound(const QString& id);
00383 
00387     void dropSound(const QString& id);
00388 
00391     int getScreenWidth();
00394     int getScreenHeight();
00395 
00398     double getScriptRate();
00403     void setScriptRate(double r);
00404 
00407     void setSelectedObjectInfo(const QString& level);
00408 
00410     void exit();
00411 
00413     void quitStellarium();
00414 
00417     void debug(const QString& s);
00418 
00421     QString getAppLanguage();
00422 
00425     void setAppLanguage(QString langCode);
00426 
00429     QString getSkyLanguage();
00430 
00433     void setSkyLanguage(QString langCode);
00434 
00438     double jdFromDateString(const QString& dt, const QString& spec);
00439     
00440 signals:
00441     void requestLoadSkyImage(const QString& id, const QString& filename,
00442                              double c1, double c2,
00443                              double c3, double c4,
00444                              double c5, double c6,
00445                              double c7, double c8,
00446                              double minRes, double maxBright, bool visible);
00447 
00448     void requestRemoveSkyImage(const QString& id);
00449 
00450     void requestLoadSound(const QString& filename, const QString& id);
00451     void requestPlaySound(const QString& id);
00452     void requestPauseSound(const QString& id);
00453     void requestStopSound(const QString& id);
00454     void requestDropSound(const QString& id);
00455     void requestSetNightMode(bool b);
00456     void requestSetProjectionMode(QString id);
00457     void requestSetSkyCulture(QString id);
00458     void requestSetDiskViewport(bool b);
00459     void requestExit();
00460 };
00461 
00462 #endif // _STELMAINSCRIPTAPI_HPP_
00463