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

James Bowlin bowlin at mindspring.com
Sat Aug 4 06:33:25 CEST 2007


SVN commit 696188 by jbowlin:

Fixed a minor bug in the code that finds which constellation a point
is in.  We needed to wrap the RA of the point to negative values for
some of the constellations that straddle the line RA == 0.  Added
a new data member to PolyList to remember which constellations need
the wrapping.  Made cosmetic changes to linelist.h and skiplist.h.

Fixed a bug in the star re-indexing code.  The new indexes I was
building were not always keeping all the stars in each trixel sorted
by brightness which was making some stars appear to disappear when
the re-indexing caused them to land in a new trixel.  This gave me
a chance to thoroughly examine the numerics in the re-indexing code
and, except for this bug of course, it all appeared solid.


CCMAIL: kstars-devel at kde.org



 M  +1 -0      skycomponents/constellationboundary.cpp  
 M  +2 -2      skycomponents/linelist.h  
 M  +13 -9     skycomponents/polylist.h  
 M  +17 -4     skycomponents/polylistindex.cpp  
 M  +4 -3      skycomponents/skiplist.h  
 M  +2 -4      skycomponents/skymapcomposite.cpp  
 M  +15 -18    skycomponents/starcomponent.cpp  
 M  +4 -4      starobject.cpp  


--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/constellationboundary.cpp #696187:696188
@@ -117,6 +117,7 @@
 
         // always add the point to the boundary (and toss dupes)
         polyList->append( QPointF( ra, dec ) );
