Kstars

lunareclipsehandler.h
1 /*
2  SPDX-FileCopyrightText: 2018 Valentin Boettcher <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 #include "eclipsehandler.h"
9 #include "ksearthshadow.h"
10 #include "ksmoon.h"
11 #include "kssun.h" // NOTE: Maybe use pointers... compile time savings
12 
13 // FIXME: (Valentin) WIP, To be completed (extra features)!
14 
15 /**
16  * @brief The LunarEclipseDetails struct
17  * @short A struct to hold detail information about an eclipse
18  */
20  enum EVENT {
21  BEGIN_PENUMBRA_CONTACT,
22  BEGIN_UMBRA_CONTACT,
23  END_PENUMBRA_CONTACT,
24  END_UMBRA_CONTACT,
25  BEGIN_FULL_UMBRA,
26  END_FULL_UMBRA,
27  BEGIN_FULL_PENUMRA,
28  END_FULL_PENUMRA,
29  CLOSEST_APPROACH
30  };
31 
32  bool available = false;
33  QMap<long double, EVENT> eclipseTimes;
34  // More Later
35 };
36 
37 /**
38  * @brief The LunarEclipseEvent class
39  * @short implementation of the EclipseEvent for the LunarEclipseHandler
40  */
42 {
43  Q_OBJECT
44 public:
45  LunarEclipseEvent(long double jd, GeoLocation geoPlace, ECLIPSE_TYPE type, KSEarthShadow::ECLIPSE_TYPE detailed_type);
46 
47  ~LunarEclipseEvent() override {} // empty for now
48 
49  QString getExtraInfo() override;
50 
51  /**
52  * @brief getDetailedType
53  * @return Type of the eclipse as in KSEarthShadow::ECLIPSE_TYPE
54  */
55  KSEarthShadow::ECLIPSE_TYPE getDetailedType() { return m_detailedType; }
56 
57  QString getEclipsingObjectName() override { return i18n("Earth Shadow"); }
58  QString getEclipsedObjectName() override { return i18n("Moon"); }
59 
61 
62  bool hasDetails() override { return false; } // false for now!
63 
64 public slots:
65  void slotShowDetails() override;
66 
67 private:
68  KSEarthShadow::ECLIPSE_TYPE m_detailedType;
69  LunarEclipseDetails m_details;
70  // More Later_details;
71 };
72 
73 
74 /**
75  * @brief The LunarEclipseHandler class
76  * @short Calculate lunar eclipses.
77  *
78  * Calculates lunar eclipses by looking for them close to full moon.
79  */
81 {
82  Q_OBJECT
83 public:
84  explicit LunarEclipseHandler(QObject * parent = nullptr);
85  virtual ~LunarEclipseHandler() override;
86 
87  EclipseVector computeEclipses(long double startJD, long double endJD) override;
88 
89  // FIXME: (Valentin) Not yet finished. Returns empty Details!
90  LunarEclipseDetails findEclipseDetails(LunarEclipseEvent *event);
91 
92 protected:
93  double findInitialStep(long double, long double) override
94  { return (m_mode == CLOSEST_APPROACH) ? INITIAL_STEP : DETAIL_STEP; }
95 
96  void updatePositions(long double jd) override;
97 
98  // NOTE: This method depends on m_mode!
99  dms findDistance() override;
100 
101  // NOTE: This method depends on m_mode!
102  double getMaxSeparation() override;
103 
104 private:
105  /**
106  * @brief getFullMoons
107  * @param startJD start Date
108  * @param endJD end Date
109  * @return a vector of JDs for full moons (actually a little earlier as it doesn't matter much)
110  */
111  QVector<long double> getFullMoons(long double startJD, long double endJD);
112 
113  // Objects for the Calculations
114  KSSun m_sun;
115  KSMoon m_moon;
116  KSEarthShadow m_shadow;
117 
118  // Controls the step size, is chosen small to minimize overshooting
119  const double INITIAL_STEP { 0.1 };
120  const double DETAIL_STEP { 0.001 };
121 
122  /**
123  * @brief The MODE enum
124  * @short Set the mode for the distance minimizer, i.e. which point to find.
125  */
126  enum {
127  CLOSEST_APPROACH,
128  PENUMBRA_CONTACT,
129  PUNUMBRA_IMMERSION,
130  UMBRA_CONTACT,
131  UMBRA_IMMERSION
132  } m_mode { CLOSEST_APPROACH };
133 };
Q_OBJECTQ_OBJECT
The EclipseEvent class.
QString getEclipsingObjectName() override
getEclipsingObjectName
ECLIPSE_TYPE
The ECLIPSE_TYPE enum describes the quality of an eclipse.
Definition: ksearthshadow.h:45
KSEarthShadow::ECLIPSE_TYPE getDetailedType()
getDetailedType
QString getExtraInfo() override
getExtraInfo
EclipseVector computeEclipses(long double startJD, long double endJD) override
compute
Provides necessary information about the Moon. A subclass of SkyObject that provides information need...
Definition: ksmoon.h:25
The EclipseHandler class.
double findInitialStep(long double, long double) override
findStep
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
Definition: ksearthshadow.h:27
Provides necessary information about the Sun.
Definition: kssun.h:23
The LunarEclipseHandler class.
virtual bool event(QEvent *e)
QString i18n(const char *text, const TYPE &arg...)
The LunarEclipseEvent class.
bool hasDetails() override
hasDetails
SkyObject * getEclipsingObjectFromSkyComposite() override
getEclipsingObjectFromSkyComposite
void updatePositions(long double jd) override
updatePositions
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
dms findDistance() override
Finds the angular distance between two solar system objects.
double getMaxSeparation() override
getMaxSeparation
QString getEclipsedObjectName() override
getEclipsingObjectName
The LunarEclipseDetails struct.
ECLIPSE_TYPE
The ECLIPSE_TYPE_T enum.
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
Relevant data about an observing location on Earth.
Definition: geolocation.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 04:04:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.