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

James Bowlin bowlin at mindspring.com
Fri Aug 10 21:28:31 CEST 2007


SVN commit 698702 by jbowlin:

Once again I've made the "final" precession correction to the indexing.

The ecliptic had mistakenly become a subclass of NoPrecessIndex but the
ecliptic does precess so this had to be fixed.  The problem was in the
LabeledListIndex class which was a subclass of NoPrecessIndex.  This was
wrong because the label should have a "has a" relationship not an "is a"
relationship.  So I changed LabeledListIndex to LineListLabel and took it
out of the index hierarchy.

Both Ecliptic and Equator have a LineListLabel data member now.  Ecliptic
subclasses from LineListIndex and Equator subclasses from NoPrecessIndex.
Life is good.

The code is ugly in a couple of spots.  It will benefit greatly from
Thomas' idea of making both SkyLabeler and SkyMesh singletons.  But the
code is doing the right thing now and the structure is sound (IMO).

I may need to tweak how the ecliptic gets updated but the hooks are in
that make this trivial.

I discovered that SatelliteComponent is still subclassing from
LineListComponent so that class can't go away.  I suspect that the
satellites may never get indexed because they move so fast.

CCMAIL: kstars-devel at kde.org


 M  +1 -1      CMakeLists.txt  
 M  +4 -5      skycomponents/README.indexing  
 M  +20 -2     skycomponents/ecliptic.cpp  
 M  +16 -4     skycomponents/ecliptic.h  
 M  +10 -2     skycomponents/equator.cpp  
 M  +17 -2     skycomponents/equator.h  
 D             skycomponents/labeledlistindex.cpp  
 D             skycomponents/labeledlistindex.h  
 A             skycomponents/linelistlabel.cpp   skycomponents/labeledlistindex.cpp#698387 [License: GPL (v2+)]
 A             skycomponents/linelistlabel.h   skycomponents/labeledlistindex.h#698387 [License: GPL (v2+)]
 M  +1 -1      skycomponents/skylabeler.cpp  
 M  +1 -1      skycomponents/skylabeler.h  
 M  +3 -1      skycomponents/skymapcomposite.cpp  


--- branches/work/kdeedu_kstars_htm/kstars/kstars/CMakeLists.txt #698701:698702
@@ -128,7 +128,7 @@
    skycomponents/skymapcomposite.cpp 
    skycomponents/skymesh.cpp
    skycomponents/linelistindex.cpp
-   skycomponents/labeledlistindex.cpp
+   skycomponents/linelistlabel.cpp
    skycomponents/noprecessindex.cpp
    skycomponents/skiplistindex.cpp
    skycomponents/polylistindex.cpp
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/README.indexing #698701:698702
@@ -261,14 +261,13 @@
 
   + LineListIndex
     - ConstellationLines
+    - Ecliptic
     + SkipListIndex
       - MilkWay
     + NoPrecessIndex
       - CoordinateGrid
       - ConsellationBoundary
-      + LabeledListIndex
-	    - Ecliptic
-		- Equator
+      - Equator
 
   + PolyListIndex
     - ConstellationBoundaryPoly
@@ -395,8 +394,8 @@
     - ConsellationBoundary
     - MilkWay
     - ConstellationBoundaryPoly
-	- Ecliptic
-	- Equator
+    - Ecliptic
+    - Equator
 
 These classes are typically small and simple, with just an init()
 routine to populate and append a bunch of LineList's (or their
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/ecliptic.cpp #698701:698702
@@ -29,7 +29,8 @@
 #include "linelist.h"
 
 Ecliptic::Ecliptic(SkyComponent *parent ) : 
-    LabeledListIndex( parent, i18n("Ecliptic") )
+   LineListIndex( parent, i18n("Ecliptic") ), 
+	m_label( parent, i18n("Ecliptic") )
 {}
 
 
@@ -38,10 +39,27 @@
     return Options::showEcliptic();
 }
 
-void Ecliptic::preDraw( KStars *kstars, QPainter &psky )
+void Ecliptic::draw( KStars *kstars, QPainter &psky, double scale )
 {
 	QColor color( kstars->data()->colorScheme()->colorNamed( "EclColor" ) );
 	psky.setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
+
+	m_label.reset( psky );
+
+	if ( ! skyMesh()->isZoomedIn() ) {
+		if ( Options::useAntialias() )
+			drawLinesFloat( kstars, psky, scale );
+		else 
+			drawLinesInt( kstars, psky, scale );
+	}
+	else {
+		if ( Options::useAntialias() )
+			drawAllLinesFloat( kstars, psky, scale );
+		else 
+			drawAllLinesInt( kstars, psky, scale );
+	}
+
+	m_label.draw( kstars, psky, scale );
 }
 
 void Ecliptic::init(KStarsData *data)
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/ecliptic.h #698701:698702
@@ -18,8 +18,8 @@
 #ifndef ECLIPTIC_H
 #define ECLIPTIC_H
 
-#include "labeledlistindex.h"
-
+#include "linelistindex.h"
+#include "linelistlabel.h"
 class KStarsData;
 
 /**
@@ -29,7 +29,7 @@
 	*@author James B. Bowlin
 	*@version 0.1
 	*/
-class Ecliptic : public LabeledListIndex
+class Ecliptic : public LineListIndex
 {
 	public:
 
@@ -39,7 +39,7 @@
 		 */
 		Ecliptic( SkyComponent *parent );
 
-		void preDraw( KStars *kstars, QPainter& psky );
+		void draw( KStars *kstars, QPainter& psky, double scale );
 
 		/**@short Initialize the Ecliptic
 		 *@p data pointer to the KStarsData object
@@ -47,6 +47,18 @@
 		virtual void init( KStarsData *data );
 
         bool selected();
+
+		void updateLabelCandidates( const QPointF& o, LineList* lineList, int i ) {
+			m_label.updateLabelCandidates( o.x(), o.y(), lineList, i );
+		}
+
+		void updateLabelCandidates( const QPoint& o, LineList* lineList, int i ) {
+			m_label.updateLabelCandidates( (qreal) o.x(), (qreal) o.y(), lineList, i );
+		}
+
+	private:
+		LineListLabel m_label;
+
 };
 
 #endif
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/equator.cpp #698701:698702
@@ -29,10 +29,10 @@
 #include "linelist.h"
 
 Equator::Equator(SkyComponent *parent ) : 
-    LabeledListIndex( parent, i18n("Equator") )
+    NoPrecessIndex( parent, i18n("Equator") ),
+	m_label( parent, i18n("Equator") )
 {}
 
-
 bool Equator::selected()
 {
     return Options::showEquator();
@@ -42,8 +42,16 @@
 {
 	QColor color( kstars->data()->colorScheme()->colorNamed( "EqColor" ) );
 	psky.setPen( QPen( QBrush( color ), 1, Qt::SolidLine ) );
+
+	m_label.reset( psky );
 }
 
+void Equator::draw( KStars *kstars, QPainter &psky, double scale )
+{
+	NoPrecessIndex::draw( kstars, psky, scale );
+	m_label.draw( kstars, psky, scale );
+}
+
 void Equator::init(KStarsData *data)
 {
 	KSNumbers num( data->ut().djd() );
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/equator.h #698701:698702
@@ -18,7 +18,8 @@
 #ifndef EQUATOR_H
 #define EQUATOR_H
 
-#include "labeledlistindex.h"
+#include "noprecessindex.h"
+#include "linelistlabel.h"
 
 class KStarsData;
 
@@ -29,7 +30,7 @@
 	*@author James B. Bowlin
 	*@version 0.1
 	*/
-class Equator : public LabeledListIndex
+class Equator : public NoPrecessIndex
 {
 	public:
 
@@ -40,13 +41,27 @@
 		Equator( SkyComponent *parent );
 
 		void preDraw( KStars *kstars, QPainter& psky );
+		
+		void draw( KStars *kstars, QPainter& psky, double scale );
 
+		void updateLabelCandidates( const QPointF& o, LineList* lineList, int i ) {
+			m_label.updateLabelCandidates( o.x(), o.y(), lineList, i );
+		}
+
+		void updateLabelCandidates( const QPoint& o, LineList* lineList, int i ) {
+			m_label.updateLabelCandidates( (qreal) o.x(), (qreal) o.y(), lineList, i );
+		}
+
 		/**@short Initialize the Equator
 		 *@p data pointer to the KStarsData object
 		 */
 		virtual void init( KStarsData *data );
 
         bool selected();
+
+	private:
+		
+		LineListLabel m_label;
 };
 
 #endif
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skylabeler.cpp #698701:698702
@@ -113,7 +113,7 @@
     }
 }
 
-bool SkyLabeler::drawLabel( QPainter& psky, QPointF& o, QString& text, 
+bool SkyLabeler::drawLabel( QPainter& psky, QPointF& o, const QString& text, 
 		                    double angle )
 {
 
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skylabeler.h #698701:698702
@@ -214,7 +214,7 @@
 		 * return false, otherwise the label is drawn, its position is marked
 		 * and we return true.
 		 */
-		bool drawLabel( QPainter& psky, QPointF& o, QString& text, double angle );
+		bool drawLabel( QPainter& psky, QPointF& o, const QString& text, double angle );
 
 		/* @short queues the label in the "type" buffer for later drawing.
 		 */
--- branches/work/kdeedu_kstars_htm/kstars/kstars/skycomponents/skymapcomposite.cpp #698701:698702
@@ -185,7 +185,9 @@
     SkyPoint* focus = m_map->focus();
     m_skyMesh->aperture( focus, radius + 1.0, DRAW_BUF ); // divide by 2 for testing
 
-    if ( Options::showGrid() || Options::showCBounds() && ! m_skyMesh->isZoomedIn() ) {
+    if ( Options::showGrid() || Options::showCBounds() || 
+			Options::showEquator() && ! m_skyMesh->isZoomedIn() ) {
+
         m_skyMesh->index( focus, radius + 1.0, NO_PRECESS_BUF );
     }
 


More information about the Kstars-devel mailing list