[Kstars-devel] branches/work/kdeedu_kstars_htm/kstars/kstars

James Bowlin bowlin at mindspring.com
Mon Aug 6 22:39:08 CEST 2007


SVN commit 697117 by jbowlin:

Implemented Jason's idea to keep some of the high proper-motions stars
in a separate list and only update stars as needed.  Created a new
class: HighPMStarList to do this.  If anyone has a better name for this
class I'm willing to change it.  It is trivial to have multiple such
lists.  Currently there are two:

  max-PM   Update Interval   # of stars
  7058      212 years             125
   838     2788 years           1,127
   304     4934 years         125,000 

The last line in the table is for the stars that are not in either
list.  If those need updating then the lists are ignored and the
entire star index is rebuilt. 

It would be trivial to add a third (or more) list, just one line of
code in the StarComponent::init() routine, but I didn't think users
would make enough multi-mellennia time jumps to justify the extra
storage space of a list with roughly 10k pointers.  If anyone has an
opinion on where we should set the proper-motion thresholds, please
let me know.  You can create a list of the stars sorted by
proper-motion by running: ./read-hippo.pl stars.data > stars.by-pm in
the data directory.  Each line in the new file will be a copy of a
line in stars.dat with the magnitude of the proper-motion prepended.


I also fixed the faint star magnitude spinner boxes in the setup menu.
The zoomed in limit was reading in new data every time the limit was
increased and the zoomed out limit was redrawing the screen every time
it was changed.  Now the stars.dat file is re-read only after the user
hits "Okay" or "Apply".  I'm actually doing the reading at the top of
StarComponent::draw() because I didn't know where the "Apply" hook
was.  But I think it is better where it is now because I can play the
same trick I did with re-indexing and delay one draw cycle before
reading the data which will allow us to present a pretty face while
the data gets read in.

Unfortunately, this still seems a little broken because it can take a
very long time to read in the star data. (I'm already using seek()
and pos() to only read in the new stars and not the entire file).  IMO
the long delay before the screen gets drawn is a big improvement over
having to battle sticky spinners but it still needs improvement.  The
4 seconds it takes to re-index all the stars is nothing compared to
the time it takes to read in the stars.dat file.

I might work on this after I port the atan2 changes. 

CCMAIL: kstars-devel at kde.org



 M  +1 -0      CMakeLists.txt  
 M  +3 -2      opscatalog.cpp  
 M  +5 -6      skycomponents/constellationlines.cpp  
 A             skycomponents/highpmstarlist.cpp   [License: GPL (v2+)]
 A             skycomponents/highpmstarlist.h   [License: GPL (v2+)]
 M  +50 -17    skycomponents/starcomponent.cpp  
 M  +7 -4      skycomponents/starcomponent.h  
 M  +2 -1      skycomponents/typedef.h  
 M  +6 -2      starobject.cpp  


--- branches/work/kdeedu_kstars_htm/kstars/kstars/CMakeLists.txt #697116:697117
@@ -124,6 +124,7 @@
 
 set(libkstarscomponents_SRCS 
    skycomponents/skylabeler.cpp 
+   skycomponents/highpmstarlist.cpp 
    skycomponents/skymapcomposite.cpp 
    skycomponents/skymesh.cpp
    skycomponents/linelistindex.cpp
--- branches/work/kdeedu_kstars_htm/kstars/kstars/opscatalog.cpp #697116:697117
@@ -194,15 +194,16 @@
 }
 
 void OpsCatalog::slotSetDrawStarMagnitude(double newValue) {
+	kcfg_MagLimitDrawStar->setValue( newValue );                             // -jbb
 	kcfg_MagLimitDrawStarZoomOut->setMaximum( newValue );
-	ksw->data()->skyComposite()->setFaintStarMagnitude( newValue );
+	//ksw->data()->skyComposite()->setFaintStarMagnitude( newValue );        // -jbb
 }
 
 void OpsCatalog::slotSetDrawStarZoomOutMagnitude(double newValue) {
 	kcfg_MagLimitDrawStar->setMinimum( newValue );
 	Options::setMagLimitDrawStarZoomOut( newValue );
 	// force redraw
-	ksw->map()->forceUpdate();
+	//ksw->map()->forceUpdate();                                             // -jbb
 }
 
 void OpsCatalog::slotStarWidgets(bool on) {
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/constellationlines.cpp #697116:697117
@@ -109,8 +109,8 @@
     if ( lineList ) appendLine( lineList );
     
     m_reindexInterval = StarObject::reindexInterval( maxPM );
-    printf("CLines:           maxPM = %6.1f milliarcsec/year\n", maxPM );
-    printf("CLines: Update Interval = %6.1f years\n", m_reindexInterval * 100.0 );
+    //printf("CLines:           maxPM = %6.1f milliarcsec/year\n", maxPM );
+    //printf("CLines: Update Interval = %6.1f years\n", m_reindexInterval * 100.0 );
    
     summary();
 }
