• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • skycomponents
solarsystemsinglecomponent.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  solarsystemsinglecomponent.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2005/30/08
5  copyright : (C) 2005 by Thomas Kabelmann
6  email : thomas.kabelmann@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "solarsystemsinglecomponent.h"
19 #include "solarsystemcomposite.h"
20 #include "skycomponent.h"
21 
22 
23 #include "dms.h"
24 #include "kstarsdata.h"
25 #include "skyobjects/starobject.h"
26 #include "skyobjects/ksplanetbase.h"
27 #include "skyobjects/ksplanet.h"
28 #include "skymap.h"
29 #include "Options.h"
30 #include "skylabeler.h"
31 
32 #include "skypainter.h"
33 #include "projections/projector.h"
34 
35 SolarSystemSingleComponent::SolarSystemSingleComponent(SolarSystemComposite *parent, KSPlanetBase *kspb, bool (*visibleMethod)()) :
36  SkyComponent( parent ),
37  visible( visibleMethod ),
38  m_Earth( parent->earth() ),
39  m_Planet( kspb )
40 {
41  m_Planet->loadData();
42  if ( ! m_Planet->name().isEmpty() )
43  objectNames(m_Planet->type()).append( m_Planet->name() );
44  if ( ! m_Planet->longname().isEmpty() && m_Planet->longname() != m_Planet->name() )
45  objectNames(m_Planet->type()).append( m_Planet->longname() );
46 }
47 
48 SolarSystemSingleComponent::~SolarSystemSingleComponent()
49 {
50  removeFromNames( m_Planet );
51  delete m_Planet;
52 }
53 
54 bool SolarSystemSingleComponent::selected() {
55  return visible();
56 }
57 
58 SkyObject* SolarSystemSingleComponent::findByName( const QString &name ) {
59  if( QString::compare( m_Planet->name(), name, Qt::CaseInsensitive ) == 0 ||
60  QString::compare( m_Planet->longname(), name, Qt::CaseInsensitive ) == 0 ||
61  QString::compare( m_Planet->name2(), name, Qt::CaseInsensitive ) == 0
62  )
63  return m_Planet;
64  return 0;
65 }
66 
67 SkyObject* SolarSystemSingleComponent::objectNearest( SkyPoint *p, double &maxrad ) {
68  double r = m_Planet->angularDistanceTo( p ).Degrees();
69  if( r < maxrad ) {
70  maxrad = r;
71  return m_Planet;
72  }
73  return 0;
74 }
75 
76 void SolarSystemSingleComponent::update(KSNumbers*) {
77  KStarsData *data = KStarsData::Instance();
78  if( selected() )
79  m_Planet->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
80 }
81 
82 void SolarSystemSingleComponent::updatePlanets(KSNumbers *num) {
83  if ( selected() ) {
84  KStarsData *data = KStarsData::Instance();
85  m_Planet->findPosition( num, data->geo()->lat(), data->lst(), m_Earth );
86  m_Planet->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
87  if ( m_Planet->hasTrail() )
88  m_Planet->updateTrail( data->lst(), data->geo()->lat() );
89  }
90 }
91 
92 void SolarSystemSingleComponent::draw( SkyPainter *skyp ) {
93  if( ! selected() )
94  return;
95 
96  skyp->setPen( m_Planet->color() );
97  skyp->setBrush( m_Planet->color() );
98 
99  bool drawn = skyp->drawPlanet(m_Planet);
100  if ( drawn && Options::showPlanetNames() )
101  SkyLabeler::AddLabel( m_Planet, SkyLabeler::PLANET_LABEL );
102 }
103 
104 
105 void SolarSystemSingleComponent::drawTrails( SkyPainter *skyp ) {
106  if( selected() )
107  m_Planet->drawTrail(skyp);
108 }
TrailObject::hasTrail
bool hasTrail() const
Definition: trailobject.h:46
KSPlanetBase::findPosition
void findPosition(const KSNumbers *num, const dms *lat=0, const dms *LST=0, const KSPlanetBase *Earth=0)
Find position, including correction for Figure-of-the-Earth.
Definition: ksplanetbase.cpp:122
ksplanetbase.h
SkyPainter::setBrush
virtual void setBrush(const QBrush &brush)=0
Set the brush of the painter.
SolarSystemSingleComponent::SolarSystemSingleComponent
SolarSystemSingleComponent(SolarSystemComposite *, KSPlanetBase *kspb, bool(*visibleMethod)())
Initialize visible method, minimum size and sizeScale.
Definition: solarsystemsinglecomponent.cpp:35
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
SolarSystemSingleComponent::update
virtual void update(KSNumbers *num)
Update the sky position(s) of this component.
Definition: solarsystemsinglecomponent.cpp:76
solarsystemsinglecomponent.h
SolarSystemSingleComponent::~SolarSystemSingleComponent
virtual ~SolarSystemSingleComponent()
Definition: solarsystemsinglecomponent.cpp:48
SolarSystemSingleComponent::draw
virtual void draw(SkyPainter *skyp)
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition: solarsystemsinglecomponent.cpp:92
SkyObject::longname
virtual QString longname(void) const
Definition: skyobject.h:140
KStarsData::lst
dms * lst()
Definition: kstarsdata.h:161
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
SkyComponent
SkyComponent represents an object on the sky map.
Definition: skycomponent.h:44
skypainter.h
SolarSystemSingleComponent::drawTrails
virtual void drawTrails(SkyPainter *skyp)
Draw trails for objects.
Definition: solarsystemsinglecomponent.cpp:105
KStarsData::geo
GeoLocation * geo()
Definition: kstarsdata.h:164
TrailObject::updateTrail
void updateTrail(dms *LST, const dms *lat)
update Horizontal coords of the trail
Definition: trailobject.cpp:45
SolarSystemSingleComponent::updatePlanets
virtual void updatePlanets(KSNumbers *num)
Definition: solarsystemsinglecomponent.cpp:82
solarsystemcomposite.h
SolarSystemSingleComponent::objectNearest
virtual SkyObject * objectNearest(SkyPoint *p, double &maxrad)
Find the SkyObject nearest the given SkyPoint.
Definition: solarsystemsinglecomponent.cpp:67
dms.h
ksplanet.h
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
SkyComponent::removeFromNames
void removeFromNames(const SkyObject *obj)
Definition: skycomponent.cpp:58
SkyPainter::drawPlanet
virtual bool drawPlanet(KSPlanetBase *planet)=0
Draw a planet.
skymap.h
KSPlanetBase::color
QColor & color()
Definition: ksplanetbase.h:190
skycomponent.h
SkyLabeler::PLANET_LABEL
Definition: skylabeler.h:123
SkyPoint::EquatorialToHorizontal
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
Definition: skypoint.cpp:55
SkyPainter::setPen
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
Options.h
SkyObject::name2
QString name2(void) const
Definition: skyobject.h:132
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
GeoLocation::lat
const dms * lat() const
Definition: geolocation.h:79
Options::showPlanetNames
static bool showPlanetNames()
Get Label planet names in the sky map?
Definition: Options.h:1968
SkyObject::type
int type(void) const
Definition: skyobject.h:164
starobject.h
TrailObject::drawTrail
void drawTrail(SkyPainter *skyp) const
Definition: trailobject.cpp:85
SolarSystemSingleComponent::findByName
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyComponent for a SkyObject whose name matches the argument name the nam...
Definition: solarsystemsinglecomponent.cpp:58
projector.h
KSPlanetBase
A subclass of TrailObject that provides additional information needed for most solar system objects...
Definition: ksplanetbase.h:63
kstarsdata.h
KSPlanetBase::loadData
virtual bool loadData()=0
skylabeler.h
SkyObject::name
virtual QString name(void) const
Definition: skyobject.h:124
SkyComponent::objectNames
QHash< int, QStringList > & objectNames()
Definition: skycomponent.h:127
SkyObject
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
Definition: skyobject.h:46
SolarSystemSingleComponent::selected
virtual bool selected()
Definition: solarsystemsinglecomponent.cpp:54
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
SkyPoint::angularDistanceTo
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=0) const
Computes the angular distance between two SkyObjects.
Definition: skypoint.cpp:608
SolarSystemComposite
The solar system composite manages all planets, asteroids and comets.
Definition: solarsystemcomposite.h:41
SkyLabeler::AddLabel
static void AddLabel(SkyObject *obj, label_t type)
static version of addLabel() below.
Definition: skylabeler.h:149
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal