Kstars

eclipsehandler.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 "geolocation.h"
9 #include "approachsolver.h"
10 #include "skycomponents/typedef.h"
11 
12 class 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  */
19 class EclipseEvent : public QObject {
20  Q_OBJECT
21 
22 public:
23  /**
24  * @brief The ECLIPSE_TYPE_T enum
25  * @short Basic eclipse type. May be supplemented
26  * by subclasses.
27  */
28  enum ECLIPSE_TYPE {
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  */
61  virtual QString getEclipsingObjectName() = 0;
62 
63  /**
64  * @brief getEclipsingObjectName
65  * @return the name of the eclipsed object
66  * @note maybe store those objects as clones...
67  */
68  virtual QString getEclipsedObjectName() = 0;
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 
88 public slots:
89  /**
90  * @brief showDetails
91  * @short (if implemented) shows a widget with details about the eclipse
92  */
93  virtual void slotShowDetails() { return; }
94 
95 private:
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 {
120  Q_OBJECT
121 public:
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 
146 signals:
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 
167 protected:
168  virtual double findInitialStep(long double startJD, long double stopJD) override { return double(stopJD - startJD) / 4.0; }
169 
170 private:
171  QVector<EclipseEvent_s> m_events;
172 };
Q_OBJECTQ_OBJECT
The EclipseEvent class.
void signalComputationFinished()
signalComputationFinished
virtual double findInitialStep(long double startJD, long double stopJD) override
findStep
virtual EclipseVector computeEclipses(long double startJD, long double endJD)=0
compute
virtual QString getExtraInfo()
getExtraInfo
virtual QString getEclipsingObjectName()=0
getEclipsingObjectName
ECLIPSE_TYPE getType()
getType
The EclipseHandler class.
virtual SkyObject * getEclipsingObjectFromSkyComposite()=0
getEclipsingObjectFromSkyComposite
void signalProgress(int)
signalProgress
virtual QString getEclipsedObjectName()=0
getEclipsingObjectName
virtual bool event(QEvent *e)
GeoLocation getGeolocation()
getGeolocation
Implements algorithms to find close approaches of two objects on the sky. A class that implements a m...
QVector< EclipseEvent_s > getEvents()
getEvents
virtual void slotShowDetails()
showDetails
virtual bool hasDetails()
hasDetails
void signalEventFound(EclipseEvent_s event)
signalEventFound
long double getJD()
getJD
ECLIPSE_TYPE
The ECLIPSE_TYPE_T enum.
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
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 Tue Aug 9 2022 04:06:02 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.