Kstars

listcomponent.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "listcomponent.h"
8
9#include "kstarsdata.h"
10#ifndef KSTARS_LITE
11#include "skymap.h"
12#endif
13
14ListComponent::ListComponent(SkyComposite *parent) : SkyComponent(parent)
15{
16}
17
18ListComponent::~ListComponent()
19{
20 qDeleteAll(m_ObjectList);
21 m_ObjectList.clear();
22 m_ObjectHash.clear();
23
24 clear();
25}
26
27void ListComponent::clear()
28{
29 while (!m_ObjectList.isEmpty())
30 {
31 SkyObject *o = m_ObjectList.takeFirst();
32 removeFromNames(o);
33 delete o;
34 }
35}
36
38{
39 // Append to the Object List
40 m_ObjectList.append(object);
41
42 // Insert multiple Names
43 m_ObjectHash.insert(object->name().toLower(), object);
44 m_ObjectHash.insert(object->longname().toLower(), object);
45 m_ObjectHash.insert(object->name2().toLower(), object);
46}
47
49{
50 if (!selected())
51 return;
52 KStarsData *data = KStarsData::Instance();
53 foreach (SkyObject *o, m_ObjectList)
54 {
55 if (num)
56 o->updateCoords(num);
57 o->EquatorialToHorizontal(data->lst(), data->geo()->lat());
58 }
59}
60
62{
64 return m_ObjectHash[name.toLower()]; // == nullptr if not found.
65}
66
68{
69 if (!selected())
70 return nullptr;
71
72 SkyObject *oBest = nullptr;
73 foreach (SkyObject *o, m_ObjectList)
74 {
75 double r = o->angularDistanceTo(p).Degrees();
76 if (r < maxrad)
77 {
78 oBest = o;
79 maxrad = r;
80 }
81 }
82 return oBest;
83}
const CachingDms * lat() const
Definition geolocation.h:70
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
KStarsData is the backbone of KStars.
Definition kstarsdata.h:72
CachingDms * lst()
Definition kstarsdata.h:224
GeoLocation * geo()
Definition kstarsdata.h:230
void appendListObject(SkyObject *object)
Add an object to the Object list.
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyComponent for a SkyObject whose name matches the argument name the nam...
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Find the SkyObject nearest the given SkyPoint.
void update(KSNumbers *num=nullptr) override
Update the sky positions of this component.
SkyComponent represents an object on the sky map.
virtual bool selected()
SkyComposite is a kind of container class for SkyComponent objects.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
virtual QString name(void) const
Definition skyobject.h:145
virtual QString longname(void) const
Definition skyobject.h:164
QString name2(void) const
Definition skyobject.h:156
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
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
virtual void updateCoords(const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0),...
Definition skypoint.cpp:582
const double & Degrees() const
Definition dms.h:141
void clear()
iterator insert(const Key &key, const T &value)
void append(QList< T > &&value)
void clear()
bool isEmpty() const const
value_type takeFirst()
QString toLower() const const
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.