Stellarium  0.16.1
EquationOfTime.hpp
1 /*
2  * Equation Of Time plug-in for Stellarium
3  *
4  * Copyright (C) 2014 Alexander Wolf
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef _EQUATIONOFTIME_HPP_
21 #define _EQUATIONOFTIME_HPP_
22 
23 #include "StelGui.hpp"
24 #include "StelModule.hpp"
25 
26 #include <QFont>
27 #include <QString>
28 
29 class QPixmap;
30 class StelButton;
32 
55 class EquationOfTime : public StelModule
60 {
61  Q_OBJECT
62  Q_PROPERTY(bool showEOT
63  READ isEnabled
65  NOTIFY equationOfTimeStateChanged)
66 
67 public:
69  virtual ~EquationOfTime();
70 
71  virtual void init();
72  virtual void deinit();
73  virtual void update(double) {;}
74  virtual void draw(StelCore *core);
75  virtual double getCallOrder(StelModuleActionName actionName) const;
76  virtual bool configureGui(bool show);
77 
80  void restoreDefaults(void);
81 
84  void readSettingsFromConfig(void);
85 
87  void saveSettingsToConfig(void) const;
88 
90  bool isEnabled() const
91  {
92  return flagShowSolutionEquationOfTime;
93  }
94 
96  int getFontSize(void) const
97  {
98  return fontSize;
99  }
101  bool getFlagMsFormat(void) const
102  {
103  return flagUseMsFormat;
104  }
106  bool getFlagInvertedValue(void) const
107  {
108  return flagUseInvertedValue;
109  }
110  bool getFlagEnableAtStartup(void) const
111  {
112  return flagEnableAtStartup;
113  }
114  bool getFlagShowEOTButton(void) const
115  {
116  return flagShowEOTButton;
117  }
118 
119 public slots:
121  void enableEquationOfTime(bool b);
123  void setFlagInvertedValue(bool b);
125  void setFlagMsFormat(bool b);
127  void setFlagEnableAtStartup(bool b);
129  void setFontSize(int size);
131  void setFlagShowEOTButton(bool b);
132 
133 private slots:
134  void updateMessageText();
135 
136 signals:
137  void equationOfTimeStateChanged(bool b);
138 
139 private:
140  // if existing, delete EquationOfTime section in main config.ini, then create with default values
141  void restoreDefaultConfigIni(void);
142 
143  EquationOfTimeWindow* mainWindow;
144  QSettings* conf;
145  StelGui* gui;
146 
147  QFont font;
148  bool flagShowSolutionEquationOfTime;
149  bool flagUseInvertedValue;
150  bool flagUseMsFormat;
151  bool flagEnableAtStartup;
152  bool flagShowEOTButton;
153  QString messageEquation;
154  QString messageEquationMinutes;
155  QString messageEquationSeconds;
156  Vec3f textColor;
157  int fontSize;
158  StelButton* toolbarButton;
159 };
160 
161 
162 #include <QObject>
163 #include "StelPluginInterface.hpp"
164 
167 {
168  Q_OBJECT
169  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
170  Q_INTERFACES(StelPluginInterface)
171 public:
172  virtual StelModule* getStelModule() const;
173  virtual StelPluginInfo getPluginInfo() const;
174  virtual QObjectList getExtensionList() const { return QObjectList(); }
175 };
176 
177 #endif /* _EQUATIONOFTIME_HPP_ */
void readSettingsFromConfig(void)
Read (or re-read) settings from the main config file.
virtual void init()
Initialize itself.
Define the interface to implement when creating a plugin.
virtual bool configureGui(bool show)
Detect or show the configuration GUI elements for the module.
void restoreDefaults(void)
Set up the plugin with default values.
void setFlagShowEOTButton(bool b)
Display plugin button on toolbar.
void setFlagMsFormat(bool b)
Enable usage minutes and seconds for value.
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.
bool getFlagMsFormat(void) const
Get status of usage minutes and seconds for value of equation.
bool isEnabled() const
Is plugin enabled?
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
void setFlagEnableAtStartup(bool b)
Enable plugin usage at startup.
int getFontSize(void) const
Get font size for messages.
Main window of the Equation of Time plug-in.
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
virtual void update(double)
Update the module with respect to the time.
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
virtual QObjectList getExtensionList() const
A mechanism to provide abitrary QObjects to the StelModuleMgr.
Main class of the Equation of Time plugin.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
This class is used by Qt to manage a plug-in interface.
void setFlagInvertedValue(bool b)
Enable usage inverted value for equation of time (switch sign of equation)
Main class for the GUI based on QGraphicView.
Definition: StelGui.hpp:53
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
void setFontSize(int size)
Set font size for message.
bool getFlagInvertedValue(void) const
Get status of usage inverted values for equation of time.
void saveSettingsToConfig(void) const
Save the settings to the main configuration file.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.
void enableEquationOfTime(bool b)
Enable plugin usage.