Kstars

constellationartitem.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #include "constellationartitem.h"
7 
8 #include "Options.h"
9 #include "projections/projector.h"
10 #include "constellationartcomponent.h"
11 #include "skynodes/constellationartnode.h"
12 
14  : SkyItem(LabelsItem::label_t::NO_LABEL, rootNode), m_artComp(artComp)
15 {
16  loadNodes();
17 }
18 
20 {
21  m_artComp->deleteData();
22  QSGNode *n = firstChild();
23  while (n != 0)
24  {
25  QSGNode *d = n;
26  n = n->nextSibling();
27  removeChildNode(d);
28  delete d;
29  }
30 }
31 
33 {
34  m_artComp->loadData();
35  if (!childCount())
36  {
37  QList<ConstellationsArt *> list = m_artComp->m_ConstList;
38  foreach (ConstellationsArt *art, list)
39  {
40  ConstellationArtNode *constArt = new ConstellationArtNode(art);
41  appendChildNode(constArt);
42  }
43  }
44 }
45 
47 {
48  if (Options::showConstellationArt())
49  {
50  loadNodes();
51  if (SkyMapLite::IsSlewing() == false)
52  {
53  show();
54  //Traverse all children nodes of RootNode
55  QSGNode *n = firstChild();
56  while (n != 0)
57  {
58  ConstellationArtNode *artNode = static_cast<ConstellationArtNode *>(n);
59  artNode->update();
60  n = n->nextSibling();
61  }
62  }
63  else
64  {
65  hide();
66  }
67  }
68  else
69  {
70  //Delete all images if we don't need to draw constellation art and save ~50 MB.
71  deleteNodes();
72  }
73 }
void update() override
calls update() of all child ConstellationArtNodes if constellation art is on.
A base class that is used for displaying SkyComponents on SkyMapLite.
Definition: skyitem.h:29
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
ConstellationArtItem(ConstellationArtComponent *artComp, RootNode *rootNode=nullptr)
A SkyNode derived class that represents ConstellationsArt object.
void loadData()
Read the skycultures.sqlite database file.
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
int childCount() const const
Handles labels in SkyMapLite.
Definition: labelsitem.h:52
void deleteNodes()
deleteNodes deletes constellation art data and ConstellationArtNodes
void deleteData()
deletes all created ConstellationsArt objects.
virtual void show() override
makes this node visible
Definition: skyitem.cpp:23
virtual void update() override
Updates coordinate of the object on SkyMapLite.
void loadNodes()
loadNodes loads constellation art data and creates ConstellationArtNodes
virtual void hide() override
hides this item and corresponding labels
Definition: skyitem.cpp:37
Information about a ConstellationsArt object. This class represents a constellation image.
QSGNode * nextSibling() const const
void removeChildNode(QSGNode *node)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Oct 1 2023 04:02:38 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.