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 
28 // Predeclaration
29 class StelCore;
30 class QSettings;
31 
51 class StelModule : public QObject
52 {
53  Q_OBJECT
54  // Do not add Q_OBJECT here!!
55  // This make this class compiled by the Qt moc compiler and for some unknown reasons makes it impossible to dynamically
56  // load plugins on windows.
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 
120  {
126  };
127 
133  virtual double getCallOrder(StelModuleActionName actionName) const {Q_UNUSED(actionName); return 0;}
134 
139  virtual bool configureGui(bool show=true) {Q_UNUSED(show); return false;}
140 
141 protected:
142 
144  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
145  QObject* target, const char* slot,
146  const QString& shortcut="", const QString& altShortcut="");
147 
149  class StelAction* addAction(const QString& id, const QString& groupId, const QString& text,
150  const char* slot,
151  const QString& shortcut="", const QString& altShortcut="") {
152  return addAction(id, groupId, text, this, slot, shortcut, altShortcut);
153  }
154 };
155 
156 Q_DECLARE_METATYPE(StelModule::StelModuleSelectAction)
157 
158 #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 to the StelActionMgr object.
Definition: StelModule.hpp:149
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:139
Action associated to the handleKeys() method.
Definition: StelModule.hpp:125
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
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:124
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:121
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:133
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:119
Action associated to the handleMouseClicks() method.
Definition: StelModule.hpp:123
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:122
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:51