File indexing completed on 2024-03-24 15:18:02
0001 /* 0002 SPDX-FileCopyrightText: 2018 Valentin Boettcher <valentin@boettcher.cf> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 #include "geolocation.h" 0009 #include "approachsolver.h" 0010 #include "skycomponents/typedef.h" 0011 0012 class KSPlanetBase; 0013 0014 /** 0015 * @brief The EclipseEvent class 0016 * @short Abstract container/interface for a eclipse event. 0017 * @note We do not use the QObject hierarchy here as it would be inefficient 0018 */ 0019 class EclipseEvent : public QObject { 0020 Q_OBJECT 0021 0022 public: 0023 /** 0024 * @brief The ECLIPSE_TYPE_T enum 0025 * @short Basic eclipse type. May be supplemented 0026 * by subclasses. 0027 */ 0028 enum ECLIPSE_TYPE { 0029 PARTIAL, 0030 FULL 0031 }; 0032 0033 EclipseEvent(long double jd, GeoLocation geoPlace, ECLIPSE_TYPE type); 0034 0035 virtual ~EclipseEvent(); // empty for now 0036 0037 /** 0038 * @brief getJD 0039 * @return the julian date of the event 0040 */ 0041 long double getJD() { return m_jd; } 0042 0043 /** 0044 * @brief getExtraInfo 0045 * @return information to display in an extra column 0046 * of the overview table. 0047 */ 0048 virtual QString getExtraInfo() { return ""; } 0049 0050 /** 0051 * @brief getType 0052 * @return the type of the eclipse 0053 */ 0054 ECLIPSE_TYPE getType() { return m_type; } 0055 0056 /** 0057 * @brief getEclipsingObjectName 0058 * @return the name of the eclipsing object 0059 * @note maybe store those objects as clones... 0060 */ 0061 virtual QString getEclipsingObjectName() = 0; 0062 0063 /** 0064 * @brief getEclipsingObjectName 0065 * @return the name of the eclipsed object 0066 * @note maybe store those objects as clones... 0067 */ 0068 virtual QString getEclipsedObjectName() = 0; 0069 0070 /** 0071 * @brief getGeolocation 0072 * @return geolocation for which the event is valid 0073 */ 0074 GeoLocation getGeolocation() { return m_geoPlace; } 0075 0076 /** 0077 * @brief getEclipsingObjectFromSkyComposite 0078 * @return a pointer to the skymap instance of the ecl. obj. 0079 */ 0080 virtual SkyObject * getEclipsingObjectFromSkyComposite() = 0; 0081 0082 /** 0083 * @brief hasDetails 0084 * @return whether a details widget can be shown 0085 */ 0086 virtual bool hasDetails() { return false; } 0087 0088 public slots: 0089 /** 0090 * @brief showDetails 0091 * @short (if implemented) shows a widget with details about the eclipse 0092 */ 0093 virtual void slotShowDetails() { return; } 0094 0095 private: 0096 ECLIPSE_TYPE m_type; 0097 GeoLocation m_geoPlace; 0098 0099 /** 0100 * @brief jd - date of the event 0101 */ 0102 long double m_jd; 0103 }; 0104 0105 /** 0106 * @brief The EclipseHandler class 0107 * 0108 * This is a base class for providing a common interface 0109 * for eclipse events which can be quite different in nature. It is 0110 * meant to be subclassed. (Check LunarEclipseHandler as an example) 0111 * 0112 * @todo remove uglieness from KSConjunct (export m_object... functionality to separate class!, 0113 * that findinitialstepsize isn't nice either) 0114 * 0115 * @note I've integrated the `findDetails` stuff in the eclipse handler because it already has 0116 * the `beef` it takes (instances and methods). OOP is not always the way. 0117 */ 0118 class EclipseHandler : public ApproachSolver 0119 { 0120 Q_OBJECT 0121 public: 0122 typedef QVector<EclipseEvent_s> EclipseVector; 0123 0124 explicit EclipseHandler(QObject * parent = nullptr); 0125 virtual ~EclipseHandler() override; 0126 0127 /** 0128 * @brief compute 0129 * @short Implements the details for finding *all* the eclipses 0130 * in a given time-frame. Should call findEclipse intelligently. 0131 * e.g. only if the moon is full for lunar eclipses et-cetera 0132 * 0133 * @returns A vector of shared pointers to eclipse events. 0134 */ 0135 virtual EclipseVector computeEclipses(long double startJD, long double endJD) = 0; 0136 0137 /** 0138 * @brief getEvents 0139 * @short May be used if the return value of computeEclipses is being ignored. 0140 * @note The underlying vector changes after every call to computeEclipses. 0141 * 0142 * @return A vector of shared pointers to eclipse events. 0143 */ 0144 QVector<EclipseEvent_s> getEvents() { return m_events; } 0145 0146 signals: 0147 /** 0148 * @brief signalEventFound 0149 * @short A signal to be dispatched as soon as a new Event is found. 0150 * @note Has to emitted by a subclass! 0151 * @param event 0152 */ 0153 void signalEventFound(EclipseEvent_s event); 0154 0155 /** 0156 * @brief signalProgress 0157 * @short gives the progress of the computation in percent 0158 */ 0159 void signalProgress(int); 0160 0161 /** 0162 * @brief signalComputationFinished 0163 * @short signals the end of the computation 0164 */ 0165 void signalComputationFinished(); 0166 0167 protected: 0168 virtual double findInitialStep(long double startJD, long double stopJD) override { return double(stopJD - startJD) / 4.0; } 0169 0170 private: 0171 QVector<EclipseEvent_s> m_events; 0172 };