Kstars

linesitem.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
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
16LineIndexNode::LineIndexNode(const QString &color) : schemeColor(color)
17{
18}
19
20LinesItem::LinesItem(RootNode *rootNode) : SkyItem(LabelsItem::label_t::NO_LABEL, rootNode)
21{
22}
23
24void 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}
QColor colorNamed(const QString &name) const
Retrieve a color by name.
ColorScheme * colorScheme()
Definition kstarsdata.h:174
This class is in charge of labels in SkyMapLite.
Definition labelsitem.h:53
Contains almost all the code needed for indexing and drawing and clipping lines and polygons.
A simple data container used by LineListIndex.
Definition linelist.h:25
SkyOpacityNode derived class that draws lines from LineList.
Definition linenode.h:28
void updateGeometry()
Update lines based on the visibility of line segments in m_lineList.
Definition linenode.cpp:65
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
virtual void update()
updates all trixels that are associated with LineListIndex or hide them if selected() of this LineLis...
Definition linesitem.cpp:72
LinesItem(RootNode *rootNode)
Constructor.
Definition linesitem.cpp:20
A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
Definition rootnode.h:60
This is an interface for implementing SkyItems that represent SkyComponent derived objects on the Sky...
Definition skyitem.h:30
virtual void show()
makes this node visible
virtual void hide()
hides this node
Convenience class that represents trixel in SkyMapLite.
Definition trixelnode.h:21
virtual void show() override
makes this node visible
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
const_iterator cbegin() const const
const_iterator cend() const const
bool contains(const AT &value) const const
iterator begin()
const_iterator cbegin() const const
const_iterator cend() const const
iterator end()
iterator insert(const Key &key, const T &value)
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
QSGNode * nextSibling() const const
PenStyle
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.