Kstars

skycomposite.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "skycomposite.h"
8
9#include "skyobjects/skyobject.h"
10#include <qdebug.h>
11
15
17{
18 qDeleteAll(components());
19 m_Components.clear();
20}
21
22void SkyComposite::addComponent(SkyComponent *component, int priority)
23{
24 //qDebug() << Q_FUNC_INFO << "Adding sky component " << component << " of type " << typeid( *component ).name() << " with priority " << priority;
25 m_Components.insert(priority, component);
26 /*
27 foreach( SkyComponent *p, components() ) {
28 qDebug() << Q_FUNC_INFO << "List now has: " << p << " of type " << typeid( *p ).name();
29 }
30 */
31}
32
34{
35 // qDebug() << Q_FUNC_INFO << "Removing sky component " << component << " of type " << typeid( *component ).name();
37 for (it = m_Components.begin(); it != m_Components.end();)
38 {
39 if (it.value() == component)
40 it = m_Components.erase(it);
41 else
42 ++it;
43 }
44 /*
45 foreach( SkyComponent *p, components() ) {
46 qDebug() << Q_FUNC_INFO << "List now has: " << p << " of type " << typeid( *p ).name();
47 }
48 */
49}
50
52{
53 if (selected())
54 foreach (SkyComponent *component, components())
55 component->draw(skyp);
56}
57
59{
60 foreach (SkyComponent *component, components())
61 component->update(num);
62}
63
65{
66 for (const auto &oneComponent : components())
67 {
68 SkyObject *o = oneComponent->findByName(name, exact);
69 if (o)
70 return o;
71 }
72 return nullptr;
73}
74
76{
77 if (!selected())
78 return nullptr;
79 SkyObject *oBest = nullptr;
80 foreach (SkyComponent *comp, components())
81 {
82 //qDebug() << Q_FUNC_INFO << "Checking " << typeid( *comp ).name() <<" for oBest";
83 SkyObject *oTry = comp->objectNearest(p, maxrad);
84 if (oTry)
85 {
86 oBest = oTry;
87 maxrad =
89 0.95; // Set a new maxrad, smaller than original to give priority to the earlier objects in the list.
90 // qDebug() << Q_FUNC_INFO << "oBest = " << oBest << " of type " << typeid( *oTry ).name() << "; updated maxrad = " << maxrad;
91 }
92 }
93 // qDebug() << Q_FUNC_INFO << "Returning best match: oBest = " << oBest;
94 return oBest; //will be 0 if no object nearer than maxrad was found
95}
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
SkyComponent represents an object on the sky map.
virtual void draw(SkyPainter *skyp)=0
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
virtual void update(KSNumbers *)
Update the sky position(s) of this component.
virtual bool selected()
SkyComposite is a kind of container class for SkyComponent objects.
void addComponent(SkyComponent *comp, int priority=1024)
Add a new sub component to the composite comp Pointer to the SkyComponent to be added priority A prio...
void removeComponent(SkyComponent *const comp)
Remove a sub component from the composite comp Pointer to the SkyComponent to be removed.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Identify the nearest SkyObject to the given SkyPoint, among the children of this SkyComposite p point...
~SkyComposite() override
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyComposite for a SkyObject whose name matches the argument.
void draw(SkyPainter *skyp) override
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.
void update(KSNumbers *num=nullptr) override
Delegate update-position requests to all sub components.
SkyComposite(SkyComposite *parent=nullptr)
Constructor parent pointer to the parent SkyComponent.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
Definition skypoint.cpp:899
const double & Degrees() const
Definition dms.h:141
iterator begin()
void clear()
iterator end()
iterator erase(const_iterator first, const_iterator last)
iterator insert(const Key &key, const T &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.