Stellarium 0.14.3
Observability.hpp
1 /*
2  * Copyright (C) 2012 Ivan Marti-Vidal
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 #ifndef OBSERVABILITY_HPP_
19 #define OBSERVABILITY_HPP_
20 
21 #include "StelModule.hpp"
22 #include <QFont>
23 #include <QString>
24 #include <QPair>
25 #include "VecMath.hpp"
26 #include "SolarSystem.hpp"
27 #include "Planet.hpp"
28 #include "StelFader.hpp"
29 
30 class QPixmap;
31 class StelButton;
33 
51 class Observability : public StelModule
55 {
56  Q_OBJECT
57  Q_PROPERTY(bool flagShowReport READ isShownReport WRITE showReport)
58 public:
59  Observability();
60  virtual ~Observability();
61  virtual void init();
62  virtual void update(double) {;}
63  virtual void draw(StelCore* core);
64  virtual double getCallOrder(StelModuleActionName actionName) const;
65 
67  virtual bool configureGui(bool show=true);
68 
69 
73  void loadConfiguration();
74 
76  bool getShowFlags(int);
77 
79  Vec3f getFontColor(void);
80 
82  int getFontSize(void);
83 
86  int getTwilightAltitude();
87 
89  int getHorizonAltitude();
90 
91  bool isShownReport() const {return flagShowReport;}
92 public slots:
94  void resetConfiguration();
96  void saveConfiguration();
97 
100 
102  void enableTodayField(bool enabled = true);
104  void enableAcroCosField(bool enabled = true);
106  void enableGoodNightsField(bool enabled = true);
108  void enableOppositionField(bool enabled = true);
111  void enableFullMoonField(bool enabled = true);
113 
114 
118  void setFontColor(const Vec3f& color);
121  void setFontSize(int size);
122 
130  void setTwilightAltitude(int altitude);
131 
135  void setHorizonAltitude(int altitude);
136 
138  void showReport(bool b);
139 
140 
141 private slots:
143  void updateMessageText();
144 
145 
146 private:
148  ObservabilityDialog* configDialog;
149 
150  void setDateFormat(bool b) { dmyFormat=b; }
151  bool getDateFormat(void) { return dmyFormat; }
152 
158  double calculateHourAngle(double latitude, double elevation, double declination);
159 
163  double HourAngle2(double RA, double ST);
164 
169  bool calculateSolarSystemEvents(StelCore* core, int bodyType);
170 
178  int calculateAcroCos(int& acroRise, int& acroSet, int& cosRise, int& cosSet);
179 
180 
186  int calculateHeli(int imethod, int& heliRise, int& heliSet);
187 
188 
201  void getSunMoonCoords(StelCore* core, QPair<double, double> JD,
202  double& raSun, double& decSun,
203  double& raMoon, double& decMoon,
204  double& eclLon, bool getBack);
205 
206 
214  void getPlanetCoords(StelCore* core,QPair<double, double> JD,
215  double &RA, double &Dec, bool getBack);
216 
219  void getMoonDistance(StelCore* core, QPair<double, double> JD,
220  double& distance, bool getBack);
221 
227  double Lambda(double RA1, double Dec1, double RA2, double Dec2);
228 
234  void double2hms(double t, int &h,int &m,int &s);
235 
237  double sign(double d);
238 
243  QString formatAsDate(int dayNumber);
244 
249  QString formatAsDateRange(int startDay, int endDay);
250 
253  double toUnsignedRA(double RA);
254 
259  void updatePlanetData(StelCore* core);
260 
263  void updateSunData(StelCore* core);
264 
266  void updateSunH();
267 
269  void toRADec(Vec3d vec3d, double& ra, double& dec);
270 
272  QPair<double, double> yearJD[366]; // GZ: This had to become a QPair of JD.first=JD_UT, JD.second=JDE
273 
276  bool CheckRise(int day);
277 
279  // GZ: Made true constants out of those, and improved accuracy of some.
280  static const double Rad2Deg, Rad2Hr, UA, TFrac, JDsec, halfpi, MoonT, RefFullMoon, MoonPerilune;
281 
283  double nextFullMoon, prevFullMoon, GMTShift, Jan1stJD;
284 
287  double twilightAltRad;
288 
291  int twilightAltDeg;
292 
294  double refractedHorizonAlt;
295 
297  double horizonAltitude;
298 
300  int horizonAltDeg;
301 
303  double selRA, selDec, mylat, mylon, alti, horizH, culmAlt;
304 
306  QPair<double, double> myJD;
307 
309  double sunRA[366];
310  double sunDec[366];
311 
313  double sunSidT[4][366];
314 
316  double objectRA[366];
317  double objectDec[366];
318  double objectH0[366];
319 
321  double objectSidT[2][366];
322 
324  double MoonRise, MoonSet, MoonCulm, lastJDMoon;
325 
327  Vec3d EarthPos[366];
328 
330  Vec3d ObserverLoc, Pos1, Pos2, RotObserver; //, Pos3;
331 
333  Mat4d LocTrans;
334 
336  Planet* myEarth;
337  Planet* myMoon;
338  Planet* myPlanet;
339 
341  int curYear;
343  int nDays;
344 
347  QString selName;
349  QString lineBestNight;
351  QString lineObservableRange;
353  QString lineAcroCos, lineHeli;
354 
356  QString RiseTime, SetTime, CulmTime;
357 
359  QStringList monthNames;
360 
362  bool dmyFormat;
363 
365  Vec3d EquPos, LocPos;
366 
368  bool isStar, isMoon, isSun, isScreen;
369 
371  bool hasRisen;
372  bool configChanged;
373  bool souChanged;
375  int lastType;
376 
379  bool show_AcroCos, show_Good_Nights, show_Best_Night, show_Today, show_FullMoon; //, show_Crescent, show_SuperMoon;
381 
385  QFont font;
386  Vec3f fontColor;
387  bool flagShowReport;
388  int fontSize;
389  StelButton* button;
391 
395  QString msgSetsAt, msgRoseAt, msgSetAt, msgRisesAt, msgCircumpolar, msgNoRise, msgCulminatesAt, msgCulminatedAt, msgH, msgM, msgS;
396  QString msgSrcNotObs, msgNoACRise, msgGreatElong, msgLargSSep, msgNone, msgAcroRise, msgNoAcroRise, msgCosmRise, msgNoCosmRise;
397  QString msgHeliRise, msgHeliSet, msgNoHeliRise;
398  QString msgWholeYear, msgNotObs, msgAboveHoriz, msgToday, msgThisYear, msgPrevFullMoon, msgNextFullMoon;
400 
401 };
402 
403 
404 #include <QObject>
405 #include "StelPluginInterface.hpp"
406 
408 {
409  Q_OBJECT
410  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
411  Q_INTERFACES(StelPluginInterface)
412 public:
413  virtual StelModule* getStelModule() const;
414  virtual StelPluginInfo getPluginInfo() const;
415 };
416 
417 #endif /*OBSERVABILITY_HPP_*/
int getTwilightAltitude()
Get the user-defined Sun altitude at twilight.
void showReport(bool b)
Controls whether an observability report will be displayed.
Vec3f getFontColor(void)
get the current font color:
void saveConfiguration()
Save the plug-in's configuration to the main configuration file.
virtual bool configureGui(bool show=true)
Implement this to tell the main Stellarium GUI that there is a GUI element to configure this plugin...
virtual StelPluginInfo getPluginInfo() const =0
void enableFullMoonField(bool enabled=true)
Display date of the full moon.
void resetConfiguration()
Restore and reload the default plug-in settings.
virtual class StelModule * getStelModule() const =0
void loadConfiguration()
Read (or re-read) settings from the main config file.
Configuration window of the Observability Analysis plug-in.
void enableTodayField(bool enabled=true)
Display today's events (rise, set and transit times).
void enableOppositionField(bool enabled=true)
Display when selected object is in opposition.
void enableGoodNightsField(bool enabled=true)
Display nights when the object is above the horizon after darkness.
void setHorizonAltitude(int altitude)
Set the angular altitude of the visual horizon.
void enableAcroCosField(bool enabled=true)
Display acronychal and cosmical rising/setting.
bool getShowFlags(int)
get Show Flags from current configuration:
int getHorizonAltitude()
Get the user-defined altitude of the visual horizon.
int getFontSize(void)
get current font size:
void setTwilightAltitude(int altitude)
Set the angular altitude below the horizon of the Sun at twilight.
void setFontSize(int size)
Set the size of the font used to display the report.
void setFontColor(const Vec3f &color)
Set the color of the font used to display the report.
Main class of the Observability Analysis plug-in.