• 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
horizontalcoordinategrid.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  horizontalcoordinategrid.h - 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 "horizontalcoordinategrid.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 HorizontalCoordinateGrid::HorizontalCoordinateGrid( SkyComposite *parent )
33  : CoordinateGrid( parent, i18n("Horizontal Coordinate Grid" ) )
34 {
35  //KStarsData *data = KStarsData::Instance();
36 
37  intro();
38 
39  double eps = 0.1;
40  double minAz = 0.0;
41  double maxAz = 359.0;
42  double dAz = 30.0;
43  double minAlt = -80.0;
44  double maxAlt = 90.0;
45  double dAlt = 20.0;
46  double dAlt2 = 4.0;
47  double dAz2 = 0.2;
48 
49  double max, alt, alt2, az, az2;
50 
51  LineList* lineList;
52 
53 
54  for ( az = minAz; az < maxAz; az += dAz ) {
55  for ( alt = -90.0; alt < maxAlt - eps; alt += dAlt ) {
56  lineList = new LineList();
57  max = alt + dAlt;
58  if ( max > 90.0 ) max = 90.0;
59  for ( alt2 = alt; alt2 <= max + eps; alt2 += dAlt2 ) {
60  SkyPoint* p = new SkyPoint();
61  p->setAz( az );
62  p->setAlt( alt2 );
63  //p->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
64  lineList->append( p );
65  }
66  appendLine( lineList );
67  }
68  }
69 
70  for ( alt = minAlt; alt < maxAlt + eps; alt += dAlt ) {
71  // Do not paint the line on the horizon
72  if ( alt < 0.1 && alt > -0.1 )
73  continue;
74 
75  // Adjust point density
76  int nPoints = int(round( fabs(cos(alt* dms::PI / 180.0)) * dAz / dAz2 ));
77  if ( nPoints < 5 )
78  nPoints = 5;
79  double dAz3 = dAz / nPoints;
80 
81  for ( az = minAz; az < maxAz + eps; az += dAz ) {
82  lineList = new LineList();
83  for ( az2 = az; az2 <= az + dAz + eps; az2 += dAz3 ) {
84  SkyPoint* p = new SkyPoint();
85  p->setAz( az2 );
86  p->setAlt( alt );
87  //p->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
88  lineList->append( p );
89  }
90  appendLine( lineList );
91  }
92  }
93  summary();
94 }
95 
96 bool HorizontalCoordinateGrid::selected()
97 {
98  if ( Options::autoSelectGrid() )
99  return( Options::useAltAz() );
100  else
101  return( Options::showHorizontalGrid() &&
102  ! ( Options::hideOnSlew() && Options::hideGrids() && SkyMap::IsSlewing() ) );
103 }
104 
105 void HorizontalCoordinateGrid::preDraw( SkyPainter* skyp )
106 {
107  KStarsData *data = KStarsData::Instance();
108  QColor color = data->colorScheme()->colorNamed( "HorizontalGridColor" );
109  skyp->setPen( QPen( QBrush( color ), 1, Qt::DotLine ) );
110 }
111 
112 void HorizontalCoordinateGrid::update( KSNumbers* )
113 {
114  KStarsData *data = KStarsData::Instance();
115 
116  for ( int i=0; i<listList().count(); i++ ) {
117  for ( int j=0; j<listList().at( i )->points()->count(); j++ ) {
118  listList().at( i )->points()->at( j )->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
119  }
120  }
121 }
HorizontalCoordinateGrid::update
void update(KSNumbers *)
Update the sky position(s) of this component.
Definition: horizontalcoordinategrid.cpp:112
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
SkyPoint::setAz
void setAz(dms az)
Sets Az, the Azimuth.
Definition: skypoint.h:152
KStarsData::lst
dms * lst()
Definition: kstarsdata.h:161
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
LineListIndex::listList
LineListList listList()
Definition: linelistindex.h:153
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
HorizontalCoordinateGrid::selected
bool selected()
Definition: horizontalcoordinategrid.cpp:96
LineListIndex::intro
void intro()
Definition: linelistindex.cpp:224
LineListIndex::appendLine
void appendLine(LineList *lineList, int debug=0)
Definition: linelistindex.cpp:73
dms.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
HorizontalCoordinateGrid::HorizontalCoordinateGrid
HorizontalCoordinateGrid(SkyComposite *parent)
Constructor Simply adds all of the coordinate grid circles (meridians and parallels) parent Pointer t...
Definition: horizontalcoordinategrid.cpp:32
skymap.h
Options::showHorizontalGrid
static bool showHorizontalGrid()
Get Draw horizontal coordinate grid in the sky map?
Definition: Options.h:1721
SkyComposite
SkyComposite is a kind of container class for SkyComponent objects.
Definition: skycomposite.h:43
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
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
PI
#define PI
Definition: satellite.cpp:43
horizontalcoordinategrid.h
SkyMap::IsSlewing
static bool IsSlewing()
Definition: skymap.h:91
Options::useAltAz
static bool useAltAz()
Get Use horizontal coordinate system?
Definition: Options.h:2386
LineListIndex::summary
void summary()
Definition: linelistindex.cpp:232
SkyPoint::setAlt
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition: skypoint.h:141
LineList::append
void append(SkyPoint *p)
Definition: linelist.h:55
kstarsdata.h
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
HorizontalCoordinateGrid::preDraw
void preDraw(SkyPainter *skyp)
Definition: horizontalcoordinategrid.cpp:105
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