File indexing completed on 2024-04-21 14:46:37

0001 /*
0002     SPDX-FileCopyrightText: 2009 Jerome SONRIER <jsid@emor3j.fr.eu.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "satellitegroup.h"
0010 #include "skycomponent.h"
0011 
0012 #include <QList>
0013 
0014 class QPointF;
0015 class Satellite;
0016 
0017 /**
0018  * @class SatellitesComponent
0019  * Represents artificial satellites on the sky map.
0020  * @author Jérôme SONRIER
0021  * @version 1.0
0022  */
0023 class SatellitesComponent : public SkyComponent
0024 {
0025     public:
0026         /**
0027          * @short Constructor
0028          * @param parent pointer to the parent SkyComposite
0029          */
0030         explicit SatellitesComponent(SkyComposite *parent = nullptr);
0031 
0032         /**
0033          * @short Destructor
0034          */
0035         ~SatellitesComponent() override;
0036 
0037         /**
0038          * @return true if satellites must be draw.
0039          */
0040         bool selected() override;
0041 
0042         /**
0043          * Draw all satellites.
0044          * @param skyp SkyPainter to use
0045          */
0046         void draw(SkyPainter *skyp) override;
0047 
0048         /**
0049          * Update satellites position.
0050          * @param num
0051          */
0052         void update(KSNumbers *num) override;
0053 
0054         /**
0055          * Download new TLE files
0056          */
0057         void updateTLEs();
0058 
0059         /**
0060          * @return The list of all groups
0061          */
0062         QList<SatelliteGroup *> groups();
0063 
0064         /**
0065          * Search a satellite by name.
0066          * @param name The name of the satellite
0067          * @return Satellite that was find or 0
0068          */
0069         Satellite *findSatellite(QString name);
0070 
0071         /**
0072          * Draw label of a satellite.
0073          * @param sat The satellite
0074          * @param pos The position of the satellite
0075          */
0076         void drawLabel(Satellite *sat, const QPointF &pos);
0077 
0078         /**
0079          * Search the nearest satellite from point p
0080          * @param p
0081          * @param maxrad
0082          */
0083         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
0084 
0085         /**
0086          * Return object given name
0087          * @param name object name
0088          * @p exact If true, it will return an exact match, otherwise it can return
0089          * a partial match.
0090          * @return object if found, otherwise nullptr
0091          */
0092         SkyObject *findByName(const QString &name, bool exact = true) override;
0093 
0094         void loadData();
0095 
0096     protected:
0097         void drawTrails(SkyPainter *skyp) override;
0098 
0099     private:
0100         QList<SatelliteGroup *> m_groups; // List of all groups
0101         QHash<QString, Satellite *> nameHash;
0102 };