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

James Bowlin bowlin at mindspring.com
Sat Aug 11 20:20:49 CEST 2007


SVN commit 698989 by jbowlin:

Added two routines to ConstellationBoundaryPoly and SkyMapComposite
(as a proxy):

    const QPolygonF* constellationPoly( SkyPoint *p );

	const QPolygonF* constellationPoly( const QString& name );

These are the new hooks for SkyMap::HighlightConstellation() after we
merge with the trunk. 

It is clear that ConsellationBoundaryPoly should also be a singleton.
Unfortunately, there is some code in SkyMapComposite::constellationName()
that I will have to move elsewhere before I can remove that proxy method
from SkyMapComposite.

CCMAIL: kstars-devel at kde.org


 M  +21 -13    constellationboundarypoly.cpp  
 M  +4 -2      constellationboundarypoly.h  
 M  +1 -1      polylist.h  
 M  +3 -3      polylistindex.cpp  
 M  +8 -0      skymapcomposite.cpp  
 M  +3 -0      skymapcomposite.h  
 M  +12 -12    skymesh.cpp  
 M  +1 -1      skymesh.h  


--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/constellationboundarypoly.cpp #698988:698989
@@ -44,19 +44,35 @@
 
 QString ConstellationBoundaryPoly::constellationName( SkyPoint *p ) 
 {
-    PolyList *poly = ContainingPoly( p );
-    if ( poly ) return poly->name();
+    PolyList *polyList = ContainingPoly( p );
+    if ( polyList ) return polyList->name();
 
  	return i18n("Unknown");
 }
 
