Kstars

labelnode.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 PlanetItemNode;
12class SkyMapLite;
13class PointNode;
15class SkyLabeler;
16class 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
26class 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};
A SkyNode derived class used for displaying labels.
Definition labelnode.h:27
bool zoomFont()
Definition labelnode.h:73
void createTexture(QColor color=QColor())
Create texture from label's name.
Definition labelnode.cpp:74
LabelNode(SkyObject *skyObject, LabelsItem::label_t type)
Constructor.
Definition labelnode.cpp:15
void setLabelPos(QPointF pos)
set the position of label with the given offset from SkyObject's position and makes the label visible...
virtual ~LabelNode()
Destructor.
Definition labelnode.cpp:28
void initialize()
Convenience function to not to repeat the same code in 2 constructors.
Definition labelnode.cpp:35
virtual void update() override
Update position of label according to labelPos and recreate texture if label's size depends on zoom l...
virtual void changePos(QPointF pos) override
Changes position of the label.
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 QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
Definition rootnode.h:60
The purpose of this class is to prevent labels from overlapping.
Definition skylabeler.h:99
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
NodeType type() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.