StelApp.hpp   StelApp.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 _STELAPP_HPP_ #ifndef _STELAPP_HPP_
#define _STELAPP_HPP_ #define _STELAPP_HPP_
#include "fixx11h.h"
#include <QString> #include <QString>
#include <QVariant>
#include <QObject> #include <QObject>
#include <QFile> #include <QFile>
// Predeclaration of some classes // Predeclaration of some classes
class StelCore; class StelCore;
class SkyLocalizer; class SkyLocalizer;
class StelTextureMgr; class StelTextureMgr;
class StelObjectMgr; class StelObjectMgr;
class StelFontMgr;
class StelLocaleMgr; class StelLocaleMgr;
class StelModuleMgr; class StelModuleMgr;
class StelSkyCultureMgr; class StelSkyCultureMgr;
class StelFileMgr;
class QStringList; class QStringList;
class StelLoadingBar; class StelLoadingBar;
class QSettings; class QSettings;
class QNetworkAccessManager; class QNetworkAccessManager;
class StelStyle; class StelStyle;
class QTime; class QTime;
class StelLocationMgr; class StelLocationMgr;
class StelSkyImageMgr; class StelSkyLayerMgr;
class StelScriptMgr;
class StelDownloadMgr;
class StelAudioMgr; class StelAudioMgr;
class QNetworkReply; class QNetworkReply;
class StelGuiBase;
//! @class StelApp //! @class StelApp
//! Singleton main Stellarium application class. //! Singleton main Stellarium application class.
//! This is the central class of Stellarium. Only one singleton instance o f //! This is the central class of Stellarium. Only one singleton instance o f
//! this class is created and can be accessed from anywhere else. This cla ss //! this class is created and can be accessed from anywhere else. This cla ss
//! is the access point to several "Manager" class which provide applicatio n-wide //! is the access point to several "Manager" class which provide applicatio n-wide
//! services for managment of font, textures, localization, sky culture, an d in //! services for managment of font, textures, localization, sky culture, an d in
//! theory all other services used by the other part of the program. //! theory all other services used by the other part of the program.
//! //!
//! The StelApp class is also the one managing the StelModule in a generic manner //! The StelApp class is also the one managing the StelModule in a generic manner
//! by calling their update, drawing and other methods when needed. //! by calling their update, drawing and other methods when needed.
//! @author Fabien Chereau //! @author Fabien Chereau
class StelApp : public QObject class StelApp : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
friend class StelAppGraphicsScene; friend class StelAppGraphicsWidget;
//! Create and initialize the main Stellarium application. //! Create and initialize the main Stellarium application.
//! @param argc The number of command line parameters //! @param argc The number of command line parameters
//! @param argv an array of char* command line arguments //! @param argv an array of char* command line arguments
//! @param parent the QObject parent //! @param parent the QObject parent
//! The configFile will be search for in the search path by the Stel FileMgr, //! The configFile will be search for in the search path by the Stel FileMgr,
//! it is therefor possible to specify either just a file name or pa th within the //! it is therefor possible to specify either just a file name or pa th within the
//! search path, or use a full path or even a relative path to an ex isting file //! search path, or use a full path or even a relative path to an ex isting file
StelApp(int argc, char** argv, QObject* parent=NULL); StelApp(QObject* parent=NULL);
//! Deinitialize and destroy the main Stellarium application. //! Deinitialize and destroy the main Stellarium application.
virtual ~StelApp(); virtual ~StelApp();
//! Initialize core and default modules. //! Initialize core and default modules.
void init(); void init(QSettings* conf);
//! Load and initialize external modules (plugins) //! Load and initialize external modules (plugins)
void initPlugIns(); void initPlugIns();
//! Get the StelApp singleton instance. //! Get the StelApp singleton instance.
//! @return the StelApp singleton instance //! @return the StelApp singleton instance
static StelApp& getInstance() {Q_ASSERT(singleton); return *singleto n;} static StelApp& getInstance() {Q_ASSERT(singleton); return *singleto n;}
//! Get the module manager to use for accessing any module loaded in the application. //! Get the module manager to use for accessing any module loaded in the application.
//! @return the module manager. //! @return the module manager.
StelModuleMgr& getModuleMgr() {return *moduleMgr;} StelModuleMgr& getModuleMgr() {return *moduleMgr;}
//! Get the locale manager to use for i18n & date/time localization. //! Get the locale manager to use for i18n & date/time localization.
//! @return the font manager to use for loading fonts. //! @return the font manager to use for loading fonts.
StelLocaleMgr& getLocaleMgr() {return *localeMgr;} StelLocaleMgr& getLocaleMgr() {return *localeMgr;}
//! Get the font manager to use for loading fonts.
//! @return the font manager to use for loading fonts.
StelFontMgr& getFontManager() {return *fontManager;}
//! Get the sky cultures manager. //! Get the sky cultures manager.
//! @return the sky cultures manager //! @return the sky cultures manager
StelSkyCultureMgr& getSkyCultureMgr() {return *skyCultureMgr;} StelSkyCultureMgr& getSkyCultureMgr() {return *skyCultureMgr;}
//! Get the texture manager to use for loading textures. //! Get the texture manager to use for loading textures.
//! @return the texture manager to use for loading textures. //! @return the texture manager to use for loading textures.
StelTextureMgr& getTextureManager() {return *textureMgr;} StelTextureMgr& getTextureManager() {return *textureMgr;}
//! Get the Location manager to use for managing stored locations //! Get the Location manager to use for managing stored locations
//! @return the Location manager to use for managing stored location s //! @return the Location manager to use for managing stored location s
StelLocationMgr& getLocationMgr() {return *planetLocationMgr;} StelLocationMgr& getLocationMgr() {return *planetLocationMgr;}
//! Get the StelObject manager to use for querying from all stellari um objects. //! Get the StelObject manager to use for querying from all stellari um objects.
//! @return the StelObject manager to use for querying from all stel larium objects . //! @return the StelObject manager to use for querying from all stel larium objects .
StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;} StelObjectMgr& getStelObjectMgr() {return *stelObjectMgr;}
//! Get the StelObject manager to use for querying from all stellari um objects. //! Get the StelObject manager to use for querying from all stellari um objects.
//! @return the StelObject manager to use for querying from all stel larium objects . //! @return the StelObject manager to use for querying from all stel larium objects .
StelSkyImageMgr& getSkyImageMgr() {return *skyImageMgr;} StelSkyLayerMgr& getSkyImageMgr() {return *skyImageMgr;}
//! Get the StelFileMgr for performing file operations.
//! @return the StelFileMgr manager to use for performing file opera
tions
StelFileMgr& getFileMgr() {return *stelFileMgr;}
//! Get the audio manager
StelAudioMgr* getStelAudioMgr() {return audioMgr;} StelAudioMgr* getStelAudioMgr() {return audioMgr;}
//! Get the script manager
StelScriptMgr& getScriptMgr() {return *scriptMgr;}
//! Get the download manager
StelDownloadMgr& getDownloadMgr() {return *downloadMgr;}
//! Get the core of the program. //! Get the core of the program.
//! It is the one which provide the projection, navigation and tone converter. //! It is the one which provide the projection, navigation and tone converter.
//! @return the StelCore instance of the program //! @return the StelCore instance of the program
StelCore* getCore() {return core;} StelCore* getCore() {return core;}
//! Get the main loading bar used by modules for displaying loading informations. //! Get the main loading bar used by modules for displaying loading informations.
//! @return the main StelLoadingBar instance of the program. //! @return the main StelLoadingBar instance of the program.
StelLoadingBar* getStelLoadingBar() {return loadingBar;} StelLoadingBar* getStelLoadingBar() {return loadingBar;}
//! Get the common instance of QNetworkAccessManager used in stellar ium //! Get the common instance of QNetworkAccessManager used in stellar ium
QNetworkAccessManager* getNetworkAccessManager() {return networkAcce ssManager;} QNetworkAccessManager* getNetworkAccessManager() {return networkAcce ssManager;}
//! Update translations, font for GUI and sky everywhere in the prog ram. //! Update translations, font for GUI and sky everywhere in the prog ram.
void updateI18n(); void updateI18n();
//! Update and reload sky culture informations everywhere in the pro gram. //! Update and reload sky culture informations everywhere in the pro gram.
void updateSkyCulture(); void updateSkyCulture();
//! Retrieve the full path of the current configuration file.
//! @return the full path of the configuration file
const QString& getConfigFilePath() { return configFile; }
//! Return the main configuration options //! Return the main configuration options
QSettings* getSettings() {return confSettings;} QSettings* getSettings() {return confSettings;}
//! Return the currently used style //! Return the currently used style
const StelStyle* getCurrentStelStyle() {return currentStelStyle;} const StelStyle* getCurrentStelStyle() {return currentStelStyle;}
//! Handler for qDebug() and friends. Writes message to log file at //! Update all object according to the deltaTime in seconds.
//! $USERDIR/log.txt and echoes to stderr. Do not call this function void update(double deltaTime);
;
//! it's only for use by qInstallMsgHandler. Use writeLog(QString) //! Draw all registered StelModule in the order defined by the order
//! instead, but preferably qDebug(). lists.
static void debugLogHandler(QtMsgType, const char*); //! @return the max squared distance in pixels that any object has t
ravelled since the last update.
void draw();
//! Iterate through the drawing sequence.
//! This allow us to split the slow drawing operation into small par
ts,
//! we can then decide to pause the painting for this frame and used
the cached image instead.
//! @return true if we should continue drawing (by calling the metho
d again)
bool drawPartial();
//! Call this when the size of the GL window has changed.
void glWindowHasBeenResized(float x, float y, float w, float h);
//! Get the GUI instance implementing the abstract GUI interface.
StelGuiBase* getGui() const {return stelGui;}
//! Tell the StelApp instance which GUI si currently being used.
//! The caller is responsible for destroying the GUI.
void setGui(StelGuiBase* b) {stelGui=b;}
//! Make sure that the GL context of the main window is current and
valid.
static void makeMainGLContextCurrent();
//! Return a copy of text of the log file. static void initStatic();
QString getLog() { return log; }
//! Get the file name of the startup script //! Get flag for using opengl shaders
QString getStartupScript() const {return startupScript;} bool getUseGLShaders() const {return useGLShaders;}
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Scriptable methods // Scriptable methods
public slots: public slots:
//! Return the full name of stellarium, i.e. "Stellarium 0.9.0".
static QString getApplicationName();
//! Return the version of stellarium, i.e. "0.9.0".
static QString getApplicationVersion();
//! Set flag for activating night vision mode. //! Set flag for activating night vision mode.
void setVisionModeNight(bool); void setVisionModeNight(bool);
//! Get flag for activating night vision mode. //! Get flag for activating night vision mode.
bool getVisionModeNight() const {return flagNightVision;} bool getVisionModeNight() const {return flagNightVision;}
//! Set the minimum frames per second. Usually this minimum will
//! 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
//! value to improve playing smoothness in scripts.
//! @param m the new minimum fps setting.
void setMinFps(float m) {minfps=m; emit(minFpsChanged());}
//! Get the current minimum frames per second.
float getMinFps() {return minfps;}
//! Set the maximum frames per second.
//! @param m the new maximum fps setting.
void setMaxFps(float m) {maxfps = m;}
//! Get the current maximum frames per second.
float getMaxFps() {return maxfps;}
//! Get the current number of frame per second. //! Get the current number of frame per second.
//! @return the FPS averaged on the last second //! @return the FPS averaged on the last second
float getFps() const {return fps;} float getFps() const {return fps;}
//! Return the time since when stellarium is running in second. //! Return the time since when stellarium is running in second.
static double getTotalRunTime(); static double getTotalRunTime();
//! Report that a download occured. This is used for statistics purp oses. //! Report that a download occured. This is used for statistics purp oses.
//! Connect this slot to QNetworkAccessManager::finished() slot to o btain statistics at the end of the program. //! Connect this slot to QNetworkAccessManager::finished() slot to o btain statistics at the end of the program.
void reportFileDownloadFinished(QNetworkReply* reply); void reportFileDownloadFinished(QNetworkReply* reply);
signals:
void minFpsChanged();
private: private:
//! Update all object according to the deltaTime in seconds.
void update(double deltaTime);
//! Draw all registered StelModule in the order defined by the order
lists.
//! @return the max squared distance in pixels that any object has t
ravelled since the last update.
void draw();
//! Handle mouse clics. //! Handle mouse clics.
void handleClick(class QMouseEvent* event); void handleClick(class QMouseEvent* event);
//! Handle mouse wheel. //! Handle mouse wheel.
void handleWheel(class QWheelEvent* event); void handleWheel(class QWheelEvent* event);
//! Handle mouse move. //! Handle mouse move.
void handleMove(int x, int y, Qt::MouseButtons b); void handleMove(int x, int y, Qt::MouseButtons b);
//! Handle key press and release. //! Handle key press and release.
void handleKeys(class QKeyEvent* event); void handleKeys(class QKeyEvent* event);
//! Call this when the size of the GL window has changed.
void glWindowHasBeenResized(int w, int h);
//! Set the colorscheme for all the modules //! Set the colorscheme for all the modules
void setColorScheme(const QString& section); void setColorScheme(const QString& section);
//! Sets the name of the configuration file.
//! It is possible to set the configuration by passing either a full
path
//! a relative path of an existing file, or path segment which will
be appended
//! to the serach path. The configuration file must be writable, or
there will
//! be trouble!
//! @param configName the name or full path of the configuration fil
e
void setConfigFile(const QString& configName, bool restoreDefaults=f
alse);
//! Copies the default configuration file.
//! This function copies the default_config.ini file to config.ini (
or other
//! name specified on the command line located in the user data dire
ctory.
void copyDefaultConfigFile();
//! Somewhere to save the command line arguments
QStringList* argList;
//! Check if a QStringList has a CLI-style option in it (before the
first --).
//! @param args a list of strings, think argv
//! @param shortOpt a short-form option string, e.g, "-h"
//! @param longOpt a long-form option string, e.g. "--help"
//! @return true if the option exists in args before any element whi
ch is "--"
bool argsGetOption(QStringList* args, QString shortOpt, QString long
Opt);
//! Retrieve the argument to an option from a QStringList.
//! Given a list of strings, this function will extract the argument
of
//! type T to an option, where the option in an element which matche
s
//! either the short or long forms, and the argument to that option
//! is the following element in the list, e.g. ("--option", "arg").
//! It is also possible to extract argument to options which are
//! part of the option element, separated by the "=" character, e.g.
//! ( "--option=arg" ).
//! Type conversion is done using the QTextStream class, and as such
//! possible types which this template function may use are restrict
ed
//! to those where there is a value operator<<() defined in the
//! QTextStream class for that type.
//! The argument list is only processed as far as the first value "-
-".
//! If an argument "--" is to be retrieved, it must be apecified usi
ng
//! the "--option=--" form.
//! @param args a list of strings, think argv.
//! @param shortOpt the short form of the option, e.g. "-n".
//! @param longOpt the long form of the option, e.g. "--number".
//! @param defaultValue the default value to return if the option wa
s
//! not found in args.
//! @exception runtime_error("no_optarg") the expected argument to t
he
//! option was not found.
//! @exception runtime_error("optarg_type") the expected argument to
//! the option could not be converted.
//! @return The value of the argument to the specified option which
//! occurs before the first element with the value "--". If the opt
ion
//! is not found, defaultValue is returned.
template<class T>
T argsGetOptionWithArg(QStringList* args, QString sh
ortOpt, QString longOpt, T defaultValue);
//! Check if a QStringList has a yes/no CLI-style option in it, and
//! find out the argument to that parameter.
//! e.g. option --use-foo can have parameter "yes" or "no"
//! It is also possible for the argument to take values, "1", "0";
//! "true", "false";
//! @param args a list of strings, think argv
//! @param shortOpt a short-form option string, e.g, "-h"
//! @param longOpt a long-form option string, e.g. "--help"
//! @param defaultValue the default value to return if the option wa
s
//! not found in args.
//! @exception runtime_error("no_optarg") the expected argument to t
he
//! option was not found. The longOpt value is appended in parenthes
is.
//! @exception runtime_error("optarg_type") the expected argument to
//! the option could not be converted. The longOpt value is appended
//! in parenthesis.
//! @return 1 if the argument to the specified opion is "yes", "y",
//! "true", "on" or 1; 0 if the argument to the specified opion is "
no",
//! "n", "false", "off" or 0; the value of the defaultValue paramete
r if
//! the option was not found in the argument list before an element
which
//! has the value "--".
int argsGetYesNoOption(QStringList* args, QString shortOpt, QString
longOpt, int defaultValue);
//! Processing of command line options which is to be done before co
nfig file is read.
//! This includes the chance to set the configuration file name. It
is to be done
//! in the sub-class of the StelApp, as the sub-class may want to ma
nage the
//! argument list, as is the case with the StelMainWindow version.
void parseCLIArgsPreConfig(void);
//! Processing of command line options which is to be done after the
config file is
//! read. This gives us the chance to over-ride settings which are
in the configuration
//! file.
void parseCLIArgsPostConfig();
//! Prepend system information to log file before any debugging outp
ut.
void setupLog();
//! Write the message plus a newline to the log file at $USERDIR/log
.txt.
//! @param msg message to write
static void writeLog(QString msg);
// The StelApp singleton // The StelApp singleton
static StelApp* singleton; static StelApp* singleton;
// The associated StelCore instance // The associated StelCore instance
StelCore* core; StelCore* core;
// Module manager for the application // Module manager for the application
StelModuleMgr* moduleMgr; StelModuleMgr* moduleMgr;
// Font manager for the application
StelFontMgr* fontManager;
// Locale manager for the application // Locale manager for the application
StelLocaleMgr* localeMgr; StelLocaleMgr* localeMgr;
// Sky cultures manager for the application // Sky cultures manager for the application
StelSkyCultureMgr* skyCultureMgr; StelSkyCultureMgr* skyCultureMgr;
// Textures manager for the application // Textures manager for the application
StelTextureMgr* textureMgr; StelTextureMgr* textureMgr;
// Manager for all the StelObjects of the program // Manager for all the StelObjects of the program
StelObjectMgr* stelObjectMgr; StelObjectMgr* stelObjectMgr;
// Manager for the list of observer locations on planets // Manager for the list of observer locations on planets
StelLocationMgr* planetLocationMgr; StelLocationMgr* planetLocationMgr;
//! Utility class for file operations, mainly locating files by name
StelFileMgr* stelFileMgr;
// Main network manager used for the program // Main network manager used for the program
QNetworkAccessManager* networkAccessManager; QNetworkAccessManager* networkAccessManager;
// The audio manager. Must execute in the main thread. // The audio manager. Must execute in the main thread.
StelAudioMgr* audioMgr; StelAudioMgr* audioMgr;
// The script manager based on Qt script engine
StelScriptMgr* scriptMgr;
// The main loading bar // The main loading bar
StelLoadingBar* loadingBar; StelLoadingBar* loadingBar;
// Currently used StelStyle // Currently used StelStyle
StelStyle* currentStelStyle; StelStyle* currentStelStyle;
// Download manager that uses networkAccessManager StelSkyLayerMgr* skyImageMgr;
StelDownloadMgr* downloadMgr;
StelSkyImageMgr* skyImageMgr; StelGuiBase* stelGui;
float fps; float fps;
//! The minimum desired frame rate in frame per second.
float minfps;
//! The maximum desired frame rate in frame per second.
float maxfps;
int frame; int frame;
double timefr, timeBase; // Used for fps counter double timefr, timeBase; // Used for fps counter
//! Define whether we are in night vision mode //! Define whether we are in night vision mode
bool flagNightVision; bool flagNightVision;
QString configFile; //! Define whether we use opengl shaders
QString startupScript; bool useGLShaders;
QSettings* confSettings; QSettings* confSettings;
// Define whether the StelApp instance has completed initialization // Define whether the StelApp instance has completed initialization
bool initialized; bool initialized;
static QTime* qtime; static QTime* qtime;
// Temporary variables used to store the last gl window resize // Temporary variables used to store the last gl window resize
// if the core was not yet initialized // if the core was not yet initialized
int saveProjW; int saveProjW;
skipping to change at line 418 skipping to change at line 279
//! Store the number of downloaded files for statistics. //! Store the number of downloaded files for statistics.
int nbDownloadedFiles; int nbDownloadedFiles;
//! Store the the summed size of all downloaded files in bytes. //! Store the the summed size of all downloaded files in bytes.
qint64 totalDownloadedSize; qint64 totalDownloadedSize;
//! Store the number of downloaded files read from the cache for sta tistics. //! Store the number of downloaded files read from the cache for sta tistics.
int nbUsedCache; int nbUsedCache;
//! Store the the summed size of all downloaded files read from the cache in bytes. //! Store the the summed size of all downloaded files read from the cache in bytes.
qint64 totalUsedCacheSize; qint64 totalUsedCacheSize;
static QFile logFile; //! The state of the drawing sequence
static QString log; int drawState;
}; };
#endif // _STELAPP_HPP_ #endif // _STELAPP_HPP_
 End of changes. 31 change blocks. 
218 lines changed or deleted 48 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/