Kstars

planetsitem.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "planetsitem.h"
8 #include "projections/projector.h"
9 #include "solarsystemsinglecomponent.h"
10 #include "ksplanet.h"
11 #include "planetmoonscomponent.h"
12 
13 #include "skynodes/planetmoonsnode.h"
14 #include "skynodes/planetnode.h"
15 #include "Options.h"
16 
18  /* QList<PlanetMoonsComponent *> moons, */ RootNode *rootNode)
19  : SkyItem(LabelsItem::label_t::PLANET_LABEL, rootNode), m_planetComponents(planets) /*, m_moonsComponents(moons)*/
20 {
21  foreach (SolarSystemSingleComponent *planetComp, m_planetComponents)
22  {
23  KSPlanetBase *planet = planetComp->planet();
24  PlanetMoonsNode *pNode = new PlanetMoonsNode(planet, rootNode);
25  appendChildNode(pNode);
26 
27  // foreach(PlanetMoonsComponent * moonsComp, m_moonsComponents) {
28  // // Find planet of moons
29  // if(planet == moonsComp->getPlanet()) {
30  // pNode->addMoons(moonsComp->getMoons());
31  // }
32  // }
33  }
34 }
35 
37 {
38  foreach (SolarSystemSingleComponent *planetComp, m_planetComponents)
39  {
40  if (planetComp->planet() == planet)
41  return planetComp;
42  }
43  return nullptr;
44 }
45 
47 {
48  show();
49  //Traverse all children nodes of RootNode
50  QSGNode *n = firstChild();
51  while (n != 0)
52  {
53  PlanetMoonsNode *pNode = static_cast<PlanetMoonsNode *>(n);
54  n = n->nextSibling();
55 
56  bool selected = getParentComponent(pNode->skyObject())->selected();
57  if (selected)
58  pNode->update();
59  else
60  pNode->hide();
61  }
62 }
63 
65 {
66  rootNode()->labelsItem()->getLabelNode(LabelsItem::label_t::JUPITER_MOON_LABEL)->show();
67  SkyItem::show();
68 }
69 
71 {
72  rootNode()->labelsItem()->getLabelNode(LabelsItem::label_t::JUPITER_MOON_LABEL)->hide();
73  SkyItem::hide();
74 }
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
virtual void show()
makes this node visible
KSPlanetBase * planet()
Return pointer to stored planet object.
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
LabelTypeNode * getLabelNode(label_t labelType)
Definition: labelsitem.h:126
A container for planets and moons that provides z-order.
Handles labels in SkyMapLite.
Definition: labelsitem.h:52
PlanetsItem(QList< SolarSystemSingleComponent * > planets, RootNode *rootNode=nullptr)
Constructor.
Definition: planetsitem.cpp:17
virtual void hide() override
hides this item and labels for all moons (currently only Jupiter moons.
Definition: planetsitem.cpp:70
virtual void update() override
If planet has any moons first updateMoons() is called then the planet is updated.
virtual void show() override
makes this node visible
Definition: skyitem.cpp:23
virtual void hide() override
Hides both planet and its moons.
virtual void hide() override
hides this item and corresponding labels
Definition: skyitem.cpp:37
void update() override
calls update() of all child PlanetMoonsNodes
Definition: planetsitem.cpp:46
SkyObject * skyObject() const
returns SkyObject associated with this SkyNode
Definition: skynode.h:86
SolarSystemSingleComponent * getParentComponent(SkyObject *planet)
returns SolarSystemSingleComponent that corresponds to the planet.
Definition: planetsitem.cpp:36
virtual void show() override
shows this item and labels for all moons (currently only Jupiter moons.
Definition: planetsitem.cpp:64
RootNode * rootNode()
Definition: skyitem.h:57
QSGNode * nextSibling() const const
virtual void hide()
hides this node
Information about an object in the sky.
Definition: skyobject.h:41
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 04:04:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.