File indexing completed on 2024-07-14 07:17:22

0001 /*
0002     SPDX-FileCopyrightText: Vipul Kumar Singh <vipulkrsingh@gmail.com>
0003     SPDX-FileCopyrightText: Médéric Boquien <mboquien@free.fr>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include "skycomponent.h"
0011 #include "skyobjects/ksplanetbase.h"
0012 
0013 #include <memory>
0014 
0015 class KSNumbers;
0016 class PlanetMoons;
0017 class SkyComposite;
0018 class SolarSystemSingleComponent;
0019 
0020 /**
0021  * @class PlanetMoonsComponent
0022  * Represents the planetmoons on the sky map.
0023  *
0024  * @author Vipul Kumar Singh
0025  * @author Médéric boquien
0026  * @version 0.1
0027  */
0028 class PlanetMoonsComponent : public SkyComponent
0029 {
0030     public:
0031         /**
0032          * @short Constructor
0033          *
0034          * @p parent pointer to the parent SkyComposite
0035          */
0036         PlanetMoonsComponent(SkyComposite *parent, SolarSystemSingleComponent *pla, KSPlanetBase::Planets &planet);
0037 
0038         virtual ~PlanetMoonsComponent() override = default;
0039 
0040         bool selected() override;
0041         void draw(SkyPainter *skyp) override;
0042 #ifndef KSTARS_LITE
0043         void update(KSNumbers *num) override;
0044 #endif
0045         void updateMoons(KSNumbers *num) override;
0046 
0047         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
0048 
0049         /**
0050          * @return a pointer to a moon if its name matches the argument
0051          *
0052          * @p name the name to be matched
0053          * @return a SkyObject pointer to the moon whose name matches
0054          * the argument, or a nullptr pointer if no match was found.
0055          */
0056         SkyObject *findByName(const QString &name, bool exact = true) override;
0057 
0058         /** Return pointer to stored planet object. */
0059         KSPlanetBase *getPlanet() const;
0060 
0061         /** Return pointer to stored moons object. */
0062         inline PlanetMoons *getMoons() const
0063         {
0064             return pmoons.get();
0065         }
0066 
0067     protected:
0068         void drawTrails(SkyPainter *skyp) override;
0069 
0070     private:
0071         KSPlanetBase::Planets planet;
0072         std::unique_ptr<PlanetMoons> pmoons;
0073         SolarSystemSingleComponent *m_Planet { nullptr };
0074 };