• 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
constellationlines.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  constellationlines.h - K Desktop Planetarium
3  -------------------
4  begin : 25 Oct. 2005
5  copyright : (C) 2005 by Jason Harris
6  email : kstars@30doradus.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 "constellationlines.h"
19 #include "linelist.h"
20 
21 #include <QPen>
22 
23 #include <kdebug.h>
24 #include <klocale.h>
25 
26 #include "Options.h"
27 #include "kstarsdata.h"
28 #include "skyobjects/skyobject.h"
29 #include "skyobjects/starobject.h"
30 #include "skycomponents/starcomponent.h"
31 #include "skycomponents/culturelist.h"
32 #include "skymap.h"
33 
34 #include "skymesh.h"
35 #include "ksfilereader.h"
36 
37 #include "skypainter.h"
38 
39 
40 ConstellationLines::ConstellationLines( SkyComposite *parent, CultureList* cultures ) :
41  LineListIndex( parent, i18n("Constellation Lines") ),
42  m_reindexNum(J2000)
43 {
44  //Create the ConstellationLinesComponents. Each is a series of points
45  //connected by line segments. A single constellation can be composed of
46  //any number of these series, and we don't need to know which series
47  //belongs to which constellation.
48 
49  //The constellation lines data file (clines.dat) contains lists
50  //of abbreviated genetive star names in the same format as they
51  //appear in the star data files (hipNNN.dat).
52  //
53  //Each constellation consists of a QList of SkyPoints,
54  //corresponding to the stars at each "node" of the constellation.
55  //These are pointers to the starobjects themselves, so the nodes
56  //will automatically be fixed to the stars even as the star
57  //positions change due to proper motions. In addition, each node
58  //has a corresponding flag that determines whether a line should
59  //connect this node and the previous one.
60 
61  intro();
62 
63  bool culture = false;
64  LineList *lineList(0);
65  double maxPM(0.0);
66 
67  KSFileReader fileReader;
68  if ( ! fileReader.open( "clines.dat" ) )
69  return;
70  while ( fileReader.hasMoreLines() ) {
71  QString line = fileReader.readLine();
72  if( line.isEmpty() )
73  continue;
74  QChar mode = line.at( 0 );
75  //ignore lines beginning with "#":
76  if( mode == '#' )
77  continue;
78  //If the first character is "M", we are starting a new series.
79  //In this case, add the existing clc component to the composite,
80  //then prepare a new one.
81 
82  if ( mode == 'C') {
83  QString cultureName = line.mid( 2 ).trimmed();
84  culture = cultureName == cultures->current();
85  continue;
86  }
87 
88  if ( culture ) {
89  //Mode == 'M' starts a new series of line segments, joined end to end
90  if ( mode == 'M' ) {
91  if( lineList )
92  appendLine( lineList );
93  lineList = new LineList();
94  }
95 
96  int HDnum = line.mid( 2 ).trimmed().toInt();
97  StarObject *star = static_cast<StarObject*>( StarComponent::Instance()->findByHDIndex( HDnum ) );
98  if ( star && lineList ) {
99  lineList->append( star );
100  double pm = star->pmMagnitude();
101  if ( maxPM < pm )
102  maxPM = pm;
103  }
104  else if ( ! star )
105  kWarning() << i18n( "Star HD%1 not found." , HDnum);
106  }
107  }
108 
109  //Add the last clc component
110  if( lineList )
111  appendLine( lineList );
112 
113  m_reindexInterval = StarObject::reindexInterval( maxPM );
114  //printf("CLines: maxPM = %6.1f milliarcsec/year\n", maxPM );
115  //printf("CLines: Update Interval = %6.1f years\n", m_reindexInterval * 100.0 );
116 
117  summary();
118 }
119 
120 bool ConstellationLines::selected()
121 {
122  return Options::showCLines() &&
123  ! ( Options::hideOnSlew() && Options::hideCLines() && SkyMap::IsSlewing() );
124 }
125 
126 void ConstellationLines::preDraw( SkyPainter* skyp )
127 {
128  KStarsData *data = KStarsData::Instance();
129  QColor color = data->colorScheme()->colorNamed( "CLineColor" );
130  skyp->setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
131 }
132 
133 const IndexHash& ConstellationLines::getIndexHash(LineList* lineList ) {
134  return skyMesh()->indexStarLine( lineList->points() );
135 }
136 
137 // JIT updating makes this simple. Star updates are called from within both
138 // StarComponent and ConstellationLines. If the update is redundant then
139 // StarObject::JITupdate() simply returns without doing any work.
140 void ConstellationLines::JITupdate( LineList* lineList )
141 {
142  KStarsData *data = KStarsData::Instance();
143  lineList->updateID = data->updateID();
144 
145  SkyList* points = lineList->points();
146  for (int i = 0; i < points->size(); i++ ) {
147  StarObject* star = (StarObject*) points->at( i );
148  star->JITupdate();
149  }
150 }
151 
152 void ConstellationLines::reindex( KSNumbers *num )
153 {
154  if ( ! num ) return;
155 
156  if ( fabs( num->julianCenturies() -
157  m_reindexNum.julianCenturies() ) < m_reindexInterval ) return;
158 
159  //printf("Re-indexing CLines to year %4.1f...\n", 2000.0 + num->julianCenturies() * 100.0);
160 
161  m_reindexNum = KSNumbers( *num );
162  skyMesh()->setKSNumbers( num );
163  LineListIndex::reindexLines();
164 
165  //printf("Done.\n");
166 }
167 
KSFileReader::hasMoreLines
bool hasMoreLines()
Definition: ksfilereader.h:108
SkyList
QVector< SkyPoint * > SkyList
Definition: skycomponents/typedef.h:45
StarObject::JITupdate
void JITupdate()
added for JIT updates from both StarComponent and ConstellationLines
Definition: starobject.cpp:317
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
StarObject::reindexInterval
static double reindexInterval(double pm)
returns the reindex interval (in centuries!) for the given magnitude of proper motion (in milliarcsec...
Definition: starobject.cpp:49
KStarsData::updateID
unsigned int updateID()
Definition: kstarsdata.h:224
LineListIndex::reindexLines
void reindexLines()
Definition: linelistindex.cpp:116
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
skyobject.h
constellationlines.h
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
starcomponent.h
Options::hideCLines
static bool hideCLines()
Get Hide constellation lines while moving?
Definition: Options.h:1132
ColorScheme::colorNamed
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:97
skypainter.h
ConstellationLines::preDraw
virtual void preDraw(SkyPainter *skyp)
Definition: constellationlines.cpp:126
ConstellationLines::selected
bool selected()
Definition: constellationlines.cpp:120
Options::hideOnSlew
static bool hideOnSlew()
Get Hide objects while moving?
Definition: Options.h:1094
LineList
Definition: linelist.h:35
culturelist.h
StarComponent::Instance
static StarComponent * Instance()
Definition: starcomponent.h:74
LineListIndex::intro
void intro()
Definition: linelistindex.cpp:224
LineListIndex::appendLine
void appendLine(LineList *lineList, int debug=0)
Definition: linelistindex.cpp:73
KSFileReader::open
bool open(const QString &fname)
Definition: ksfilereader.cpp:46
LineList::points
SkyList * points()
Definition: linelist.h:53
linelist.h
skymap.h
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.
SkyMesh::indexStarLine
const IndexHash & indexStarLine(SkyList *points)
Definition: skymesh.cpp:164
Options.h
SkyMesh::setKSNumbers
void setKSNumbers(KSNumbers *num)
Definition: skymesh.h:163
StarObject::pmMagnitude
double pmMagnitude()
returns the magnitude of the proper motion correction in milliarcsec/year
Definition: starobject.h:180
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
StarComponent::findByHDIndex
SkyObject * findByHDIndex(int HDnum)
Find stars by HD catalog index.
Definition: starcomponent.cpp:526
ksfilereader.h
ConstellationLines::reindex
void reindex(KSNumbers *num)
Definition: constellationlines.cpp:152
KSFileReader::readLine
QString readLine()
Definition: ksfilereader.h:113
KSFileReader
Definition: ksfilereader.h:65
Options::showCLines
static bool showCLines()
Get Draw constellation lines in the sky map?
Definition: Options.h:1588
LineListIndex
Definition: linelistindex.h:39
J2000
#define J2000
Definition: kstarsdatetime.h:21
LineListIndex::skyMesh
SkyMesh * skyMesh()
Definition: linelistindex.h:92
ConstellationLines::JITupdate
virtual void JITupdate(LineList *lineList)
Definition: constellationlines.cpp:140
SkyMap::IsSlewing
static bool IsSlewing()
Definition: skymap.h:91
starobject.h
IndexHash
QHash< Trixel, bool > IndexHash
Definition: skycomponents/typedef.h:46
ConstellationLines::ConstellationLines
ConstellationLines(SkyComposite *parent, CultureList *cultures)
Definition: constellationlines.cpp:40
CultureList::current
QString current()
Return the current sky culture.
Definition: culturelist.h:33
LineListIndex::summary
void summary()
Definition: linelistindex.cpp:232
LineList::append
void append(SkyPoint *p)
Definition: linelist.h:55
kstarsdata.h
skymesh.h
LineList::updateID
UpdateID updateID
Definition: linelist.h:47
KSNumbers::julianCenturies
double julianCenturies() const
Definition: ksnumbers.h:90
ConstellationLines::getIndexHash
const IndexHash & getIndexHash(LineList *lineList)
Definition: constellationlines.cpp:133
StarObject
This is a subclass of SkyObject.
Definition: starobject.h:41
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
CultureList
A list of all cultures.
Definition: culturelist.h:26
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