File indexing completed on 2024-07-07 07:08:38

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 "kstarslite.h"
0009 
0010 #include <QPolygonF>
0011 #include <QSGClipNode>
0012 
0013 class QSGTexture;
0014 class SkyMapLite;
0015 
0016 class StarItem;
0017 class DeepSkyItem;
0018 
0019 class PlanetsItem;
0020 class AsteroidsItem;
0021 class CometsItem;
0022 
0023 class ConstellationNamesItem;
0024 class LabelsItem;
0025 class ConstellationArtItem;
0026 class SatellitesItem;
0027 class SupernovaeItem;
0028 
0029 class LinesItem;
0030 class HorizonItem;
0031 class EquatorItem;
0032 class EclipticItem;
0033 class MilkyWayItem;
0034 
0035 class SkyMapComposite;
0036 class SolarSystemComposite;
0037 
0038 class FOVItem;
0039 
0040 class TelescopeSymbolsItem;
0041 
0042 /**
0043  * @class RootNode
0044  *
0045  * A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
0046  * Upon construction RootNode generates all textures that are used by PointNode.
0047  *
0048  * KStars Lite has the following hierarchy:
0049  * 1. RootNode - the parent of all nodes that also acts as a clipping node
0050  * 2. SkyItem derived nodes that acts like SkyComponent in regular KStars
0051  * 3. SkyNode derived nodes that represent SkyObjects (similar to SkyComponent::draw())
0052  * 4. Simple nodes like EllipseNode or PointNode that draw basic geometry and stars
0053  *
0054  * @short A container for nodes that holds collection of textures for stars and provides clipping
0055  * @author Artem Fedoskin
0056  * @version 1.0
0057  */
0058 
0059 class RootNode : public QSGClipNode
0060 {
0061   public:
0062     RootNode();
0063     virtual ~RootNode();
0064 
0065     /**
0066      * @short returns cached texture from textureCache
0067      * @param size size of the star
0068      * @param spType spectral class
0069      * @return cached QSGTexture from textureCache
0070      */
0071     QSGTexture *getCachedTexture(int size, char spType);
0072 
0073     /** @short triangulates and sets new clipping polygon provided by Projection system */
0074     void updateClipPoly();
0075 
0076     /**
0077      * @short update positions of all child SkyItems
0078      * @param clearTextures true if textures for PointNodes should recreated (required when color scheme
0079      * is changed)
0080      */
0081     void update(bool clearTextures = false);
0082 
0083     /** Debug functions **/
0084     void testLeakDelete();
0085     void testLeakAdd();
0086 
0087     inline CometsItem *cometsItem() { return m_cometsItem; }
0088 
0089     inline LabelsItem *labelsItem() { return m_labelsItem; }
0090 
0091     inline StarItem *starItem() { return m_starItem; }
0092     /** @short initializes textureCache with cached images of stars from SkyMapLite */
0093     void genCachedTextures();
0094 
0095     inline TelescopeSymbolsItem *telescopeSymbolsItem() { return m_telescopeSymbols; }
0096 
0097   private:
0098     QVector<QVector<QSGTexture *>> m_textureCache;
0099     QVector<QVector<QSGTexture *>> m_oldTextureCache;
0100     SkyMapLite *m_skyMapLite { nullptr };
0101 
0102     QPolygonF m_clipPoly;
0103     QSGGeometry *m_clipGeometry { nullptr };
0104 
0105     StarItem *m_starItem { nullptr };
0106     DeepSkyItem *m_dsoItem { nullptr };
0107 
0108     PlanetsItem *m_planetsItem { nullptr };
0109     AsteroidsItem *m_asteroidsItem { nullptr };
0110     CometsItem *m_cometsItem { nullptr };
0111 
0112     ConstellationNamesItem *m_constelNamesItem { nullptr };
0113     LabelsItem *m_labelsItem { nullptr };
0114     ConstellationArtItem *m_artItem { nullptr };
0115     SatellitesItem *m_satItem { nullptr };
0116     SupernovaeItem *m_snovaItem { nullptr };
0117 
0118     HorizonItem *m_horizonItem { nullptr };
0119     LinesItem *m_linesItem { nullptr };
0120     EquatorItem *m_equator { nullptr };
0121     EclipticItem *m_ecliptic { nullptr };
0122     MilkyWayItem *m_MWItem { nullptr };
0123 
0124     SkyMapComposite *m_skyComposite { nullptr };
0125     SolarSystemComposite *m_solarSystem { nullptr };
0126 
0127     FOVItem *m_FOVItem { nullptr };
0128     TelescopeSymbolsItem *m_telescopeSymbols { nullptr };
0129 };