Kstars

eclipticitem.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#include "eclipticitem.h"
7
8#include "ecliptic.h"
9#include "../labelsitem.h"
10#include "../rootnode.h"
11#include "../skynodes/labelnode.h"
12#include "../skynodes/nodes/linenode.h"
13#include "../skynodes/trixelnode.h"
14
16 : SkyItem(LabelsItem::label_t::ECLIPTIC_LABEL, rootNode), m_eclipticComp(eclipticComp)
17{
18 LineListHash *trixels = eclipticComp->lineIndex();
19
20 auto i = trixels->cbegin();
21
22 while (i != trixels->cend())
23 {
24 std::shared_ptr<LineListList> linesList = *i;
25
27
28 if (linesList->size())
29 {
30 QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed("EclColor");
31
32 for (int c = 0; c < linesList->size(); ++c)
33 {
34 std::shared_ptr<LineList> lines = linesList->at(c);
35
36 if (!addedLines.contains(lines))
37 {
38 LineNode *ln = new LineNode(lines.get(), 0, schemeColor, 1, Qt::SolidLine);
39
41 addedLines.append(lines);
42 }
43 }
44 }
45 ++i;
46 }
47
48 KStarsData *data = KStarsData::Instance();
49 KSNumbers num(data->ut().djd());
50 dms elat(0.0), elng(0.0);
51 QString label;
52
53 for (int ra = 0; ra < 23; ra += 6)
54 {
55 elng.setH(ra);
56 SkyPoint *o = new SkyPoint;
58 o->setRA0(o->ra());
59 o->setDec0(o->dec());
60 o->EquatorialToHorizontal(data->lst(), data->geo()->lat());
61
62 label.setNum(o->ra().reduce().Degrees());
63
64 LabelNode *compass = rootNode->labelsItem()->addLabel(label, labelType());
65 m_compassLabels.insert(o, compass);
66 }
67}
68
70{
71 if (m_eclipticComp->selected())
72 {
73 show();
74 QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed("EclColor");
75
76 UpdateID updateID = KStarsData::Instance()->updateID();
77
78 QSGNode *l = firstChild();
79 while (l != 0)
80 {
81 LineNode *lines = static_cast<LineNode *>(l);
82 lines->setColor(schemeColor);
83 l = l->nextSibling();
84
85 LineList *lineList = lines->lineList();
86 if (lineList->updateID != updateID)
87 m_eclipticComp->JITupdate(lineList);
88
89 lines->updateGeometry();
90 }
91
92 const Projector *proj = SkyMapLite::Instance()->projector();
93 KStarsData *data = KStarsData::Instance();
94
96
97 while (i != m_compassLabels.end())
98 {
99 SkyPoint *c = i.key();
100 c->EquatorialToHorizontal(data->lst(), data->geo()->lat());
101
102 LabelNode *compass = (*i);
103
104 bool visible;
105 QPointF cpoint = proj->toScreen(c, false, &visible);
106 if (visible && proj->checkVisibility(c))
107 {
108 compass->setLabelPos(cpoint);
109 }
110 else
111 {
112 compass->hide();
113 }
114 ++i;
115 }
116 }
117 else
118 {
119 hide();
120 }
121}
EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode)
Constructor.
virtual void update() override
updates positions of lines and compass labels
Represents the ecliptic on the sky map.
Definition ecliptic.h:20
bool selected() override
Definition ecliptic.cpp:52
const CachingDms * lat() const
Definition geolocation.h:70
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
const CachingDms * obliquity() const
Definition ksnumbers.h:56
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
CachingDms * lst()
Definition kstarsdata.h:224
const KStarsDateTime & ut() const
Definition kstarsdata.h:157
GeoLocation * geo()
Definition kstarsdata.h:230
A SkyNode derived class used for displaying labels.
Definition labelnode.h:27
This class is in charge of labels in SkyMapLite.
Definition labelsitem.h:53
LabelNode * addLabel(SkyObject *skyObject, label_t labelType)
Create LabelNode with given skyObject and append it to LabelTypeNode that corresponds to type.
virtual void JITupdate(LineList *lineList)
this is called from within the draw routines when the updateID of the lineList is stale.
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
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
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 hide() override
hides this item and corresponding labels
Definition skyitem.cpp:37
RootNode * rootNode()
Definition skyitem.h:57
LabelsItem::label_t labelType()
Definition skyitem.h:60
virtual void show() override
makes this node visible
Definition skyitem.cpp:23
The sky coordinates of a point in the sky.
Definition skypoint.h:45
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
void setFromEcliptic(const CachingDms *Obliquity, const dms &EcLong, const dms &EcLat)
Set the current (RA, Dec) coordinates of the SkyPoint, given pointers to its Ecliptic (Long,...
Definition skypoint.cpp:201
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
Definition skypoint.h:94
void setDec0(dms d)
Sets Dec0, the catalog Declination.
Definition skypoint.h:119
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
iterator begin()
iterator end()
iterator insert(const Key &key, const T &value)
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
QSGNode * nextSibling() const const
QString & setNum(double n, char format, int precision)
SolidLine
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.