Stellarium  24.3
Public Types | Public Member Functions | Protected Member Functions
StelModule Class Referenceabstract

This is the common base class for all the main components of stellarium. More...

#include <StelModule.hpp>

Public Types

enum  StelModuleSelectAction { AddToSelection , ReplaceSelection , RemoveFromSelection }
 Enum used when selecting objects to define whether to add to, replace, or remove from the existing selection list. More...
 
enum  StelModuleActionName {
  ActionDraw , ActionUpdate , ActionHandleMouseClicks , ActionHandleMouseMoves ,
  ActionHandleKeys
}
 Define the possible action for which an order is defined. More...
 

Public Member Functions

 StelModule ()
 Constructor. Every derived class MUST call setObjectName(className) in its constructor.
 
virtual void init ()=0
 Initialize itself. More...
 
virtual void deinit ()
 Called before the module will be deleted, and before the OpenGL context is suppressed. More...
 
virtual QSettings * getSettings ()
 Return module-specific settings. More...
 
virtual void draw (StelCore *core)
 Execute all the drawing functions for this module. More...
 
virtual void update (double deltaTime)
 Update the module with respect to the time. More...
 
virtual QString getModuleVersion () const
 Get the version of the module, default is stellarium main version.
 
virtual QString getAuthorName () const
 Get the name of the module author.
 
virtual QString getAuthorEmail () const
 Get the email address of the module author.
 
virtual void handleMouseClicks (class QMouseEvent *)
 Handle mouse clicks. More...
 
virtual void handleMouseWheel (class QWheelEvent *)
 Handle mouse wheel. More...
 
virtual bool handleMouseMoves (int x, int y, Qt::MouseButtons b)
 Handle mouse moves. More...
 
virtual void handleKeys (class QKeyEvent *e)
 Handle key events. More...
 
virtual bool handlePinch (qreal scale, bool started)
 Handle pinch gesture events. More...
 
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. More...
 
virtual bool configureGui (bool show=true)
 Detect or show the configuration GUI elements for the module. More...
 

Protected Member Functions