+const QPolygonF* ConstellationBoundaryPoly::constellationPoly( const QString &name )
+{
+	if ( nameHash().contains( name ) )
+		return nameHash().value( name )->poly();
 
+	return 0;
+}
+
+const QPolygonF* ConstellationBoundaryPoly::constellationPoly( SkyPoint *p ) 
+{
+    PolyList *polyList = ContainingPoly( p );
+    if ( polyList ) return polyList->poly();
+
+ 	return 0;
+}
+
+
 bool ConstellationBoundaryPoly::inConstellation( const QString &name, SkyPoint *p )
 {
     PolyList* polyList = nameHash().value( name );
     if ( ! polyList ) return false;
-    const QPolygonF& poly = polyList->poly();
-	if ( poly.containsPoint( QPointF( p->ra()->Hours(), 
+    const QPolygonF* poly = polyList->poly();
+	if ( poly->containsPoint( QPointF( p->ra()->Hours(), 
                              p->dec()->Degrees() ), Qt::OddEvenFill ) )
 	    return true;
 
@@ -64,12 +80,4 @@
 }
 
 
-/**
-const QPolygonF& ConstellationBoundaryPoly::boundary( const QString &name ) const
-{
-	if ( nameHash.contains( name ) )
-		return nameHash.value( name )->poly();
-	else
-		return QPolygonF();  // FIXME: ref to temp.  -jbb
-}
-**/
+
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/constellationboundarypoly.h #698988:698989
@@ -44,10 +44,12 @@
 		*/
 		ConstellationBoundaryPoly( SkyComponent *parent );
 
-		const QPolygonF& boundary( const QString &name ) const;
-
 		QString constellationName( SkyPoint *p );
 
+		const QPolygonF* constellationPoly( SkyPoint *p );
+
+		const QPolygonF* constellationPoly( const QString& name );
+
     	bool inConstellation( const QString &name, SkyPoint *p );
 
     private:
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/polylist.h #698988:698989
@@ -39,7 +39,7 @@
 
         /* @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.
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/polylistindex.cpp #698988:698989
@@ -122,13 +122,13 @@
 
         //kDebug() << QString("checking %1 boundary\n").arg( polyList->name() );
 
-        const QPolygonF& poly = polyList->poly();
+        const QPolygonF* poly = polyList->poly();
         if ( wrapRA && polyList->wrapRA() ) {
-            if ( poly.containsPoint( wrapPoint, Qt::OddEvenFill ) )
+            if ( poly->containsPoint( wrapPoint, Qt::OddEvenFill ) )
                 return polyList;
         }
         else {
-            if ( poly.containsPoint( point, Qt::OddEvenFill ) )
+            if ( poly->containsPoint( point, Qt::OddEvenFill ) )
                 return polyList;
         }
     }
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skymapcomposite.cpp #698988:698989
@@ -491,7 +491,15 @@
 		return name;
 }
 
+const QPolygonF* SkyMapComposite::constellationPoly( SkyPoint *p ) {
+	return m_CBoundsBoundary->constellationPoly( p );
+}
 
+const QPolygonF* SkyMapComposite::constellationPoly( const QString& name ) {
+	return m_CBoundsBoundary->constellationPoly( name );
+}
+
+
 //bool SkyMapComposite::inConstellation( const QString &name, SkyPoint *p ) {
 //	return m_CBounds->inConstellation( name, p );
 //}
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skymapcomposite.h #698988:698989
@@ -165,7 +165,10 @@
 
 		QString constellationName( SkyPoint *p );
 		//bool inConstellation( const QString &name, SkyPoint *p );
+		const QPolygonF* constellationPoly( SkyPoint *p );
 
+		const QPolygonF* constellationPoly( const QString& name );
+
 		virtual void emitProgressText( const QString &message );
 		virtual QHash<int, QStringList>& objectNames();
 		virtual QStringList& objectNames( int k );
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skymesh.cpp #698988:698989
@@ -272,23 +272,23 @@
     return indexHash;
 }
 
-const IndexHash& SkyMesh::indexPoly( const QPolygonF &points )
+const IndexHash& SkyMesh::indexPoly( const QPolygonF* points )
 {
     indexHash.clear();
 
-    if (points.size() < 3) return indexHash;
+    if (points->size() < 3) return indexHash;
 
-    const QPointF startP = points.first();
+    const QPointF startP = points->first();
 
-    int end = points.size() - 2;     // 1) size - 1  -> last index,
+    int end = points->size() - 2;     // 1) size - 1  -> last index,
                                       // 2) minimum of 2 points
     for( int p = 1; p <= end; p+= 2 ) {
 
         if ( p == end ) {
-            index( startP, points.at(p), points.at(p+1) );
+            index( startP, points->at(p), points->at(p+1) );
         }
         else {
-            index( startP, points.at(p), points.at(p+1), points.at(p+2) );
+            index( startP, points->at(p), points->at(p+1), points->at(p+2) );
         }
 
         MeshIterator region( this );
@@ -297,16 +297,16 @@
             printf("\nSkyMesh::indexPoly: too many trixels: %d\n", region.size() );
 
             printf("    ra1 = %f;\n", startP.x() );
-            printf("    ra2 = %f;\n", points.at(p).x() );
-            printf("    ra3 = %f;\n", points.at(p+1).x()) ;
+            printf("    ra2 = %f;\n", points->at(p).x() );
+            printf("    ra3 = %f;\n", points->at(p+1).x()) ;
             if ( p < end )
-                printf("    ra4 = %f;\n", points.at(p+2).x() );
+                printf("    ra4 = %f;\n", points->at(p+2).x() );
 
             printf("    dec1 = %f;\n", startP.y() );
-            printf("    dec2 = %f;\n", points.at(p).y() );
-            printf("    dec3 = %f;\n", points.at(p+1).y() );
+            printf("    dec2 = %f;\n", points->at(p).y() );
+            printf("    dec3 = %f;\n", points->at(p+1).y() );
             if ( p < end )
-                printf("    dec4 = %f;\n", points.at(p+2).y());
+                printf("    dec4 = %f;\n", points->at(p+2).y());
 
             printf("\n");
 
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skymesh.h #698988:698989
@@ -242,7 +242,7 @@
         /* @short does the same as above but with a QPolygonF as the
          * container for the points.
          */
-        const IndexHash& indexPoly( const QPolygonF &points );
+        const IndexHash& indexPoly( const QPolygonF* points );
 
         /* @short Returns the debug level.  This is used as a global debug level
          * for LineListIndex and its subclasses.


More information about the Kstars-devel mailing list