Kstars

planetsitem.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
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();
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();
68}
69
71{
72 rootNode()->labelsItem()->getLabelNode(LabelsItem::label_t::JUPITER_MOON_LABEL)->hide();
74}
A subclass of TrailObject that provides additional information needed for most solar system objects.
This class is in charge of labels in SkyMapLite.
Definition labelsitem.h:53
LabelTypeNode * getLabelNode(label_t labelType)
Definition labelsitem.h:126
A SkyNode derived class used as a container for displaying a planet with its moons (if any).
void update() override
calls update() of all child PlanetMoonsNodes
virtual void hide() override
hides this item and labels for all moons (currently only Jupiter moons.
SolarSystemSingleComponent * getParentComponent(SkyObject *planet)
returns SolarSystemSingleComponent that corresponds to the planet.
PlanetsItem(QList< SolarSystemSingleComponent * > planets, RootNode *rootNode=nullptr)
Constructor.
virtual void show() override
shows this item and labels for all moons (currently only Jupiter moons.
A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
Definition rootnode.h:60
This is an interface for implementing SkyItems that represent SkyComponent derived objects on the Sky...
Definition skyitem.h:30
virtual void hide() override
hides this item and corresponding labels
Definition skyitem.cpp:37
RootNode * rootNode()
Definition skyitem.h:57
virtual void show() override
makes this node visible
Definition skyitem.cpp:23
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
virtual void show()
makes this node visible
virtual void hide()
hides this node
This class encapsulates some methods which are shared between all single-object solar system componen...
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
QSGNode * nextSibling() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.