class StelActionaddAction (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. More...
 
class StelActionaddAction (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. More...
 
StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *contextObject, std::function< void()> lambda, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to Lambda functor) to the StelActionMgr object. More...
 

Detailed Description

This is the common base class for all the main components of stellarium.

Standard StelModules are the one displaying the stars, the constellations, the planets etc.. Every new module derived class should implement the methods defined in StelModule.hpp. Once a module is registered into the StelModuleMgr, it is automatically managed by the program. It can be called using the GETSTELMODULE macro, passing as argument its name, which is also the QObject name Because StelModules are very generic components, it is also possible to load them dynamically, thus enabling creation of external plug-ins for stellarium.

See also
StelObjectModule for StelModule managing collections of StelObject.
Plugins for documentation on how to develop external plugins.

There are several signals that StelApp emits that subclasses may be interested in: laguageChanged() Update i18n strings from english names according to current global sky and application language. This method also reload the proper fonts depending on the language. The translation shall be done using the StelTranslator provided by the StelApp singleton instance. skyCultureChanged(const QString&) Update sky culture, i.e. load data if necessary and translate them to current sky language if needed. colorSchemeChanged(const QString&) Load the given color style

Member Enumeration Documentation

◆ StelModuleActionName

Define the possible action for which an order is defined.

Enumerator
ActionDraw 

Action associated to the draw() method.

ActionUpdate 

Action associated to the update() method.

ActionHandleMouseClicks 

Action associated to the handleMouseClicks() method.

ActionHandleMouseMoves 

Action associated to the handleMouseMoves() method.

ActionHandleKeys 

Action associated to the handleKeys() method.

◆ StelModuleSelectAction

Enum used when selecting objects to define whether to add to, replace, or remove from the existing selection list.

Enumerator
AddToSelection 

Add the StelObject to the current list of selected ones.

ReplaceSelection 

Set the StelObject as the new list of selected ones.

RemoveFromSelection 

Subtract the StelObject from the current list of selected ones.

Member Function Documentation

◆ addAction() [1/3]

class StelAction* StelModule::addAction ( const QString &  id,
const QString &  groupId,
const QString &  text,
const char *  slot,
const QString &  shortcut = "",
const QString &  altShortcut = "" 
)
inlineprotected

convenience methods to add an action (call to own slot) to the StelActionMgr object.

Parameters
idunique identifier. Should be called actionMy_Action. (i.e., start with "action" and then "Capitalize_Underscore" style.)
groupIdstring to be used in the Help menu. The action will be listed in this group.
textshort translatable description what the action does.
slotname of slot in target recipient
shortcutdefault shortcut. Can be reconfigured.
altShortcutdefault alternative shortcut. Can be reconfigured.

◆ addAction() [2/3]

StelAction* StelModule::addAction ( const QString &  id,
const QString &  groupId,
const QString &  text,
QObject *  contextObject,
std::function< void()>  lambda,
const QString &  shortcut = "",
const QString &  altShortcut = "" 
)
protected

convenience methods to add an action (call to Lambda functor) to the StelActionMgr object.

Parameters
idunique identifier. Should be called actionMy_Action. (i.e., start with "action" and then "Capitalize_Underscore" style.)
groupIdstring to be used in the Help menu. The action will be listed in this group.
textshort translatable description what the action does.
contextObjectThe lambda will only be called if this object exists. Use "this" in most cases.
lambdaa C++11 Lambda function.
shortcutdefault shortcut. Can be reconfigured.
altShortcutdefault alternative shortcut. Can be reconfigured.

◆ addAction() [3/3]

class StelAction* StelModule::addAction ( const QString &  id,
const QString &  groupId,
const QString &  text,
QObject *  target,
const char *  slot,
const QString &  shortcut = "",
const QString &  altShortcut = "" 
)
protected

convenience methods to add an action (call to slot) to the StelActionMgr object.

Parameters
idunique identifier. Should be called actionMy_Action. (i.e., start with "action" and then "Capitalize_Underscore" style.)
groupIdstring to be used in the Help menu. The action will be listed in this group.
textshort translatable description what the action does.
targetrecipient of the call
slotname of slot in target recipient
shortcutdefault shortcut. Can be reconfigured.
altShortcutdefault alternative shortcut. Can be reconfigured.

◆ configureGui()

virtual bool StelModule::configureGui ( bool  show = true)
inlinevirtual

Detect or show the configuration GUI elements for the module.

This is to be used with plugins to display a configuration dialog from the plugin list window.

Parameters
showif true, make the configuration GUI visible. If false, hide the config GUI if there is one.
Returns
true if the module has a configuration GUI, else false.

Reimplemented in TelescopeControl, Supernovae, Satellites, RemoteSync, RemoteControl, Quasars, Pulsars, Oculars, Observability, Novae, MissingStars, MeteorShowersMgr, LensDistortionEstimator, Exoplanets, Calendars, ArchaeoLines, AngleMeasure, SolarSystemEditor, Scenery3d, PointerCoordinates, OnlineQueries, NavStars, and EquationOfTime.

◆ deinit()

virtual void StelModule::deinit ( )
inlinevirtual

Called before the module will be deleted, and before the OpenGL context is suppressed.

Deinitialize all OpenGL texture in this method.

Reimplemented in ToastMgr, SpecificTimeMgr, SolarSystem, NomenclatureMgr, HipsMgr, HighlightMgr, CustomObjectMgr, TelescopeControl, Supernovae, Scenery3d, Satellites, Quasars, Pulsars, Oculus, Oculars, NavStars, MissingStars, MeteorShowersMgr, Exoplanets, and EquationOfTime.

◆ draw()

virtual void StelModule::draw ( StelCore core)
inlinevirtual

◆ getCallOrder()

virtual double StelModule::getCallOrder ( StelModuleActionName  actionName) const
inlinevirtual

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.

Parameters
actionNamethe name of the action for which we want the call order
Returns
the value defining the order. The closer to 0 the earlier the module's action will be called

Reimplemented in ScreenImageMgr, StelSkyLayerMgr, StelMovementMgr, ZodiacalLight, ToastMgr, StarMgr, SporadicMeteorMgr, SpecialMarkersMgr, SolarSystem, NomenclatureMgr, NebulaMgr, MilkyWay, MarkerMgr, LandscapeMgr, LabelMgr, HipsMgr, HighlightMgr, GridLinesMgr, CustomObjectMgr, ConstellationMgr, AsterismMgr, TextUserInterface, TelescopeControl, Supernovae, SimpleDrawLine, Scenery3d, Satellites, RemoteSync, RemoteControl, Quasars, Pulsars, PointerCoordinates, Oculus, Oculars, Observability, Novae, NavStars, MissingStars, MeteorShowersMgr, LensDistortionEstimator, HelloStelModule, Exoplanets, EquationOfTime, Calendars, ArchaeoLines, and AngleMeasure.

◆ getSettings()

virtual QSettings* StelModule::getSettings ( )
inlinevirtual

Return module-specific settings.

This can be useful mostly by plugins which may want to keep their settings to their own files. The default implementation returns a null pointer!

◆ handleKeys()

virtual void StelModule::handleKeys ( class QKeyEvent *  e)
inlinevirtual

Handle key events.

Please note that most of the interactions will be done through the GUI module.

Parameters
ethe Key event
Returns
set the event as accepted if it was intercepted

Reimplemented in StelMovementMgr, RemoteControl, Scenery3d, TextUserInterface, ArchaeoLines, and AngleMeasure.

◆ handleMouseClicks()

virtual void StelModule::handleMouseClicks ( class QMouseEvent *  )
inlinevirtual

Handle mouse clicks.

Please note that most of the interactions will be done through the GUI module.

Returns
set the event as accepted if it was intercepted

Reimplemented in LensDistortionEstimator, StelMovementMgr, Oculars, AngleMeasure, and CustomObjectMgr.

◆ handleMouseMoves()

virtual bool StelModule::handleMouseMoves ( int  x,
int  y,
Qt::MouseButtons  b 
)
inlinevirtual

Handle mouse moves.

Please note that most of the interactions will be done through the GUI module.

Returns
true if the event was intercepted

Reimplemented in LensDistortionEstimator, StelMovementMgr, and AngleMeasure.

◆ handleMouseWheel()

virtual void StelModule::handleMouseWheel ( class QWheelEvent *  )
inlinevirtual

Handle mouse wheel.

Please note that most of the interactions will be done through the GUI module.

Returns
set the event as accepted if it was intercepted

Reimplemented in StelMovementMgr.

◆ handlePinch()

virtual bool StelModule::handlePinch ( qreal  scale,
bool  started 
)
inlinevirtual

Handle pinch gesture events.

Parameters
scalethe value of the pinch gesture.
starteddefine whether the pinch has just started.
Returns
true if the event was intercepted.

Reimplemented in StelMovementMgr.

◆ init()

virtual void StelModule::init ( )
pure virtual

◆ update()

virtual void StelModule::update ( double  deltaTime)
inlinevirtual