Introduction
This documentation concerns the inner workings of Stellarium. This documentation is targetted at developers of scripts, plugins and the core program.
Program Architecture
The code of Stellarium is split into several main blocks:
-
the main loop and main widget classes StelMainWindow and StelMainGraphicsView. Those classes have a single instance which is created at startup by the main() function. They perform various tasks such as the creation of the main program window and openGL context, the creation of the stellarium core, the creation of the GUI. After initialization, they manage user's input event propagation and event loop. There are heavily based on Qt features.
-
the core which provides a number of generic services and features to the other components. The main class is the StelApp singleton class which is used everywhere in the code to access other elements. It is the StelApp instance which creates all the main core services and modules at initialization. Example services are OpenGL textures management with the StelTextureMgr, font management with the StelFontMgr, sky images management (images which have a fixed position in the sky) with the StelSkyImageMgr etc.. Two especially important manager classes (the ones with the "Mgr" suffix) are the StelModuleMgr and StelCore classes: the first one manages the collection of StelModule instances which are registered in the program (see next point for more info on what a StelModule is). The second one provides performance critical features for rendering various elements using openGL, or for computing coordinate transformation and other mathematical services.
-
a collection of StelModule instances which display the main elements of the program such as planets and stars. Each StelModule should be registered to the StelModuleMgr. Because many components of Stellarium derive from the StelModule class, it is possible for the main loop to treat them generically by calling their standard methods such StelModule::update() and StelModule::draw() at each program iteration. It also allows other program components to access them by name. StelProperty can be used to access all defined static properties (see the Qt property system for more information) of all registered StelModule instances. StelModule can also be loaded dynamically by Stellarium, which is the standard way of creating Plugins. StelAction instances can be used to define actions that can be triggered by the user through UI controls or key combinations.
-
the Graphical User Interface (StelGui). It is based on styled Qt widgets which are rendered directly in the openGL window. Users actions can trigger signals which are connected to core and StelModules slots. Many UI controls can also be directly connected to StelAction and/or StelProperty instances to reduce the amount of boilerplate code required to link UI changes to the back-end modules and vice-versa.
-
the script engine (StelScriptMgr) allows user scripts based on QtScript (a JavaScript dialect) to access properties and calls slots from the core and StelModule instances.