+        if ( ra < 0 ) polyList->wrapRA( true );
         
         if ( flag ) {
 
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/linelist.h #696187:696188
@@ -34,8 +34,8 @@
  * @author James B. Bowlin
  * @version 0.2
 */
-class LineList {
-
+class LineList
+{
 	public:
         LineList() : drawID(0), updateID(0) {}
 
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/polylist.h #696187:696188
@@ -29,22 +29,17 @@
  *
  * @author James B. Bowlin @version 0.1
  */
-class PolyList {
-
-    private: 
-        QPolygonF m_poly;
-        QString   m_name;
-
+class PolyList
+{
     public:
-
         /* @short trivial constructor that also sets the name.   It was
          * convenient to specify the name at construction time.
          */
-        PolyList( QString name) { m_name = name; };
+        PolyList( QString name) : m_wrapRA(false) { m_name = name; };
 
         /* @short returns the QPolygonF that holds the points.
          */
-const QPolygonF& poly() { return m_poly; }
+        const QPolygonF& poly() { return m_poly; }
 
         /* @short we need a new append() method to append QPointF's
          * instead of SkyPoints.
@@ -59,6 +54,15 @@
         /* @short returns the name.
          */
         const QString &name() { return m_name; }
+
+        bool wrapRA() { return m_wrapRA; }
+        void wrapRA( bool wrap ) { m_wrapRA = wrap; }
+
+    private: 
+        QPolygonF m_poly;
+        QString   m_name;
+        bool      m_wrapRA;
+
 };
 
 #endif
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/polylistindex.cpp #696187:696188
@@ -88,13 +88,17 @@
 
     QHash<PolyList*, bool> polyHash;
     QHash<PolyList*, bool>::const_iterator iter;
- 
+
+    printf("\n");
+
     // the boundaries don't precess so we use index() not aperture()
     skyMesh()->index( p, 1.0, IN_CONSTELL_BUF );         
     MeshIterator region( skyMesh(), IN_CONSTELL_BUF );
     while ( region.hasNext() ) {
 
         Trixel trixel = region.next();
+        //printf("Trixel: %4d %s\n", trixel, skyMesh()->indexToName( trixel ) );
+
         PolyListList *polyListList = m_polyIndex[ trixel ];
 
         //printf("    size: %d\n", polyListList->size() );
@@ -110,6 +114,10 @@
     // Don't bother with boundaries if there is only one
     if ( polyHash.size() == 1 ) return iter.key();
 
+    QPointF point( p->ra()->Hours(), p->dec()->Degrees() );
+    QPointF wrapPoint( p->ra()->Hours() - 24.0, p->dec()->Degrees() );
+    bool wrapRA = p->ra()->Hours() > 12.0;
+
     while ( iter != polyHash.constEnd() ) {
 
         PolyList* polyList = iter.key();
@@ -118,9 +126,14 @@
         //kDebug() << QString("checking %1 boundary\n").arg( polyList->name() );
 
         const QPolygonF& poly = polyList->poly();
-        if ( poly.containsPoint( QPointF( p->ra()->Hours(), 
-                                 p->dec()->Degrees() ), Qt::OddEvenFill ) )
-            return polyList;
+        if ( wrapRA && polyList->wrapRA() ) {
+            if ( poly.containsPoint( wrapPoint, Qt::OddEvenFill ) )
+                return polyList;
+        }
+        else {
+            if ( poly.containsPoint( point, Qt::OddEvenFill ) )
+                return polyList;
+        }
     }
 
     return 0;
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skiplist.h #696187:696188
@@ -33,9 +33,6 @@
  */
 class SkipList : public LineList
 {
-    private:
-         IndexHash m_skip;     
-         
 	public:
         /* @short returns the entire skip hash.  Used by the
          * indexLines() routine so all the line segments in
@@ -52,6 +49,10 @@
          * segment.
          */
         bool skip( int i ) { return m_skip.contains( i );  }
+
+    private:
+         IndexHash m_skip;
+
 };
 
 #endif
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skymapcomposite.cpp #696187:696188
@@ -188,10 +188,8 @@
     }
     **/
 
-    // FIXME: ensure we are using the proper font here -jbb
     m_skyLabeler->reset( m_map, psky, scale ); 
 
-
 	//TIMING
 	//QTime t;
     //t.start();
@@ -271,8 +269,8 @@
 
     // -jbb uncomment these to see trixel outlines:
 
-    psky.setPen(  QPen( QBrush( QColor( "green" ) ), 1, Qt::SolidLine ) );
-    m_skyMesh->draw( ks, psky, scale, IN_CONSTELL_BUF );
+    //psky.setPen(  QPen( QBrush( QColor( "green" ) ), 1, Qt::SolidLine ) );
+    //m_skyMesh->draw( ks, psky, scale, IN_CONSTELL_BUF );
 
     //psky.setPen(  QPen( QBrush( QColor( "yellow" ) ), 1, Qt::SolidLine ) );
     //m_skyMesh->draw( ks, psky, scale, OBJ_NEAREST_BUF );
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/starcomponent.cpp #696187:696188
@@ -66,34 +66,31 @@
     if ( ! num ) return;
     if (fabs( data->ut().epoch() - m_indexDate.epoch() ) < 150.0 ) return;
     
-    printf("Now: %.1f\n", data->ut().epoch() );
-    printf("LU : %.1f\n", m_indexDate.epoch() );
-
     m_indexDate.setDJD( data->ut().djd() );
 
     printf("Re-indexing Stars ...\n");
 
+    // delete the old index 
+    for ( int i = 0; i < m_starIndex->size(); i++ ) {
+        delete m_starIndex->at( i );
+    }
+    delete m_starIndex;
+
     // Create a new index
-    StarIndex* newIndex = new StarIndex();
+    m_starIndex = new StarIndex();
     for (int i = 0; i < m_skyMesh->size(); i++) {
-        newIndex->append( new StarList() );
+        m_starIndex->append( new StarList() );
     }
 
     // Fill it with stars from old index
     double ra, dec;
 
-    for ( int i = 0; i < m_skyMesh->size(); i++ ) {
-        StarList* starList = m_starIndex->at( i );
-        for ( int j = 0; j < starList->size(); j++ ) {
-            StarObject* star = starList->at( j );
-            star->getIndexCoords( num, &ra, &dec );
-            Trixel trixel = m_skyMesh->index( ra, dec );
-            newIndex->at( trixel )->append( star );
-        }
-        delete starList;
+    for ( int i = 0; i < objectList().size(); i++ ) {
+        StarObject* star = (StarObject*) objectList()[ i ];
+        star->getIndexCoords( num, &ra, &dec );
+        Trixel trixel = m_skyMesh->index( ra, dec );
+        m_starIndex->at( trixel )->append( star );
     }
-    delete m_starIndex;
-    m_starIndex = newIndex;
 
     printf("Done.\n");
 }
@@ -188,14 +185,14 @@
 
             if ( noLabels ) continue;
             if ( mag > labelMagLim ) continue;
-            if ( curStar->name() == i18n("star") ) continue;
             //if ( checkSlewing || ! (Options::showStarMagnitudes() || Options::showStarNames()) ) continue;
 
             // NOTE: the code below was copied here from StarObject.  Perhaps
             // there is a cleaner way. -jbb
             float offset = scale * (6. + 0.5*( 5.0 - mag ) + 0.01*( zoom/500. ) );
 
-            bool drawName = ( Options::showStarNames() && curStar->name() != i18n("star") );
+            //bool drawName = ( Options::showStarNames() && curStar->name() != i18n("star") );
+            bool drawName = ( Options::showStarNames() );
 
             QString sName( i18n("star") + ' ' );
             if ( drawName ) {
--- branches/work/kdeedu_kstars_htm/kstars/kstars/starobject.cpp #696187:696188
@@ -108,11 +108,11 @@
 
 void StarObject::getIndexCoords( KSNumbers *num, double *ra, double *dec )
 {
-    *ra = ra0()->Degrees() + 
-        pmRA() * num->julianMillenia() / cos( dec0()->radians() ) / 3600.0;
+    double dra = pmRA() * num->julianMillenia() / ( cos( dec0()->radians() ) * 3600.0 );
+    double ddec = pmDec() * num->julianMillenia() / 3600.0;
 
-    *dec = dec0()->Degrees() + 
-        pmDec() * num->julianMillenia() / 3600.0;
+    *ra = ra0()->Degrees() + dra;       
+    *dec = dec0()->Degrees() + ddec;
 }
 
 void StarObject::JITupdate( KStarsData* data )


More information about the Kstars-devel mailing list