File indexing completed on 2024-09-29 11:56:46

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 "typedef.h"
0009 #include "../skyopacitynode.h"
0010 
0011 #include <QLinkedList>
0012 
0013 class SkyObject;
0014 class SkyNode;
0015 
0016 /**
0017  * @short Convenience class that represents trixel in SkyMapLite. It should be used as a parent for
0018  * nodes that represent SkyObjects indexed by HTMesh
0019  */
0020 class TrixelNode : public SkyOpacityNode
0021 {
0022   public:
0023     /** Constructor **/
0024     explicit TrixelNode(const Trixel &trixel);
0025 
0026     /**
0027      * m_hideCount is a counter of how much updates of SkyMapLite this trixel remained
0028      * hidden. Used to reduce memory consumption
0029      **/
0030     inline int hideCount() { return m_hideCount; }
0031 
0032     /** Whenever the corresponding trixel is visible, m_hideCount is reset */
0033     inline void resetHideCount() { m_hideCount = 0; }
0034 
0035     void virtual hide() override;
0036     void virtual show() override;
0037 
0038     inline Trixel trixelID() { return m_trixel; }
0039 
0040     /** m_nodes - holds SkyNodes with corresponding SkyObjects */
0041     QLinkedList<QPair<SkyObject *, SkyNode *>> m_nodes;
0042 
0043     /** @short Delete all childNodes and remove nodes from pairs in m_nodes **/
0044     virtual void deleteAllChildNodes();
0045 
0046   private:
0047     Trixel m_trixel;
0048     int m_hideCount { 0 };
0049 };