1 /*
2     SPDX-FileCopyrightText: 2009 Jerome SONRIER <jsid@emor3j.fr.eu.org>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "satellitegroup.h"
10 #include "skycomponent.h"
11 
12 #include <QList>
13 
14 class QPointF;
15 class Satellite;
16 
17 /**
18  * @class SatellitesComponent
19  * Represents artificial satellites on the sky map.
20  * @author Jérôme SONRIER
21  * @version 1.0
22  */
23 class SatellitesComponent : public SkyComponent
24 {
25     public:
26         /**
27          * @short Constructor
28          * @param parent pointer to the parent SkyComposite
29          */
30         explicit SatellitesComponent(SkyComposite *parent = nullptr);
31 
32         /**
33          * @short Destructor
34          */
35         ~SatellitesComponent() override;
36 
37         /**
38          * @return true if satellites must be draw.
39          */
40         bool selected() override;
41 
42         /**
43          * Draw all satellites.
44          * @param skyp SkyPainter to use
45          */
46         void draw(SkyPainter *skyp) override;
47 
48         /**
49          * Update satellites position.
50          * @param num
51          */
52         void update(KSNumbers *num) override;
53 
54         /**
55          * Download new TLE files
56          */
57         void updateTLEs();
58 
59         /**
60          * @return The list of all groups
61          */
62         QList<SatelliteGroup *> groups();
63 
64         /**
65          * Search a satellite by name.
66          * @param name The name of the satellite
67          * @return Satellite that was find or 0
68          */
69         Satellite *findSatellite(QString name);
70 
71         /**
72          * Draw label of a satellite.
73          * @param sat The satellite
74          * @param pos The position of the satellite
75          */
76         void drawLabel(Satellite *sat, const QPointF &pos);
77 
78         /**
79          * Search the nearest satellite from point p
80          * @param p
81          * @param maxrad
82          */
83         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
84 
85         /**
86          * Return object given name
87          * @param name object name
88          * @return object if found, otherwise nullptr
89          */
90         SkyObject *findByName(const QString &name) override;
91 
92         void loadData();
93 
94     protected:
95         void drawTrails(SkyPainter *skyp) override;
96 
97     private:
98         QList<SatelliteGroup *> m_groups; // List of all groups
99         QHash<QString, Satellite *> nameHash;
100 };
101