Kstars

planetmoonsnode.h
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
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 
10 class PlanetNode;
11 class PlanetMoons;
12 class RootNode;
13 class PointSourceNode;
14 class 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 
30 class PlanetMoonsNode : public SkyNode
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);
40  ~PlanetMoonsNode();
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 container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
void updateMoons()
Update position of moons if planet has them.
void addMoons(PlanetMoons *planetMoons)
Add object of type PlanetMoons to this node.
A container for planets and moons that provides z-order.
virtual void update() override
If planet has any moons first updateMoons() is called then the planet is updated.
A container for PointNode and QSGSimpleTextureNode used for displaying some solar system objects.
Definition: planetnode.h:29
label_t
The label_t enum.
Definition: labelsitem.h:61
A SkyNode derived class that represents stars and objects that are drawn as stars.
virtual void hide() override
Hides both planet and its moons.
PlanetMoonsNode(KSPlanetBase *planet, RootNode *parentNode)
Constructor.
Provides virtual functions for update of coordinates and nodes hiding.
Definition: skynode.h:27
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 Fri Aug 12 2022 04:00:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.