Stellarium 0.90.0
StelModule.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2006 Fabien Chereau
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 _STELMODULE_HPP_
21 #define _STELMODULE_HPP_
22 
23 #include <QString>
24 #include <QObject>
25 
26 // Predeclaration
27 class StelCore;
28 class QSettings;
29 
49 class StelModule : public QObject
50 {
51  Q_OBJECT
52  // Do not add Q_OBJECT here!!
53  // This make this class compiled by the Qt moc compiler and for some unknown reasons makes it impossible to dynamically
54  // load plugins on windows.
55  Q_ENUMS(StelModuleSelectAction)
56  Q_ENUMS(StelModuleActionName)
57 public:
58  StelModule();
59 
60  virtual ~StelModule() {;}
61 
64  virtual void init() = 0;
65 
68  virtual void deinit() {;}
69 
72  virtual void draw(StelCore* core) {Q_UNUSED(core);}
73 
76  virtual void update(double deltaTime) = 0;
77 
79  virtual QString getModuleVersion() const;
80 
82  virtual QString getAuthorName() const {return "Stellarium's Team";}
83 
85  virtual QString getAuthorEmail() const {return "http://www.stellarium.org";}
86 
89  virtual void handleMouseClicks(class QMouseEvent*) {;}
90 
93  virtual void handleMouseWheel(class QWheelEvent*) {;}
94 
97  virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b) {Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(b); return false;}
98 
102  virtual void handleKeys(class QKeyEvent* e) {Q_UNUSED(e);}
103 
108  virtual bool handlePinch(qreal scale, bool started) {Q_UNUSED(scale); Q_UNUSED(started); return false;}
109 
112  {
116  };
117 #if QT_VERSION >= 0x050500
118  Q_ENUM(StelModuleSelectAction)
119 #endif
122  {
128  };
129 #if QT_VERSION >= 0x050500
130  Q_ENUM(StelModuleActionName)
131 #endif
132  virtual double getCallOrder(StelModuleActionName actionName) const {Q_UNUSED(actionName); return 0;}
138 
143  virtual bool configureGui(bool show=true) {Q_UNUSED(show); return false;}
144 
145 protected:
146 
155  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
156  QObject* target, const char* slot,
157  const QString& shortcut="", const QString& altShortcut="");
158 
166  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
167  const char* slot,
168  const QString& shortcut="", const QString& altShortcut="") {
169  return addAction(id, groupId, text, this, slot, shortcut, altShortcut);
170  }
171 };
172 
173 Q_DECLARE_METATYPE(StelModule::StelModuleSelectAction)
174 
175 #endif // _STELMODULE_HPP_
virtual QString getAuthorName() const
Get the name of the module author.
Definition: StelModule.hpp:82
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
Definition: StelModule.hpp:68
class StelAction * addAction(const QString &id, const QString &groupId, const QString &text, const char *slot, const QString &shortcut="", const QString &altShortcut="")
convenience methods to add an action (call to own slot) to the StelActionMgr object.
Definition: StelModule.hpp:166
Add the StelObject to the current list of selected ones.
Definition: StelModule.hpp:113
virtual QString getModuleVersion() const
Get the version of the module, default is stellarium main version.
virtual bool configureGui(bool show=true)
Detect or show the configuration GUI elements for the module.
Definition: StelModule.hpp:143
Action associated to the handleKeys() method.
Definition: StelModule.hpp:127
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
virtual bool handlePinch(qreal scale, bool started)
Handle pinch gesture events.
Definition: StelModule.hpp:108
virtual void handleKeys(class QKeyEvent *e)
Handle key events.
Definition: StelModule.hpp:102
virtual void handleMouseClicks(class QMouseEvent *)
Handle mouse clicks.
Definition: StelModule.hpp:89
Action associated to the handleMouseMoves() method.
Definition: StelModule.hpp:126
Wrapper around an argumentless QObject slot or a bool Q_PROPERTY with WRITE method, allowing the slot to be called/property to be toggled using this action object.
virtual void update(double deltaTime)=0
Update the module with respect to the time.
virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b)
Handle mouse moves.
Definition: StelModule.hpp:97
Subtract the StelObject from the current list of selected ones.
Definition: StelModule.hpp:115
Action associated to the draw() method.
Definition: StelModule.hpp:123
virtual void handleMouseWheel(class QWheelEvent *)
Handle mouse wheel.
Definition: StelModule.hpp:93
virtual QString getAuthorEmail() const
Get the email adress of the module author.
Definition: StelModule.hpp:85
virtual void init()=0
Initialize itself.
virtual double getCallOrder(StelModuleActionName actionName) const
Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations.
Definition: StelModule.hpp:137
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
Action associated to the handleMouseClicks() method.
Definition: StelModule.hpp:125
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:111
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
Definition: StelModule.hpp:72
Set the StelObject as the new list of selected ones.
Definition: StelModule.hpp:114
Action associated to the update() method.
Definition: StelModule.hpp:124
class StelAction * addAction(const QString &id, const QString &groupId, const QString &text, QObject *target, const char *slot, const QString &shortcut="", const QString &altShortcut="")
convenience methods to add an action (call to slot) to the StelActionMgr object.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49