Kstars

starcomponent.h
1/*
2 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ksnumbers.h"
10#include "listcomponent.h"
11#include "skylabel.h"
12#include "stardata.h"
13#include "skyobjects/starobject.h"
14
15#include <memory>
16
17#ifdef KSTARS_LITE
18class StarItem;
19#endif
20
21class KStarsSplash;
22class BinFileHelper;
24class HighPMStarList;
25class MeshIterator;
26class SkyLabeler;
27class SkyMesh;
28class StarObject;
30
31#define MAX_LINENUMBER_MAG 90
32
33/**
34 * @class StarComponent
35 *
36 * @short Represents the stars on the sky map. For optimization reasons the stars are not
37 * separate objects and are stored in a list.
38 *
39 * The StarComponent class manages all stars drawn in KStars. While it handles all stars
40 * having names using its own member methods, it shunts the responsibility of unnamed stars
41 * to the class 'DeepStarComponent', objects of which it maintains.
42 *
43 * @author Thomas Kabelmann
44 * @author Akarsh Simha
45 * @version 1.0
46 */
48{
49#ifdef KSTARS_LITE
50 friend class StarItem; //Needs access to faintMagnitude() and reindex()
51#endif
52
53 protected:
55
56 public:
57 ~StarComponent() override;
58
59 // TODO: Desingletonize StarComponent
60 /** @short Create an instance of StarComponent */
62
63 /** @return the instance of StarComponent if already created, nullptr otherwise */
64 static StarComponent *Instance() { return pinstance; }
65
66 //This function is empty; we need that so that the JiT update
67 //is the only one being used.
68 void update(KSNumbers *num) override;
69
70 bool selected() override;
71
72 void draw(SkyPainter *skyp) override;
73
74 /**
75 * @short draw all the labels in the prioritized LabelLists and then clear the LabelLists.
76 */
77 void drawLabels();
78
79 static float zoomMagnitudeLimit();
80
81 SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
82
83 virtual SkyObject *findStarByGenetiveName(const QString name);
84
85 /**
86 * @short Searches the region(s) and appends the SkyObjects found to the list of sky objects
87 *
88 * Look for a SkyObject that is in one of the regions
89 * If found, then append to the list of sky objects
90 * @p list list of SkyObject to which matching list has to be appended to
91 * @p region defines the regions in which the search for SkyObject should be done within
92 */
93 void objectsInArea(QList<SkyObject *> &list, const SkyRegion &region) override;
94
95 /**
96 * @short Find stars by HD catalog index
97 * @param HDnum HD Catalog Number of the star to find
98 * @return If the star is a static star, a pointer to the star will be returned
99 * If it is a dynamic star, a fake copy will be created that survives till
100 * the next findByHDIndex() call. If no match was found, returns nullptr.
101 */
102 StarObject *findByHDIndex(int HDnum);
103
104
105 /**
106 * @short Append a star to the Object List. (including genetive name)
107 *
108 * Overrides ListComponent::appendListObject() to include genetive names of stars as well.
109 */
110 void appendListObject(SkyObject * object);
111
112 /**
113 * @short Add to the given list, the stars from this component, that lie within the
114 * specified circular aperture, and that are brighter than the limiting magnitude specified.
115 * @p center The center point of the aperture
116 * @p radius The radius around the center point that defines the aperture
117 * @p maglim Optional parameter indicating the limiting magnitude.
118 * If magnitude limit is numerically < -28, the limiting magnitude
119 * is assumed to be the limiting magnitude of the catalog (i.e. no magnitude limit)
120 * @p list The list to operate on
121 */
122 void starsInAperture(QList<StarObject *> &list, const SkyPoint &center, float radius, float maglim = -29);
123
124 // TODO: Make byteSwap a template method and put it in byteorder.h
125 // It should ideally handle 32-bit, 16-bit fields and StarData and
126 // DeepStarData fields
127 static void byteSwap(StarData *stardata);
128
129 private:
130 /**
131 * @short Read data for stars which will remain static in the memory
132 *
133 * This method reads data for named stars (stars having names, which are stored by
134 * default in "namedstars.dat") into memory. These stars are always kept in memory,
135 * as against 'deep' stars which are mostly loaded dynamically (KStars treats all
136 * unnamed stars as 'deep' stars) into memory when required, depending on region
137 * and magnitude limit. Once loading is successful, this method sets the starsLoaded flag to true
138 */
139 bool loadStaticData();
140
141 /** @return the magnitude of the faintest star */
142 float faintMagnitude() const;
143
144 /** true if all stars(not only high PM ones) were reindexed else false**/
145 bool reindex(KSNumbers *num);
146
147 /** Adds a label to the lists of labels to be drawn prioritized by magnitude. */
148 void addLabel(const QPointF &p, StarObject *star);
149
150 void reindexAll(KSNumbers *num);
151
152 /** Load available deep star catalogs */
153 int loadDeepStarCatalogs();
154
155 bool addDeepStarCatalogIfExists(const QString &fileName, float trigMag, bool staticstars = false);
156
157 SkyMesh *m_skyMesh { nullptr };
158 std::unique_ptr<StarIndex> m_starIndex;
159
160 KSNumbers m_reindexNum;
161 double m_reindexInterval { 0 };
162
163 LabelList *m_labelList[MAX_LINENUMBER_MAG + 1];
164 bool m_hideLabels { false };
165
166 float m_zoomMagLimit { 0 };
167
168 /// Limiting magnitude of the catalog currently loaded
169 float m_FaintMagnitude { -5 };
170 bool starsLoaded { false };
171 /// Current limiting magnitude for visible stars
172 float magLim { 0 };
173
174 StarObject m_starObject;
175 StarObject *focusStar { nullptr }; // This object is always drawn
176
177 KStarsSplash *m_reindexSplash { nullptr };
178
179 StarBlockFactory *m_StarBlockFactory { nullptr };
180
181 QVector<HighPMStarList *> m_highPMStars;
184 QVector<DeepStarComponent *> m_DeepStarComponents;
185
186 /**
187 * @struct starName
188 * @brief Structure that holds star name information, to be read as-is from the
189 * corresponding binary data file
190 */
191 typedef struct starName
192 {
193 char bayerName[8];
194 char longName[32];
195 } starName;
196
197 StarData stardata;
198 starName starname;
199
200 static StarComponent *pinstance;
201};
This class provides utility functions to handle binary data files in the format prescribed by KStars.
Stores and manages unnamed stars, most of which are dynamically loaded into memory.
Holds a list of stars with high proper motion along with the trixel each star is currently located in...
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
The KStars Splash Screen.
An abstract parent class, to be inherited by SkyComponents that store a QList of SkyObjects.
MeshIterator is a very lightweight class used to iterate over the result set of an HTMesh intersectio...
SkyComposite is a kind of container class for SkyComponent objects.
The purpose of this class is to prevent labels from overlapping.
Definition skylabeler.h:99
Provides an interface to the Hierarchical Triangular Mesh (HTM) library written by A.
Definition skymesh.h:74
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
A factory that creates StarBlocks and recycles them in an LRU Cache.
Represents the stars on the sky map.
void update(KSNumbers *num) override
Update the sky positions of this component.
bool selected() override
static StarComponent * Instance()
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
void starsInAperture(QList< StarObject * > &list, const SkyPoint &center, float radius, float maglim=-29)
Add to the given list, the stars from this component, that lie within the specified circular aperture...
StarObject * findByHDIndex(int HDnum)
Find stars by HD catalog index.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Find the SkyObject nearest the given SkyPoint.
void appendListObject(SkyObject *object)
Append a star to the Object List.
static StarComponent * Create(SkyComposite *)
Create an instance of StarComponent.
void drawLabels()
draw all the labels in the prioritized LabelLists and then clear the LabelLists.
void objectsInArea(QList< SkyObject * > &list, const SkyRegion &region) override
Searches the region(s) and appends the SkyObjects found to the list of sky objects.
Class that handles Stars.
Definition staritem.h:23
This is a subclass of SkyObject.
Definition starobject.h:33
A 32-byte Structure that holds star data.
Definition stardata.h:18
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:11:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.