Kstars
9#include <QSGSimpleTextureNode>
10#include <QQuickWindow>
12#include "skymaplite.h"
17 m_fontSize(0), m_zoomFont(false)
30 m_opacity->removeChildNode(m_textTexture);
31 m_textTexture->setOwnsTexture(
true);
39 case LabelsItem::label_t::PLANET_LABEL:
40 case LabelsItem::label_t::SATURN_MOON_LABEL:
41 case LabelsItem::label_t::JUPITER_MOON_LABEL:
42 case LabelsItem::label_t::COMET_LABEL:
43 case LabelsItem::label_t::RUDE_LABEL:
44 case LabelsItem::label_t::ASTEROID_LABEL:
45 m_schemeColor =
"PNameColor";
48 case LabelsItem::label_t::DEEP_SKY_LABEL:
49 case LabelsItem::label_t::DSO_OTHER_LABEL:
50 case LabelsItem::label_t::CATALOG_DSO_LABEL:
51 m_schemeColor =
"DSNameColor";
54 case LabelsItem::label_t::TELESCOPE_SYMBOL:
55 m_schemeColor =
"TargetColor";
58 case LabelsItem::label_t::CONSTEL_NAME_LABEL:
59 m_schemeColor =
"CNameColor";
61 case LabelsItem::label_t::STAR_LABEL:
62 case LabelsItem::label_t::CATALOG_STAR_LABEL:
63 m_schemeColor =
"SNameColor";
66 m_schemeColor =
"UserLabelColor";
70 createTexture(KStarsData::Instance()->colorScheme()->colorNamed(m_schemeColor));
71 m_opacity->appendChildNode(m_textTexture);
78 case LabelsItem::label_t::SATURN_MOON_LABEL:
79 case LabelsItem::label_t::JUPITER_MOON_LABEL:
80 SkyLabeler::Instance()->shrinkFont(2);
86 QSGTexture *oldTexture = m_textTexture->texture();
88 m_textTexture->setTexture(SkyMapLite::Instance()->textToTexture(m_name, color, m_zoomFont));
92 m_fontSize = SkyLabeler::Instance()->drawFont().pointSize();
96 case LabelsItem::label_t::SATURN_MOON_LABEL:
97 case LabelsItem::label_t::JUPITER_MOON_LABEL:
98 SkyLabeler::Instance()->resetFont();
107 m_textSize = m_textTexture->texture()->
textureSize();
108 QRectF oldRect = m_textTexture->rect();
109 qreal ratio = SkyMapLite::Instance()->window()->effectiveDevicePixelRatio();
111 m_textTexture->
setRect(
QRect(oldRect.
x(), oldRect.
y(), m_textSize.width() / ratio, m_textSize.height() / ratio));
116 QMatrix4x4 m(1, 0, 0, pos.
x(), 0, 1, 0, pos.
y(), 0, 0, 1, 0, 0, 0, 0, 1);
126 qreal ratio = SkyMapLite::Instance()->window()->effectiveDevicePixelRatio();
129 labelPos =
QPointF(pos.
x() + m_skyObject->labelOffset(),
130 pos.
y() + m_skyObject->labelOffset() - m_textSize.height() / ratio);
137 QColor newColor = KStarsData::Instance()->colorScheme()->colorNamed(m_schemeColor);
138 if ((m_zoomFont && m_fontSize != SkyLabeler::Instance()->skyFont().pointSize()) || m_color != newColor)
void createTexture(QColor color=QColor())
Create texture from label's name.
LabelNode(SkyObject *skyObject, LabelsItem::label_t type)
Constructor.
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.
void initialize()
Convenience function to not to repeat the same code in 2 constructors.
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.
SkyObject * skyObject() const
returns SkyObject associated with this SkyNode
virtual void show()
shows all child nodes (sets opacity of m_opacity to 1)
SkyNode(SkyObject *skyObject)
Constructor.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
void setRect(qreal x, qreal y, qreal width, qreal height)
void markDirty(DirtyState bits)
NodeType type() const const
virtual QSize textureSize() const const=0
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:53:02 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.