File indexing completed on 2024-04-14 03:43:05

0001 /*
0002     SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "skycomponent.h"
0010 
0011 #include <QList>
0012 
0013 class SkyComposite;
0014 class SkyMap;
0015 
0016 /**
0017  * @class ListComponent
0018  * An abstract parent class, to be inherited by SkyComponents that store a QList of SkyObjects.
0019  *
0020  * @author Jason Harris
0021  * @version 0.1
0022  */
0023 class ListComponent : public SkyComponent
0024 {
0025     public:
0026         explicit ListComponent(SkyComposite *parent);
0027 
0028         ~ListComponent() override;
0029 
0030         /**
0031          * @short Update the sky positions of this component.
0032          *
0033          * This function usually just updates the Horizontal (Azimuth/Altitude)
0034          * coordinates of the objects in this component.  If the KSNumbers*
0035          * argument is not nullptr, this function also recomputes precession and
0036          * nutation for the date in KSNumbers.
0037          * @p num Pointer to the KSNumbers object
0038          * @note By default, the num parameter is nullptr, indicating that
0039          * Precession/Nutation computation should be skipped; this computation
0040          * is only occasionally required.
0041          */
0042         void update(KSNumbers *num = nullptr) override;
0043 
0044         SkyObject *findByName(const QString &name, bool exact = true) override;
0045         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
0046 
0047         void clear();
0048 
0049         const QList<SkyObject *> &objectList() const
0050         {
0051             return m_ObjectList;
0052         }
0053 
0054         /**
0055          * @short Add an object to the Object list.
0056          *
0057          * This method is a handy wrapper, which automatically appends the given
0058          * SkyObject to m_ObjectList and inserts references with all common names (name,
0059          * name2, longname) into the m_ObjectHash QHash to enable a faster findbyname.
0060          */
0061         void appendListObject(SkyObject * object);
0062 
0063     protected:
0064         QList<SkyObject *> m_ObjectList;
0065         QHash<QString, SkyObject *> m_ObjectHash;
0066 };