[Kstars-devel] KDE/kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Sat Nov 4 05:51:12 CET 2006


SVN commit 601655 by harris:

CoordinatGridComponent is now a LineListComponent.

Also fixed some problems with the Milky Way, which 
were caused by a reversal of the meaning og a bool 
argument in toScreen().  It used to take a 
"clipped" argument that was set to "true" if the point 
was more than 90 degrees from the focus position (and 
therefore on the "front side" of the projected sphere 
and not to be drawn).  I decided it made more sense to
make this variable "onscreen", which is true if the 
screen point falls within the bounds of the SkyMap 
rect().  

I had forgotten to switch MilkyWayComponent to use this 
new sense of the bool variable, which was causing some 
drawing problems.

CCMAIL: kstars-devel at kde.org



 M  +20 -11    skycomponents/coordinategridcomponent.cpp  
 M  +3 -3      skycomponents/coordinategridcomponent.h  
 M  +9 -9      skymapdraw.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/coordinategridcomponent.cpp #601654:601655
@@ -23,11 +23,12 @@
 #include "kstars.h"
 #include "kstarsdata.h"
 #include "skymap.h"
+#include "skyline.h" 
 #include "skypoint.h" 
 #include "Options.h"
 
 CoordinateGridComponent::CoordinateGridComponent(SkyComponent *parent, bool (*visibleMethod)(), bool isParallel, double coord ) 
-: PointListComponent(parent, visibleMethod), Parallel( isParallel ), Coordinate( coord )
+: LineListComponent(parent, visibleMethod), Parallel( isParallel ), Coordinate( coord )
 {
 }
 
@@ -37,34 +38,41 @@
 void CoordinateGridComponent::init( KStarsData *data ) {
 	emitProgressText( i18n("Loading coordinate grid" ) );
 
-	//	setPen( QPen( QBrush( ks->data()->colorScheme()->colorNamed( "GridColor" ) ), 
-	//								1, Qt::DotLine ) );
+	setPen( QPen( QBrush( data->colorScheme()->colorNamed( "GridColor" ) ), 
+								1, Qt::DotLine ) );
 
 	if ( Parallel ) { //line of constant Declination
 		double dra = 1./5.; //120 points around full circle
+		SkyPoint o1( 0.0, Coordinate );
 		for ( double ra=0.0; ra < 24.0; ra += dra ) {
-			SkyPoint *sp = new SkyPoint( ra, Coordinate );
-			sp->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
-			pointList().append( sp );
+			SkyPoint o2( ra, Coordinate );
+			SkyLine *sl = new SkyLine( o1, o2 );
+			sl->update( data );
+			lineList().append( sl );
+			o1 = o2;
 		}
 	} else { //line of constant Right Ascension
 		double RA = Coordinate;
 		double OppositeRA = Coordinate + 12.0;
 		if ( OppositeRA > 24.0 ) OppositeRA -= 24.0;
-		for ( double dec=-90.; dec < 270.; dec += 4.0 ) {
+
+		SkyPoint o1( RA, -90.0 );
+		for ( double dec=-90. + 4.0; dec < 270.; dec += 4.0 ) {
 			double Dec = dec;
-			
 			if ( dec > 90. ) {
 				Dec = 180. - dec;
 				RA = OppositeRA;
 			}
-			SkyPoint *sp = new SkyPoint( RA, Dec );
-			sp->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
-			pointList().append( sp );
+			SkyPoint o2( RA, Dec );
+			SkyLine *sl = new SkyLine( o1, o2 );
+			sl->update( data );
+			lineList().append( sl );
+			o1 = o2;
 		}
 	}
 }
 
+/*
 void CoordinateGridComponent::draw(KStars *ks, QPainter& psky, double scale)
 {
 // TODO add accessor methods to map for guideMax etc.
@@ -108,3 +116,4 @@
 					QPoint(int(o1.x()),int(o1.y())) );
 	}
 }
+*/
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/coordinategridcomponent.h #601654:601655
@@ -18,7 +18,7 @@
 #ifndef COORDINATEGRIDCOMPONENT_H
 #define COORDINATEGRIDCOMPONENT_H
 
-#include "pointlistcomponent.h"
+#include "linelistcomponent.h"
 
 /**
 	*@class CoordinateGridComponent
@@ -32,7 +32,7 @@
 class KStarsData;
 class SkyMap;
 
-class CoordinateGridComponent : public PointListComponent
+class CoordinateGridComponent : public LineListComponent
 {
 	public:
 		
@@ -52,7 +52,7 @@
 		*@p psky Reference to the QPainter on which to paint
 		*@p scale scaling factor (1.0 for screen draws)
 		*/
-		virtual void draw(KStars *ks, QPainter& psky, double scale);
+		//		virtual void draw(KStars *ks, QPainter& psky, double scale);
 
 	/**
 		*@short Initialize the Constellation names component
--- trunk/KDE/kdeedu/kstars/kstars/skymapdraw.cpp #601654:601655
@@ -67,18 +67,18 @@
 We do the interpolation in x-y-z space because interpolation in [ra, dec] gives
 weird results, especially around the poles.
 **/
-    bool clipped1, clipped2;
+	bool onscreen1, onscreen2;
     QPointF o1, o2, oMid;
-    o1 = toScreen( p1, scale, Options::useRefraction(), &clipped1 );
-    o2 = toScreen( p2, scale, Options::useRefraction(), &clipped2 );
+    o1 = toScreen( p1, scale, Options::useRefraction(), &onscreen1 );
+    o2 = toScreen( p2, scale, Options::useRefraction(), &onscreen2 );
 
-    if (clipped1 && clipped2 ) {
+    if (!onscreen1 && !onscreen2 ) {
         return;
     }
-    else if (! clipped1 && ! clipped2 ) {
+    else if (onscreen1 && onscreen2 ) {
          psky.drawLine( o1, o2 );
     }
-    else if (clipped2) {
+    else if (onscreen1) {
         oMid = clipLine( p1, p2, scale );
         psky.drawLine( o1, oMid );
     }
@@ -95,7 +95,7 @@
  */              
     int iteration = 15;         // For "perfect" clipping:
                                 // 2^interations should be >= max pixels/line
-    bool clipped = false;       // so we start at midpoint
+    bool onscreen = true;       // so we start at midpoint
     SkyPoint mid;
     QPointF oMid;
     double x, y, z, dx, dy, dz, ra, dec;
@@ -112,7 +112,7 @@
         dx *= .5;
         dy *= .5;
         dz *= .5;
-        if ( clipped ) {              // move back toward visible p1
+        if ( ! onscreen ) {              // move back toward visible p1
             x -= dx;
             y -= dy;
             z -= dz;
@@ -129,7 +129,7 @@
         mid = SkyPoint( ra * 12. / dms::PI, dec * 180. / dms::PI );
         mid.EquatorialToHorizontal( data->LST, data->geo()->lat() );
 
-        oMid = toScreen( &mid, scale, Options::useRefraction(), &clipped );
+        oMid = toScreen( &mid, scale, Options::useRefraction(), &onscreen );
         newx = (int) oMid.x();
         newy = (int) oMid.y();
         if ( (oldx == newx) && (oldy == newy) ) {


More information about the Kstars-devel mailing list