Kstars

earthshadowcomponent.cpp
1 /*
2  SPDX-FileCopyrightText: 2018 Valentin Boettcher <[email protected] (do not hesitate to contact)>
3  matrix : @[email protected]
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #include "earthshadowcomponent.h"
9 #include "skycomposite.h"
10 #include "skypainter.h"
11 #include "kstarsdata.h"
12 
13 //TODO: (Valentin) Error Handling
14 EarthShadowComponent::EarthShadowComponent(SkyComposite *parent, KSEarthShadow *shadow) : SkyComponent(parent)
15 {
16  m_shadow = shadow;
17  m_up_to_date = false;
18 }
19 
21 {
22  KStarsData *data = KStarsData::Instance();
23  m_shadow->EquatorialToHorizontal(data->lst(), data->geo()->lat());
24 }
25 
26 void EarthShadowComponent::updateSolarSystemBodies(KSNumbers *num)
27 {
28  // don't bother if the moon is not in position
29  if(!m_shadow->shouldUpdate()) { // TODO: There must be sth. more efficient
30  m_up_to_date = false;
31  return;
32  }
33 
34  KStarsData *data = KStarsData::Instance();
35  CachingDms *LST = data->lst();
36  const CachingDms *lat = data->geo()->lat();
37 
38  m_shadow->findPosition(num, lat, LST);
39  m_shadow->EquatorialToHorizontal(LST, lat);
40  m_up_to_date = true;
41 }
42 
44 {
45  // check if the shadow has been updated
46  if(m_up_to_date && (m_shadow->isInEclipse()))
47  skyp->drawEarthShadow(m_shadow);
48 }
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition: cachingdms.h:18
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.
CachingDms * lst()
Definition: kstarsdata.h:223
bool isInEclipse()
isInEclipse - a slim version of getEclipseType()
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
A class that manages the calculation of the earths shadow (in moon distance) as a 'virtual' skyobject...
Definition: ksearthshadow.h:27
virtual bool drawEarthShadow(KSEarthShadow *shadow)=0
Draw the earths shadow on the moon (red-ish)
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
const CachingDms * lat() const
Definition: geolocation.h:70
GeoLocation * geo()
Definition: kstarsdata.h:229
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
bool shouldUpdate()
The earths shadow on the moon appears only at new moon so calculating it on other occasions is rather...
void update(KSNumbers *num) override
Update the sky position(s) of this component.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.