Kstars

horizonitem.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#include "horizonitem.h"
7
8#include "horizoncomponent.h"
9#include "labelsitem.h"
10#include "Options.h"
11#include "rootnode.h"
12#include "skynodes/horizonnode.h"
13#include "skynodes/labelnode.h"
14
16 : SkyItem(LabelsItem::label_t::HORIZON_LABEL, rootNode), m_horizonComp(hComp)
17{
19
20 double az = -0.01;
21 static QString name[8];
22 name[0] = i18nc("Northeast", "NE");
23 name[1] = i18nc("East", "E");
24 name[2] = i18nc("Southeast", "SE");
25 name[3] = i18nc("South", "S");
26 name[4] = i18nc("Southwest", "SW");
27 name[5] = i18nc("West", "W");
28 name[6] = i18nc("Northwest", "NW");
29 name[7] = i18nc("North", "N");
30
31 for (int i = 0; i < 8; i++)
32 {
33 SkyPoint *c = new SkyPoint;
34
35 az += 45.0;
36 c->setAz(az);
37 c->setAlt(0.0);
38 LabelNode *compass = rootNode->labelsItem()->addLabel(name[i], labelType());
39
40 m_compassLabels.insert(c, compass);
41 }
42}
43
45{
46 if (!childCount())
47 {
49 }
50
51 //HorizonNode *hNode = static_cast<HorizonNode *>(n->skyNodeAtIndex(0));
52 QSGNode *n = firstChild();
53 SkyNode *hNode = static_cast<SkyNode *>(n);
54 if (m_horizonComp->selected())
55 {
56 QPointF cpoint;
57 bool visible;
58
59 const Projector *proj = SkyMapLite::Instance()->projector();
60 KStarsData *data = KStarsData::Instance();
61
63
64 while (i != m_compassLabels.cend())
65 {
66 SkyPoint *c = i.key();
67 if (!Options::useAltAz())
68 {
69 c->HorizontalToEquatorial(data->lst(), data->geo()->lat());
70 }
71
72 LabelNode *compass = (*i);
73 cpoint = proj->toScreen(c, false, &visible);
74 if (visible && proj->onScreen(cpoint))
75 {
76 compass->setLabelPos(cpoint);
77 }
78 else
79 {
80 compass->hide();
81 }
82 ++i;
83 }
84
85 hNode->update();
86 }
87 else
88 {
89 hNode->hide();
90 rootNode()->labelsItem()->hideLabels(LabelsItem::label_t::HORIZON_LABEL);
91 }
92}
const CachingDms * lat() const
Definition geolocation.h:70
Represents the horizon on the sky map.
bool selected() override
HorizonItem(HorizonComponent *hComp, RootNode *rootNode)
Constructor.
virtual void update()
Call update() of HorizonNode and update/hide compass labels based on their visibility.
This node acts as a parent of nodes that comprise horizon and both filled and non-filled ground.
Definition horizonnode.h:21
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
CachingDms * lst()
Definition kstarsdata.h:224
GeoLocation * geo()
Definition kstarsdata.h:230
A SkyNode derived class used for displaying labels.
Definition labelnode.h:27
void setLabelPos(QPointF pos)
set the position of label with the given offset from SkyObject's position and makes the label visible...
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.
void hideLabels(label_t labelType)
hides all labels of type labelType
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
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
bool onScreen(const QPointF &p) const
Check whether the projected point is on-screen.
Definition projector.cpp:98
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
RootNode * rootNode()
Definition skyitem.h:57
LabelsItem::label_t labelType()
Definition skyitem.h:60
const Projector * projector() const
Get the current projector.
Definition skymaplite.h:323
Provides virtual functions for update of coordinates and nodes hiding.
Definition skynode.h:28
virtual void hide()
hides all child nodes (sets opacity of m_opacity to 0)
Definition skynode.cpp:21
virtual void update()
Updates coordinate of the object on SkyMapLite.
Definition skynode.h:48
The sky coordinates of a point in the sky.
Definition skypoint.h:45
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition skypoint.h:194
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition skypoint.cpp:143
void setAz(dms az)
Sets Az, the Azimuth.
Definition skypoint.h:230
QString i18nc(const char *context, const char *text, const TYPE &arg...)
const_iterator cbegin() const const
const_iterator cend() const const
iterator insert(const Key &key, const T &value)
void appendChildNode(QSGNode *node)
int childCount() const const
QSGNode * firstChild() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.