@@ -119,10 +119,9 @@
     return skyMesh()->indexStarLine( lineList->points() );
 }
 
-
 // JIT updating makes this simple.  Star updates are called from within both
 // StarComponent and ConstellationLines.  If the update is redundant then
-// StarObject::update() simply returns without doing any work.
+// StarObject::JITupdate() simply returns without doing any work.
 
 void ConstellationLines::JITupdate( KStarsData *data, LineList* lineList )
 {
@@ -142,12 +141,12 @@
     if ( fabs( num->julianCenturies() - 
          m_reindexNum.julianCenturies() ) < m_reindexInterval ) return;
 
-    printf("Re-indexing CLines to year %4.1f...\n", 2000.0 + num->julianCenturies() * 100.0);
+    //printf("Re-indexing CLines to year %4.1f...\n", 2000.0 + num->julianCenturies() * 100.0);
 
     m_reindexNum = KSNumbers( *num );
     skyMesh()->setKSNumbers( num );
     LineListIndex::reindexLines();
     
-    printf("Done.\n");
+    //printf("Done.\n");
 }
 
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/starcomponent.cpp #697116:697117
@@ -46,6 +46,9 @@
     for (int i = 0; i < m_skyMesh->size(); i++) {
         m_starIndex->append( new StarList() );
     }
+    m_highPMStars.append( new HighPMStarList( m_skyMesh, 840.0 ) );
+    m_highPMStars.append( new HighPMStarList( m_skyMesh, 304.0 ) );
+    m_reindexInterval = StarObject::reindexInterval( 304.0 );
 
     lastFilePos = 0;
 }
@@ -66,14 +69,21 @@
     if ( ! num ) return;
 
     if ( fabs( num->julianCenturies() - 
-         m_reindexNum.julianCenturies() ) < 1.5 ) return;
+         m_reindexNum.julianCenturies() ) > m_reindexInterval ) {
+        reindexAll( num );
+        return;
+    }
 
-    //if (fabs( data->ut().epoch() - m_indexDate.epoch() ) < 150.0 ) return;
-    
-    //m_reindexNum = KSNumbers( data
+    for ( int j = 0; j < m_highPMStars.size(); j++ ) {
+        m_highPMStars.at( j )->reindex( num, m_starIndex );
+    }
+}
 
-    printf("Re-indexing Stars to year %4.1f...\n", 2000.0 + num->julianCenturies() * 100.0);
+void StarComponent::reindexAll( KSNumbers *num )
+{
 
+    //printf("Re-indexing Stars to year %4.1f...\n", 2000.0 + num->julianCenturies() * 100.0);
+
     m_reindexNum = KSNumbers( *num );
     m_skyMesh->setKSNumbers( num );
 
@@ -96,7 +106,12 @@
         m_starIndex->at( trixel )->append( star );
     }
 
-    printf("Done.\n");
+    // Let everyone know we have re-indexed to num
+    for ( int j = 0; j < m_highPMStars.size(); j++ ) {
+        m_highPMStars.at( j )->setIndexTime( num );
+    }
+
+    //printf("Done.\n");
 }
 
 
@@ -126,13 +141,17 @@
 
     //shortcuts to inform whether to draw different objects
 	bool hideFaintStars( checkSlewing && Options::hideStars() );
+	double maglim = Options::magLimitDrawStar();
 
+    if ( ! hideFaintStars && ( m_FaintMagnitude < maglim ) ) {        // -jbb
+        setFaintMagnitude( maglim );
+    }
+
 	//adjust maglimit for ZoomLevel
 	double lgmin = log10(MINZOOM);
 	double lgmax = log10(MAXZOOM);
 	double lgz = log10(Options::zoomFactor());
 
-	double maglim = Options::magLimitDrawStar();
 	if ( lgz <= 0.75*lgmax )
         maglim -= (Options::magLimitDrawStar() - 
                    Options::magLimitDrawStarZoomOut() ) *
@@ -223,14 +242,15 @@
     //int filePos = lastFilePos;
 
     m_skyMesh->setKSNumbers( &m_reindexNum );
-    printf("Indexing stars for year %.1f\n",  2000.0 + m_reindexNum.julianCenturies() * 100.0 );
+    //printf("Indexing stars for year %.1f\n",  
+    //        2000.0 + m_reindexNum.julianCenturies() * 100.0 );
 
     float currentMag = -5.0;
 
 	KSFileReader fileReader;
     if ( ! fileReader.open( "stars.dat" ) ) return;
 
