[Kstars-devel] [kstars] kstars: The star hopper now takes the field of view from the current visible

Akarsh Simha akarsh.simha at kdemail.net
Sun Sep 2 09:12:31 UTC 2012


Git commit 1d591cd61de242f2f27ea9e0b6cf3b9c3098f2f1 by Akarsh Simha.
Committed on 02/09/2012 at 11:10.
Pushed by asimha into branch 'master'.

The star hopper now takes the field of view from the current visible
FOV symbol. If more than one FOV symbol is visible, then the user gets
to choose which one to use. If no FOV symbol is visible, the user is
prompted to enter a field-of-view in arcminutes.

FEATURE

CCMAIL: kstars-devel at kde.org

M  +44   -11   kstars/skymap.cpp

http://commits.kde.org/kstars/1d591cd61de242f2f27ea9e0b6cf3b9c3098f2f1

diff --git a/kstars/skymap.cpp b/kstars/skymap.cpp
index 99c49aa..b548fe1 100644
--- a/kstars/skymap.cpp
+++ b/kstars/skymap.cpp
@@ -32,6 +32,7 @@
 #include <QPointF>
 #include <QApplication>
 #include <QGraphicsScene>
+#include <QInputDialog>
 
 #include <kactioncollection.h>
 #include <kconfig.h>
@@ -67,6 +68,7 @@
 #include "projections/orthographicprojector.h"
 #include "projections/azimuthalequidistantprojector.h"
 #include "projections/equirectangularprojector.h"
+#include "fov.h"
 
 #include "tools/flagmanager.h"
 
@@ -567,19 +569,50 @@ void SkyMap::slotEndRulerMode() {
     }
     else { // Star Hop
         StarHopper hopper;
-        QList<const StarObject *> path = hopper.computePath( *AngularRuler.point( 0 ), *clickedPoint(), 1.0, 9.0 ); // FIXME: Hardcoded FOV and magnitude limits for testing
-
-        QList<SkyObject *> *mutablestarlist = new QList<SkyObject *>(); // FIXME: Memory leak
-        kDebug() << "path count: " << path.count();
-        foreach( const StarObject *conststar, path ) {
-            StarObject *mutablestar = const_cast<StarObject *>(conststar); // FIXME: Ugly const_cast
-            mutablestarlist->append( mutablestar );
-            kDebug() << "Added star!";
+        const SkyPoint &startHop = *AngularRuler.point( 0 );
+        const SkyPoint &stopHop = *clickedPoint();
+        double fov; // Field of view in arcminutes
+        bool ok; // true if user did not cancel the operation
+        if( data->getVisibleFOVs().size() == 1 ) {
+            // Exactly 1 FOV symbol visible, so use that. Also assume a circular FOV of size min{sizeX, sizeY}
+            FOV *f = data->getVisibleFOVs().first();
+            fov = ( ( f->sizeX() >= f->sizeY() && f->sizeY() != 0 ) ? f->sizeY() : f->sizeX() );
+            ok = true;
         }
+        else if( !data->getVisibleFOVs().isEmpty() ) {
+            // Ask the user to choose from a list of available FOVs.
+            FOV const *f;
+            QMap< QString, double > nameToFovMap;
+            foreach( f, data->getVisibleFOVs() ) {
+                nameToFovMap.insert( f->name(), ( ( f->sizeX() >= f->sizeY() && f->sizeY() != 0) ? f->sizeY() : f->sizeX() ) );
+            }
+            fov = nameToFovMap[ QInputDialog::getItem( this, i18n("Star Hopper: Choose a field-of-view"), i18n("FOV to use for star hopping:"), nameToFovMap.uniqueKeys(), 0, false, &ok ) ];
+        }
+        else {
+            // Ask the user to enter a field of view
+            fov = QInputDialog::getDouble( this, i18n("Star Hopper: Enter field-of-view to use"), i18n("FOV to use for star hopping (in arcminutes):"), 60.0, 1.0, 600.0, 1, &ok );
+        }
+
+        Q_ASSERT( fov > 0.0 );
+
+        if( ok ) {
 
-        TargetListComponent *t = KStarsData::Instance()->skyComposite()->getStarHopRouteList();
-        delete t->list;
-        t->list = mutablestarlist;
+            kDebug() << "fov = " << fov;
+
+            QList<const StarObject *> path = hopper.computePath( startHop, stopHop, fov/60.0, 9.0 ); // FIXME: Hardcoded magnitude limits for testing
+
+            QList<SkyObject *> *mutablestarlist = new QList<SkyObject *>(); // FIXME: Memory leak
+            kDebug() << "path count: " << path.count();
+            foreach( const StarObject *conststar, path ) {
+                StarObject *mutablestar = const_cast<StarObject *>(conststar); // FIXME: Ugly const_cast
+                mutablestarlist->append( mutablestar );
+                kDebug() << "Added star!";
+            }
+
+            TargetListComponent *t = KStarsData::Instance()->skyComposite()->getStarHopRouteList();
+            delete t->list;
+            t->list = mutablestarlist;
+        }
 
         rulerMode = false;
     }



More information about the Kstars-devel mailing list