File indexing completed on 2024-04-14 03:42:49

0001 /*
0002     SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #pragma once
0007 
0008 #include "skyopacitynode.h"
0009 #include "labelsitem.h"
0010 
0011 class SkyComponent;
0012 class SkyMapLite;
0013 class QQuickItem;
0014 class RootNode;
0015 class SkyNode;
0016 
0017 /**
0018  * @class SkyItem
0019  *
0020  * This is an interface for implementing SkyItems that represent SkyComponent derived objects on
0021  * the SkyMapLite. It is derived from QSGOpacityNode to make it possible to hide the whole node tree
0022  * by simply setting opacity to 0.
0023  *
0024  * @short A base class that is used for displaying SkyComponents on SkyMapLite.
0025  * @author Artem Fedoskin
0026  * @version 1.0
0027  */
0028 
0029 class SkyItem : public SkyOpacityNode
0030 {
0031   public:
0032     /**
0033      * Constructor, appends SkyItem to rootNode as a child in a node tree
0034      *
0035      * @param labelType type of label that corresponds to this item
0036      * @note see LabelsItem::label_t
0037      * @param parent a pointer to SkyItem's parent node
0038      */
0039     explicit SkyItem(LabelsItem::label_t labelType, RootNode *rootNode = nullptr);
0040     /** @see PointSourceNode::~PointSourceNode() */
0041     virtual ~SkyItem();
0042 
0043     /**
0044      * @short updates the coordinates and visibility of child node. Similar to draw routine in
0045      * SkyComponent derived classes
0046      */
0047     virtual void update() = 0;
0048 
0049     virtual void show() override;
0050 
0051     /** @short hides this item and corresponding labels */
0052     virtual void hide() override;
0053 
0054     void hideLabels();
0055 
0056     /** @return RootNode that is the parent of this SkyItem in a node tree */
0057     inline RootNode *rootNode() { return m_rootNode; }
0058 
0059     /** @return label type of this SkyItem */
0060     inline LabelsItem::label_t labelType() { return m_labelType; }
0061 
0062   private:
0063     RootNode *m_rootNode { nullptr };
0064     QVector<SkyNode *> m_skyNodes;
0065     LabelsItem::label_t m_labelType;
0066 };