StelMainScriptAPI.hpp   StelMainScriptAPI.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELMAINSCRIPTAPI_HPP_ #ifndef _STELMAINSCRIPTAPI_HPP_
#define _STELMAINSCRIPTAPI_HPP_ #define _STELMAINSCRIPTAPI_HPP_
#include "ScriptSleeper.hpp"
#include <QObject> #include <QObject>
#include <QVariant> #include <QVariant>
#include <QStringList> #include <QStringList>
class QScriptEngine;
//! Provide script API for Stellarium global functions. Public slots in th is class //! Provide script API for Stellarium global functions. Public slots in th is class
//! may be used in Stellarium scripts, and are accessed as member function to the //! may be used in Stellarium scripts, and are accessed as member function to the
//! "core" scripting object. Module-specific functions, such as setting an d clearing //! "core" scripting object. Module-specific functions, such as setting an d clearing
//! of display flags (e.g. LandscapeMgr::setFlagAtmosphere) can be accessed directly //! of display flags (e.g. LandscapeMgr::setFlagAtmosphere) can be accessed directly
//! via the scripting object with the class name, e.g. by using the script ing command: //! via the scripting object with the class name, e.g. by using the script ing command:
//! LandscapeMgr.setFlagAtmosphere(true); //! LandscapeMgr.setFlagAtmosphere(true);
class StelMainScriptAPI : public QObject class StelMainScriptAPI : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(double JDay READ getJDay WRITE setJDay) Q_PROPERTY(double JDay READ getJDay WRITE setJDay)
Q_PROPERTY(double timeSpeed READ getTimeRate WRITE setTimeRate) Q_PROPERTY(double timeSpeed READ getTimeRate WRITE setTimeRate)
public: public:
StelMainScriptAPI(QObject *parent = 0); StelMainScriptAPI(QObject *parent = 0);
~StelMainScriptAPI(); ~StelMainScriptAPI();
ScriptSleeper& getScriptSleeper(void);
// These functions will be available in scripts // These functions will be available in scripts
public slots: public slots:
//! Set the current date in Julian Day //! Set the current date in Julian Day
//! @param JD the Julian Date //! @param JD the Julian Date
void setJDay(double JD); void setJDay(double JD);
//! Get the current date in Julian Day //! Get the current date in Julian Day
//! @return the Julian Date //! @return the Julian Date
double getJDay(void) const; double getJDay() const;
//! set the date in ISO format, e.g. "2008-03-24T13:21:01" //! set the date in ISO format, e.g. "2008-03-24T13:21:01"
//! @param dt the date string to use. Formats: //! @param dt the date string to use. Formats:
//! - ISO, e.g. "2008-03-24T13:21:01" //! - ISO, e.g. "2008-03-24T13:21:01"
//! - "now" (set sim time to real time) //! - "now" (set sim time to real time)
//! - relative, e.g. "+ 4 days", "-2 weeks". can use these //! - relative, e.g. "+ 4 days", "-2 weeks". can use these
//! units: seconds, minutes, hours, days, weeks, months, years. //! units: seconds, minutes, hours, days, weeks, months, years.
//! You may also append " sidereal" to use sidereal days and so on . //! You may also append " sidereal" to use sidereal days and so on .
//! You can also use "now" at the start. For example: //! You can also use "now" at the start. For example:
//! "now + 3 hours sidereal" //! "now + 3 hours sidereal"
skipping to change at line 90 skipping to change at line 88
QString getDate(const QString& spec="utc"); QString getDate(const QString& spec="utc");
//! Set time speed in JDay/sec //! Set time speed in JDay/sec
//! @param ts the new rate of passage of time as a multiple of real time. //! @param ts the new rate of passage of time as a multiple of real time.
//! For example if ts is 1, time will pass at the normal rate. If t s == 10 //! For example if ts is 1, time will pass at the normal rate. If t s == 10
//! then simulation time will pass at 10 times the normal rate. //! then simulation time will pass at 10 times the normal rate.
//! If ts is negative, simulation time will go backwards. //! If ts is negative, simulation time will go backwards.
void setTimeRate(double ts); void setTimeRate(double ts);
//! Get simulation time rate. //! Get simulation time rate.
//! @return time speed as a multiple of real time. //! @return time speed as a multiple of real time.
double getTimeRate(void) const; double getTimeRate() const;
//! Get the simulation time and rate state - is it "real time" //! Get the simulation time and rate state - is it "real time"
//! @return true if the time rate is normal, and the simulation time //! @return true if the time rate is normal, and the simulation time
//! is real time, else return false //! is real time, else return false
bool isRealTime(); bool isRealTime();
//! Set the simulation time to the current system time, and the time rate to 1 //! Set the simulation time to the current system time, and the time rate to 1
void setRealTime(); void setRealTime();
//! Pauses the script for t seconds
//! @param t the number of seconds to wait
void wait(double t);
//! Waits until a specified simulation date/time. This function
//! will take into account the rate (and direction) in which simulat
ion
//! time is passing. e.g. if a future date is specified and the
//! time is moving backwards, the function will return immediately.
//! If the time rate is 0, the function will not wait. This is to
//! prevent infinite wait time.
//! @param dt the date string to use
//! @param spec "local" or "utc"
void waitFor(const QString& dt, const QString& spec="utc");
//! Select an object by name //! Select an object by name
//! @param name the name of the object to select (english) //! @param name the name of the object to select (english)
//! If the name is "", any currently selected objects will be //! If the name is "", any currently selected objects will be
//! de-selected. //! de-selected.
//! @param pointer whether or not to have the selection pointer enab led //! @param pointer whether or not to have the selection pointer enab led
void selectObjectByName(const QString& name, bool pointer=false); void selectObjectByName(const QString& name, bool pointer=false);
//! Fetch a map with data about an object's position, magnitude and so on //! Fetch a map with data about an object's position, magnitude and so on
//! @param name is the English name of the object for which data wil l be //! @param name is the English name of the object for which data wil l be
//! returned. //! returned.
skipping to change at line 215 skipping to change at line 199
//! @param planet the English name of the new planet. //! @param planet the English name of the new planet.
//! If the planet name is not known (e.g. ""), the //! If the planet name is not known (e.g. ""), the
//! planet will not be set. //! planet will not be set.
void setObserverLocation(double longitude, double latitude, double a ltitude, double duration=1., const QString& name="", const QString& planet= ""); void setObserverLocation(double longitude, double latitude, double a ltitude, double duration=1., const QString& name="", const QString& planet= "");
//! Set the location by the name of the location. //! Set the location by the name of the location.
//! @param id the location ID as it would be found in the database //! @param id the location ID as it would be found in the database
//! of locations - do a search in the Location window to see what //! of locations - do a search in the Location window to see what
//! where is. e.g. "York, UnitedKingdom". //! where is. e.g. "York, UnitedKingdom".
//! @param duration the number of seconds to take to move location. //! @param duration the number of seconds to take to move location.
void setObserverLocation(const QString id, double duration=1.); void setObserverLocation(const QString id, float duration=1.);
//! Get the ID of the current observer location. //! Get the ID of the current observer location.
//! @param duration the number of seconds to take to move location.
QString getObserverLocation(); QString getObserverLocation();
//! Save a screenshot. //! Save a screenshot.
//! @param prefix the prefix for the file name to use //! @param prefix the prefix for the file name to use
//! @param dir the path of the directory to save the screenshot in. If //! @param dir the path of the directory to save the screenshot in. If
//! none is specified, the default screenshot directory will be used . //! none is specified, the default screenshot directory will be used .
//! @param invert whether colors have to be inverted in the output i mage //! @param invert whether colors have to be inverted in the output i mage
void screenshot(const QString& prefix, bool invert=false, const QStr ing& dir=""); void screenshot(const QString& prefix, bool invert=false, const QStr ing& dir="");
//! Show or hide the GUI (toolbars). Note this only applies to GUI plugins which //! Show or hide the GUI (toolbars). Note this only applies to GUI plugins which
//! provide the public slot "setGuiVisible(bool)". //! provide the public slot "setGuiVisible(bool)".
//! @param b if true, show the GUI, if false, hide the GUI. //! @param b if true, show the GUI, if false, hide the GUI.
void setGuiVisible(bool b); void setGuiVisible(bool b);
//! Set the minimum frames per second. Usually this minimum will //! Set the minimum frames per second. Usually this minimum will
//! be switched to after there are no user events for some seconds //! be switched to after there are no user events for some seconds
//! to save power. However, if can be useful to set this to a high //! to save power. However, if can be useful to set this to a high
//! value to improve playing smoothness in scripts. //! value to improve playing smoothness in scripts.
//! @param m the new minimum fps setting. //! @param m the new minimum fps setting.
void setMinFps(float m); void setMinFps(float m);
//! Get the current minimum frames per second. //! Get the current minimum frames per second.
//! @return The current minimum frames per secon setting. //! @return The current minimum frames per secon setting.
float getMinFps(); float getMinFps();
//! Set the maximum frames per second. //! Set the maximum frames per second.
//! @param m the new maximum fps setting. //! @param m the new maximum fps setting.
void setMaxFps(float m); void setMaxFps(float m);
//! Get the current maximum frames per second. //! Get the current maximum frames per second.
//! @return The current maximum frames per secon setting. //! @return The current maximum frames per secon setting.
float getMaxFps(); float getMaxFps();
//! Get the mount mode as a string //! Get the mount mode as a string
//! @return "equatorial" or "azimuthal" //! @return "equatorial" or "azimuthal"
QString getMountMode(); QString getMountMode();
//! Set the mount mode //! Set the mount mode
//! @param mode should be "equatorial" or "azimuthal" //! @param mode should be "equatorial" or "azimuthal"
void setMountMode(const QString& mode); void setMountMode(const QString& mode);
//! Get the current status of Night Mode //! Get the current status of Night Mode
skipping to change at line 296 skipping to change at line 279
//! Get the status of the disk viewport //! Get the status of the disk viewport
//! @return true if the disk view port is currently enabled //! @return true if the disk view port is currently enabled
bool getDiskViewport(); bool getDiskViewport();
//! Set the disk viewport //! Set the disk viewport
//! @param b if true, sets the disk viewport on, else sets it off //! @param b if true, sets the disk viewport on, else sets it off
void setDiskViewport(bool b); void setDiskViewport(bool b);
//! Get a list of Sky Culture IDs //! Get a list of Sky Culture IDs
//! @return a list of valid sky culture IDs //! @return a list of valid sky culture IDs
QStringList getAllSkyCultureIDs(void); QStringList getAllSkyCultureIDs();
//! Find out the current sky culture //! Find out the current sky culture
//! @return the ID of the current sky culture (i.e. the name of the directory in //! @return the ID of the current sky culture (i.e. the name of the directory in
//! which the curret sky cultures files are found, e.g. "western") //! which the curret sky cultures files are found, e.g. "western")
QString getSkyCulture(); QString getSkyCulture();
//! Set the current sky culture //! Set the current sky culture
//! @param id the ID of the sky culture to set, e.g. western or inui t etc. //! @param id the ID of the sky culture to set, e.g. western or inui t etc.
void setSkyCulture(const QString& id); void setSkyCulture(const QString& id);
skipping to change at line 334 skipping to change at line 317
//! @param ra1 The right ascension of the second corner of the image in degrees //! @param ra1 The right ascension of the second corner of the image in degrees
//! @param dec1 The declenation of the second corner of the image in degrees //! @param dec1 The declenation of the second corner of the image in degrees
//! @param ra2 The right ascension of the third corner of the image in degrees //! @param ra2 The right ascension of the third corner of the image in degrees
//! @param dec2 The declenation of the third corner of the image in degrees //! @param dec2 The declenation of the third corner of the image in degrees
//! @param ra3 The right ascension of the fourth corner of the image in degrees //! @param ra3 The right ascension of the fourth corner of the image in degrees
//! @param dec3 The declenation of the fourth corner of the image in degrees //! @param dec3 The declenation of the fourth corner of the image in degrees
//! @param minRes The minimum resolution setting for the image //! @param minRes The minimum resolution setting for the image
//! @param maxBright The maximum brightness setting for the image //! @param maxBright The maximum brightness setting for the image
//! @param visible The initial visibility of the image //! @param visible The initial visibility of the image
void loadSkyImage(const QString& id, const QString& filename, void loadSkyImage(const QString& id, const QString& filename,
double ra0, double dec0, double ra0, double dec0,
double ra1, double dec1, double ra1, double dec1,
double ra2, double dec2, double ra2, double dec2,
double ra3, double dec3, double ra3, double dec3,
double minRes=2.5, double maxBright=14, bool visib double minRes=2.5, double maxBrigh
le=true); t=14, bool visible=true);
//! Convenience function which allows the user to provide RA and DEC angles //! Convenience function which allows the user to provide RA and DEC angles
//! as strings (e.g. "12d 14m 8s" or "5h 26m 8s" - formats accepted by //! as strings (e.g. "12d 14m 8s" or "5h 26m 8s" - formats accepted by
//! StelUtils::getDecAngle()). //! StelUtils::getDecAngle()).
void loadSkyImage(const QString& id, const QString& filename, void loadSkyImage(const QString& id, const QString& filename,
const QString& ra0, const QString& dec0, const QString& ra0, const QString&
const QString& ra1, const QString& dec1, dec0,
const QString& ra2, const QString& dec2, const QString& ra1, const QString&
const QString& ra3, const QString& dec3, dec1,
double minRes=2.5, double maxBright=14, bool visib const QString& ra2, const QString&
le=true); dec2,
const QString& ra3, const QString&
dec3,
double minRes=2.5, double maxBrigh
t=14, bool visible=true);
//! Convenience function which allows loading of a sky image based o n a //! Convenience function which allows loading of a sky image based o n a
//! central coordinate, angular size and rotation. //! central coordinate, angular size and rotation.
//! @param id a string ID to be used when referring to this //! @param id a string ID to be used when referring to this
//! image (e.g. when changing the displayed status or deleting it. //! image (e.g. when changing the displayed status or deleting it.
//! @param filename the file name of the image. If a relative //! @param filename the file name of the image. If a relative
//! path is specified, "scripts/" will be prefixed before the //! path is specified, "scripts/" will be prefixed before the
//! image is searched for using StelFileMgr. //! image is searched for using StelFileMgr.
//! @param ra The right ascension of the center of the image in J200 0 frame degrees //! @param ra The right ascension of the center of the image in J200 0 frame degrees
//! @param dec The declenation of the center of the image in J2000 f rame degrees //! @param dec The declenation of the center of the image in J2000 f rame degrees
//! @param angSize The angular size of the image in arc minutes //! @param angSize The angular size of the image in arc minutes
//! @param rotation The clockwise rotation angle of the image in deg rees //! @param rotation The clockwise rotation angle of the image in deg rees
//! @param minRes The minimum resolution setting for the image //! @param minRes The minimum resolution setting for the image
//! @param maxBright The maximum brightness setting for the image //! @param maxBright The maximum brightness setting for the image
//! @param visible The initial visibility of the image //! @param visible The initial visibility of the image
void loadSkyImage(const QString& id, const QString& filename, void loadSkyImage(const QString& id, const QString& filename,
double ra, double dec, double angSize, double rota double ra, double dec, double angS
tion, ize, double rotation,
double minRes=2.5, double maxBright=14, bool visib double minRes=2.5, double maxBrigh
le=true); t=14, bool visible=true);
//! Convenience function which allows loading of a sky image based o n a //! Convenience function which allows loading of a sky image based o n a
//! central coordinate, angular size and rotation. Parameters are t he same //! central coordinate, angular size and rotation. Parameters are t he same
//! as the version of this function which takes double values for th e //! as the version of this function which takes double values for th e
//! ra and dec, except here text expressions of angles may be used. //! ra and dec, except here text expressions of angles may be used.
void loadSkyImage(const QString& id, const QString& filename, void loadSkyImage(const QString& id, const QString& filename,
const QString& ra, const QString& dec, double angS const QString& ra, const QString&
ize, double rotation, dec, double angSize, double rotation,
double minRes=2.5, double maxBright=14, bool visib double minRes=2.5, double maxBrigh
le=true); t=14, bool visible=true);
//! Remove a SkyImage. //! Remove a SkyImage.
//! @param id the ID of the image to remove. //! @param id the ID of the image to remove.
void removeSkyImage(const QString& id); void removeSkyImage(const QString& id);
//! Load a sound from a file. //! Load a sound from a file.
//! @param filename the name of the file to load. //! @param filename the name of the file to load.
//! @param id the identifier which will be used to refer to the soun d //! @param id the identifier which will be used to refer to the soun d
//! when calling playSound, pauseSound, stopSound and dropSound. //! when calling playSound, pauseSound, stopSound and dropSound.
void loadSound(const QString& filename, const QString& id); void loadSound(const QString& filename, const QString& id);
skipping to change at line 408 skipping to change at line 391
//! @param id the identifier used when loadSound was called //! @param id the identifier used when loadSound was called
void stopSound(const QString& id); void stopSound(const QString& id);
//! Drop a sound from memory. You should do this before the end //! Drop a sound from memory. You should do this before the end
//! of your script. //! of your script.
//! @param id the identifier used when loadSound was called //! @param id the identifier used when loadSound was called
void dropSound(const QString& id); void dropSound(const QString& id);
//! Get the screen width in pixels. //! Get the screen width in pixels.
//! @return The screen width in pixels //! @return The screen width in pixels
int getScreenWidth(void); int getScreenWidth();
//! Get the screen height in pixels. //! Get the screen height in pixels.
//! @return The screen height in pixels //! @return The screen height in pixels
int getScreenHeight(void); int getScreenHeight();
//! Get the script execution rate as a multiple of normal execution speed //! Get the script execution rate as a multiple of normal execution speed
//! @return the current script execution rate. //! @return the current script execution rate.
double getScriptRate(void); double getScriptRate();
//! Set the script execution rate as a multiple of normal execution speed //! Set the script execution rate as a multiple of normal execution speed
//! @param r the multiple of the normal script execution speed, i.e. //! @param r the multiple of the normal script execution speed, i.e.
//! if 5 is passed the script will execute 5 times faster than it wo uld //! if 5 is passed the script will execute 5 times faster than it wo uld
//! if the script rate was 1. //! if the script rate was 1.
void setScriptRate(double r); void setScriptRate(double r);
//! Set the amount of selected object information to display //! Set the amount of selected object information to display
//! @param level, can be "AllInfo", "ShortInfo", "None" //! @param level can be "AllInfo", "ShortInfo", "None"
void setSelectedObjectInfo(const QString& level); void setSelectedObjectInfo(const QString& level);
//! stop the script //! Stop the script
void exit(void); void exit();
//! Close Stellarium //! Close Stellarium
void quitStellarium(void); void quitStellarium();
//! print a debugging message to the console //! print a debugging message to the console
//! @param s the message to be displayed on the console. //! @param s the message to be displayed on the console.
void debug(const QString& s); void debug(const QString& s);
//! Get the current application language.
//! @return two letter language code, e.g. "en", or "de" and so on.
QString getAppLanguage();
//! Set the current application language.
//! @param langCode two letter language code, e.g. "en", or "de".
void setAppLanguage(QString langCode);
//! Get the current sky language.
//! @return two letter language code, e.g. "en", or "de" and so on.
QString getSkyLanguage();
//! Set the current sky language.
//! @param langCode two letter language code, e.g. "en", or "de".
void setSkyLanguage(QString langCode);
//! For use in setDate and waitFor
//! For parameter descriptions see setDate().
//! @returns Julian day.
double jdFromDateString(const QString& dt, const QString& spec);
signals: signals:
void requestLoadSkyImage(const QString& id, const QString& filename, void requestLoadSkyImage(const QString& id, const QString& filename,
double c1, double c2, double c1, double c
double c3, double c4, 2,
double c5, double c6, double c3, double c
double c7, double c8, 4,
double minRes, double maxBright, bool visib double c5, double c
le); 6,
double c7, double c
8,
double minRes, doub
le maxBright, bool visible);
void requestRemoveSkyImage(const QString& id); void requestRemoveSkyImage(const QString& id);
void requestLoadSound(const QString& filename, const QString& id); void requestLoadSound(const QString& filename, const QString& id);
void requestPlaySound(const QString& id); void requestPlaySound(const QString& id);
void requestPauseSound(const QString& id); void requestPauseSound(const QString& id);
void requestStopSound(const QString& id); void requestStopSound(const QString& id);
void requestDropSound(const QString& id); void requestDropSound(const QString& id);
void requestSetNightMode(bool b); void requestSetNightMode(bool b);
void requestSetProjectionMode(QString id); void requestSetProjectionMode(QString id);
void requestSetSkyCulture(QString id); void requestSetSkyCulture(QString id);
void requestSetDiskViewport(bool b); void requestSetDiskViewport(bool b);
void requestExit(); void requestExit();
private:
//! For use in setDate and waitFor
//! For parameter descriptions see setDate().
//! @returns Julian day.
double jdFromDateString(const QString& dt, const QString& spec);
ScriptSleeper scriptSleeper;
}; };
#endif // _STELMAINSCRIPTAPI_HPP_ #endif // _STELMAINSCRIPTAPI_HPP_
 End of changes. 23 change blocks. 
82 lines changed or deleted 86 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/