Kstars

solarsystemcomposite.cpp
1 /*
2  SPDX-FileCopyrightText: 2005 Thomas Kabelmann <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "solarsystemcomposite.h"
8 
9 #include "asteroidscomponent.h"
10 #include "cometscomponent.h"
11 #include "kstarsdata.h"
12 #include "Options.h"
13 #ifndef KSTARS_LITE
14 #include "skymap.h"
15 #endif
16 #include "solarsystemsinglecomponent.h"
17 #include "earthshadowcomponent.h"
18 #include "skyobjects/ksmoon.h"
19 #include "skyobjects/ksplanet.h"
20 #include "skyobjects/kssun.h"
21 #include "skyobjects/ksearthshadow.h"
22 
23 SolarSystemComposite::SolarSystemComposite(SkyComposite *parent) : SkyComposite(parent)
24 {
25  emitProgressText(i18n("Loading solar system"));
26  m_Earth = new KSPlanet(i18n("Earth"), QString(), QColor("white"), 12756.28 /*diameter in km*/);
27  m_Sun = new KSSun();
28  SolarSystemSingleComponent *sun = new SolarSystemSingleComponent(this, m_Sun, Options::showSun);
29  addComponent(sun, 2);
30  m_Moon = new KSMoon();
31  SolarSystemSingleComponent *moon = new SolarSystemSingleComponent(this, m_Moon, Options::showMoon, true);
32  addComponent(moon, 3);
33  m_EarthShadow = new KSEarthShadow(m_Moon, m_Sun, m_Earth);
34  EarthShadowComponent * shadow = new EarthShadowComponent(this, m_EarthShadow);
35  addComponent(shadow);
37  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::MERCURY), Options::showMercury);
38  addComponent(mercury, 4);
40  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::VENUS), Options::showVenus);
41  addComponent(venus, 4);
43  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::MARS), Options::showMars);
44  addComponent(mars, 4);
46  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::JUPITER), Options::showJupiter);
47  addComponent(jup, 4);
48  /*
49  m_JupiterMoons = new PlanetMoonsComponent( this, jup, KSPlanetBase::JUPITER);
50  addComponent( m_JupiterMoons, 5 );
51  */
53  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::SATURN), Options::showSaturn);
54  addComponent(sat, 4);
56  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::URANUS), Options::showUranus);
57  addComponent(uranus, 4);
59  new SolarSystemSingleComponent(this, new KSPlanet(KSPlanetBase::NEPTUNE), Options::showNeptune);
60  addComponent(nep, 4);
61  //addComponent( new SolarSystemSingleComponent( this, new KSPluto(), Options::showPluto ) );
62 
63  m_planets.append(sun);
64  m_planets.append(moon);
65  m_planets.append(mercury);
66  m_planets.append(venus);
67  m_planets.append(mars);
68  m_planets.append(sat);
69  m_planets.append(jup);
70  m_planets.append(uranus);
71  m_planets.append(nep);
72 
73  /*m_planetObjects.append(sun->planet());
74  m_planetObjects.append(moon->planet());
75  m_planetObjects.append(mercury->planet());
76  m_planetObjects.append(venus->planet());
77  m_planetObjects.append(mars->planet());
78  m_planetObjects.append(sat->planet());
79  m_planetObjects.append(jup->planet());
80  m_planetObjects.append(uranus->planet());
81  m_planetObjects.append(nep->planet());
82 
83  foreach(PlanetMoonsComponent *pMoons, planetMoonsComponent()) {
84  PlanetMoons *moons = pMoons->getMoons();
85  for(int i = 0; i < moons->nMoons(); ++i) {
86  SkyObject *moon = moons->moon(i);
87  objectLists(SkyObject::MOON).append(QPair<QString, const SkyObject*>(moon->name(), moon));
88  }
89  }*/
90 
91  addComponent(m_AsteroidsComponent = new AsteroidsComponent(this), 7);
92  addComponent(m_CometsComponent = new CometsComponent(this), 7);
93 }
94 
95 SolarSystemComposite::~SolarSystemComposite()
96 {
97  delete (m_EarthShadow);
98 }
99 
101 {
102 #ifndef KSTARS_LITE
103  return Options::showSolarSystem() && !(Options::hideOnSlew() && Options::hidePlanets() && SkyMap::IsSlewing());
104 #else
105  return Options::showSolarSystem() && !(Options::hideOnSlew() && Options::hidePlanets());
106 #endif
107 }
108 
110 {
111  // if ( ! selected() ) return;
112 
113  KStarsData *data = KStarsData::Instance();
114  m_Sun->EquatorialToHorizontal(data->lst(), data->geo()->lat());
115  m_Moon->EquatorialToHorizontal(data->lst(), data->geo()->lat());
116  // m_JupiterMoons->update( num );
117 
118  foreach (SkyComponent *comp, components())
119  {
120  comp->update(num);
121  }
122 }
123 
124 void SolarSystemComposite::updateSolarSystemBodies(KSNumbers *num)
125 {
126  m_Earth->findPosition(num);
127  foreach (SkyComponent *comp, components())
128  {
129  comp->updateSolarSystemBodies(num);
130  }
131 }
132 
133 void SolarSystemComposite::updateMoons(KSNumbers *num)
134 {
135  // if ( ! selected() ) return;
136  m_Earth->findPosition(num);
137  foreach (SkyComponent *comp, components())
138  {
139  comp->updateMoons(num);
140  }
141  // m_JupiterMoons->updateMoons( num );
142 }
143 
145 {
146  if (selected())
147  foreach (SkyComponent *comp, components())
148  comp->drawTrails(skyp);
149 }
150 
151 const QList<SkyObject *> &SolarSystemComposite::asteroids() const
152 {
153  return m_AsteroidsComponent->objectList();
154 }
155 
156 const QList<SkyObject *> &SolarSystemComposite::comets() const
157 {
158  return m_CometsComponent->objectList();
159 }
160 
161 const QList<SkyObject *> &SolarSystemComposite::planetObjects() const
162 {
163  return m_planetObjects;
164 }
165 
166 const QList<SkyObject *> &SolarSystemComposite::moons() const
167 {
168  return m_moons;
169 }
170 
171 CometsComponent *SolarSystemComposite::cometsComponent()
172 {
173  return m_CometsComponent;
174 }
175 
176 AsteroidsComponent *SolarSystemComposite::asteroidsComponent()
177 {
178  return m_AsteroidsComponent;
179 }
180 
181 const QList<SolarSystemSingleComponent *> &SolarSystemComposite::planets() const
182 {
183  return m_planets;
184 }
185 
186 /*
187 QList<PlanetMoonsComponent *> SolarSystemComposite::planetMoonsComponent() const
188 {
189  return QList <PlanetMoonsComponent *>({m_JupiterMoons});
190 }
191 */
void drawTrails(SkyPainter *skyp) override
Draw trails for objects.
void findPosition(const KSNumbers *num, const CachingDms *lat=nullptr, const CachingDms *LST=nullptr, const KSPlanetBase *Earth=nullptr)
Find position, including correction for Figure-of-the-Earth.
virtual void update(KSNumbers *)
Update the sky position(s) of this component.
Definition: skycomponent.h:126
void update(KSNumbers *num) override
Delegate update-position requests to all sub components.
CachingDms * lst()
Definition: kstarsdata.h:223
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition: skypoint.cpp:77
Provides necessary information about the Moon. A subclass of SkyObject that provides information need...
Definition: ksmoon.h:25
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
Definition: ksearthshadow.h:27
Provides necessary information about the Sun.
Definition: kssun.h:23
QString i18n(const char *text, const TYPE &arg...)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms * lat() const
Definition: geolocation.h:70
GeoLocation * geo()
Definition: kstarsdata.h:229
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
The EarthShadowComponent class.
Provides necessary information about objects in the solar system.
Definition: ksplanet.h:32
virtual void drawTrails(SkyPainter *skyp)
Draw trails for objects.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:06 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.