-    if (lastFilePos == 0 ) {
+    if ( lastFilePos == 0 ) {
         fileReader.setProgress( m_Data, i18n("Loading stars"), 125994, 100 );
     }
 
@@ -247,8 +267,18 @@
 			// check star magnitude
         currentMag = line.mid( 46,5 ).toFloat();
         
-        processStar( line );
+        StarObject* star = processStar( line );
 
+	    objectList().append( star );
+        Trixel trixel = m_skyMesh->indexStar( star );
+        m_starIndex->at( trixel )->append( star );
+        double pm = star->pmMagnitude();
+
+        for (int j = 0; j < m_highPMStars.size(); j++ ) {
+            HighPMStarList* list = m_highPMStars.at( j );
+            if ( list->append( trixel, star, pm ) ) break;
+        }
+
         if ( currentMag > m_FaintMagnitude ) {   // Done!
             lastFilePos = fileReader.pos();
             break; 
@@ -257,12 +287,18 @@
         fileReader.showProgress();
     }
 
-	Options::setMagLimitDrawStar( newMagnitude );
-    emitProgressText( i18n("Loading stars done.") );
+	//Options::setMagLimitDrawStar( newMagnitude );       -jbb
+    //if ( lastFilePos == 0 ) emitProgressText( i18n("Loading stars done.") );
+
+    //for (int j = 0; j < m_highPMStars.size(); j++ ) {
+    //    m_highPMStars.at( j )->stats();
+    //}
+
+    //printf("star catalog reindexInterval = %6.1f years\n", 100.0 * m_reindexInterval );
 }
 
 
-void StarComponent::processStar( const QString &line ) {
+StarObject* StarComponent::processStar( const QString &line ) {
 	QString name, gname, SpType, visibleName;
 	int rah, ram, ras, ras2, dd, dm, ds, ds2;
 	bool mult(false), var(false);
@@ -340,11 +376,7 @@
 
 	StarObject *o = new StarObject( r, d, mag, name, visibleName, SpType, pmra, pmdec, plx, mult, var );
 	o->EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
-	objectList().append(o);
 
-    Trixel trixel = m_skyMesh->indexStar( o );
-    m_starIndex->at( trixel )->append( o );
-
     if ( ! gname.isEmpty() ) m_genName.insert( gname, o );
 
 	if ( ! name.isEmpty() && name != i18n("star") ) {
@@ -353,6 +385,7 @@
 	if ( ! gname.isEmpty() && gname != name ) {
         objectNames(SkyObject::STAR).append( o->gname(false) );
     }
+    return o;
 }
 
 SkyObject* StarComponent::findStarByGenetiveName( const QString name ) {
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/starcomponent.h #697116:697117
@@ -33,6 +33,7 @@
 #include "ksnumbers.h"
 
 #include "typedef.h"
+#include "highpmstarlist.h"
 
 class SkyComponent;
 class KStars;
@@ -43,7 +44,7 @@
 class SkyLabeler;
 
 
-typedef QVector< StarList* > StarIndex;
+//typedef QVector< StarList* > StarIndex;
 
 class StarComponent: public ListComponent
 {
@@ -104,13 +105,15 @@
         SkyLabeler*    m_skyLabeler;
 
         KSNumbers      m_reindexNum;
+        double         m_reindexInterval;
+
+        QVector<HighPMStarList*> m_highPMStars;
         
         qint64 lastFilePos;
 
         QHash<QString, SkyObject*> m_genName;
 
-		// some helper methods
-		bool openStarFile(int i);
+        void reindexAll( KSNumbers *num );
 
 	/** 
 		*Parse a line from a stars data file, construct a StarObject from the data,
@@ -141,7 +144,7 @@
 		*
 		*@param line pointer to the line of data to be processed as a StarObject
 		*/
-		void processStar( const QString &line );
+		StarObject* processStar( const QString &line );
 
         bool selected();
 
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/typedef.h #697116:697117
@@ -39,7 +39,8 @@
 
 typedef QVector< SkyPoint*>            SkyList;
 typedef QHash< Trixel, bool>           IndexHash;
-typedef QVector< StarObject*>          StarList;
+typedef QList< StarObject*>            StarList;
+typedef QVector< StarList* >           StarIndex;
 typedef QVector< LineList*>            LineListList;
 typedef QHash< Trixel, LineListList*>  LineListHash;  // Wanted LineListIndex but
                                                       // that is used by a class.
--- branches/work/kdeedu_kstars_htm/kstars/kstars/starobject.cpp #697116:697117
@@ -36,8 +36,12 @@
 //
 double StarObject::reindexInterval( double pm )
 {
-    // arcminutes * sec/min * [milliarcsec/year] / ( years/century * milliarcsec / arcsec )
-    return 25.0 * 60.0 * pm / ( 100.0 * 10000.0 ); 
+    if ( pm < 1.0e-6) return 1.0e6;
+
+    // arcminutes * sec/min * milliarcsec/sec centuries/year 
+    // / [milliarcsec/year] = centuries
+
+    return 25.0 * 60.0 * 10.0 / pm;
 }
 
 StarObject::StarObject( StarObject &o )


More information about the Kstars-devel mailing list