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 0006 #pragma once 0007 0008 #include "skynode.h" 0009 #include "../labelsitem.h" 0010 0011 class PlanetItemNode; 0012 class SkyMapLite; 0013 class PointNode; 0014 class LabelNode; 0015 class QSGSimpleTextureNode; 0016 class DSOSymbolNode; 0017 0018 /** 0019 * @class DeepSkyNode 0020 * 0021 * @short A SkyNode derived class used for displaying DeepSkyObjects. 0022 * 0023 * Keep in mind that DSO symbol is handled by DSOSymbolNode that has different parent from this node 0024 * but DeepSkyNode calls update routines of DSOSymbolNode. 0025 * @author Artem Fedoskin 0026 * @version 1.0 0027 */ 0028 0029 class RootNode; 0030 class DeepSkyObject; 0031 0032 class DeepSkyNode : public SkyNode 0033 { 0034 public: 0035 /** 0036 * @short Constructor. 0037 * @param skyObject - DSOs that is represented by this node 0038 * @param symbol - DSOSymbolNode of this DSO 0039 * @param labelType - type of label 0040 * @param trixel - trixelID, with which this node is indexed 0041 */ 0042 DeepSkyNode(DeepSkyObject *skyObject, DSOSymbolNode *symbol, LabelsItem::label_t labelType, short trixel = -1); 0043 0044 /** @short Destructor. Call delete routines of label */ 0045 virtual ~DeepSkyNode(); 0046 0047 /** 0048 * @short changePos changes the position of this node and rotate it according to m_angle 0049 * @param pos new position 0050 */ 0051 virtual void changePos(QPointF pos) override; 0052 0053 /** 0054 * @short Update position and visibility of this node 0055 * @param drawImage - true if image (if exists) should be drawn 0056 * @param drawLabel - true if label should be drawn 0057 * @param pos - new position of the object. If default parameter is passed, the visibility and 0058 * position of node is calculated. 0059 * There is one case when we pass this parameter - in DeepSkyItem::updateDeepSkyNode() when 0060 * we check whether DeepSkyObject is visible or no and instantiate it accordingly. There is no 0061 * need to calculate the position again and we pass it as a parameter. 0062 */ 0063 void update(bool drawImage, bool drawLabel, QPointF pos = QPointF(-1, -1)); 0064 0065 virtual void hide() override; 0066 0067 /** 0068 * @short sets color of DSO symbol and label 0069 * To not increase the code for symbols we just recreate the symbol painted with desired color 0070 * @param color the color to be set 0071 * @param symbolTrixel the TrixelNode to which symbol node should be appended 0072 */ 0073 void setColor(QColor color, TrixelNode *symbolTrixel); 0074 0075 DeepSkyObject *dsObject() { return m_dso; } 0076 DSOSymbolNode *symbol() { return m_symbol; } 0077 0078 private: 0079 QSGSimpleTextureNode *m_objImg { nullptr }; 0080 /// Trixel to which this object belongs. Used only in stars. By default -1 for all 0081 Trixel m_trixel { 0 }; 0082 0083 LabelNode *m_label { nullptr }; 0084 LabelsItem::label_t m_labelType { LabelsItem::NO_LABEL }; 0085 0086 DeepSkyObject *m_dso { nullptr }; 0087 DSOSymbolNode *m_symbol { nullptr }; 0088 float m_angle { 0 }; 0089 QPointF pos; 0090 };