File indexing completed on 2025-02-16 06:40:47
0001 /* 0002 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "culturelist.h" 0010 #include "ksnumbers.h" 0011 #include "skycomposite.h" 0012 #include "skylabeler.h" 0013 #include "skymesh.h" 0014 #include "skyobject.h" 0015 #include "config-kstars.h" 0016 #include <QList> 0017 0018 #include <memory> 0019 0020 class QPolygonF; 0021 0022 class ArtificialHorizonComponent; 0023 class ConstellationArtComponent; 0024 class ConstellationBoundaryLines; 0025 class ConstellationLines; 0026 class ConstellationNamesComponent; 0027 class ConstellationsArt; 0028 class CatalogsComponent; 0029 class DeepStarComponent; 0030 class Ecliptic; 0031 class Equator; 0032 class EquatorialCoordinateGrid; 0033 class FlagComponent; 0034 class HorizontalCoordinateGrid; 0035 class LocalMeridianComponent; 0036 class HorizonComponent; 0037 class KSPlanet; 0038 class KSPlanetBase; 0039 class MilkyWay; 0040 class SatellitesComponent; 0041 class SkyMap; 0042 class SkyObject; 0043 class SolarSystemComposite; 0044 class StarComponent; 0045 class SupernovaeComponent; 0046 class TargetListComponent; 0047 class HIPSComponent; 0048 class TerrainComponent; 0049 class ImageOverlayComponent; 0050 class MosaicComponent; 0051 0052 /** 0053 * @class SkyMapComposite 0054 * 0055 * SkyMapComposite is the root object in the object hierarchy of the sky map. 0056 * All requests to update, init, draw etc. will be done with this class. 0057 * The requests will be delegated to it's children. 0058 * The object hierarchy will created by adding new objects via addComponent(). 0059 * 0060 * @author Thomas Kabelmann 0061 * @version 0.1 0062 */ 0063 class SkyMapComposite : public QObject, public SkyComposite 0064 { 0065 Q_OBJECT 0066 0067 public: 0068 /** 0069 * Constructor 0070 * @p parent pointer to the parent SkyComponent 0071 */ 0072 explicit SkyMapComposite(SkyComposite *parent = nullptr); 0073 0074 virtual ~SkyMapComposite() override = default; 0075 0076 void update(KSNumbers *num = nullptr) override; 0077 0078 /** 0079 * @short Delegate planet position updates to the SolarSystemComposite 0080 * 0081 * Planet positions change over time, so they need to be recomputed 0082 * periodically, but not on every call to update(). This function 0083 * will recompute the positions of all solar system bodies except the 0084 * Earth's Moon, Jupiter's Moons AND Saturn Moons (because these objects' positions 0085 * change on a much more rapid timescale). 0086 * @p num Pointer to the KSNumbers object 0087 * @sa update() 0088 * @sa updateMoons() 0089 * @sa SolarSystemComposite::updatePlanets() 0090 */ 0091 void updateSolarSystemBodies(KSNumbers *num) override; 0092 0093 /** 0094 * @short Delegate moon position updates to the SolarSystemComposite 0095 * 0096 * Planet positions change over time, so they need to be recomputed 0097 * periodically, but not on every call to update(). This function 0098 * will recompute the positions of the Earth's Moon and Jupiter's four 0099 * Galilean moons. These objects are done separately from the other 0100 * solar system bodies, because their positions change more rapidly, 0101 * and so updateMoons() must be called more often than updatePlanets(). 0102 * @p num Pointer to the KSNumbers object 0103 * @sa update() 0104 * @sa updatePlanets() 0105 * @sa SolarSystemComposite::updateMoons() 0106 */ 0107 void updateMoons(KSNumbers *num) override; 0108 0109 /** 0110 * @short Delegate draw requests to all sub components 0111 * @p psky Reference to the QPainter on which to paint 0112 */ 0113 void draw(SkyPainter *skyp) override; 0114 0115 /** 0116 * @return the object nearest a given point in the sky. 0117 * @param p The point to find an object near 0118 * @param maxrad The maximum search radius, in Degrees 0119 * @note the angular separation to the matched object is returned 0120 * through the maxrad variable. 0121 */ 0122 SkyObject *objectNearest(SkyPoint *p, double &maxrad) override; 0123 0124 /** 0125 * @return the star nearest a given point in the sky. 0126 * @param p The point to find a star near 0127 * @param maxrad The maximum search radius, in Degrees 0128 * @note the angular separation to the matched star is returned 0129 * through the maxrad variable. 0130 */ 0131 SkyObject *starNearest(SkyPoint *p, double &maxrad); 0132 0133 /** 0134 * @short Search the children of this SkyMapComposite for 0135 * a SkyObject whose name matches the argument. 0136 * 0137 * The objects' primary, secondary and long-form names will 0138 * all be checked for a match. 0139 * @note Overloaded from SkyComposite. In this version, we search 0140 * the most likely object classes first to be more efficient. 0141 * @p name the name to be matched 0142 * @p exact If true, it will return an exact match (default), otherwise it can return 0143 * a partial match. 0144 * @return a pointer to the SkyObject whose name matches 0145 * the argument, or a nullptr pointer if no match was found. 0146 */ 0147 SkyObject *findByName(const QString &name, bool exact = true) override; 0148 0149 /** 0150 * @return the list of objects in the region defined by skypoints 0151 * @param p1 first sky point (top-left vertex of rectangular region) 0152 * @param p2 second sky point (bottom-right vertex of rectangular region) 0153 */ 0154 QList<SkyObject *> findObjectsInArea(const SkyPoint &p1, const SkyPoint &p2); 0155 0156 bool addNameLabel(SkyObject *o); 0157 bool removeNameLabel(SkyObject *o); 0158 0159 void reloadDeepSky(); 0160 void reloadAsteroids(); 0161 void reloadComets(); 0162 void reloadCLines(); 0163 void reloadCNames(); 0164 void reloadConstellationArt(); 0165 #ifndef KSTARS_LITE 0166 FlagComponent *flags(); 0167 #endif 0168 SatellitesComponent *satellites(); 0169 SupernovaeComponent *supernovaeComponent(); 0170 ArtificialHorizonComponent *artificialHorizon(); 0171 ImageOverlayComponent *imageOverlay(); 0172 0173 /** Getters for SkyComponents **/ 0174 inline HorizonComponent *horizon() 0175 { 0176 return m_Horizon; 0177 } 0178 0179 inline ConstellationBoundaryLines *constellationBoundary() 0180 { 0181 return m_CBoundLines; 0182 } 0183 inline ConstellationLines *constellationLines() 0184 { 0185 return m_CLines; 0186 } 0187 0188 inline Ecliptic *ecliptic() 0189 { 0190 return m_Ecliptic; 0191 } 0192 inline Equator *equator() 0193 { 0194 return m_Equator; 0195 } 0196 0197 inline EquatorialCoordinateGrid *equatorialCoordGrid() 0198 { 0199 return m_EquatorialCoordinateGrid; 0200 } 0201 inline HorizontalCoordinateGrid *horizontalCoordGrid() 0202 { 0203 return m_HorizontalCoordinateGrid; 0204 } 0205 inline LocalMeridianComponent *localMeridianComponent() 0206 { 0207 return m_LocalMeridianComponent; 0208 } 0209 0210 inline ConstellationArtComponent *constellationArt() 0211 { 0212 return m_ConstellationArt; 0213 } 0214 0215 inline SolarSystemComposite *solarSystemComposite() 0216 { 0217 return m_SolarSystem; 0218 } 0219 0220 inline ConstellationNamesComponent *constellationNamesComponent() 0221 { 0222 return m_CNames; 0223 } 0224 0225 inline CatalogsComponent *catalogsComponent() 0226 { 0227 return m_Catalogs; 0228 } 0229 0230 inline MilkyWay *milkyWay() 0231 { 0232 return m_MilkyWay; 0233 } 0234 0235 #ifdef HAVE_INDI 0236 inline MosaicComponent *mosaicComponent() 0237 { 0238 return m_Mosaic; 0239 } 0240 #endif 0241 0242 //Accessors for StarComponent 0243 SkyObject *findStarByGenetiveName(const QString name); 0244 void emitProgressText(const QString &message) override; 0245 QList<SkyObject *> &labelObjects() 0246 { 0247 return m_LabeledObjects; 0248 } 0249 0250 const QList<SkyObject *> &constellationNames() const; 0251 const QList<SkyObject *> &stars() const; 0252 const QList<SkyObject *> &asteroids() const; 0253 const QList<SkyObject *> &comets() const; 0254 const QList<SkyObject *> &supernovae() const; 0255 QList<SkyObject *> planets(); 0256 // QList<SkyObject*> moons(); 0257 0258 const QList<SkyObject *> *getSkyObjectsList(SkyObject::TYPE t); 0259 0260 KSPlanet *earth(); 0261 KSPlanetBase *planet(int n); 0262 QStringList getCultureNames(); 0263 QString getCultureName(int index); 0264 QString currentCulture(); 0265 void setCurrentCulture(QString culture); 0266 bool isLocalCNames(); 0267 0268 inline TargetListComponent *getStarHopRouteList() 0269 { 0270 return m_StarHopRouteList; 0271 } 0272 signals: 0273 void progressText(const QString &message); 0274 0275 private: 0276 QHash<int, QStringList> &getObjectNames() override; 0277 QHash<int, QVector<QPair<QString, const SkyObject *>>> &getObjectLists() override; 0278 0279 std::unique_ptr<CultureList> m_Cultures; 0280 ConstellationBoundaryLines *m_CBoundLines{ nullptr }; 0281 ConstellationNamesComponent *m_CNames{ nullptr }; 0282 ConstellationLines *m_CLines{ nullptr }; 0283 ConstellationArtComponent *m_ConstellationArt{ nullptr }; 0284 EquatorialCoordinateGrid *m_EquatorialCoordinateGrid{ nullptr }; 0285 HorizontalCoordinateGrid *m_HorizontalCoordinateGrid{ nullptr }; 0286 LocalMeridianComponent *m_LocalMeridianComponent{ nullptr }; 0287 CatalogsComponent *m_Catalogs{ nullptr }; 0288 Equator *m_Equator{ nullptr }; 0289 ArtificialHorizonComponent *m_ArtificialHorizon{ nullptr }; 0290 Ecliptic *m_Ecliptic{ nullptr }; 0291 HorizonComponent *m_Horizon{ nullptr }; 0292 MilkyWay *m_MilkyWay{ nullptr }; 0293 SolarSystemComposite *m_SolarSystem{ nullptr }; 0294 StarComponent *m_Stars{ nullptr }; 0295 #ifndef KSTARS_LITE 0296 FlagComponent *m_Flags { nullptr }; 0297 HIPSComponent *m_HiPS{ nullptr }; 0298 TerrainComponent *m_Terrain{ nullptr }; 0299 ImageOverlayComponent *m_ImageOverlay{ nullptr }; 0300 #ifdef HAVE_INDI 0301 MosaicComponent *m_Mosaic { nullptr }; 0302 #endif 0303 #endif 0304 TargetListComponent *m_ObservingList { nullptr }; 0305 TargetListComponent *m_StarHopRouteList{ nullptr }; 0306 SatellitesComponent *m_Satellites{ nullptr }; 0307 SupernovaeComponent *m_Supernovae{ nullptr }; 0308 0309 SkyMesh *m_skyMesh; 0310 std::unique_ptr<SkyLabeler> m_skyLabeler; 0311 0312 KSNumbers m_reindexNum; 0313 0314 QList<DeepStarComponent *> m_DeepStars; 0315 0316 QList<SkyObject *> m_LabeledObjects; 0317 QHash<int, QStringList> m_ObjectNames; 0318 QHash<int, QVector<QPair<QString, const SkyObject *>>> m_ObjectLists; 0319 QHash<QString, QString> m_ConstellationNames; 0320 };