Kstars

linesitem.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #include "linesitem.h"
7 
8 #include "linelist.h"
9 #include "linelistindex.h"
10 #include "projections/projector.h"
11 #include "../skynodes/nodes/linenode.h"
12 #include "../skynodes/trixelnode.h"
13 
14 #include <QSGNode>
15 
16 LineIndexNode::LineIndexNode(const QString &color) : schemeColor(color)
17 {
18 }
19 
20 LinesItem::LinesItem(RootNode *rootNode) : SkyItem(LabelsItem::label_t::NO_LABEL, rootNode)
21 {
22 }
23 
24 void LinesItem::addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style)
25 {
26  LineIndexNode *node = new LineIndexNode(color);
27  appendChildNode(node);
28 
29  m_lineIndexes.insert(node, linesComp);
30  LineListHash *list = linesComp->lineIndex();
31  //Sort by trixels
33 
34  auto s = list->cbegin();
35 
36  while (s != list->cend())
37  {
38  trixels.insert(s.key(), *s);
39  s++;
40  }
41 
42  auto i = trixels.cbegin();
44 
45  while (i != trixels.cend())
46  {
47  std::shared_ptr<LineListList> linesList = *i;
48 
49  if (linesList->size())
50  {
51  TrixelNode *trixel = new TrixelNode(i.key());
52 
53  node->appendChildNode(trixel);
54 
55  QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed(color);
56 
57  for (int c = 0; c < linesList->size(); ++c)
58  {
59  std::shared_ptr<LineList> list = linesList->at(c);
60 
61  if (!addedLines.contains(list))
62  {
63  trixel->appendChildNode(new LineNode(linesList->at(c).get(), 0, schemeColor, width, style));
64  addedLines.append(list);
65  }
66  }
67  }
68  ++i;
69  }
70 }
71 
73 {
75 
76  UpdateID updateID = KStarsData::Instance()->updateID();
77 
78  while (i != m_lineIndexes.end())
79  {
80  LineIndexNode *node = i.key();
81  QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed(node->getSchemeColor());
82  if (i.value()->selected())
83  {
84  node->show();
85 
86  QSGNode *n = node->firstChild();
87  while (n != 0)
88  {
89  TrixelNode *trixel = static_cast<TrixelNode *>(n);
90  trixel->show();
91 
92  QSGNode *l = trixel->firstChild();
93  while (l != 0)
94  {
95  LineNode *lines = static_cast<LineNode *>(l);
96  lines->setColor(schemeColor);
97  l = l->nextSibling();
98 
99  LineList *lineList = lines->lineList();
100  if (lineList->updateID != updateID)
101  i.value()->JITupdate(lineList);
102 
103  lines->updateGeometry();
104  }
105  n = n->nextSibling();
106  }
107  }
108  else
109  {
110  node->hide();
111  }
112  ++i;
113  }
114 }
void append(const T &value)
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
const T value(const Key &key, const T &defaultValue) const const
void updateGeometry()
Update lines based on the visibility of line segments in m_lineList.
Definition: linenode.cpp:65
QMap::iterator begin()
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
LinesItem(RootNode *rootNode)
Constructor.
Definition: linesitem.cpp:20
Handles labels in SkyMapLite.
Definition: labelsitem.h:52
bool contains(const T &value) const const
QMap::const_iterator cbegin() const const
QMap::iterator insert(const Key &key, const T &value)
virtual void show() override
makes this node visible
Definition: trixelnode.cpp:40
QMap::iterator end()
QMap::const_iterator cend() const const
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
const T & at(int i) const const
Convenience class that represents trixel in SkyMapLite.
Definition: trixelnode.h:20
SkyOpacityNode derived class that draws lines from LineList.
Definition: linenode.h:27
QList::const_iterator cend() const const
const Key key(const T &value, const Key &defaultKey) const const
virtual void update()
updates all trixels that are associated with LineListIndex or hide them if selected() of this LineLis...
Definition: linesitem.cpp:72
QList::const_iterator cbegin() const const
void addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style)
adds LinesListIndex that is needed to be displayed to m_lineIndexes
Definition: linesitem.cpp:24
PenStyle
QSGNode * nextSibling() const const
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:86
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.