Kstars

pointsourcenode.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#pragma once
7
8#include "skynode.h"
9#include "../labelsitem.h"
10
11class LabelNode;
12class PlanetItemNode;
13class PointNode;
14class RootNode;
15class 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 */
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};
A SkyNode derived class used for displaying labels.
Definition labelnode.h:27
label_t
The label_t enum.
Definition labelsitem.h:62
SkyOpacityNode derived class that represents stars and planets using cached QSGTexture.
Definition pointnode.h:25
A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
virtual void hide() override
hides 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.
virtual void update() override
update updates coordinates of this node based on the visibility of its SkyObject
void updatePoint()
updatePoint initializes PointNode if not done that yet.
void updatePos(QPointF pos, bool drawLabel)
updatePos updates position of this node and its label.
virtual void changePos(QPointF pos) override
changePos changes the position m_point
float starWidth(float mag) const
Get the width of a star of magnitude mag.
A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
Definition rootnode.h:60
This is the main item that displays all SkyItems.
Definition skymaplite.h:59
Provides virtual functions for update of coordinates and nodes hiding.
Definition skynode.h:28
SkyObject * skyObject() const
returns SkyObject associated with this SkyNode
Definition skynode.h:86
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.