File indexing completed on 2024-04-21 03:44:45

0001 /*
0002     SPDX-FileCopyrightText: 2007 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QSet>
0010 
0011 #include "skyobject.h"
0012 
0013 class SkyPainter;
0014 
0015 /**
0016  *@class TrailObject
0017  *@short provides a SkyObject with an attachable Trail
0018  *@author Jason Harris
0019  *@version 1.0
0020  */
0021 class TrailObject : public SkyObject
0022 {
0023     public:
0024         /** Constructor */
0025         explicit TrailObject(int t = TYPE_UNKNOWN, dms r = dms(0.0), dms d = dms(0.0), float m = 0.0,
0026                              const QString &n = QString());
0027 
0028         /** Constructor */
0029         TrailObject(int t, double r, double d, float m = 0.0, const QString &n = QString());
0030 
0031         ~TrailObject() override;
0032 
0033         TrailObject *clone() const override;
0034 
0035         /** @return whether the planet has a trail */
0036         inline bool hasTrail() const
0037         {
0038             return (Trail.count() > 0);
0039         }
0040 
0041         /** @return a reference to the planet's trail */
0042         inline const QList<SkyPoint> &trail() const
0043         {
0044             return Trail;
0045         }
0046 
0047         /** @short adds a point to the planet's trail */
0048         void addToTrail(const QString &label = QString());
0049 
0050         /** @short removes the oldest point from the trail */
0051         void clipTrail();
0052 
0053         /** @short clear the Trail */
0054         void clearTrail();
0055 
0056         /** @short update Horizontal coords of the trail */
0057         void updateTrail(dms *LST, const dms *lat);
0058 
0059         /**Remove trail for all objects but one which is passed as
0060              * parameter. It has SkyObject type for generality. */
0061         static void clearTrailsExcept(SkyObject *o);
0062 
0063         void drawTrail(SkyPainter *skyp) const;
0064 
0065         /** Maximum trail size */
0066         static const int MaxTrail = 400;
0067 
0068         void initPopupMenu(KSPopupMenu *pmenu) override;
0069 
0070     protected:
0071         QList<SkyPoint> Trail;
0072         QList<QString> m_TrailLabels;
0073         /// Store list of objects with trails.
0074         static QSet<TrailObject *> trailObjects;
0075 
0076     private:
0077 };
0078