• 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
equator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  equator.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2007-08-09
5  copyright : (C) 2007 by James B. Bowlin
6  email : bowlin@mindspring.com
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 "equator.h"
19 
20 #include "ksnumbers.h"
21 #include "kstarsdata.h"
22 #include "skymap.h"
23 #include "skyobjects/skypoint.h"
24 #include "dms.h"
25 #include "Options.h"
26 #include "linelist.h"
27 #include "skylabeler.h"
28 
29 #include "skypainter.h"
30 #include "projections/projector.h"
31 
32 Equator::Equator(SkyComposite *parent ) :
33  NoPrecessIndex( parent, i18n("Equator") ),
34  m_label( LineListIndex::name() )
35 {
36  KStarsData *data = KStarsData::Instance();
37  KSNumbers num( data->ut().djd() );
38 
39  const double eps = 0.1;
40  const double minRa = 0.0;
41  const double maxRa = 23.0;
42  const double dRa = 2.0;
43  const double dRa2 = .5 / 5.;
44 
45  for(double ra = minRa; ra < maxRa; ra += dRa ) {
46  LineList* lineList = new LineList();
47  for(double ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa2 ) {
48  SkyPoint* o = new SkyPoint( ra2, 0.0 );
49  o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
50  lineList->append( o );
51  }
52  appendLine( lineList );
53  }
54 }
55 
56 bool Equator::selected()
57 {
58  return Options::showEquator();
59 }
60 
61 void Equator::preDraw( SkyPainter *skyp )
62 {
63  KStarsData *data = KStarsData::Instance();
64  QColor color( data->colorScheme()->colorNamed( "EqColor" ) );
65  skyp->setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
66 }
67 
68 void Equator::draw( SkyPainter *skyp )
69 {
70  if ( ! selected() ) return;
71 
72  m_label.reset();
73  NoPrecessIndex::draw( skyp );
74 
75  KStarsData *data = KStarsData::Instance();
76  QColor color( data->colorScheme()->colorNamed( "EqColor" ) );
77  SkyLabeler::Instance()->setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
78  m_label.draw();
79 
80  drawCompassLabels();
81 }
82 
83 void Equator::drawCompassLabels() {
84  QString label;
85 
86  const Projector *proj = SkyMap::Instance()->projector();
87  KStarsData *data = KStarsData::Instance();
88  SkyLabeler* skyLabeler = SkyLabeler::Instance();
89  // Set proper color for labels
90  QColor color( data->colorScheme()->colorNamed( "CompassColor" ) );
91  skyLabeler->setPen( QPen( QBrush(color), 1, Qt::SolidLine) );
92 
93  KSNumbers num( data->ut().djd() );
94  for( int ra = 0; ra < 23; ra += 2 ) {
95  SkyPoint o( ra, 0.0 );
96  o.EquatorialToHorizontal( data->lst(), data->geo()->lat() );
97  bool visible;
98  QPointF cpoint = proj->toScreen( &o, false, &visible );
99  if ( visible && proj->checkVisibility( &o ) ) {
100  label.setNum( o.ra().hour() );
101  skyLabeler->drawGuideLabel( cpoint, label, 0.0 );
102  }
103  }
104 }
dms::hour
int hour() const
Definition: dms.h:104
Options::showEquator
static bool showEquator()
Get Draw equator line in the sky map?
Definition: Options.h:1664
SkyPoint::ra
const dms & ra() const
Definition: skypoint.h:171
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
Equator::Equator
Equator(SkyComposite *parent)
Definition: equator.cpp:32
KStarsData::lst
dms * lst()
Definition: kstarsdata.h:161
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
Equator::label
virtual LineListLabel * label()
Definition: equator.h:45
ColorScheme::colorNamed
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:97
skypainter.h
KStarsData::geo
GeoLocation * geo()
Definition: kstarsdata.h:164
LineList
Definition: linelist.h:35
Projector::checkVisibility
bool checkVisibility(SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
Definition: projector.cpp:181
NoPrecessIndex
Definition: noprecessindex.h:28
LineListIndex::appendLine
void appendLine(LineList *lineList, int debug=0)
Definition: linelistindex.cpp:73
dms.h
SkyLabeler::Instance
static SkyLabeler * Instance()
Definition: skylabeler.cpp:49
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
Projector
This class serves as an interface to handle projections.
Definition: projector.h:49
Projector::toScreen
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=0) const
This is exactly the same as toScreenVec but it returns a QPointF.
Definition: projector.cpp:93
linelist.h
equator.h
Equator::draw
virtual void draw(SkyPainter *skyp)
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition: equator.cpp:68
KStarsDateTime::djd
long double djd() const
Definition: kstarsdatetime.h:145
skymap.h
ksnumbers.h
SkyComposite
SkyComposite is a kind of container class for SkyComponent objects.
Definition: skycomposite.h:43
Equator::preDraw
virtual void preDraw(SkyPainter *skyp)
Definition: equator.cpp:61
skypoint.h
SkyLabeler::drawGuideLabel
bool drawGuideLabel(QPointF &o, const QString &text, double angle)
Tries to draw the text at the position and angle specified.
Definition: skylabeler.cpp:104
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
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
LineListLabel::reset
void reset()
Definition: linelistlabel.cpp:40
GeoLocation::lat
const dms * lat() const
Definition: geolocation.h:79
LineListIndex
Definition: linelistindex.h:39
Equator::drawCompassLabels
virtual void drawCompassLabels()
Definition: equator.cpp:83
projector.h
LineListLabel::draw
void draw()
Definition: linelistlabel.cpp:92
SkyMap::Instance
static SkyMap * Instance()
Definition: skymap.cpp:141
SkyLabeler::setPen
void setPen(const QPen &pen)
sets the pen used for drawing labels on the sky.
Definition: skylabeler.cpp:173
LineList::append
void append(SkyPoint *p)
Definition: linelist.h:55
kstarsdata.h
KStarsData::ut
const KStarsDateTime & ut() const
Definition: kstarsdata.h:140
skylabeler.h
SkyLabeler
The purpose of this class is to prevent labels from overlapping.
Definition: skylabeler.h:112
SkyMap::projector
const Projector * projector() const
Get the current projector.
Definition: skymap.h:264
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
Equator::selected
virtual bool selected()
Definition: equator.cpp:56
LineListIndex::draw
virtual void draw(SkyPainter *skyp)
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition: linelistindex.cpp:162
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 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