Kstars

pointsourcenode.h
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #pragma once
7 
8 #include "skynode.h"
9 #include "../labelsitem.h"
10 
11 class LabelNode;
12 class PlanetItemNode;
13 class PointNode;
14 class RootNode;
15 class SkyMapLite;
16 
17 /**
18  * @class PointSourceNode
19  *
20  * A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
21  *
22  * @short A SkyNode derived class that represents stars and objects that are drawn as stars
23  * @author Artem Fedoskin
24  * @version 1.0
25  */
26 class PointSourceNode : public SkyNode
27 {
28  public:
29  /**
30  * @short Constructor
31  * @param skyObject pointer to SkyObject that has to be displayed on SkyMapLite
32  * @param parentNode pointer to the top parent node, which holds texture cache
33  * @param labelType label type of PointNode
34  * @param spType spectral class of PointNode
35  * @param size initial size of PointNode
36  * @param trixel trixelID, with which this node is indexed
37  */
39  LabelsItem::label_t labelType = LabelsItem::label_t::STAR_LABEL,
40  char spType = 'A', float size = 1, short trixel = -1);
41  virtual ~PointSourceNode();
42 
43  /** @short Get the width of a star of magnitude mag */
44  float starWidth(float mag) const;
45 
46  /**
47  * @short updatePoint initializes PointNode if not done that yet. Makes it visible and updates
48  * its size.
49  * By using this function we can save some memory because m_point is created only when this
50  * PointSourceNode becomes visible.
51  */
52  void updatePoint();
53 
54  /**
55  * @short changePos changes the position m_point
56  * @param pos new position
57  */
58  virtual void changePos(QPointF pos) override;
59 
60  /**
61  * @short updatePos updates position of this node and its label. Initializes label if needed
62  * The reason behind this function is that in StarItem we are already checking the visibility of star
63  * to decide whether we need to create this node or no. So to avoid calculating the same thing twice
64  * we set position of object directly. Also through this function StarItem sets the visibility of label
65  * @param pos position of this node on SkyMapLite
66  * @param drawLabel true if label has to be drawn
67  */
68  void updatePos(QPointF pos, bool drawLabel);
69 
70  /** @short update updates coordinates of this node based on the visibility of its SkyObject */
71  virtual void update() override;
72 
73  /**
74  * @short hides this node and its label. m_point is hided without explicitly doing this because
75  * it is a child node of m_opacity inherited from SkyNode
76  */
77  virtual void hide() override;
78 
79  private:
80  PointNode *m_point { nullptr };
81  RootNode *m_rootNode { nullptr };
82  LabelNode *m_label { nullptr };
83  char m_spType { 0 };
84  float m_size { 0 };
85  LabelsItem::label_t m_labelType { LabelsItem::NO_LABEL };
86  /**
87  * Trixel to which this object belongs. Used only in stars. By default -1 for
88  * all other objects that are not indexed by SkyMesh
89  */
90  short m_trixel { 0 };
91  QPointF pos;
92 };
SkyOpacityNode derived class that represents stars and planets using cached QSGTexture.
Definition: pointnode.h:24
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
A SkyNode derived class used for displaying labels.
Definition: labelnode.h:26
float starWidth(float mag) const
Get the width of a star of magnitude mag.
label_t
The label_t enum.
Definition: labelsitem.h:61
void updatePoint()
updatePoint initializes PointNode if not done that yet.
A SkyNode derived class that represents stars and objects that are drawn as stars.
virtual void update() override
update updates coordinates of this node based on the visibility of its SkyObject
Item for displaying sky objects; also handles user interaction events.
Definition: skymaplite.h:58
SkyObject * skyObject() const
returns SkyObject associated with this SkyNode
Definition: skynode.h:86
void updatePos(QPointF pos, bool drawLabel)
updatePos updates position of this node and its label.
PointSourceNode(SkyObject *skyObject, RootNode *parentNode, LabelsItem::label_t labelType=LabelsItem::label_t::STAR_LABEL, char spType='A', float size=1, short trixel=-1)
Constructor.
Provides virtual functions for update of coordinates and nodes hiding.
Definition: skynode.h:27
virtual void changePos(QPointF pos) override
changePos changes the position m_point
virtual void hide() override
hides this node and its label.
Information about an object in the sky.
Definition: skyobject.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Sep 25 2023 03:54:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.