File indexing completed on 2024-05-05 03:50:42
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Rene Kuettner <rene@bitkanal.net> 0004 // 0005 0006 #ifndef MARBLE_ECLIPSESITEM_H 0007 #define MARBLE_ECLIPSESITEM_H 0008 0009 #include <QObject> 0010 #include <QDateTime> 0011 0012 #include "GeoDataLineString.h" 0013 #include "GeoDataCoordinates.h" 0014 #include "GeoDataLinearRing.h" 0015 0016 #include <eclsolar.h> 0017 0018 namespace Marble 0019 { 0020 0021 /** 0022 * @brief The representation of an eclipse event 0023 * 0024 * This class represents an eclipse event on earth. It calculates all 0025 * basic information like date and visibility upon initialization. 0026 * Expensive calculations like boundary polygons are done the first time 0027 * they are requested. 0028 * 0029 * The calculations are done using the eclsolar backend that has to be 0030 * passed to the constructor. 0031 */ 0032 class EclipsesItem : public QObject 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 0038 /** 0039 * @brief A type of an eclipse event 0040 */ 0041 enum EclipsePhase { 0042 TotalMoon = -4, 0043 PartialMoon = -3, 0044 PenumbralMoon = -1, 0045 PartialSun = 1, 0046 NonCentralAnnularSun = 2, 0047 NonCentralTotalSun = 3, 0048 AnnularSun = 4, 0049 TotalSun = 5, 0050 AnnularTotalSun = 6 0051 }; 0052 0053 /** 0054 * @brief Construct the EclipseItem object and trigger basic calculations 0055 * @param ecl The EclSolar backend 0056 * @param index The object index 0057 * @param parent The parent object 0058 */ 0059 explicit EclipsesItem( EclSolar *ecl, int index, QObject *parent = nullptr ); 0060 0061 ~EclipsesItem() override; 0062 0063 /** 0064 * @brief The index of the eclipse event 0065 * 0066 * Returns the index of the eclipse event. 0067 * 0068 * @return The eclipse events index. 0069 */ 0070 int index() const; 0071 0072 /** 0073 * @brief Check if the event takes place at a given datetime 0074 * @param dateTime The date time to check 0075 * 0076 * Checks whether or not this eclipse event takes place at the given 0077 * @p dateTime. This is true if @p dateTime is between the global 0078 * start and end dates of the event. 0079 * 0080 * @return True if the event takes place at @p dateTime or false otherwise. 0081 */ 0082 bool takesPlaceAt( const QDateTime &dateTime ) const; 0083 0084 /** 0085 * @brief Returns the phase of this eclipse event 0086 * @return the phase or type of this eclipse event 0087 * @see phaseText 0088 */ 0089 EclipsesItem::EclipsePhase phase() const; 0090 0091 0092 /** 0093 * @brief Returns an icon of the eclipse type 0094 * @return an icon representing the eclipse's type 0095 */ 0096 QIcon icon() const; 0097 0098 /** 0099 * @brief Returns a human readable representation of the eclipse type 0100 * @return A string representing the eclipse's type 0101 * @see phase 0102 */ 0103 QString phaseText() const; 0104 0105 /** 0106 * @brief Returns the date of the eclipse event's maximum 0107 * @return The DateTime of the eclipse's maximum 0108 * @see maxLocation 0109 */ 0110 const QDateTime& dateMaximum() const; 0111 0112 /** 0113 * @brief Returns the start date of the eclipse's partial phase 0114 * @return The start date of the partial phase 0115 * @see endDatePartial 0116 */ 0117 const QDateTime& startDatePartial() const; 0118 0119 /** 0120 * @brief Returns the end date of the eclipse's partial phase 0121 * @return The end date of the partial phase 0122 * @see startDatePartial 0123 */ 0124 const QDateTime& endDatePartial() const; 0125 0126 /** 0127 * @brief Returns the number of hours the partial phase takes place 0128 * @return The number of hours of the partial phase 0129 * @see startDatePartial, endDatePartial 0130 */ 0131 int partialDurationHours() const; 0132 0133 /** 0134 * @brief Returns the start date of the eclipse's total phase 0135 * 0136 * If the eclipse has a total phase, the date and time of its beginning 0137 * is returned. If this is no total eclipse, an invalid datetime object 0138 * will be returned. 0139 * 0140 * @return The start date of the total phase or an invalid date 0141 * @see endDateTotal 0142 */ 0143 const QDateTime& startDateTotal() const; 0144 0145 /** 0146 * @brief Returns the end date of the eclipse's total phase 0147 * 0148 * If the eclipse has a total phase, the date and time of its ending 0149 * is returned. If this is no total eclipse, an invalid datetime object 0150 * will be returned. 0151 * 0152 * @return The end date of the total phase or an invalid date 0153 * @see startDateTotal 0154 */ 0155 const QDateTime& endDateTotal() const; 0156 0157 /** 0158 * @brief Return the eclipse's magnitude 0159 * @return The magnitude of the eclipse 0160 */ 0161 double magnitude() const; 0162 0163 /** 0164 * @brief Return the coordinates of the eclipse's maximum 0165 * @return GeoDataCoordinates of the eclipse's maximum 0166 * @see dateMaximum 0167 */ 0168 const GeoDataCoordinates& maxLocation(); 0169 0170 /** 0171 * @brief The eclipse's central line 0172 * @return The central line of the eclipse 0173 */ 0174 const GeoDataLineString& centralLine(); 0175 0176 /** 0177 * @brief Return the eclipse's umbra 0178 * @return The eclipse's umbra 0179 */ 0180 const GeoDataLinearRing& umbra(); 0181 0182 /** 0183 * @brief Return the eclipse's southern penumbra 0184 * @return The eclipse's southern penumbra 0185 */ 0186 const GeoDataLineString& southernPenumbra(); 0187 0188 /** 0189 * @brief Return the eclipse's northern penumbra 0190 * @return The eclipse's northern umbra 0191 */ 0192 const GeoDataLineString& northernPenumbra(); 0193 0194 /** 0195 * @brief Return the eclipse's sun boundaries 0196 * @return The eclipse's sun boundaries 0197 */ 0198 const QList<GeoDataLinearRing>& sunBoundaries(); 0199 0200 /** 0201 * @brief Return the shadow cone of the umbra 0202 * @return The shadow cone of the umbra 0203 */ 0204 GeoDataLinearRing shadowConeUmbra(); 0205 0206 /** 0207 * @brief Return the shadow cone of the penumbra 0208 * @return The shadow cone of the penumbra 0209 */ 0210 GeoDataLinearRing shadowConePenumbra(); 0211 0212 /** 0213 * @brief Return the shadow cone of the penumbra at 60 percent magnitude 0214 * @return The shadow cone of the penumbra at 60 percent magnitude 0215 */ 0216 GeoDataLinearRing shadowCone60MagPenumbra(); 0217 0218 private: 0219 /** 0220 * @brief Initialize the eclipse item 0221 * 0222 * Initializes all properties of the eclipse item and does basic 0223 * calculations. Expensive calculations are done as required. 0224 * 0225 * @see calculate 0226 */ 0227 void initialize(); 0228 0229 /** 0230 * @brief Do detailed calculations 0231 * 0232 * Do the expensive calculations (like shadow cones) for this eclipse 0233 * event. This is normally called on the first request of such data. 0234 */ 0235 void calculate(); 0236 0237 EclSolar *m_ecl; 0238 int m_index; 0239 bool m_calculationsNeedUpdate; 0240 bool m_isTotal; 0241 QDateTime m_dateMaximum; 0242 QDateTime m_startDatePartial; 0243 QDateTime m_endDatePartial; 0244 QDateTime m_startDateTotal; 0245 QDateTime m_endDateTotal; 0246 EclipsesItem::EclipsePhase m_phase; 0247 double m_magnitude; 0248 0249 GeoDataCoordinates m_maxLocation; 0250 GeoDataLineString m_centralLine; 0251 GeoDataLinearRing m_umbra; 0252 GeoDataLineString m_southernPenumbra; 0253 GeoDataLineString m_northernPenumbra; 0254 GeoDataLinearRing m_shadowConeUmbra; 0255 GeoDataLinearRing m_shadowConePenumbra; 0256 GeoDataLinearRing m_shadowCone60MagPenumbra; 0257 QList<GeoDataLinearRing> m_sunBoundaries; 0258 }; 0259 0260 } 0261 0262 #endif // MARBLE_ECLIPSESITEM_H 0263