File indexing completed on 2024-04-28 03:44:25
0001 /* 0002 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 #ifndef PLANETMOONSNODE_H_ 0006 #define PLANETMOONSNODE_H_ 0007 #include "skynode.h" 0008 #include "../labelsitem.h" 0009 0010 class PlanetNode; 0011 class PlanetMoons; 0012 class RootNode; 0013 class PointSourceNode; 0014 class KSPlanetBase; 0015 class QSGSimpleTextureNode; 0016 0017 /** @class PlanetMoonsNode 0018 * 0019 * A SkyNode derived class used as a container for displaying a planet with its moons (if any). Unlike 0020 * PlanetMoons derived from SkyComponent PlanetMoonsNode represents both planet and moons. Ths PlanetNode 0021 * shouldn't be instantiated outside of this class (exception is AsteroidsItem). Although all SkyNodes 0022 * are "movable" objects (they change transform matrix to move across the SkyMapLite) this class is 0023 * just a container that provides z-order for moons and planets that change their positions on their own. 0024 * 0025 *@short A container for planets and moons that provides z-order. 0026 *@author Artem Fedoskin 0027 *@version 1.0 0028 */ 0029 0030 class PlanetMoonsNode : public SkyNode 0031 { 0032 public: 0033 /** 0034 * @short Constructor 0035 * @param planet pointer to planet object 0036 * @param parentNode pointer to the RootNode. It is needed for PointSourceNodes that use textures, 0037 * which are cached in RootNode. 0038 */ 0039 PlanetMoonsNode(KSPlanetBase *planet, RootNode *parentNode); 0040 ~PlanetMoonsNode(); 0041 0042 /** 0043 * @short Add object of type PlanetMoons to this node 0044 * @param planetMoons PlanetMoons component 0045 */ 0046 inline void addMoons(PlanetMoons *planetMoons) { pmoons = planetMoons; } 0047 0048 /** 0049 * If planet has any moons first updateMoons() is called then the planet is updated 0050 */ 0051 virtual void update() override; 0052 0053 /** 0054 * @short Hides both planet and its moons 0055 */ 0056 virtual void hide() override; 0057 0058 /** 0059 * Update position of moons if planet has them. To allow z-ordering we need to change the structure 0060 * of node tree by removing all child nodes of this tree and adding them again so that moons that 0061 * are behind the planet are before the m_planetNode in the hierarchy and all others are appended 0062 * after m_planetNode. 0063 */ 0064 void updateMoons(); 0065 0066 private: 0067 RootNode *m_rootNode; 0068 PlanetMoons *pmoons; 0069 PlanetNode *m_planetNode; 0070 0071 LabelsItem::label_t m_labelType; 0072 0073 QList<PointSourceNode *> m_moonNodes; 0074 }; 0075 0076 #endif