• 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
highpmstarlist.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  highpmstarlist.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2007-08-06
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 "highpmstarlist.h"
19 #include "skyobjects/starobject.h"
20 #include "kstarsdatetime.h"
21 #include "skymesh.h"
22 
23 
24 typedef struct HighPMStar
25 {
26  HighPMStar( Trixel t, StarObject* s ) : trixel(t), star(s) {}
27  Trixel trixel;
28  StarObject *star;
29 
30 } HighPMStar;
31 
32 
33 HighPMStarList::HighPMStarList( double threshold )
34  : m_reindexNum(J2000), m_threshold(threshold), m_maxPM(0.0)
35 {
36  m_skyMesh = SkyMesh::Instance();
37 }
38 
39 HighPMStarList::~HighPMStarList()
40 {
41  for (int i = 0; i < size(); i++ ) {
42  delete m_stars[ i ];
43  }
44 }
45 
46 bool HighPMStarList::append( Trixel trixel, StarObject* star, double pm )
47 {
48  if ( pm < m_threshold ) return false;
49 
50  if( trixel >= (unsigned int)m_skyMesh->size() )
51  kDebug() << "### Trixel ID out of range for the Mesh currently in use!" << trixel;
52 
53  m_stars.append( new HighPMStar( trixel, star ) );
54  if ( m_maxPM >= pm ) return true;
55 
56  m_maxPM = pm;
57  m_reindexInterval = StarObject::reindexInterval( pm );
58 
59  return true;
60 }
61 
62 void HighPMStarList::setIndexTime( KSNumbers *num )
63 {
64  m_reindexNum = KSNumbers( *num );
65 }
66 
67 void HighPMStarList::reindex( KSNumbers *num, StarIndex* starIndex )
68 {
69  if ( fabs( num->julianCenturies() -
70  m_reindexNum.julianCenturies() ) < m_reindexInterval ) return;
71 
72  m_reindexNum = KSNumbers( *num );
73  m_skyMesh->setKSNumbers( num );
74 
75  int cnt(0);
76 
77  for ( int i = 0; i < m_stars.size(); i++ ) {
78  HighPMStar* HPStar = m_stars.at( i );
79  Trixel trixel = m_skyMesh->indexStar( HPStar->star );
80  if ( trixel == HPStar->trixel ) continue;
81  cnt++;
82  StarObject* star = HPStar->star;
83 
84  // out with the old ...
85  if( HPStar->trixel >= (unsigned int)m_skyMesh->size() ) {
86  kDebug() << "### Expect an Index out-of-range error. star->trixel =" << HPStar->trixel;
87  }
88 
89  StarList *old = starIndex->at( HPStar->trixel );
90  old->removeAt( old->indexOf( star ) );
91 
92  float mag = star->mag();
93  //printf("\n mag = %4.2f trixel %d -> %d\n", mag, HPStar->trixel, trixel );
94 
95  // in with the new ...
96  HPStar->trixel = trixel;
97  if( trixel >= (unsigned int)m_skyMesh->size() )
98  kDebug() << "### Expect an Index out-of-range error. trixel =" << trixel;
99 
100  StarList *list = starIndex->at( trixel );
101  int j;
102  for ( j = 0; j < list->size(); j++ ) {
103  if ( list->at(j)->mag() < mag ) continue;
104  list->insert( j, star );
105  break;
106  }
107  if ( j == list->size() ) list->append( star );
108 
109  //for ( j = 0; j < list->size(); j++ ) {
110  // printf(" %4.2f\n", list->at(j)->mag() );
111  //}
112  }
113  //printf("Re-indexed %d stars at interval %6.1f\n", cnt, 100.0 * m_reindexInterval );
114 }
115 
116 
117 void HighPMStarList::stats()
118 {
119  printf("\n");
120  printf("maxPM: %6.1f threshold %5.1f\n", m_maxPM, m_threshold );
121  printf("stars: %d\n", size() );
122  printf("Update Interval: %6.1f years\n", 100.0 * m_reindexInterval );
123  printf("Last Update: %6.1f\n", 2000.0 + 100.0 * (int) m_reindexNum.julianCenturies() );
124 }
125 
HighPMStarList::append
bool append(Trixel trixel, StarObject *star, double pm)
Definition: highpmstarlist.cpp:46
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
highpmstarlist.h
HTMesh::size
int size() const
Definition: HTMesh.h:125
SkyMesh::indexStar
Trixel indexStar(StarObject *star)
Definition: skymesh.cpp:98
HighPMStarList::reindex
void reindex(KSNumbers *num, StarIndex *starIndex)
Definition: highpmstarlist.cpp:67
HighPMStarList::setIndexTime
void setIndexTime(KSNumbers *num)
Definition: highpmstarlist.cpp:62
HighPMStar
struct HighPMStar HighPMStar
SkyMesh::Instance
static SkyMesh * Instance()
Definition: skymesh.cpp:48
Trixel
unsigned int Trixel
Definition: htmesh/typedef.h:4
SkyObject::mag
float mag(void) const
Definition: skyobject.h:182
SkyMesh::setKSNumbers
void setKSNumbers(KSNumbers *num)
Definition: skymesh.h:163
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
StarIndex
QVector< StarList * > StarIndex
Definition: skycomponents/typedef.h:49
J2000
#define J2000
Definition: kstarsdatetime.h:21
HighPMStarList::stats
void stats()
Definition: highpmstarlist.cpp:117
starobject.h
kstarsdatetime.h
HighPMStarList::~HighPMStarList
~HighPMStarList()
Definition: highpmstarlist.cpp:39
skymesh.h
KSNumbers::julianCenturies
double julianCenturies() const
Definition: ksnumbers.h:90
StarObject
This is a subclass of SkyObject.
Definition: starobject.h:41
HighPMStarList::HighPMStarList
HighPMStarList(double threshold)
Definition: highpmstarlist.cpp:33
HighPMStarList::size
int size()
Definition: highpmstarlist.h:62
QList
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