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

Akarsh Simha akarshsimha at gmail.com
Tue Jun 10 03:46:00 CEST 2008


SVN commit 818928 by asimha:

+ Implementing byte swapping on starData as a function

+ loadShallowStarData now uses the StarObject::init and
StarObject::setNames for named stars

+ Fixing bug in setting of long names in StarObject

CCMAIL: kstars-devel at kde.org



 M  +22 -26    skycomponents/starcomponent.cpp  
 M  +3 -0      skycomponents/starcomponent.h  
 M  +2 -2      starobject.cpp  


--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #818927:818928
@@ -397,35 +397,23 @@
     Trixel expectedTrixelId = -1;
     QTime t;
 
-    /* TODO : Remove timing code when we are done with all possible optimizations */
+    // TODO : Remove timing code when we are done with all possible optimizations
     t.start();
 
-    /* Start reading the data file */
     fseek(dataFile, dataReader.getDataOffset(), SEEK_SET);
 
-    /* Recurse over trixels */
     for(int i = 0; i < m_skyMesh -> size(); ++i) {
 
-        /* Recurse over stars in each trixel */
         for(unsigned long j = 0; j < (unsigned long)dataReader.getRecordCount(i); ++j) {
 
-            /* Read star data */
             if(!fread(&stardata, sizeof(starData), 1, dataFile)){
                 kDebug() << "ERROR: Could not read starData structure for star #" << j << " under trixel #" << i << endl;
             }
 
             /* Swap Bytes when required */            
-            if(swapBytes) {
-                bswap_32(stardata.RA);
-                bswap_32(stardata.Dec);
-                bswap_32(stardata.dRA);
-                bswap_32(stardata.dDec);
-                bswap_32(stardata.parallax);
-                bswap_32(stardata.HD);
-                bswap_16(stardata.mag);
-                bswap_16(stardata.bv_index);
-            }
-            
+            if(swapBytes)
+                byteSwap( &stardata );
+
             gname = "";
             name = "";
             visibleName = "";
@@ -451,9 +439,14 @@
 
             /* Create the new StarObject */
             if ( named ) {
+                /*
                 star = new StarObject( stardata.RA/1000000.0, stardata.Dec/100000.0, stardata.mag/100.0, name, visibleName, 
                                        QByteArray(stardata.spec_type, 2), stardata.dRA/10.0, stardata.dDec/10.0, 
                                        stardata.parallax/10.0, stardata.flags & 0x02, stardata.flags & 0x04 );
+                */
+                star = new StarObject;
+                star->init( &stardata );
+                star->setNames( name, visibleName );
             }
             else {
                 /*
@@ -550,16 +543,8 @@
         }
 
         /* Swap Bytes when required */            
-        if(swapBytes) {
-            bswap_32(stardata.RA);
-            bswap_32(stardata.Dec);
-            bswap_32(stardata.dRA);
-            bswap_32(stardata.dDec);
-            bswap_32(stardata.parallax);
-            bswap_32(stardata.HD);
-            bswap_16(stardata.mag);
-            bswap_16(stardata.bv_index);
-        }
+        if(swapBytes)
+            byteSwap( &stardata );
         
         if(stardata.flags & 0x01)
             kDebug() << "WARNING: Named Star encountered while reading StarBlock. Name will not be loaded!";
@@ -629,3 +614,14 @@
 int StarComponent::starColorIntensity( void ) const {
     return m_Data->colorScheme()->starColorIntensity();
 }
+
+void StarComponent::byteSwap( starData *stardata ) {
+    bswap_32( stardata->RA );
+    bswap_32( stardata->Dec );
+    bswap_32( stardata->dRA );
+    bswap_32( stardata->dDec );
+    bswap_32( stardata->parallax );
+    bswap_32( stardata->HD );
+    bswap_16( stardata->mag );
+    bswap_16( stardata->bv_index );
+}
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.h #818927:818928
@@ -161,7 +161,10 @@
      */
     //    int lineNumber( float mag );
 
+    // TODO: Find the right place for this method
+    static void byteSwap( starData *stardata );
 
+
 private:
     SkyMesh*       m_skyMesh;
     StarIndex*     m_starIndex;
--- branches/kstars/summer/kdeedu/kstars/kstars/starobject.cpp #818927:818928
@@ -106,7 +106,7 @@
     QString lname;
     if ( hasName() ) {
         lname = n;
-        if ( hasName2() )lname += n + " (" + gname() + ')';
+        if ( hasName2() )lname += " (" + gname() + ')';
     } else if ( hasName2() )
         lname = gname();
     
@@ -169,7 +169,7 @@
 
     if ( hasName() ) {
         lname = name;
-        if ( hasName2() ) lname += name + " (" + gname() + ')';
+        if ( hasName2() ) lname += " (" + gname() + ')';
     } else if ( hasName2() )
         lname = gname();
     setLongName(lname);


More information about the Kstars-devel mailing list