Kstars

earthshadowcomponent.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Valentin Boettcher <valentin@boettcher.cf (do not hesitate to contact)>
3 matrix : @hiro98@tchncs.de
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
14EarthShadowComponent::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
26void 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:19
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
void update(KSNumbers *num) override
Update the sky position(s) of this component.
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...
bool shouldUpdate()
The earths shadow on the moon appears only at new moon so calculating it on other occasions is rather...
bool isInEclipse()
isInEclipse - a slim version of getEclipseType()
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.
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.
SkyComposite is a kind of container class for SkyComponent objects.
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
virtual bool drawEarthShadow(KSEarthShadow *shadow)=0
Draw the earths shadow on the moon (red-ish)
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.