Kstars

cometsitem.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#include "cometsitem.h"
7
8#include "Options.h"
9#include "projections/projector.h"
10#include "kscomet.h"
11
12#include "rootnode.h"
13#include "labelsitem.h"
14#include "skylabeler.h"
15
16#include "skynodes/pointsourcenode.h"
17
19 : SkyItem(LabelsItem::label_t::COMET_LABEL, rootNode), m_cometsList(cometsList)
20{
22}
23
25{
26 if (Options::zoomFactor() < 10 * MINZOOM)
27 {
28 hide();
29 return;
30 }
31
32 show();
33
34 bool hideLabel = !Options::showCometNames() || (SkyMapLite::Instance()->isSlewing() && Options::hideLabels());
35
36 if (hideLabel)
37 {
38 hideLabels();
39 }
40 double rsunLabelLimit = Options::maxRadCometName();
41
42 /*//FIXME: Should these be config'able?
43 skyp->setPen( QPen( QColor( "darkcyan" ) ) );
44 skyp->setBrush( QBrush( QColor( "darkcyan" ) ) );*/
45
46 //Traverse all children nodes
47 QSGNode *n = firstChild();
48 while (n != 0)
49 {
50 SkyNode *skyNode = static_cast<SkyNode *>(n);
51 n = n->nextSibling();
52
53 //TODO: Might be better move it to PointSourceNode
54 KSComet *com = static_cast<KSComet *>(skyNode->skyObject());
55 double mag = com->mag();
56 if (std::isnan(mag) == 0)
57 {
58 bool drawLabel = false;
59 if (!(hideLabel || com->rsun() >= rsunLabelLimit))
60 {
61 drawLabel = true;
62 }
63 skyNode->update(drawLabel);
64 }
65 else
66 {
67 skyNode->hide();
68 }
69 }
70}
71
73{
74 //Delete all child nodes
75 while (QSGNode *n = firstChild())
76 {
78 delete n;
79 }
80
81 foreach (SkyObject *comet, m_cometsList)
82 {
83 KSComet *com = static_cast<KSComet *>(comet);
85 }
86}
void recreateList()
recreates the node tree (deletes old nodes and appends new ones according to m_cometsList)
virtual void update() override
Determines the visibility of the object and its label and hides/updates them accordingly.
CometsItem(const QList< SkyObject * > &cometsList, RootNode *rootNode=nullptr)
Constructor.
A subclass of KSPlanetBase that implements comets.
Definition kscomet.h:44
This class is in charge of labels in SkyMapLite.
Definition labelsitem.h:53
A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
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
Provides virtual functions for update of coordinates and nodes hiding.
Definition skynode.h:28
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
QSGNode * nextSibling() const const
void removeChildNode(QSGNode *node)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.