Kstars

solarsystemcomposite.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
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
23SolarSystemComposite::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
95SolarSystemComposite::~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
124void SolarSystemComposite::updateSolarSystemBodies(KSNumbers *num)
125{
126 m_Earth->findPosition(num);
127 foreach (SkyComponent *comp, components())
128 {
129 comp->updateSolarSystemBodies(num);
130 }
131}
132
133void 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 {
148 foreach (SkyComponent *comp, components())
149 comp->drawTrails(skyp);
150 }
151}
152
153const QList<SkyObject *> &SolarSystemComposite::asteroids() const
154{
155 return m_AsteroidsComponent->objectList();
156}
157
158const QList<SkyObject *> &SolarSystemComposite::comets() const
159{
160 return m_CometsComponent->objectList();
161}
162
163const QList<SkyObject *> &SolarSystemComposite::planetObjects() const
164{
165 return m_planetObjects;
166}
167
168const QList<SkyObject *> &SolarSystemComposite::moons() const
169{
170 return m_moons;
171}
172
173CometsComponent *SolarSystemComposite::cometsComponent()
174{
175 return m_CometsComponent;
176}
177
178AsteroidsComponent *SolarSystemComposite::asteroidsComponent()
179{
180 return m_AsteroidsComponent;
181}
182
183const QList<SolarSystemSingleComponent *> &SolarSystemComposite::planets() const
184{
185 return m_planets;
186}
187
188/*
189QList<PlanetMoonsComponent *> SolarSystemComposite::planetMoonsComponent() const
190{
191 return QList <PlanetMoonsComponent *>({m_JupiterMoons});
192}
193*/
Represents the asteroids on the sky map.
This class encapsulates the Comets.
The EarthShadowComponent class.
const CachingDms * lat() const
Definition geolocation.h:70
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
Provides necessary information about the Moon.
Definition ksmoon.h:26
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
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.
A subclass of KSPlanetBase for seven of the major planets in the solar system (Earth and Pluto have t...
Definition ksplanet.h:33
Child class of KSPlanetBase; encapsulates information about the Sun.
Definition kssun.h:24
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
CachingDms * lst()
Definition kstarsdata.h:226
GeoLocation * geo()
Definition kstarsdata.h:232
SkyComponent represents an object on the sky map.
virtual void drawTrails(SkyPainter *skyp)
Draw trails for objects.
virtual void update(KSNumbers *)
Update the sky position(s) of this component.
SkyComposite is a kind of container class for SkyComponent objects.
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
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
void update(KSNumbers *num) override
Delegate update-position requests to all sub components.
void drawTrails(SkyPainter *skyp) override
Draw trails for objects.
This class encapsulates some methods which are shared between all single-object solar system componen...
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.