Kstars

eclipticitem.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
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 
15 EclipticItem::EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode)
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 
40  appendChildNode(ln);
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;
57  o->setFromEcliptic(num.obliquity(), elng, elat);
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 
95  QMap<SkyPoint *, LabelNode *>::iterator i = m_compassLabels.begin();
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 }
void append(const T &value)
A base class that is used for displaying SkyComponents on SkyMapLite.
Definition: skyitem.h:29
long double djd() const
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
LabelsItem::label_t labelType()
Definition: skyitem.h:60
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void setDec0(dms d)
Sets Dec0, the catalog Declination.
Definition: skypoint.h:119
void updateGeometry()
Update lines based on the visibility of line segments in m_lineList.
Definition: linenode.cpp:65
QMap::iterator begin()
A SkyNode derived class used for displaying labels.
Definition: labelnode.h:26
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
CachingDms * lst()
Definition: kstarsdata.h:223
Handles labels in SkyMapLite.
Definition: labelsitem.h:52
bool contains(const T &value) const const
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
Definition: skypoint.h:94
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
QHash::const_iterator cend() const const
virtual void show() override
makes this node visible
Definition: skyitem.cpp:23
QMap::iterator insert(const Key &key, const T &value)
virtual void setH(const double &x)
Sets floating-point value of angle, in hours.
Definition: dms.h:210
QMap::iterator end()
bool selected() override
Definition: ecliptic.cpp:52
QString & setNum(short n, int base)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const Projector * projector() const
Get the current projector.
Definition: skymaplite.h:323
const CachingDms & dec() const
Definition: skypoint.h:269
const CachingDms * lat() const
Definition: geolocation.h:70
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
GeoLocation * geo()
Definition: kstarsdata.h:229
SkyOpacityNode derived class that draws lines from LineList.
Definition: linenode.h:27
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
virtual void hide() override
hides this item and corresponding labels
Definition: skyitem.cpp:37
const Key key(const T &value, const Key &defaultKey) const const
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
const KStarsDateTime & ut() const
Definition: kstarsdata.h:156
const CachingDms & ra() const
Definition: skypoint.h:263
const CachingDms * obliquity() const
Definition: ksnumbers.h:56
const double & Degrees() const
Definition: dms.h:141
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=nullptr) const
This is exactly the same as toScreenVec but it returns a QPointF.
Definition: projector.cpp:93
void setLabelPos(QPointF pos)
set the position of label with the given offset from SkyObject's position and makes the label visible...
Definition: labelnode.cpp:123
RootNode * rootNode()
Definition: skyitem.h:57
virtual void update() override
updates positions of lines and compass labels
QHash::const_iterator cbegin() const const
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
Definition: dms.cpp:251
SolidLine
QSGNode * nextSibling() const const
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:86
EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode)
Constructor.
LabelNode * addLabel(SkyObject *skyObject, label_t labelType)
Create LabelNode with given skyObject and append it to LabelTypeNode that corresponds to type.
Definition: labelsitem.cpp:111
virtual void hide()
hides all child nodes (sets opacity of m_opacity to 0)
Definition: skynode.cpp:21
virtual void JITupdate(LineList *lineList)
this is called from within the draw routines when the updateID of the lineList is stale.
bool checkVisibility(const SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
Definition: projector.cpp:183
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 8 2022 04:13:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.