• 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
equatorialcoordinategrid.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  equatorialcoordinategrid.cpp - K Desktop Planetarium
3  -------------------
4  begin : Tue 01 Mar 2012
5  copyright : (C) 2012 by Jerome SONRIER
6  email : jsid@emor3j.fr.eu.org
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 "equatorialcoordinategrid.h"
19 
20 #include <QPen>
21 #include <QBrush>
22 #include <QColor>
23 
24 #include "Options.h"
25 #include "kstarsdata.h"
26 #include "skymap.h"
27 #include "linelist.h"
28 #include "dms.h"
29 
30 #include "skypainter.h"
31 
32 EquatorialCoordinateGrid::EquatorialCoordinateGrid( SkyComposite *parent )
33  : CoordinateGrid( parent, i18n("Equatorial Coordinate Grid" ) )
34 {
35  KStarsData *data = KStarsData::Instance();
36 
37  intro();
38 
39  double eps = 0.1;
40  double minRa = 0.0;
41  double maxRa = 23.0;
42  double dRa = 2.0;
43  double minDec = -80.0;
44  double maxDec = 90.0;
45  double dDec = 20.0;
46  double dDec2 = 4.0;
47  double dRa2 = 0.2;
48 
49  double max, dec, dec2, ra, ra2;
50 
51  LineList* lineList;
52 
53  for ( ra = minRa; ra < maxRa; ra += dRa ) {
54  for ( dec = -90.0; dec < maxDec - eps; dec += dDec ) {
55  lineList = new LineList();
56  max = dec + dDec;
57  if ( max > 90.0 ) max = 90.0;
58  for ( dec2 = dec; dec2 <= max + eps; dec2 += dDec2 ) {
59  SkyPoint* p = new SkyPoint( ra, dec2 );
60  p->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
61  lineList->append( p );
62  }
63  appendLine( lineList );
64  }
65  }
66 
67  for ( dec = minDec; dec < maxDec + eps; dec += dDec ) {
68  // Do not paint the line on the equator
69  if ( dec < 0.1 && dec > -0.1 )
70  continue;
71 
72  // Adjust point density
73  int nPoints = int(round( fabs(cos(dec* dms::PI / 180.0)) * dRa / dRa2 ));
74  if ( nPoints < 5 )
75  nPoints = 5;
76  double dRa3 = dRa / nPoints;
77 
78  for ( ra = minRa; ra < maxRa + eps; ra += dRa ) {
79  lineList = new LineList();
80  for ( ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa3 ) {
81  SkyPoint* p = new SkyPoint( ra2, dec );
82  p->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
83  lineList->append( p );
84  }
85  appendLine( lineList );
86  }
87  }
88 
89  summary();
90 }
91 
92 bool EquatorialCoordinateGrid::selected()
93 {
94  if ( Options::autoSelectGrid() )
95  return( ! Options::useAltAz() );
96  else
97  return( Options::showEquatorialGrid() &&
98  ! ( Options::hideOnSlew() && Options::hideGrids() && SkyMap::IsSlewing() ) );
99 }
100 
101 void EquatorialCoordinateGrid::preDraw( SkyPainter* skyp )
102 {
103  KStarsData *data = KStarsData::Instance();
104  QColor color = data->colorScheme()->colorNamed( "EquatorialGridColor" );
105  skyp->setPen( QPen( QBrush( color ), 1, Qt::DotLine ) );
106 }
EquatorialCoordinateGrid::EquatorialCoordinateGrid
EquatorialCoordinateGrid(SkyComposite *parent)
Constructor Simply adds all of the equatorial coordinate grid circles (meridians and parallels) paren...
Definition: equatorialcoordinategrid.cpp:32
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
KStarsData::lst
dms * lst()
Definition: kstarsdata.h:161
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
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
Options::hideOnSlew
static bool hideOnSlew()
Get Hide objects while moving?
Definition: Options.h:1094
LineList
Definition: linelist.h:35
LineListIndex::intro
void intro()
Definition: linelistindex.cpp:224
LineListIndex::appendLine
void appendLine(LineList *lineList, int debug=0)
Definition: linelistindex.cpp:73
dms.h
equatorialcoordinategrid.h
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
Options::autoSelectGrid
static bool autoSelectGrid()
Get Draw grids according to active coordinate system?
Definition: Options.h:1683
linelist.h
skymap.h
SkyComposite
SkyComposite is a kind of container class for SkyComponent objects.
Definition: skycomposite.h:43
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
CoordinateGrid
Collection of all the circles in the coordinate grid.
Definition: coordinategrid.h:30
GeoLocation::lat
const dms * lat() const
Definition: geolocation.h:79
PI
#define PI
Definition: satellite.cpp:43
SkyMap::IsSlewing
static bool IsSlewing()
Definition: skymap.h:91
Options::useAltAz
static bool useAltAz()
Get Use horizontal coordinate system?
Definition: Options.h:2386
EquatorialCoordinateGrid::selected
bool selected()
Definition: equatorialcoordinategrid.cpp:92
LineListIndex::summary
void summary()
Definition: linelistindex.cpp:232
LineList::append
void append(SkyPoint *p)
Definition: linelist.h:55
kstarsdata.h
Options::showEquatorialGrid
static bool showEquatorialGrid()
Get Draw equatorial coordinate grid in the sky map?
Definition: Options.h:1702
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
Options::hideGrids
static bool hideGrids()
Get Hide coordinate grids while moving?
Definition: Options.h:1189
EquatorialCoordinateGrid::preDraw
void preDraw(SkyPainter *skyp)
Definition: equatorialcoordinategrid.cpp:101
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