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

0001 /*
0002     SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "solarsystemlistcomponent.h"
0008 
0009 #include "kstarsdata.h"
0010 #include "Options.h"
0011 #ifndef KSTARS_LITE
0012 #include "skymap.h"
0013 #endif
0014 #include "solarsystemcomposite.h"
0015 #include "skyobjects/ksplanet.h"
0016 #include "skyobjects/ksplanetbase.h"
0017 
0018 #include <KLocalizedString>
0019 
0020 #include <QPen>
0021 
0022 SolarSystemListComponent::SolarSystemListComponent(SolarSystemComposite *p) : ListComponent(p), m_Earth(p->earth())
0023 {
0024 }
0025 
0026 SolarSystemListComponent::~SolarSystemListComponent()
0027 {
0028     //Object deletes handled by parent class (ListComponent)
0029 }
0030 
0031 void SolarSystemListComponent::update(KSNumbers *)
0032 {
0033     if (selected())
0034     {
0035         KStarsData *data = KStarsData::Instance();
0036 
0037         foreach (SkyObject *o, m_ObjectList)
0038         {
0039             KSPlanetBase *p = dynamic_cast<KSPlanetBase*>(o);
0040 
0041             if (p)
0042                 p->EquatorialToHorizontal(data->lst(), data->geo()->lat());
0043         }
0044     }
0045 }
0046 
0047 void SolarSystemListComponent::updateSolarSystemBodies(KSNumbers *num)
0048 {
0049     if (selected())
0050     {
0051         KStarsData *data = KStarsData::Instance();
0052         foreach (SkyObject *o, m_ObjectList)
0053         {
0054             KSPlanetBase *p = (KSPlanetBase *)o;
0055             p->findPosition(num, data->geo()->lat(), data->lst(), m_Earth);
0056             p->EquatorialToHorizontal(data->lst(), data->geo()->lat());
0057 
0058             if (p->hasTrail())
0059                 p->updateTrail(data->lst(), data->geo()->lat());
0060         }
0061     }
0062 }
0063 
0064 void SolarSystemListComponent::drawTrails(SkyPainter *skyp)
0065 {
0066     //FIXME: here for all objects trails are drawn this could be source of inefficiency
0067     if (selected())
0068         foreach (SkyObject *obj, m_ObjectList)
0069             // Will segfault if not TrailObject
0070             dynamic_cast<TrailObject *>(obj)->drawTrail(skyp);
0071 }