Kstars

satellitesitem.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #include "satellitesitem.h"
7 #include "satellitescomponent.h"
8 
9 #include "Options.h"
10 #include "projections/projector.h"
11 #include "kscomet.h"
12 
13 #include "rootnode.h"
14 #include "labelsitem.h"
15 #include "satellite.h"
16 #include "skylabeler.h"
17 
18 #include "skynodes/satellitenode.h"
19 
21  : SkyItem(LabelsItem::label_t::SATELLITE_LABEL, rootNode), m_satComp(satComp)
22 {
23  recreateList();
24  Options::setDrawSatellitesLikeStars(false);
25 }
26 
28 {
29  if (!m_satComp->selected())
30  {
31  hide();
32  return;
33  }
34 
35  QSGNode *n = firstChild();
36 
37  while (n != 0)
38  {
39  SatelliteNode *satNode = static_cast<SatelliteNode *>(n);
40  Satellite *sat = satNode->sat();
41  if (sat->selected())
42  {
43  if (Options::showVisibleSatellites())
44  {
45  if (sat->isVisible())
46  {
47  satNode->update();
48  }
49  else
50  {
51  satNode->hide();
52  }
53  }
54  else
55  {
56  satNode->update();
57  }
58  }
59  else
60  {
61  satNode->hide();
62  }
63  n = n->nextSibling();
64  }
65 }
66 
68 {
69  QList<SatelliteGroup *> list = m_satComp->groups();
70  for (int i = 0; i < list.size(); ++i)
71  {
72  SatelliteGroup *group = list.at(i);
73  for (int c = 0; c < group->size(); ++c)
74  {
75  appendChildNode(new SatelliteNode(group->at(c), rootNode()));
76  }
77  }
78 }
bool isVisible()
Definition: satellite.cpp:1294
A base class that is used for displaying SkyComponents on SkyMapLite.
Definition: skyitem.h:29
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
SatellitesItem(SatellitesComponent *satComp, RootNode *rootNode=nullptr)
Constructor.
Handles labels in SkyMapLite.
Definition: labelsitem.h:52
bool selected()
Definition: satellite.cpp:1299
int size() const const
const T & at(int i) const const
virtual void hide() override
hides all child nodes (sets opacity of m_opacity to 0)
A SkyNode derived class that represents satellite.
Definition: satellitenode.h:24
virtual void update() override
Update positions and visibility of satellites.
virtual void hide() override
hides this item and corresponding labels
Definition: skyitem.cpp:37
QList< SatelliteGroup * > groups()
RootNode * rootNode()
Definition: skyitem.h:57
void recreateList()
recreates the node tree (deletes old nodes and appends new ones according to SatelliteGroups from Sat...
QSGNode * nextSibling() const const
virtual void update() override
Update position and visibility of satellite.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.