Kstars

planetnode.h
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 #ifndef PLANETNODE_H_
6 #define PLANETNODE_H_
7 #include "skynode.h"
8 #include "../skyopacitynode.h"
9 
11 class QImage;
12 class KSPlanetBase;
13 class RootNode;
14 class PointNode;
15 class LabelNode;
16 #include "../labelsitem.h"
17 
18 /** @class PlanetNode
19  *
20  * A SkyNode derived class used as a container for holding two other nodes: PointNode
21  * and QSGSimpleTextureNode(displays object as image) that are displayed depending according to the
22  * conditions (zoom level, user options)
23  *
24  *@short A container for PointNode and QSGSimpleTextureNode used for displaying some solar system objects
25  *@author Artem Fedoskin
26  *@version 1.0
27  */
28 
29 class PlanetNode : public SkyNode
30 {
31  public:
32  /**
33  * @brief Constructor
34  * @param pb used in PlanetItem to update position of PlanetNode
35  * @param parentNode used by PointNode to get textures from cache
36  * @param labelType type of label. Pluto has different from planets label type
37  */
38  PlanetNode(KSPlanetBase *pb, RootNode *parentNode,
39  LabelsItem::label_t labelType = LabelsItem::label_t::PLANET_LABEL);
40 
41  /**
42  * @short updates the size of m_point
43  * @param size new size of m_point
44  */
45  void setPointSize(float size);
46  /**
47  * @short updates the size of m_planetPic
48  * @param size new size of m_planetPic
49  */
50  void setPlanetPicSize(float size);
51  /**
52  * @short hides m_planetPic and shows m_point
53  */
54  void showPoint();
55  /**
56  * @short hides m_point and shows m_planetPic
57  */
58  void showPlanetPic();
59  /**
60  * @short changePos changes the position m_point and m_planetPic
61  * @param pos new position
62  */
63  virtual void changePos(QPointF pos) override;
64 
65  /**
66  * @note similar to SolarSystemSingleComponent::draw()
67  */
68  virtual void update() override;
69  virtual void hide() override;
70 
71  private:
72  PointNode *m_point;
73 
74  // This opacity node is used to hide m_planetPic. m_point is subclass of QSGOpacityNode so it needs
75  // no explicit opacity node here.
76  QSGSimpleTextureNode *m_planetPic;
77  SkyOpacityNode *m_planetOpacity;
78  LabelNode *m_label;
79 };
80 
81 #endif
SkyOpacityNode derived class that represents stars and planets using cached QSGTexture.
Definition: pointnode.h:24
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
A SkyNode derived class used for displaying labels.
Definition: labelnode.h:26
void showPlanetPic()
hides m_point and shows m_planetPic
Definition: planetnode.cpp:132
void setPlanetPicSize(float size)
updates the size of m_planetPic
Definition: planetnode.cpp:120
void setPointSize(float size)
updates the size of m_point
Definition: planetnode.cpp:115
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
virtual void hide() override
hides all child nodes (sets opacity of m_opacity to 0)
Definition: planetnode.cpp:138
A wrapper for QSGOpacityNode that provides hide() and show() functions. If node is invisible (opacity...
void showPoint()
hides m_planetPic and shows m_point
Definition: planetnode.cpp:126
PlanetNode(KSPlanetBase *pb, RootNode *parentNode, LabelsItem::label_t labelType=LabelsItem::label_t::PLANET_LABEL)
Constructor.
Definition: planetnode.cpp:20
Provides virtual functions for update of coordinates and nodes hiding.
Definition: skynode.h:27
virtual void changePos(QPointF pos) override
changePos changes the position m_point and m_planetPic
Definition: planetnode.cpp:145
virtual void update() override
Definition: planetnode.cpp:51
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 Tue Aug 9 2022 04:06:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.