Kstars

telescopesymbolsitem.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#include "telescopesymbolsitem.h"
7
8#include "kstarslite.h"
9#include "labelsitem.h"
10#include "Options.h"
11#include "indi/clientmanagerlite.h"
12#include "kstarslite/skyitems/rootnode.h"
13#include "projections/projector.h"
14#include "skynodes/crosshairnode.h"
15
16#include <basedevice.h>
17
19 : SkyItem(LabelsItem::label_t::TELESCOPE_SYMBOL, rootNode)
20{
21 m_clientManager = KStarsLite::Instance()->clientManagerLite();
22 m_KStarsData = KStarsData::Instance();
23}
24
25void TelescopeSymbolsItem::addTelescope(INDI::BaseDevice *bd)
26{
27 if (!m_telescopes.value(bd))
28 {
29 CrosshairNode *crossHair = new CrosshairNode(bd, rootNode());
31
32 m_telescopes.insert(bd, crossHair);
33 }
34}
35
36void TelescopeSymbolsItem::removeTelescope(INDI::BaseDevice *bd)
37{
38 CrosshairNode *crossHair = m_telescopes.value(bd);
39 if (crossHair)
40 {
42 delete crossHair;
43 }
44 m_telescopes.remove(bd);
45}
46
48{
50 bool deleteAll = !m_clientManager->isConnected();
51
52 QColor color = m_KStarsData->colorScheme()->colorNamed("TargetColor");
53
54 bool show = Options::showTargetCrosshair();
55 if (!show)
56 {
57 hide();
58 }
59
60 for (i = m_telescopes.begin(); i != m_telescopes.end(); ++i)
61 {
62 CrosshairNode *crossHair = i.value();
63 INDI::BaseDevice *device = i.key();
64 if (crossHair)
65 {
66 if (deleteAll || !(device->isConnected()))
67 {
69 delete crossHair;
70 m_telescopes.insert(device, nullptr);
71 }
72 else if (show)
73 {
74 if (device->isConnected())
75 {
76 crossHair->setColor(color);
77 crossHair->update();
78 }
79 else
80 {
81 crossHair->hide();
82 }
83 }
84 }
85 }
86 if (deleteAll)
87 {
88 m_telescopes.clear();
89 }
90}
QColor colorNamed(const QString &name) const
Retrieve a color by name.
ColorScheme * colorScheme()
Definition kstarsdata.h:172
static KStarsLite * Instance()
Definition kstarslite.h:77
This class is in charge of labels in SkyMapLite.
Definition labelsitem.h:53
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
virtual void show() override
makes this node visible
Definition skyitem.cpp:23
void addTelescope(INDI::BaseDevice *bd)
Add telescope symbol for device bd.
TelescopeSymbolsItem(RootNode *rootNode)
Constructor.
void removeTelescope(INDI::BaseDevice *bd)
Remove telescope symbol of device bd.
virtual void update() override
Updates position and visibility of CrosshairNodes that represent telescope symbols If client is no mo...
iterator begin()
void clear()
iterator end()
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
T value(const Key &key) const const
void appendChildNode(QSGNode *node)
void removeChildNode(QSGNode *node)
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.