Kstars

labelnode.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 PlanetItemNode;
12 class SkyMapLite;
13 class PointNode;
15 class SkyLabeler;
16 class RootNode;
17 
18 /**
19  * @class LabelNode
20  *
21  * @short A SkyNode derived class used for displaying labels
22  * @author Artem Fedoskin
23  * @version 1.0
24  */
25 
26 class LabelNode : public SkyNode
27 {
28  public:
29  /**
30  * @short Constructor. Use name of skyObject as a text
31  * @param skyObject - target object, for which this label is created.
32  * @param type - type of label (corresponds to type of SkyObject)
33  */
35 
36  /**
37  * @short Constructor. Use string parameter name as a text
38  * @param name - text of label
39  * @param type - type of label (corresponds to type of SkyObject)
40  */
42 
43  /**
44  * @short Destructor.
45  */
46  virtual ~LabelNode();
47 
48  /**
49  * @short Convenience function to not to repeat the same code in 2 constructors. Set parameters of label
50  * based on its type
51  */
52  void initialize();
53 
54  /**
55  * @short Changes position of the label
56  * @param pos - new position
57  */
58  virtual void changePos(QPointF pos) override;
59 
60  inline QString name() { return m_name; }
61 
62  inline LabelsItem::label_t labelType() { return m_labelType; }
63 
64  /**
65  * @short Create texture from label's name
66  * @param color - color of the label
67  */
68  void createTexture(QColor color = QColor());
69 
70  /**
71  * @return true if the size of text depends on zoom
72  */
73  inline bool zoomFont() { return m_zoomFont; }
74 
75  /**
76  * @short set the position of label with the given offset from SkyObject's position and
77  * makes the label visible if it was hidden
78  * @warning Keep mind that to update labels position, you should first set it with setLabelPos()
79  * and then call update()
80  * @param pos position of label
81  */
82  void setLabelPos(QPointF pos);
83 
84  /**
85  * @short Update position of label according to labelPos and recreate texture if label's size
86  * depends on zoom level
87  */
88  virtual void update() override;
89 
90  QPointF labelPos;
91 
92  private:
93  QString m_name;
94  QSGSimpleTextureNode *m_textTexture;
95  QSize m_textSize;
96 
97  LabelsItem::label_t m_labelType;
98  int m_fontSize;
99  bool m_zoomFont;
100  QString m_schemeColor;
101  QColor m_color;
102 };
SkyOpacityNode derived class that represents stars and planets using cached QSGTexture.
Definition: pointnode.h:24
void createTexture(QColor color=QColor())
Create texture from label's name.
Definition: labelnode.cpp:74
virtual ~LabelNode()
Destructor.
Definition: labelnode.cpp:28
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
bool zoomFont()
Definition: labelnode.h:73
A SkyNode derived class used for displaying labels.
Definition: labelnode.h:26
label_t
The label_t enum.
Definition: labelsitem.h:61
void initialize()
Convenience function to not to repeat the same code in 2 constructors.
Definition: labelnode.cpp:35
LabelNode(SkyObject *skyObject, LabelsItem::label_t type)
Constructor.
Definition: labelnode.cpp:15
virtual void update() override
Update position of label according to labelPos and recreate texture if label's size depends on zoom l...
Definition: labelnode.cpp:135
virtual void changePos(QPointF pos) override
Changes position of the label.
Definition: labelnode.cpp:114
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
QSGNode::NodeType type() const const
void setLabelPos(QPointF pos)
set the position of label with the given offset from SkyObject's position and makes the label visible...
Definition: labelnode.cpp:123
Provides virtual functions for update of coordinates and nodes hiding.
Definition: skynode.h:27
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 Tue Dec 5 2023 03:58:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.