Kstars

eclipsehandler.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 "geolocation.h"
9#include "approachsolver.h"
10#include "skycomponents/typedef.h"
11
12class KSPlanetBase;
13
14/**
15 * @brief The EclipseEvent class
16 * @short Abstract container/interface for a eclipse event.
17 * @note We do not use the QObject hierarchy here as it would be inefficient
18 */
19class EclipseEvent : public QObject {
21
22public:
23 /**
24 * @brief The ECLIPSE_TYPE_T enum
25 * @short Basic eclipse type. May be supplemented
26 * by subclasses.
27 */
29 PARTIAL,
30 FULL
31 };
32
33 EclipseEvent(long double jd, GeoLocation geoPlace, ECLIPSE_TYPE type);
34
35 virtual ~EclipseEvent(); // empty for now
36
37 /**
38 * @brief getJD
39 * @return the julian date of the event
40 */
41 long double getJD() { return m_jd; }
42
43 /**
44 * @brief getExtraInfo
45 * @return information to display in an extra column
46 * of the overview table.
47 */
48 virtual QString getExtraInfo() { return ""; }
49
50 /**
51 * @brief getType
52 * @return the type of the eclipse
53 */
54 ECLIPSE_TYPE getType() { return m_type; }
55
56 /**
57 * @brief getEclipsingObjectName
58 * @return the name of the eclipsing object
59 * @note maybe store those objects as clones...
60 */
62
63 /**
64 * @brief getEclipsingObjectName
65 * @return the name of the eclipsed object
66 * @note maybe store those objects as clones...
67 */
69
70 /**
71 * @brief getGeolocation
72 * @return geolocation for which the event is valid
73 */
74 GeoLocation getGeolocation() { return m_geoPlace; }
75
76 /**
77 * @brief getEclipsingObjectFromSkyComposite
78 * @return a pointer to the skymap instance of the ecl. obj.
79 */
81
82 /**
83 * @brief hasDetails
84 * @return whether a details widget can be shown
85 */
86 virtual bool hasDetails() { return false; }
87
88public slots:
89 /**
90 * @brief showDetails
91 * @short (if implemented) shows a widget with details about the eclipse
92 */
93 virtual void slotShowDetails() { return; }
94
95private:
96 ECLIPSE_TYPE m_type;
97 GeoLocation m_geoPlace;
98
99 /**
100 * @brief jd - date of the event
101 */
102 long double m_jd;
103};
104
105/**
106 * @brief The EclipseHandler class
107 *
108 * This is a base class for providing a common interface
109 * for eclipse events which can be quite different in nature. It is
110 * meant to be subclassed. (Check LunarEclipseHandler as an example)
111 *
112 * @todo remove uglieness from KSConjunct (export m_object... functionality to separate class!,
113 * that findinitialstepsize isn't nice either)
114 *
115 * @note I've integrated the `findDetails` stuff in the eclipse handler because it already has
116 * the `beef` it takes (instances and methods). OOP is not always the way.
117 */
119{
121public:
123
124 explicit EclipseHandler(QObject * parent = nullptr);
125 virtual ~EclipseHandler() override;
126
127 /**
128 * @brief compute
129 * @short Implements the details for finding *all* the eclipses
130 * in a given time-frame. Should call findEclipse intelligently.
131 * e.g. only if the moon is full for lunar eclipses et-cetera
132 *
133 * @returns A vector of shared pointers to eclipse events.
134 */
135 virtual EclipseVector computeEclipses(long double startJD, long double endJD) = 0;
136
137 /**
138 * @brief getEvents
139 * @short May be used if the return value of computeEclipses is being ignored.
140 * @note The underlying vector changes after every call to computeEclipses.
141 *
142 * @return A vector of shared pointers to eclipse events.
143 */
144 QVector<EclipseEvent_s> getEvents() { return m_events; }
145
146signals:
147 /**
148 * @brief signalEventFound
149 * @short A signal to be dispatched as soon as a new Event is found.
150 * @note Has to emitted by a subclass!
151 * @param event
152 */
153 void signalEventFound(EclipseEvent_s event);
154
155 /**
156 * @brief signalProgress
157 * @short gives the progress of the computation in percent
158 */
159 void signalProgress(int);
160
161 /**
162 * @brief signalComputationFinished
163 * @short signals the end of the computation
164 */
166
167protected:
168 virtual double findInitialStep(long double startJD, long double stopJD) override { return double(stopJD - startJD) / 4.0; }
169
170private:
172};
Implements algorithms to find close approaches of two objects on the sky.
The EclipseEvent class.
virtual QString getEclipsingObjectName()=0
getEclipsingObjectName
ECLIPSE_TYPE
The ECLIPSE_TYPE_T enum.
virtual QString getEclipsedObjectName()=0
getEclipsingObjectName
virtual void slotShowDetails()
showDetails
virtual SkyObject * getEclipsingObjectFromSkyComposite()=0
getEclipsingObjectFromSkyComposite
long double getJD()
getJD
virtual bool hasDetails()
hasDetails
GeoLocation getGeolocation()
getGeolocation
ECLIPSE_TYPE getType()
getType
virtual QString getExtraInfo()
getExtraInfo
The EclipseHandler class.
void signalProgress(int)
signalProgress
QVector< EclipseEvent_s > getEvents()
getEvents
virtual double findInitialStep(long double startJD, long double stopJD) override
findStep
void signalEventFound(EclipseEvent_s event)
signalEventFound
void signalComputationFinished()
signalComputationFinished
virtual EclipseVector computeEclipses(long double startJD, long double endJD)=0
compute
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
A subclass of TrailObject that provides additional information needed for most solar system objects.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
Q_OBJECTQ_OBJECT
virtual bool event(QEvent *e)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.