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

Jason Harris kstars at 30doradus.org
Tue Jun 27 09:15:10 CEST 2006


SVN commit 555367 by harris:

Adding SkyLine class, which will be used everywhere a line between two 
SkyPoints is needed: the coordinate grid and equator/ecliptic/horizon, 
as well as constellation lines and boundaries.  This change will make 
these Component classes simpler, and is necessary for the upcoming HTM 
indexing code.

I have not yet ported any of these Components to use SkyLines.  
However, I did implement the Angular Ruler using a SkyLine.  
SkyPoint::angularDistanceTo( SkyPoint ) is now 
SkyLine::angularDistance().

CCMAIL: kstars-devel at kde.org



 M  +1 -1      CMakeLists.txt  
 A             skyline.cpp   [License: GPL (v2+)]
 A             skyline.h   [License: GPL (v2+)]
 M  +30 -19    skymap.cpp  
 M  +2 -1      skymap.h  
 M  +5 -2      skymapdraw.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/CMakeLists.txt #555366:555367
@@ -223,7 +223,7 @@
            ksutils.cpp kswizard.cpp locationdialog.cpp main.cpp 
            opsadvanced.cpp opscatalog.cpp opscolors.cpp 
            opsguides.cpp opssolarsystem.cpp simclock.cpp skymap.cpp 
-           skymapdraw.cpp skymapevents.cpp skyobject.cpp skypoint.cpp 
+           skymapdraw.cpp skymapevents.cpp skyobject.cpp skypoint.cpp skyline.cpp 
            starobject.cpp streamwg.cpp telescopewizardprocess.cpp telescopeprop.cpp 
            timedialog.cpp timezonerule.cpp 
            toggleaction.cpp thumbnailpicker.cpp thumbnaileditor.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #555366:555367
@@ -401,33 +401,41 @@
 }
 
 void SkyMap::slotBeginAngularDistance() {
-	setPreviousClickedPoint( mousePoint() );
+//ANGULAR
+//	setPreviousClickedPoint( mousePoint() );
 	angularDistanceMode = true;
-	beginRulerPoint = toScreen( previousClickedPoint() );
-	endRulerPoint =  QPointF( beginRulerPoint.x(),beginRulerPoint.y() );
+	AngularRuler = SkyLine( mousePoint(), mousePoint() ); 
+//	beginRulerPoint = toScreen( previousClickedPoint() );
+//	endRulerPoint =  QPointF( beginRulerPoint.x(),beginRulerPoint.y() );
 }
 
 void SkyMap::slotEndAngularDistance() {
-	dms angularDistance;
-	if(angularDistanceMode) {
+	if( angularDistanceMode ) {
+		dms angularDistance;
+		QString sbMessage = QString::null;
+
+		//If the cursor is near a SkyObject, reset the AngularRuler's 
+		//end point to the position of the SkyObject
 		double maxrad = 1000.0/Options::zoomFactor();
 		if ( SkyObject *so = data->skyComposite()->objectNearest( mousePoint(), maxrad ) ) {
-			angularDistance = so->angularDistanceTo( previousClickedPoint() );
-			ks->statusBar()->changeItem( so->translatedLongName() +
-					"     " +
-					i18n("Angular distance: " ) +
-					angularDistance.toDMSString(), 0 );
-		} else {
-			angularDistance = mousePoint()->angularDistanceTo( previousClickedPoint() );
-			ks->statusBar()->changeItem( i18n("Angular distance: " ) +
-				angularDistance.toDMSString(), 0 );
-		}
+			AngularRuler.setEndPoint( *so );
+			sbMessage = so->translatedLongName() + "   ";
+		} else
+			AngularRuler.setEndPoint( mousePoint() );
+		
+		angularDistance = AngularRuler.angularSize();
+		sbMessage += i18n( "Angular distance: %1", angularDistance.toDMSString() );
+
+		ks->statusBar()->changeItem( sbMessage, 0 );
+
 		angularDistanceMode=false;
+		AngularRuler = SkyLine(); //null SkyLine
 	}
 }
 
 void SkyMap::slotCancelAngularDistance(void) {
 	angularDistanceMode=false;
+	AngularRuler = SkyLine(); //null SkyLine
 }
 
 void SkyMap::slotImage() {
@@ -1169,11 +1177,14 @@
 }
 
 void SkyMap::updateAngleRuler() {
-	if ( Options::useAltAz() ) PreviousClickedPoint.EquatorialToHorizontal( data->LST, data->geo()->lat() );
-	beginRulerPoint = toScreen( previousClickedPoint() );
+	//determine RA, Dec of mouse pointer
+	QPoint mp( mapFromGlobal( QCursor::pos() ) );
+	double dx = ( 0.5*width()  - mp.x() )/Options::zoomFactor();
+	double dy = ( 0.5*height() - mp.y() )/Options::zoomFactor();
 
-//	endRulerPoint =  QPoint(e->x(), e->y());
-	endRulerPoint = mapFromGlobal( QCursor::pos() );
+	if (! unusablePoint (dx, dy)) {
+		AngularRuler.setEndPoint( fromScreen( dx, dy, data->LST, data->geo()->lat() ) );
+	}
 }
 
 bool SkyMap::isSlewing() const  {
--- trunk/KDE/kdeedu/kstars/kstars/skymap.h #555366:555367
@@ -29,6 +29,7 @@
 #include <QPaintEvent>
 
 #include "skypoint.h"
+#include "skyline.h"
 
 #define HOVER_INTERVAL 500 
 
@@ -803,7 +804,7 @@
 //	QPointArray *pts;	// needed in paintEvent() so it should not every event call reallocated (save time)
 	SkyPoint *sp;			// see line above
 
-	QPointF beginRulerPoint, endRulerPoint;  // used in angle mode
+	SkyLine AngularRuler; //The line for measuring angles in the map
 	QRect ZoomRect; //The manual-focus circle.
 
 	//data for transient object labels
--- trunk/KDE/kdeedu/kstars/kstars/skymapdraw.cpp #555366:555367
@@ -171,7 +171,10 @@
 
 void SkyMap::drawAngleRuler( QPainter &p ) {
 	p.setPen( QPen( data->colorScheme()->colorNamed( "AngularRuler" ), 1.0, Qt::DotLine ) );
-	p.drawLine( beginRulerPoint, endRulerPoint );
+
+	QPointF startPoint = toScreen( AngularRuler.startPoint() );
+	QPointF endPoint = toScreen( AngularRuler.endPoint() );
+	p.drawLine( startPoint, endPoint );
 }
 
 void SkyMap::drawZoomBox( QPainter &p ) {
@@ -271,7 +274,7 @@
 	if ( ks && ks->observingList()->obsList().size() ) {
 		foreach ( SkyObject* obj, ks->observingList()->obsList() ) {
 			if ( checkVisibility( obj ) ) {
-				QPointF o = toScreen( obj );
+				QPointF o = toScreen( obj, scale );
 
 				// label object if it is currently on screen
 				if (o.x() >= 0. && o.x() <= width() && o.y() >=0. && o.y() <= height() ) {


More information about the Kstars-devel mailing list