[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars/skycomponents

Akarsh Simha akarshsimha at gmail.com
Fri Jun 13 21:39:16 CEST 2008


I forgot to CCMAIL to the list, so I'm copy-pasting the mail to the
kde-commits list. Sorry for the inconvenience, if this doesn't look
like a regular commit message.

SVN commit 820295 by asimha:

+ Fixing bug that was causing fainter stars not to be displayed in
some trixels. We use different trixel ID numbers on the data file and
within the SkyMesh class to identify the same trixel. The code in
starblocklist.cpp was using the wrong trixel ID to readout the number
of stars from the data file header. As a confirmation of the fix,
KStars now displays mag 12.1 stars in the M22 region

+ Implementing the code required to re-use StarBlocks. This code was
not implemented correctly, causing 3 times more memory to be
used. This involved updating drawID at each draw, and making some
changes in the StarBlock and StarBlockFactory classes.





 M  +6 -0      starblock.cpp  
 M  +5 -5      starblock.h  
 M  +1 -0      starblockfactory.cpp  
 M  +4 -3      starblocklist.cpp  
 M  +4 -0      starcomponent.cpp  


--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblock.cpp \
#820294:820295 @@ -48,6 +48,12 @@
     if( !plainStarTemplate )
         plainStarTemplate = new StarObject;
     refCount++;
+    reset();
+}
+
+void StarBlock::reset() {
+    if( parent )
+        parent->releaseBlock( this );
     faintMag = -5.0;
     brightMag = 15.0;
     nStars = 0;
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblock.h \
#820294:820295 @@ -86,11 +86,6 @@
     inline bool isFull() { return ( ( nStars == size() ) ? true : false ); }
 
     /**
-     *@short Resets nStars to zero, so that we can start afresh
-     */
-    inline void reset() { nStars = 0; }
-
-    /**
      *@short  Return the capacity of this StarBlock
      *
      *This is different from nStars. While nStars indicates the number of stars that \
this StarBlock @@ -130,6 +125,11 @@
      */
     inline int getStarCount() { return nStars; }
 
+    /**
+     *@short  Reset this StarBlock's data, for reuse of the StarBl
+     */
+    void reset();
+
     float faintMag;
     float brightMag;
     StarBlockList *parent;
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblockfactory.cpp \
#820294:820295 @@ -61,6 +61,7 @@
             last->next = NULL;
         if( freeBlock == first )
             first = NULL;
+        freeBlock->reset();
         freeBlock->prev = NULL;
         freeBlock->next = NULL;
         return freeBlock;
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblocklist.cpp \
#820294:820295 @@ -65,14 +65,15 @@
     if( !dataFile )
         return false;
 
+    Trixel trixelId = ( ( trixel < 256 ) ? ( trixel + 256 ) : ( trixel - 256 ) ); // \
Trixel ID on datafile is assigned differently +
     if( readOffset == 0 ) {
-        Trixel i = ( ( trixel < 256 ) ? ( trixel + 256 ) : ( trixel - 256 ) ); // \
                Trixel ID on datafile is assigned differently
-        readOffset = dSReader->getOffset( i );
+        readOffset = dSReader->getOffset( trixelId );
     }
     
     fseek( dataFile, readOffset, SEEK_SET );
     
-    while( maglim >= blocks[nBlocks - 1]->faintMag && nStars < \
dSReader->getRecordCount( trixel ) + blocks[0]->getStarCount() ) { +    while( maglim \
>= blocks[nBlocks - 1]->faintMag && nStars < dSReader->getRecordCount( trixelId ) + \
> blocks[0]->getStarCount() ) {
         if( blocks[nBlocks - 1]->isFull() ) {
             blocks.append( SBFactory->getBlock() );
             if( !blocks[nBlocks] ) {
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp \
#820294:820295 @@ -280,6 +280,10 @@
         //        kDebug() << "Drawing SBL for trixel " << currentRegion << ", SBL \
                has " 
         //                 <<  m_starBlockList[ currentRegion ]->getBlockCount() << \
" blocks" << endl;  
+        // Increment drawID, for time being
+        // TODO: Figure out where the current drawID is stored and sync it with that
+        m_StarBlockFactory.drawID++;
+
         for( int i = 0; i < m_starBlockList[ currentRegion ]->getBlockCount(); ++i ) \
                {
             StarBlock *block = m_starBlockList[ currentRegion ]->block( i );


More information about the Kstars-devel mailing list