Kstars

horizonnode.cpp
1
2#include "horizonnode.h"
3
4#include "ksutils.h"
5#include "Options.h"
6#include "nodes/polynode.h"
7
8HorizonNode::HorizonNode() : m_polygonNode(new PolyNode)
9{
10 appendChildNode(m_polygonNode);
11}
12
14{
15 if (!m_polygonNode->visible())
16 {
17 m_polygonNode->show();
18 }
19
20 QColor color = KStarsData::Instance()->colorScheme()->colorNamed("HorzColor");
21
22 m_polygonNode->setColor(color);
23 m_polygonNode->setLineWidth(2);
24
25 QVector<Eigen::Vector2f> ground = SkyMapLite::Instance()->projector()->groundPoly();
26
27 if (ground.size())
28 {
29 QPolygonF groundPoly(ground.size());
30 for (int i = 0; i < ground.size(); ++i)
31 groundPoly[i] = KSUtils::vecToPoint(ground[i]);
32 if (Options::showGround())
33 {
34 m_polygonNode->updateGeometry(groundPoly, true);
35 }
36 else
37 {
38 groundPoly.append(groundPoly.first());
39 m_polygonNode->updateGeometry(groundPoly, false);
40 }
41 }
42 else
43 {
44 m_polygonNode->hide();
45 return;
46 }
47 m_polygonNode->markDirty(QSGNode::DirtyGeometry);
48}
49
51{
52 m_polygonNode->hide();
53}
QColor colorNamed(const QString &name) const
Retrieve a color by name.
virtual void update() override
Update child nodes based on user settings (filled/non-filled ground) and their visibility.
HorizonNode()
Constructor.
virtual void hide() override
hides all child nodes (sets opacity of m_opacity to 0)
ColorScheme * colorScheme()
Definition kstarsdata.h:172
A SkyOpacityNode derived class used for drawing of polygons (both filled and non-filled)
Definition polynode.h:23
void updateGeometry(const QPolygonF &polygon, bool filled)
Update the geometry of polygon.
Definition polynode.cpp:47
void setLineWidth(int width)
Set thickness of border line.
Definition polynode.cpp:38
virtual QVector< Eigen::Vector2f > groundPoly(SkyPoint *labelpoint=nullptr, bool *drawLabel=nullptr) const
Get the ground polygon.
const Projector * projector() const
Get the current projector.
Definition skymaplite.h:323
virtual void show()
makes this node visible
virtual void hide()
hides this node
void append(QList< T > &&value)
T & first()
qsizetype size() const const
void appendChildNode(QSGNode *node)
void markDirty(DirtyState bits)
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.