Stellarium 0.13.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 "config.h"
24 
25 #include <QString>
26 #include <QObject>
27 #include <QOpenGLFunctions>
28 
29 // Predeclaration
30 class StelCore;
31 class QSettings;
32 
52 class StelModule : public QObject, protected QOpenGLFunctions
53 {
54  Q_OBJECT
55  // Do not add Q_OBJECT here!!
56  // This make this class compiled by the Qt moc compiler and for some unknown reasons makes it impossible to dynamically
57  // load plugins on windows.
58 public:
59  StelModule() {;}
60 
61  virtual ~StelModule() {;}
62 
65  virtual void init() = 0;
66 
69  virtual void deinit() {;}
70 
73  virtual void draw(StelCore* core) {Q_UNUSED(core);}
74 
79  virtual bool drawPartial(StelCore* core);
80 
83  virtual void update(double deltaTime) = 0;
84 
86  virtual QString getModuleVersion() const;
87 
89  virtual QString getAuthorName() const {return "Stellarium's Team";}
90 
92  virtual QString getAuthorEmail() const {return "http://www.stellarium.org";}
93 
96  virtual void handleMouseClicks(class QMouseEvent*) {;}
97 
100  virtual void handleMouseWheel(class QWheelEvent*) {;}
101 
104  virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b) {Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(b); return false;}
105 
109  virtual void handleKeys(class QKeyEvent* e) {Q_UNUSED(e);}
110 
113  {
117  };
118 
121  {
127  };
128 
134  virtual double getCallOrder(StelModuleActionName actionName) const {Q_UNUSED(actionName); return 0;}
135 
140  virtual bool configureGui(bool show=true) {Q_UNUSED(show); return false;}
141 
142 protected:
143 
145  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
146  QObject* target, const char* slot,
147  const QString& shortcut="", const QString& altShortcut="");
148 
150  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
151  const char* slot,
152  const QString& shortcut="", const QString& altShortcut="") {
153  return addAction(id, groupId, text, this, slot, shortcut, altShortcut);
154  }
155 };
156 
157 Q_DECLARE_METATYPE(StelModule::StelModuleSelectAction)
158 
159 #endif // _STELMODULE_HPP_
virtual QString getAuthorName() const
Get the name of the module author.
Definition: StelModule.hpp:89
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
Definition: StelModule.hpp:69
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:150
Add the StelObject to the current list of selected ones.
Definition: StelModule.hpp:114
virtual QString getModuleVersion() const
Get the version of the module, default is stellarium main version.
virtual bool drawPartial(StelCore *core)
Iterate through the drawing sequence.
virtual bool configureGui(bool show=true)
Detect or show the configuration GUI elements for the module.
Definition: StelModule.hpp:140
Action associated to the handleKeys() method.
Definition: StelModule.hpp:126
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
virtual void handleKeys(class QKeyEvent *e)
Handle key events.
Definition: StelModule.hpp:109
virtual void handleMouseClicks(class QMouseEvent *)
Handle mouse clicks.
Definition: StelModule.hpp:96
Action associated to the handleMouseMoves() method.
Definition: StelModule.hpp:125
Definition: StelActionMgr.hpp:29
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:104
Subtract the StelObject from the current list of selected ones.
Definition: StelModule.hpp:116
Action associated to the draw() method.
Definition: StelModule.hpp:122
virtual void handleMouseWheel(class QWheelEvent *)
Handle mouse wheel.
Definition: StelModule.hpp:100
virtual QString getAuthorEmail() const
Get the email adress of the module author.
Definition: StelModule.hpp:92
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:134
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:120
Action associated to the handleMouseClicks() method.
Definition: StelModule.hpp:124
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:112
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
Definition: StelModule.hpp:73
Set the StelObject as the new list of selected ones.
Definition: StelModule.hpp:115
Action associated to the update() method.
Definition: StelModule.hpp:123
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:52