Kstars

skymapcomposite.h
1 /*
2  SPDX-FileCopyrightText: 2005 Thomas Kabelmann <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "culturelist.h"
10 #include "ksnumbers.h"
11 #include "skycomposite.h"
12 #include "skylabeler.h"
13 #include "skymesh.h"
14 #include "skyobject.h"
15 #include "config-kstars.h"
16 #include <QList>
17 
18 #include <memory>
19 
20 class QPolygonF;
21 
22 class ArtificialHorizonComponent;
24 class ConstellationBoundaryLines;
25 class ConstellationLines;
27 class ConstellationsArt;
28 class CatalogsComponent;
29 class DeepStarComponent;
30 class Ecliptic;
31 class Equator;
33 class FlagComponent;
36 class HorizonComponent;
37 class KSPlanet;
38 class KSPlanetBase;
39 class MilkyWay;
41 class SkyMap;
42 class SkyObject;
44 class StarComponent;
47 class HIPSComponent;
48 class TerrainComponent;
50 class MosaicComponent;
51 
52 /**
53  * @class SkyMapComposite
54  *
55  * SkyMapComposite is the root object in the object hierarchy of the sky map.
56  * All requests to update, init, draw etc. will be done with this class.
57  * The requests will be delegated to it's children.
58  * The object hierarchy will created by adding new objects via addComponent().
59  *
60  * @author Thomas Kabelmann
61  * @version 0.1
62  */
63 class SkyMapComposite : public QObject, public SkyComposite
64 {
65  Q_OBJECT
66 
67  public:
68  /**
69  * Constructor
70  * @p parent pointer to the parent SkyComponent
71  */
72  explicit SkyMapComposite(SkyComposite *parent = nullptr);
73 
74  virtual ~SkyMapComposite() override = default;
75 
76  void update(KSNumbers *num = nullptr) override;
77 
78  /**
79  * @short Delegate planet position updates to the SolarSystemComposite
80  *
81  * Planet positions change over time, so they need to be recomputed
82  * periodically, but not on every call to update(). This function
83  * will recompute the positions of all solar system bodies except the
84  * Earth's Moon, Jupiter's Moons AND Saturn Moons (because these objects' positions
85  * change on a much more rapid timescale).
86  * @p num Pointer to the KSNumbers object
87  * @sa update()
88  * @sa updateMoons()
89  * @sa SolarSystemComposite::updatePlanets()
90  */
91  void updateSolarSystemBodies(KSNumbers *num) override;
92 
93  /**
94  * @short Delegate moon position updates to the SolarSystemComposite
95  *
96  * Planet positions change over time, so they need to be recomputed
97  * periodically, but not on every call to update(). This function
98  * will recompute the positions of the Earth's Moon and Jupiter's four
99  * Galilean moons. These objects are done separately from the other
100  * solar system bodies, because their positions change more rapidly,
101  * and so updateMoons() must be called more often than updatePlanets().
102  * @p num Pointer to the KSNumbers object
103  * @sa update()
104  * @sa updatePlanets()
105  * @sa SolarSystemComposite::updateMoons()
106  */
107  void updateMoons(KSNumbers *num) override;
108 
109  /**
110  * @short Delegate draw requests to all sub components
111  * @p psky Reference to the QPainter on which to paint
112  */
113  void draw(SkyPainter *skyp) override;
114 
115  /**
116  * @return the object nearest a given point in the sky.
117  * @param p The point to find an object near
118  * @param maxrad The maximum search radius, in Degrees
119  * @note the angular separation to the matched object is returned
120  * through the maxrad variable.
121  */
122  SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
123 
124  /**
125  * @return the star nearest a given point in the sky.
126  * @param p The point to find a star near
127  * @param maxrad The maximum search radius, in Degrees
128  * @note the angular separation to the matched star is returned
129  * through the maxrad variable.
130  */
131  SkyObject *starNearest(SkyPoint *p, double &maxrad);
132 
133  /**
134  * @short Search the children of this SkyMapComposite for
135  * a SkyObject whose name matches the argument.
136  *
137  * The objects' primary, secondary and long-form names will
138  * all be checked for a match.
139  * @note Overloaded from SkyComposite. In this version, we search
140  * the most likely object classes first to be more efficient.
141  * @p name the name to be matched
142  * @p exact If true, it will return an exact match (default), otherwise it can return
143  * a partial match.
144  * @return a pointer to the SkyObject whose name matches
145  * the argument, or a nullptr pointer if no match was found.
146  */
147  SkyObject *findByName(const QString &name, bool exact = true) override;
148 
149  /**
150  * @return the list of objects in the region defined by skypoints
151  * @param p1 first sky point (top-left vertex of rectangular region)
152  * @param p2 second sky point (bottom-right vertex of rectangular region)
153  */
155 
156  bool addNameLabel(SkyObject *o);
157  bool removeNameLabel(SkyObject *o);
158 
159  void reloadDeepSky();
160  void reloadAsteroids();
161  void reloadComets();
162  void reloadCLines();
163  void reloadCNames();
164  void reloadConstellationArt();
165 #ifndef KSTARS_LITE
166  FlagComponent *flags();
167 #endif
168  SatellitesComponent *satellites();
169  SupernovaeComponent *supernovaeComponent();
170  ArtificialHorizonComponent *artificialHorizon();
171  ImageOverlayComponent *imageOverlay();
172 
173  /** Getters for SkyComponents **/
175  {
176  return m_Horizon;
177  }
178 
179  inline ConstellationBoundaryLines *constellationBoundary()
180  {
181  return m_CBoundLines;
182  }
183  inline ConstellationLines *constellationLines()
184  {
185  return m_CLines;
186  }
187 
188  inline Ecliptic *ecliptic()
189  {
190  return m_Ecliptic;
191  }
192  inline Equator *equator()
193  {
194  return m_Equator;
195  }
196 
197  inline EquatorialCoordinateGrid *equatorialCoordGrid()
198  {
199  return m_EquatorialCoordinateGrid;
200  }
201  inline HorizontalCoordinateGrid *horizontalCoordGrid()
202  {
203  return m_HorizontalCoordinateGrid;
204  }
205  inline LocalMeridianComponent *localMeridianComponent()
206  {
207  return m_LocalMeridianComponent;
208  }
209 
210  inline ConstellationArtComponent *constellationArt()
211  {
212  return m_ConstellationArt;
213  }
214 
215  inline SolarSystemComposite *solarSystemComposite()
216  {
217  return m_SolarSystem;
218  }
219 
220  inline ConstellationNamesComponent *constellationNamesComponent()
221  {
222  return m_CNames;
223  }
224 
225  inline CatalogsComponent *catalogsComponent()
226  {
227  return m_Catalogs;
228  }
229 
230  inline MilkyWay *milkyWay()
231  {
232  return m_MilkyWay;
233  }
234 
235 #ifdef HAVE_INDI
236  inline MosaicComponent *mosaicComponent()
237  {
238  return m_Mosaic;
239  }
240 #endif
241 
242  //Accessors for StarComponent
243  SkyObject *findStarByGenetiveName(const QString name);
244  void emitProgressText(const QString &message) override;
245  QList<SkyObject *> &labelObjects()
246  {
247  return m_LabeledObjects;
248  }
249 
250  const QList<SkyObject *> &constellationNames() const;
251  const QList<SkyObject *> &stars() const;
252  const QList<SkyObject *> &asteroids() const;
253  const QList<SkyObject *> &comets() const;
254  const QList<SkyObject *> &supernovae() const;
255  QList<SkyObject *> planets();
256  // QList<SkyObject*> moons();
257 
258  const QList<SkyObject *> *getSkyObjectsList(SkyObject::TYPE t);
259 
260  KSPlanet *earth();
261  KSPlanetBase *planet(int n);
262  QStringList getCultureNames();
263  QString getCultureName(int index);
264  QString currentCulture();
265  void setCurrentCulture(QString culture);
266  bool isLocalCNames();
267 
268  inline TargetListComponent *getStarHopRouteList()
269  {
270  return m_StarHopRouteList;
271  }
272  signals:
273  void progressText(const QString &message);
274 
275  private:
276  QHash<int, QStringList> &getObjectNames() override;
277  QHash<int, QVector<QPair<QString, const SkyObject *>>> &getObjectLists() override;
278 
279  std::unique_ptr<CultureList> m_Cultures;
280  ConstellationBoundaryLines *m_CBoundLines{ nullptr };
281  ConstellationNamesComponent *m_CNames{ nullptr };
282  ConstellationLines *m_CLines{ nullptr };
283  ConstellationArtComponent *m_ConstellationArt{ nullptr };
284  EquatorialCoordinateGrid *m_EquatorialCoordinateGrid{ nullptr };
285  HorizontalCoordinateGrid *m_HorizontalCoordinateGrid{ nullptr };
286  LocalMeridianComponent *m_LocalMeridianComponent{ nullptr };
287  CatalogsComponent *m_Catalogs{ nullptr };
288  Equator *m_Equator{ nullptr };
289  ArtificialHorizonComponent *m_ArtificialHorizon{ nullptr };
290  Ecliptic *m_Ecliptic{ nullptr };
291  HorizonComponent *m_Horizon{ nullptr };
292  MilkyWay *m_MilkyWay{ nullptr };
293  SolarSystemComposite *m_SolarSystem{ nullptr };
294  StarComponent *m_Stars{ nullptr };
295 #ifndef KSTARS_LITE
296  FlagComponent *m_Flags { nullptr };
297  HIPSComponent *m_HiPS{ nullptr };
298  TerrainComponent *m_Terrain{ nullptr };
299  ImageOverlayComponent *m_ImageOverlay{ nullptr };
300 #ifdef HAVE_INDI
301  MosaicComponent *m_Mosaic { nullptr };
302 #endif
303 #endif
304  TargetListComponent *m_ObservingList { nullptr };
305  TargetListComponent *m_StarHopRouteList{ nullptr };
306  SatellitesComponent *m_Satellites{ nullptr };
307  SupernovaeComponent *m_Supernovae{ nullptr };
308 
309  SkyMesh *m_skyMesh;
310  std::unique_ptr<SkyLabeler> m_skyLabeler;
311 
312  KSNumbers m_reindexNum;
313 
314  QList<DeepStarComponent *> m_DeepStars;
315 
316  QList<SkyObject *> m_LabeledObjects;
317  QHash<int, QStringList> m_ObjectNames;
319  QHash<QString, QString> m_ConstellationNames;
320 };
Q_OBJECTQ_OBJECT
Represents the stars on the sky map. For optimization reasons the stars are not separate objects and ...
Definition: starcomponent.h:47
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
HorizonComponent * horizon()
Getters for SkyComponents.
Class that handles drawing of MilkyWay (both filled and non-filled)
Definition: milkyway.h:24
QList< SkyObject * > findObjectsInArea(const SkyPoint &p1, const SkyPoint &p2)
void emitProgressText(const QString &message) override
Emit signal about progress.
void updateMoons(KSNumbers *num) override
Delegate moon position updates to the SolarSystemComposite.
void draw(SkyPainter *skyp) override
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
void updateSolarSystemBodies(KSNumbers *num) override
Delegate planet position updates to the SolarSystemComposite.
void update(KSNumbers *num=nullptr) override
Delegate update-position requests to all sub components.
Draws things on the sky, without regard to backend.
Definition: skypainter.h:39
Provides necessary information about objects in the solar system.
Definition: ksplanet.h:32
Highlights objects present in certain lists by drawing "target" symbols around them.
This class encapsulates Supernovae.
Canvas widget for displaying the sky bitmap; also handles user interaction events.
Definition: skymap.h:53
SkyMapComposite(SkyComposite *parent=nullptr)
Constructor parent pointer to the parent SkyComponent.
Represents objects loaded from an sqlite backed, trixel indexed catalog.
Represents a flag on the sky map. Each flag is composed by a SkyPoint where coordinates are stored,...
Definition: flagcomponent.h:33
Information about a ConstellationsArt object. This class represents a constellation image.
SkyObject * starNearest(SkyPoint *p, double &maxrad)
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
QString message
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 04:03:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.