Kstars

skynode.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#pragma once
7
8#include "skymaplite.h"
9
10#include <QSGTransformNode>
11
12class Projector;
13class SkyOpacityNode;
14
15/**
16 * @class SkyNode
17 * @short Provides virtual functions for update of coordinates and nodes hiding
18 *
19 * A QSGTransformNode derived class that has to be subclassed by node containers like PlanetNode and
20 * PointSourceNode. SkyObject * that is passed as parameter to constructor is used in subclasses
21 * to calculate new coordinates in update(). Subclasses have to implement hide() so that each of
22 * their child nodes can be hidden.
23 *
24 * @author Artem Fedoskin
25 * @version 1.0
26 */
28{
29 public:
30 /**
31 * @brief Constructor
32 * @param skyObject that is represented on the SkyMapLIte
33 */
34 explicit SkyNode(SkyObject *skyObject);
35 SkyNode();
36
37 virtual ~SkyNode() {}
38
39 inline const Projector *projector() { return SkyMapLite::Instance()->projector(); }
40
41 /**
42 * @short short function to access SkyMapLite
43 * @return pointer to instance of SkyMapLite class
44 */
45 inline SkyMapLite *map() const { return SkyMapLite::Instance(); }
46
47 /** Updates coordinate of the object on SkyMapLite */
48 virtual void update() {}
49
50 /**
51 * @short sets m_drawLabel to true if it is needed to be drawn and calls update()
52 * @param drawLabel true of label has to be drawn
53 */
54 void update(bool drawLabel);
55
56 void addChildNode(QSGNode *node);
57
58 /**
59 * @short hides all child nodes (sets opacity of m_opacity to 0)
60 */
61 virtual void hide();
62
63 /**
64 * @short shows all child nodes (sets opacity of m_opacity to 1)
65 */
66 virtual void show();
67
68 inline int hideCount() { return m_hideCount; }
69
70 /**
71 * @short changes the position of SkyNode on SkyMapLite. Has to be overridden by the classes
72 * that support moving
73 * @param pos new position
74 */
75 virtual void changePos(QPointF pos) { Q_UNUSED(pos); }
76
77 /**
78 * @return true if object is visible (m_opacity->opacity() != 0) else returns false
79 */
80 bool visible();
81
82 /**
83 * @short returns SkyObject associated with this SkyNode
84 * @return pointer to the object of type SkyObject
85 */
86 SkyObject *skyObject() const { return m_skyObject; }
87
88 SkyOpacityNode *m_opacity { nullptr };
89
90 protected:
91 SkyObject *m_skyObject { nullptr };
92 bool m_drawLabel { false };
93 int m_hideCount { 0 };
94};
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
This is the main item that displays all SkyItems.
Definition skymaplite.h:59
const Projector * projector() const
Get the current projector.
Definition skymaplite.h:323
Provides virtual functions for update of coordinates and nodes hiding.
Definition skynode.h:28
SkyObject * skyObject() const
returns SkyObject associated with this SkyNode
Definition skynode.h:86
virtual void show()
shows all child nodes (sets opacity of m_opacity to 1)
Definition skynode.cpp:27
virtual void hide()
hides all child nodes (sets opacity of m_opacity to 0)
Definition skynode.cpp:21
virtual void changePos(QPointF pos)
changes the position of SkyNode on SkyMapLite.
Definition skynode.h:75
virtual void update()
Updates coordinate of the object on SkyMapLite.
Definition skynode.h:48
bool visible()
Definition skynode.cpp:44
SkyMapLite * map() const
short function to access SkyMapLite
Definition skynode.h:45
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
A wrapper for QSGOpacityNode that provides hide() and show() functions.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.