Stellarium 0.14.3
ArchaeoLines.hpp
1 /*
2  * Copyright (C) 2014 Georg Zotti
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17  */
18 
19 #ifndef ARCHAEOLINES_HPP_
20 #define ARCHAEOLINES_HPP_
21 
22 #include <QFont>
23 #include <QColor>
24 #include <QKeyEvent>
25 #include "VecMath.hpp"
26 #include "StelModule.hpp"
27 #include "StelFader.hpp"
28 #include "StelCore.hpp"
29 #include "StelObjectMgr.hpp"
30 
31 class QTimer;
32 class QPixmap;
33 class StelButton;
34 class ArchaeoLinesDialog;
35 class ArchaeoLine;
36 
70 class ArchaeoLine : QObject
76 {
77  Q_OBJECT
78  Q_PROPERTY(Vec3f color READ getColor WRITE setColor)
79  Q_PROPERTY(bool flagLabel READ isLabelVisible WRITE setLabelVisible)
80 public:
81  enum Line {
82  Equinox,
83  Solstices,
84  Crossquarters,
85  MajorStandstill,
86  MinorStandstill,
87  ZenithPassage,
88  NadirPassage,
89  SelectedObject,
90  CurrentSun,
91  CurrentMoon,
92  CurrentPlanetNone, // actually a placeholder for counting/testing. By itself it makes no sense, i.e. deactivates the planet line
93  CurrentPlanetMercury,
94  CurrentPlanetVenus,
95  CurrentPlanetMars,
96  CurrentPlanetJupiter,
97  CurrentPlanetSaturn
98  };
99 
100  ArchaeoLine(ArchaeoLine::Line lineType, double declination);
101  virtual ~ArchaeoLine(){}
102  void draw(StelCore* core, float intensity=1.0f) const;
103  const Vec3f& getColor() const {return color;}
104  bool isDisplayed(void) const {return fader;}
105 
106 public slots:
107  void setColor(const Vec3f& c) {color = c;}
108  void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
109  void setFadeDuration(float duration) {fader.setDuration((int)(duration*1000.f));}
110  void setDisplayed(const bool displayed){fader = displayed;}
111  void setFontSize(double newSize){font.setPixelSize(newSize);}
113  void updateLabel();
114  void setLabelVisible(bool b){flagLabel=b;}
116  void setDeclination(double decl){declination=decl;}
117  bool isLabelVisible() const{return flagLabel;}
118  void setLineType(ArchaeoLine::Line line) {lineType=line; updateLabel();} // Meaningful only for CurrentPlanet... types
120  void setLabel(const QString newLabel){label=newLabel;}
121 
122 private:
123  ArchaeoLine::Line lineType;
124  double declination; // degrees
125  Vec3f color;
126  StelCore::FrameType frameType;
127  bool flagLabel;
128  QString label;
129  LinearFader fader;
130  QFont font;
131 };
132 
136 class ArchaeoLines : public StelModule
137 {
138  Q_OBJECT
139  Q_PROPERTY(bool enabled
140  READ isEnabled
141  WRITE enableArchaeoLines)
142 // Q_PROPERTY(bool dmsFormat
143 // READ isDmsFormat
144 // WRITE useDmsFormat)
145  Q_PROPERTY(bool flagShowEquinox
146  READ isEquinoxDisplayed
147  WRITE showEquinox)
148  Q_PROPERTY(bool flagShowSolstices
149  READ isSolsticesDisplayed
150  WRITE showSolstices)
151  Q_PROPERTY(bool flagShowCrossquarters
152  READ isCrossquartersDisplayed
153  WRITE showCrossquarters)
154  Q_PROPERTY(bool flagShowMajorStandstills
155  READ isMajorStandstillsDisplayed
156  WRITE showMajorStandstills)
157  Q_PROPERTY(bool flagShowMinorStandstills
158  READ isMinorStandstillsDisplayed
159  WRITE showMinorStandstills)
160  Q_PROPERTY(bool flagShowZenithPassage
161  READ isZenithPassageDisplayed
162  WRITE showZenithPassage)
163  Q_PROPERTY(bool flagShowNadirPassage
164  READ isNadirPassageDisplayed
165  WRITE showNadirPassage)
166  Q_PROPERTY(bool flagShowSelectedObject
167  READ isSelectedObjectDisplayed
168  WRITE showSelectedObject)
169  Q_PROPERTY(bool flagShowCurrentSun
170  READ isCurrentSunDisplayed
171  WRITE showCurrentSun)
172  Q_PROPERTY(bool flagShowCurrentMoon
173  READ isCurrentMoonDisplayed
174  WRITE showCurrentMoon)
175  Q_PROPERTY(ArchaeoLine::Line enumShowCurrentPlanet
176  READ whichCurrentPlanetDisplayed
177  WRITE showCurrentPlanet)
178 
179 public:
180  ArchaeoLines();
181  virtual ~ArchaeoLines();
182 
183 
184 
186  // Methods defined in the StelModule class
187  virtual void init();
188  virtual void update(double deltaTime);
189  virtual void draw(StelCore* core);
190  virtual double getCallOrder(StelModuleActionName actionName) const;
191  virtual void handleKeys(class QKeyEvent* event){event->setAccepted(false);}
192  virtual bool configureGui(bool show=true);
193  bool isEnabled() const {return flagShowArchaeoLines;}
194  bool isDmsFormat() const { return flagUseDmsFormat; } // NOT SURE IF USEFUL
195  bool isEquinoxDisplayed() const {return flagShowEquinox;}
196  bool isSolsticesDisplayed() const {return flagShowSolstices;}
197  bool isCrossquartersDisplayed() const {return flagShowCrossquarters;}
198  bool isMajorStandstillsDisplayed() const {return flagShowMajorStandstills;}
199  bool isMinorStandstillsDisplayed() const {return flagShowMinorStandstills;}
200  bool isZenithPassageDisplayed() const {return flagShowZenithPassage;}
201  bool isNadirPassageDisplayed() const {return flagShowNadirPassage;}
202  bool isSelectedObjectDisplayed() const {return flagShowSelectedObject;}
203  bool isCurrentSunDisplayed() const {return flagShowCurrentSun;}
204  bool isCurrentMoonDisplayed() const {return flagShowCurrentMoon;}
205  ArchaeoLine::Line whichCurrentPlanetDisplayed() const {return enumShowCurrentPlanet;}
206 
211  void restoreDefaultSettings();
212 
218  void loadSettings();
219 
220 
221 public slots:
222  void enableArchaeoLines(bool b);
223  //void useDmsFormat(bool b);
224 
225  void showEquinox(bool b);
226  void showSolstices(bool b);
227  void showCrossquarters(bool b);
228  void showMajorStandstills(bool b);
229  void showMinorStandstills(bool b);
230  void showZenithPassage(bool b);
231  void showNadirPassage(bool b);
232  void showSelectedObject(bool b);
233  void showCurrentSun(bool b);
234  void showCurrentMoon(bool b);
235  void showCurrentPlanet(ArchaeoLine::Line l); // Allowed values for l: CurrentPlanetNone...CurrentPlanetSaturn.
236  void showCurrentPlanet(QString planet); // Allowed values for planet: "none", "Mercury", "Venus", "Mars", "Jupiter", "Saturn".
237 
238  // called by the dialog GUI, converts GUI's QColor (0..255) to Stellarium's Vec3f float color.
239  void setLineColor(ArchaeoLine::Line whichLine, QColor color);
240  // called by the dialog UI, converts Stellarium's Vec3f float color to QColor (0..255).
241  QColor getLineColor(ArchaeoLine::Line whichLine);
242 
243 private:
244  QFont font;
245  bool flagShowArchaeoLines;
246  bool withDecimalDegree;
247  bool flagUseDmsFormat;
248  LinearFader lineFader;
249 
250  Vec3f equinoxColor;
251  Vec3f solsticesColor;
252  Vec3f crossquartersColor;
253  Vec3f majorStandstillColor;
254  Vec3f minorStandstillColor;
255  Vec3f zenithPassageColor;
256  Vec3f nadirPassageColor;
257  Vec3f selectedObjectColor;
258  Vec3f currentSunColor;
259  Vec3f currentMoonColor;
260  Vec3f currentPlanetColor;
261 
262 
263 
264  bool flagShowEquinox;
265  bool flagShowSolstices;
266  bool flagShowCrossquarters;
267  bool flagShowMajorStandstills;
268  bool flagShowMinorStandstills;
269  bool flagShowZenithPassage;
270  bool flagShowNadirPassage;
271  bool flagShowSelectedObject;
272  bool flagShowCurrentSun;
273  bool flagShowCurrentMoon;
274  ArchaeoLine::Line enumShowCurrentPlanet;
275  double lastJDE; // cache last-time-computed to every 10 days or so?
276 
277  ArchaeoLine * equinoxLine;
278  ArchaeoLine * northernSolsticeLine;
279  ArchaeoLine * southernSolsticeLine;
280  ArchaeoLine * northernCrossquarterLine;
281  ArchaeoLine * southernCrossquarterLine;
282  ArchaeoLine * northernMajorStandstillLine0;
283  ArchaeoLine * northernMajorStandstillLine1;
284  ArchaeoLine * northernMinorStandstillLine2;
285  ArchaeoLine * northernMinorStandstillLine3;
286  ArchaeoLine * southernMinorStandstillLine4;
287  ArchaeoLine * southernMinorStandstillLine5;
288  ArchaeoLine * southernMajorStandstillLine6;
289  ArchaeoLine * southernMajorStandstillLine7;
290  ArchaeoLine * zenithPassageLine;
291  ArchaeoLine * nadirPassageLine;
292  ArchaeoLine * selectedObjectLine;
293  ArchaeoLine * currentSunLine;
294  ArchaeoLine * currentMoonLine;
295  ArchaeoLine * currentPlanetLine;
296 
297  StelButton* toolbarButton;
298 
299  // draw one arc.
306 // void drawOne(StelCore *core, const float declination, const StelCore::FrameType frameType, const StelCore::RefractionMode refractionMode, const Vec3f txtColor, const Vec3f lineColor);
307 
308  QSettings* conf;
309 
310  // GUI
311  ArchaeoLinesDialog* configDialog;
312  StelCore* core; // used quite often, better keep a reference...
313  StelObjectMgr* objMgr;
314 };
315 
316 
317 
318 #include <QObject>
319 #include "StelPluginInterface.hpp"
320 
323 {
324  Q_OBJECT
325  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
326  Q_INTERFACES(StelPluginInterface)
327 public:
328  virtual StelModule* getStelModule() const;
329  virtual StelPluginInfo getPluginInfo() const;
330 };
331 
332 #endif /*ARCHAEOLINES_HPP_*/
333 
void setLabel(const QString newLabel)
change label. Used only for selected-object line - the other labels should not be changed! ...
Definition: Line.hpp:26
void loadSettings()
Load the plug-in's settings from the configuration file.
void updateLabel()
Re-translates the label.
void setDeclination(double decl)
reset declination (degrees) of this small arc.
This class is used by Qt to manage a plug-in interface.
Class which manages a line (small circle) to display around the sky like the solstices line...
virtual StelPluginInfo getPluginInfo() const =0
Main window of the ArchaeoLines plug-in.
virtual class StelModule * getStelModule() const =0
Main class of the ArchaeoLines plug-in.
void restoreDefaultSettings()
Restore the plug-in's settings to the default state.