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;
49 class MosaicComponent;
50 
51 /**
52  * @class SkyMapComposite
53  *
54  * SkyMapComposite is the root object in the object hierarchy of the sky map.
55  * All requests to update, init, draw etc. will be done with this class.
56  * The requests will be delegated to it's children.
57  * The object hierarchy will created by adding new objects via addComponent().
58  *
59  * @author Thomas Kabelmann
60  * @version 0.1
61  */
62 class SkyMapComposite : public QObject, public SkyComposite
63 {
64  Q_OBJECT
65 
66  public:
67  /**
68  * Constructor
69  * @p parent pointer to the parent SkyComponent
70  */
71  explicit SkyMapComposite(SkyComposite *parent = nullptr);
72 
73  virtual ~SkyMapComposite() override = default;
74 
75  void update(KSNumbers *num = nullptr) override;
76 
77  /**
78  * @short Delegate planet position updates to the SolarSystemComposite
79  *
80  * Planet positions change over time, so they need to be recomputed
81  * periodically, but not on every call to update(). This function
82  * will recompute the positions of all solar system bodies except the
83  * Earth's Moon, Jupiter's Moons AND Saturn Moons (because these objects' positions
84  * change on a much more rapid timescale).
85  * @p num Pointer to the KSNumbers object
86  * @sa update()
87  * @sa updateMoons()
88  * @sa SolarSystemComposite::updatePlanets()
89  */
90  void updateSolarSystemBodies(KSNumbers *num) override;
91 
92  /**
93  * @short Delegate moon position updates to the SolarSystemComposite
94  *
95  * Planet positions change over time, so they need to be recomputed
96  * periodically, but not on every call to update(). This function
97  * will recompute the positions of the Earth's Moon and Jupiter's four
98  * Galilean moons. These objects are done separately from the other
99  * solar system bodies, because their positions change more rapidly,
100  * and so updateMoons() must be called more often than updatePlanets().
101  * @p num Pointer to the KSNumbers object
102  * @sa update()
103  * @sa updatePlanets()
104  * @sa SolarSystemComposite::updateMoons()
105  */
106  void updateMoons(KSNumbers *num) override;
107 
108  /**
109  * @short Delegate draw requests to all sub components
110  * @p psky Reference to the QPainter on which to paint
111  */
112  void draw(SkyPainter *skyp) override;
113 
114  /**
115  * @return the object nearest a given point in the sky.
116  * @param p The point to find an object near
117  * @param maxrad The maximum search radius, in Degrees
118  * @note the angular separation to the matched object is returned
119  * through the maxrad variable.
120  */
121  SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
122 
123  /**
124  * @return the star nearest a given point in the sky.
125  * @param p The point to find a star near
126  * @param maxrad The maximum search radius, in Degrees
127  * @note the angular separation to the matched star is returned
128  * through the maxrad variable.
129  */
130  SkyObject *starNearest(SkyPoint *p, double &maxrad);
131 
132  /**
133  * @short Search the children of this SkyMapComposite for
134  * a SkyObject whose name matches the argument.
135  *
136  * The objects' primary, secondary and long-form names will
137  * all be checked for a match.
138  * @note Overloaded from SkyComposite. In this version, we search
139  * the most likely object classes first to be more efficient.
140  * @p name the name to be matched
141  * @p exact If true, it will return an exact match (default), otherwise it can return
142  * a partial match.
143  * @return a pointer to the SkyObject whose name matches
144  * the argument, or a nullptr pointer if no match was found.
145  */
146  SkyObject *findByName(const QString &name, bool exact = true) override;
147 
148  /**
149  * @return the list of objects in the region defined by skypoints
150  * @param p1 first sky point (top-left vertex of rectangular region)
151  * @param p2 second sky point (bottom-right vertex of rectangular region)
152  */
154 
155  bool addNameLabel(SkyObject *o);
156  bool removeNameLabel(SkyObject *o);
157 
158  void reloadDeepSky();
159  void reloadAsteroids();
160  void reloadComets();
161  void reloadCLines();
162  void reloadCNames();
163  void reloadConstellationArt();
164 #ifndef KSTARS_LITE
165  FlagComponent *flags();
166 #endif
167  SatellitesComponent *satellites();
168  SupernovaeComponent *supernovaeComponent();
169  ArtificialHorizonComponent *artificialHorizon();
170 
171  /** Getters for SkyComponents **/
173  {
174  return m_Horizon;
175  }
176 
177  inline ConstellationBoundaryLines *constellationBoundary()
178  {
179  return m_CBoundLines;
180  }
181  inline ConstellationLines *constellationLines()
182  {
183  return m_CLines;
184  }
185 
186  inline Ecliptic *ecliptic()
187  {
188  return m_Ecliptic;
189  }
190  inline Equator *equator()
191  {
192  return m_Equator;
193  }
194 
195  inline EquatorialCoordinateGrid *equatorialCoordGrid()
196  {
197  return m_EquatorialCoordinateGrid;
198  }
199  inline HorizontalCoordinateGrid *horizontalCoordGrid()
200  {
201  return m_HorizontalCoordinateGrid;
202  }
203  inline LocalMeridianComponent *localMeridianComponent()
204  {
205  return m_LocalMeridianComponent;
206  }
207 
208  inline ConstellationArtComponent *constellationArt()
209  {
210  return m_ConstellationArt;
211  }
212 
213  inline SolarSystemComposite *solarSystemComposite()
214  {
215  return m_SolarSystem;
216  }
217 
218  inline ConstellationNamesComponent *constellationNamesComponent()
219  {
220  return m_CNames;
221  }
222 
223  inline CatalogsComponent *catalogsComponent()
224  {
225  return m_Catalogs;
226  }
227 
228  inline MilkyWay *milkyWay()
229  {
230  return m_MilkyWay;
231  }
232 
233 #ifdef HAVE_INDI
234  inline MosaicComponent *mosaicComponent()
235  {
236  return m_Mosaic;
237  }
238 #endif
239 
240  //Accessors for StarComponent
241  SkyObject *findStarByGenetiveName(const QString name);
242  void emitProgressText(const QString &message) override;
243  QList<SkyObject *> &labelObjects()
244  {
245  return m_LabeledObjects;
246  }
247 
248  const QList<SkyObject *> &constellationNames() const;
249  const QList<SkyObject *> &stars() const;
250  const QList<SkyObject *> &asteroids() const;
251  const QList<SkyObject *> &comets() const;
252  const QList<SkyObject *> &supernovae() const;
253  QList<SkyObject *> planets();
254  // QList<SkyObject*> moons();
255 
256  const QList<SkyObject *> *getSkyObjectsList(SkyObject::TYPE t);
257 
258  KSPlanet *earth();
259  KSPlanetBase *planet(int n);
260  QStringList getCultureNames();
261  QString getCultureName(int index);
262  QString currentCulture();
263  void setCurrentCulture(QString culture);
264  bool isLocalCNames();
265 
266  inline TargetListComponent *getStarHopRouteList()
267  {
268  return m_StarHopRouteList;
269  }
270  signals:
271  void progressText(const QString &message);
272 
273  private:
274  QHash<int, QStringList> &getObjectNames() override;
275  QHash<int, QVector<QPair<QString, const SkyObject *>>> &getObjectLists() override;
276 
277  std::unique_ptr<CultureList> m_Cultures;
278  ConstellationBoundaryLines *m_CBoundLines{ nullptr };
279  ConstellationNamesComponent *m_CNames{ nullptr };
280  ConstellationLines *m_CLines{ nullptr };
281  ConstellationArtComponent *m_ConstellationArt{ nullptr };
282  EquatorialCoordinateGrid *m_EquatorialCoordinateGrid{ nullptr };
283  HorizontalCoordinateGrid *m_HorizontalCoordinateGrid{ nullptr };
284  LocalMeridianComponent *m_LocalMeridianComponent{ nullptr };
285  CatalogsComponent *m_Catalogs{ nullptr };
286  Equator *m_Equator{ nullptr };
287  ArtificialHorizonComponent *m_ArtificialHorizon{ nullptr };
288  Ecliptic *m_Ecliptic{ nullptr };
289  HorizonComponent *m_Horizon{ nullptr };
290  MilkyWay *m_MilkyWay{ nullptr };
291  SolarSystemComposite *m_SolarSystem{ nullptr };
292  StarComponent *m_Stars{ nullptr };
293 #ifndef KSTARS_LITE
294  FlagComponent *m_Flags { nullptr };
295  HIPSComponent *m_HiPS{ nullptr };
296  TerrainComponent *m_Terrain{ nullptr };
297 #ifdef HAVE_INDI
298  MosaicComponent *m_Mosaic { nullptr };
299 #endif
300 #endif
301  TargetListComponent *m_ObservingList { nullptr };
302  TargetListComponent *m_StarHopRouteList{ nullptr };
303  SatellitesComponent *m_Satellites{ nullptr };
304  SupernovaeComponent *m_Supernovae{ nullptr };
305 
306  SkyMesh *m_skyMesh;
307  std::unique_ptr<SkyLabeler> m_skyLabeler;
308 
309  KSNumbers m_reindexNum;
310 
311  QList<DeepStarComponent *> m_DeepStars;
312 
313  QList<SkyObject *> m_LabeledObjects;
314  QHash<int, QStringList> m_ObjectNames;
316  QHash<QString, QString> m_ConstellationNames;
317 };
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:37
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:52
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-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.