Kstars

horizonnode.cpp
1 
2 #include "horizonnode.h"
3 
4 #include "ksutils.h"
5 #include "Options.h"
6 #include "nodes/polynode.h"
7 
8 HorizonNode::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 }
virtual void show()
makes this node visible
virtual void hide() override
hides all child nodes (sets opacity of m_opacity to 0)
Definition: horizonnode.cpp:50
void append(const T &value)
void appendChildNode(QSGNode *node)
virtual void update() override
Update child nodes based on user settings (filled/non-filled ground) and their visibility.
Definition: horizonnode.cpp:13
T & first()
const Projector * projector() const
Get the current projector.
Definition: skymaplite.h:323
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
A SkyOpacityNode derived class used for drawing of polygons (both filled and non-filled)
Definition: polynode.h:22
void markDirty(QSGNode::DirtyState bits)
virtual QVector< Eigen::Vector2f > groundPoly(SkyPoint *labelpoint=nullptr, bool *drawLabel=nullptr) const
Get the ground polygon.
Definition: projector.cpp:270
void setLineWidth(int width)
Set thickness of border line.
Definition: polynode.cpp:38
HorizonNode()
Constructor.
Definition: horizonnode.cpp:8
void updateGeometry(const QPolygonF &polygon, bool filled)
Update the geometry of polygon.
Definition: polynode.cpp:47
int size() const const
virtual void hide()
hides this node
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:86
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.