Kstars

lunareclipsehandler.h
1/*
2 SPDX-FileCopyrightText: 2018 Valentin Boettcher <valentin@boettcher.cf>
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{
44public:
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
64public slots:
65 void slotShowDetails() override;
66
67private:
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{
83public:
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
92protected:
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
104private:
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};
The EclipseEvent class.
ECLIPSE_TYPE
The ECLIPSE_TYPE_T enum.
The EclipseHandler class.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
ECLIPSE_TYPE
The ECLIPSE_TYPE enum describes the quality of an eclipse.
Provides necessary information about the Moon.
Definition ksmoon.h:26
Child class of KSPlanetBase; encapsulates information about the Sun.
Definition kssun.h:24
The LunarEclipseEvent class.
bool hasDetails() override
hasDetails
QString getExtraInfo() override
getExtraInfo
QString getEclipsingObjectName() override
getEclipsingObjectName
SkyObject * getEclipsingObjectFromSkyComposite() override
getEclipsingObjectFromSkyComposite
QString getEclipsedObjectName() override
getEclipsingObjectName
KSEarthShadow::ECLIPSE_TYPE getDetailedType()
getDetailedType
The LunarEclipseHandler class.
EclipseVector computeEclipses(long double startJD, long double endJD) override
compute
double findInitialStep(long double, long double) override
findStep
dms findDistance() override
Finds the angular distance between two solar system objects.
double getMaxSeparation() override
getMaxSeparation
void updatePositions(long double jd) override
updatePositions
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
QString i18n(const char *text, const TYPE &arg...)
Q_OBJECTQ_OBJECT
virtual bool event(QEvent *e)
QObject * parent() const const
The LunarEclipseDetails struct.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.