Kstars

starblock.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Akarsh Simha <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include <QDebug>
8 
9 #include "starblock.h"
10 #include "skyobjects/starobject.h"
11 #include "starcomponent.h"
12 #include "skyobjects/stardata.h"
13 #include "skyobjects/deepstardata.h"
14 
15 #ifdef KSTARS_LITE
16 #include "skymaplite.h"
17 #include "kstarslite/skyitems/skynodes/pointsourcenode.h"
18 
19 StarNode::StarNode() : starNode(0)
20 {
21 }
22 
23 StarNode::~StarNode()
24 {
25  if (starNode)
26  {
27  SkyMapLite::Instance()->deleteSkyNode(starNode);
28  qDebug() << Q_FUNC_INFO << "REAL NODE DESTRUCTOR";
29  }
30 }
31 #endif
32 
34  : faintMag(-5), brightMag(35), parent(nullptr), prev(nullptr), next(nullptr), drawID(0), nStars(0),
35 #ifdef KSTARS_LITE
36  stars(nstars, StarNode())
37 #else
38  stars(nstars, StarObject())
39 #endif
40 {
41 }
42 
44 {
45  if (parent)
46  parent->releaseBlock(this);
47 
48  parent = nullptr;
49  faintMag = -5.0;
50  brightMag = 35.0;
51  nStars = 0;
52 }
53 
54 #ifdef KSTARS_LITE
55 StarNode *StarBlock::addStar(const StarData &data)
56 {
57  if (isFull())
58  return 0;
59  StarNode &node = stars[nStars++];
60  StarObject &star = node.star;
61 
62  star.init(&data);
63  if (star.mag() > faintMag)
64  faintMag = star.mag();
65  if (star.mag() < brightMag)
66  brightMag = star.mag();
67  return &node;
68 }
69 
70 StarNode *StarBlock::addStar(const DeepStarData &data)
71 {
72  if (isFull())
73  return 0;
74  StarNode &node = stars[nStars++];
75  StarObject &star = node.star;
76 
77  star.init(&data);
78  if (star.mag() > faintMag)
79  faintMag = star.mag();
80  if (star.mag() < brightMag)
81  brightMag = star.mag();
82  return &node;
83 }
84 #else
86 {
87  if (isFull())
88  return nullptr;
89  StarObject &star = stars[nStars++];
90 
91  star.init(&data);
92  if (star.mag() > faintMag)
93  faintMag = star.mag();
94  if (star.mag() < brightMag)
95  brightMag = star.mag();
96  return &star;
97 }
98 
100 {
101  if (isFull())
102  return nullptr;
103  StarObject &star = stars[nStars++];
104 
105  star.init(&data);
106  if (star.mag() > faintMag)
107  faintMag = star.mag();
108  if (star.mag() < brightMag)
109  brightMag = star.mag();
110  return &star;
111 }
112 #endif
A 32-byte Structure that holds star data.
Definition: stardata.h:17
void reset()
Reset this StarBlock's data, for reuse of the StarBlock.
Definition: starblock.cpp:43
bool isFull() const
Returns true if the StarBlock is full.
Definition: starblock.h:81
float mag() const
Definition: skyobject.h:206
StarBlockEntry * addStar(const StarData &data)
Initialize another star with data.
Definition: starblock.cpp:85
int releaseBlock(StarBlock *block)
Drops the StarBlock with the given pointer from the list.
subclass of SkyObject specialized for stars.
Definition: starobject.h:32
void init(const StarData *stardata)
Initializes a StarObject to given data.
Definition: starobject.cpp:133
void deleteSkyNode(SkyNode *skyNode)
skyNode will be deleted on the next call to updatePaintNode (currently used only in StarNode(struct i...
Definition: skymaplite.cpp:205
StarBlockEntry * star(int i)
Return the i-th star in this StarBlock.
Definition: starblock.h:100
A 16-byte structure that holds star data for really faint stars.
StarBlock(int nstars=100)
Constructor.
Definition: starblock.cpp:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 03:58:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.