Kstars

planetmoonsnode.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5#ifndef PLANETMOONSNODE_H_
6#define PLANETMOONSNODE_H_
7#include "skynode.h"
8#include "../labelsitem.h"
9
10class PlanetNode;
11class PlanetMoons;
12class RootNode;
13class PointSourceNode;
14class KSPlanetBase;
16
17/** @class PlanetMoonsNode
18 *
19 * A SkyNode derived class used as a container for displaying a planet with its moons (if any). Unlike
20 * PlanetMoons derived from SkyComponent PlanetMoonsNode represents both planet and moons. Ths PlanetNode
21 * shouldn't be instantiated outside of this class (exception is AsteroidsItem). Although all SkyNodes
22 * are "movable" objects (they change transform matrix to move across the SkyMapLite) this class is
23 * just a container that provides z-order for moons and planets that change their positions on their own.
24 *
25 *@short A container for planets and moons that provides z-order.
26 *@author Artem Fedoskin
27 *@version 1.0
28 */
29
31{
32 public:
33 /**
34 * @short Constructor
35 * @param planet pointer to planet object
36 * @param parentNode pointer to the RootNode. It is needed for PointSourceNodes that use textures,
37 * which are cached in RootNode.
38 */
39 PlanetMoonsNode(KSPlanetBase *planet, RootNode *parentNode);
41
42 /**
43 * @short Add object of type PlanetMoons to this node
44 * @param planetMoons PlanetMoons component
45 */
46 inline void addMoons(PlanetMoons *planetMoons) { pmoons = planetMoons; }
47
48 /**
49 * If planet has any moons first updateMoons() is called then the planet is updated
50 */
51 virtual void update() override;
52
53 /**
54 * @short Hides both planet and its moons
55 */
56 virtual void hide() override;
57
58 /**
59 * Update position of moons if planet has them. To allow z-ordering we need to change the structure
60 * of node tree by removing all child nodes of this tree and adding them again so that moons that
61 * are behind the planet are before the m_planetNode in the hierarchy and all others are appended
62 * after m_planetNode.
63 */
64 void updateMoons();
65
66 private:
67 RootNode *m_rootNode;
68 PlanetMoons *pmoons;
69 PlanetNode *m_planetNode;
70
71 LabelsItem::label_t m_labelType;
72
73 QList<PointSourceNode *> m_moonNodes;
74};
75
76#endif
A subclass of TrailObject that provides additional information needed for most solar system objects.
label_t
The label_t enum.
Definition labelsitem.h:62
A SkyNode derived class used as a container for displaying a planet with its moons (if any).
void updateMoons()
Update position of moons if planet has them.
PlanetMoonsNode(KSPlanetBase *planet, RootNode *parentNode)
Constructor.
void addMoons(PlanetMoons *planetMoons)
Add object of type PlanetMoons to this node.
virtual void hide() override
Hides both planet and its moons.
virtual void update() override
If planet has any moons first updateMoons() is called then the planet is updated.
Implements the moons of a planet.
Definition planetmoons.h:30
A SkyNode derived class used as a container for holding two other nodes: PointNode and QSGSimpleTextu...
Definition planetnode.h:30
A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
Definition rootnode.h:60
Provides virtual functions for update of coordinates and nodes hiding.
Definition skynode.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:15:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.