Stellarium 0.13.3
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 public:
56  StelModule() {;}
57 
58  virtual ~StelModule() {;}
59 
62  virtual void init() = 0;
63 
66  virtual void deinit() {;}
67 
70  virtual void draw(StelCore* core) {Q_UNUSED(core);}
71 
74  virtual void update(double deltaTime) = 0;
75 
77  virtual QString getModuleVersion() const;
78 
80  virtual QString getAuthorName() const {return "Stellarium's Team";}
81 
83  virtual QString getAuthorEmail() const {return "http://www.stellarium.org";}
84 
87  virtual void handleMouseClicks(class QMouseEvent*) {;}
88 
91  virtual void handleMouseWheel(class QWheelEvent*) {;}
92 
95  virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b) {Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(b); return false;}
96 
100  virtual void handleKeys(class QKeyEvent* e) {Q_UNUSED(e);}
101 
106  virtual bool handlePinch(qreal scale, bool started) {Q_UNUSED(scale); Q_UNUSED(started); return false;}
107 
110  {
114  };
115 
118  {
124  };
125 
131  virtual double getCallOrder(StelModuleActionName actionName) const {Q_UNUSED(actionName); return 0;}
132 
137  virtual bool configureGui(bool show=true) {Q_UNUSED(show); return false;}
138 
139 protected:
140 
142  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
143  QObject* target, const char* slot,
144  const QString& shortcut="", const QString& altShortcut="");
145 
147  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
148  const char* slot,
149  const QString& shortcut="", const QString& altShortcut="") {
150  return addAction(id, groupId, text, this, slot, shortcut, altShortcut);
151  }
152 };
153 
154 Q_DECLARE_METATYPE(StelModule::StelModuleSelectAction)
155 
156 #endif // _STELMODULE_HPP_
virtual QString getAuthorName() const
Get the name of the module author.
Definition: StelModule.hpp:80
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
Definition: StelModule.hpp:66
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 to the StelActionMgr object.
Definition: StelModule.hpp:147
Add the StelObject to the current list of selected ones.
Definition: StelModule.hpp:111
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:137
Action associated to the handleKeys() method.
Definition: StelModule.hpp:123
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
virtual bool handlePinch(qreal scale, bool started)
Handle pinch gesture events.
Definition: StelModule.hpp:106
virtual void handleKeys(class QKeyEvent *e)
Handle key events.
Definition: StelModule.hpp:100
virtual void handleMouseClicks(class QMouseEvent *)
Handle mouse clicks.
Definition: StelModule.hpp:87
Action associated to the handleMouseMoves() method.
Definition: StelModule.hpp:122
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:95
Subtract the StelObject from the current list of selected ones.
Definition: StelModule.hpp:113
Action associated to the draw() method.
Definition: StelModule.hpp:119
virtual void handleMouseWheel(class QWheelEvent *)
Handle mouse wheel.
Definition: StelModule.hpp:91
virtual QString getAuthorEmail() const
Get the email adress of the module author.
Definition: StelModule.hpp:83
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:131
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:117
Action associated to the handleMouseClicks() method.
Definition: StelModule.hpp:121
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:109
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
Definition: StelModule.hpp:70
Set the StelObject as the new list of selected ones.
Definition: StelModule.hpp:112
Action associated to the update() method.
Definition: StelModule.hpp:120
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 to the StelActionMgr object.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49