Stellarium  0.90.0
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
58  READ isShownReport
59  WRITE showReport
60  NOTIFY flagReportVisibilityChanged
61  )
62 public:
63  Observability();
64  virtual ~Observability();
65  virtual void init();
66  virtual void update(double) {;}
67  virtual void draw(StelCore* core);
68  virtual double getCallOrder(StelModuleActionName actionName) const;
69 
71  virtual bool configureGui(bool show=true);
72 
73 
77  void loadConfiguration();
78 
80  bool getShowFlags(int);
81 
83  Vec3f getFontColor(void);
84 
86  int getFontSize(void);
87 
90  int getTwilightAltitude();
91 
93  int getHorizonAltitude();
94 
95  bool isShownReport() const {return flagShowReport;}
96 
97 signals:
98  void flagReportVisibilityChanged(bool b);
99 
100 public slots:
102  void resetConfiguration();
104  void saveConfiguration();
105 
108 
110  void enableTodayField(bool enabled = true);
112  void enableAcroCosField(bool enabled = true);
114  void enableGoodNightsField(bool enabled = true);
116  void enableOppositionField(bool enabled = true);
119  void enableFullMoonField(bool enabled = true);
121 
122 
126  void setFontColor(const Vec3f& color);
129  void setFontSize(int size);
130 
138  void setTwilightAltitude(int altitude);
139 
143  void setHorizonAltitude(int altitude);
144 
146  void showReport(bool b);
147 
148 
149 private slots:
151  void updateMessageText();
152 
153 
154 private:
156  ObservabilityDialog* configDialog;
157 
158  void setDateFormat(bool b) { dmyFormat=b; }
159  bool getDateFormat(void) { return dmyFormat; }
160 
166  double calculateHourAngle(double latitude, double elevation, double declination);
167 
171  double HourAngle2(double RA, double ST);
172 
177  bool calculateSolarSystemEvents(StelCore* core, int bodyType);
178 
186  int calculateAcroCos(int& acroRise, int& acroSet, int& cosRise, int& cosSet);
187 
188 
194  int calculateHeli(int imethod, int& heliRise, int& heliSet);
195 
196 
209  void getSunMoonCoords(StelCore* core, QPair<double, double> JD,
210  double& raSun, double& decSun,
211  double& raMoon, double& decMoon,
212  double& eclLon, bool getBack);
213 
214 
222  void getPlanetCoords(StelCore* core,QPair<double, double> JD,
223  double &RA, double &Dec, bool getBack);
224 
227  void getMoonDistance(StelCore* core, QPair<double, double> JD,
228  double& distance, bool getBack);
229 
235  double Lambda(double RA1, double Dec1, double RA2, double Dec2);
236 
242  void double2hms(double t, int &h,int &m,int &s);
243 
245  double sign(double d);
246 
251  QString formatAsDate(int dayNumber);
252 
257  QString formatAsDateRange(int startDay, int endDay);
258 
261  double toUnsignedRA(double RA);
262 
267  void updatePlanetData(StelCore* core);
268 
271  void updateSunData(StelCore* core);
272 
274  void updateSunH();
275 
277  void toRADec(Vec3d vec3d, double& ra, double& dec);
278 
280  QPair<double, double> yearJD[366]; // GZ: This had to become a QPair of JD.first=JD_UT, JD.second=JDE
281 
284  bool CheckRise(int day);
285 
287  // GZ: Made true constants out of those, and improved accuracy of some.
288  static const double Rad2Deg, Rad2Hr, UA, TFrac, halfpi, MoonT, RefFullMoon, MoonPerilune;
289 
291  double nextFullMoon, prevFullMoon, GMTShift, Jan1stJD;
292 
295  double twilightAltRad;
296 
299  int twilightAltDeg;
300 
302  double refractedHorizonAlt;
303 
305  double horizonAltitude;
306 
308  int horizonAltDeg;
309 
311  double selRA, selDec, mylat, mylon, alti, horizH, culmAlt;
312 
314  QPair<double, double> myJD;
315 
317  double sunRA[366];
318  double sunDec[366];
319 
321  double sunSidT[4][366];
322 
324  double objectRA[366];
325  double objectDec[366];
326  double objectH0[366];
327 
329  double objectSidT[2][366];
330 
332  double MoonRise, MoonSet, MoonCulm, lastJDMoon;
333 
335  Vec3d EarthPos[366];
336 
338  Vec3d ObserverLoc, Pos1, Pos2, RotObserver; //, Pos3;
339 
341  Mat4d LocTrans;
342 
344  Planet* myEarth;
345  Planet* myMoon;
346  Planet* myPlanet;
347 
349  int curYear;
351  int nDays;
352 
355  QString selName;
357  QString lineBestNight;
359  QString lineObservableRange;
361  QString lineAcroCos, lineHeli;
362 
364  QString RiseTime, SetTime, CulmTime;
365 
367  QStringList monthNames;
368 
370  bool dmyFormat;
371 
373  Vec3d EquPos, LocPos;
374 
376  bool isStar, isMoon, isSun, isScreen;
377 
379  bool hasRisen;
380  bool configChanged;
381  bool souChanged;
383  int lastType;
384 
387  bool show_AcroCos, show_Good_Nights, show_Best_Night, show_Today, show_FullMoon; //, show_Crescent, show_SuperMoon;
389 
393  QFont font;
394  Vec3f fontColor;
395  bool flagShowReport;
396  int fontSize;
397  StelButton* button;
399 
403  QString msgSetsAt, msgRoseAt, msgSetAt, msgRisesAt, msgCircumpolar, msgNoRise, msgCulminatesAt, msgCulminatedAt, msgH, msgM, msgS;
404  QString msgSrcNotObs, msgNoACRise, msgGreatElong, msgLargSSep, msgNone, msgAcroRise, msgNoAcroRise, msgCosmRise, msgNoCosmRise;
405  QString msgHeliRise, msgHeliSet, msgNoHeliRise;
406  QString msgWholeYear, msgNotObs, msgAboveHoriz, msgToday, msgThisYear, msgPrevFullMoon, msgNextFullMoon;
408 
409 };
410 
411 
412 #include <QObject>
413 #include "StelPluginInterface.hpp"
414 
416 {
417  Q_OBJECT
418  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
419  Q_INTERFACES(StelPluginInterface)
420 public:
421  virtual StelModule* getStelModule() const;
422  virtual StelPluginInfo getPluginInfo() const;
423  virtual QObjectList getExtensionList() const { return QObjectList(); }
424 };
425 
426 #endif /*OBSERVABILITY_HPP_*/
Define the interface to implement when creating a plugin.
int getTwilightAltitude()
Get the user-defined Sun altitude at twilight.
void showReport(bool b)
Controls whether an observability report will be displayed.
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
Vec3f getFontColor(void)
get the current font color:
virtual QObjectList getExtensionList() const
A mechanism to provide abitrary QObjects to the StelModuleMgr.
void saveConfiguration()
Save the plug-in&#39;s configuration to the main configuration file.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
virtual bool configureGui(bool show=true)
Implement this to tell the main Stellarium GUI that there is a GUI element to configure this plugin...
void enableFullMoonField(bool enabled=true)
Display date of the full moon.
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
virtual void update(double)
Update the module with respect to the time.
void resetConfiguration()
Restore and reload the default plug-in settings.
void loadConfiguration()
Read (or re-read) settings from the main config file.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
Configuration window of the Observability Analysis plug-in.
void enableTodayField(bool enabled=true)
Display today&#39;s events (rise, set and transit times).
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.
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.
virtual void init()
Initialize itself.
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.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
void setFontSize(int size)
Set the size of the font used to display the report.
Contains information about a Stellarium plugin.
void setFontColor(const Vec3f &color)
Set the color of the font used to display the report.
Main class of the Observability Analysis plug-in.