[Kstars-devel] branches/kstars/unfrozen/kstars/kstars

James Bowlin bowlin at mindspring.com
Sun Jun 22 20:27:24 CEST 2008


SVN commit 823176 by jbowlin:

Added large zoom steps to unfrozen branch.

The change in zoom due to the mouse wheel or "-" and "=" keys is now 2.0
instead of the previous 1.1.  This reduces the number of key presses or
wheel clicks to change to to a given zoom by roughly a factor of eight.

The Shift and Control keys reduce the zoom step by factors of 2 and 4
respectively.  Combined, they reduce it by a factor of 8 which is close
to (but not equal to) the original factor of 1.1.

Also increased MINZOOM from 200 to 250, which I think roughly compensates
for the change caused when we converted SkyMap::fov() to reporting the
diagonal of the screen instead of the minimum of the height and width.
The change in fov() was made to provide a radius for the SkyMesh::aperture()
call.


CCMAIL: kstars-devel at kde.org


 M  +13 -0     kstars.h  
 M  +21 -12    kstarsactions.cpp  
 M  +3 -2      kstarsdata.h  
 M  +15 -0     skymap.h  
 M  +24 -4     skymapevents.cpp  


--- branches/kstars/unfrozen/kstars/kstars/kstars.h #823175:823176
@@ -414,10 +414,23 @@
     void slotApplyToolbarConfig();
 
     /**
+    	* Zoom in by a given factor
+        *
+    	*/
+    void zoomIn( const double factor );
+
+    /**
+    	* Zoom out by a given factor
+        *
+    	*/
+    void zoomOut( const double factor );
+
+    /**
     	*action slot: Zoom in one step
     	*/
     void slotZoomIn();
 
+
     /**
     	*action slot: Zoom out one step
     	*/
--- branches/kstars/unfrozen/kstars/kstars/kstarsactions.cpp #823175:823176
@@ -738,29 +738,38 @@
     }
 }
 
-//View Menu
 void KStars::slotZoomIn() {
+    zoomIn ( DZOOM );
+}
+
+void KStars::slotZoomOut() {
+    zoomOut ( DZOOM );
+}
+
+void KStars::zoomIn( const double factor ) {
     actionCollection()->action("zoom_out")->setEnabled (true);
-    if ( Options::zoomFactor() < MAXZOOM )
-        Options::setZoomFactor( Options::zoomFactor()*DZOOM );
+    double newZoom = Options::zoomFactor() * factor;
+    if ( newZoom >= MAXZOOM )
+        newZoom = MAXZOOM;
 
-    if ( Options::zoomFactor() >= MAXZOOM ) {
-        Options::setZoomFactor( MAXZOOM );
+    Options::setZoomFactor( newZoom );
+
+    if ( newZoom == MAXZOOM )
         actionCollection()->action("zoom_in")->setEnabled (false);
-    }
 
     map()->forceUpdate();
 }
 
-void KStars::slotZoomOut() {
+void KStars::zoomOut( const double factor ) {
     actionCollection()->action("zoom_in")->setEnabled (true);
-    if ( Options::zoomFactor() > MINZOOM )
-        Options::setZoomFactor( Options::zoomFactor()/DZOOM );
+    double newZoom = Options::zoomFactor() / factor;
+    if ( newZoom < MINZOOM )
+        newZoom = MINZOOM;
 
-    if ( Options::zoomFactor() <= MINZOOM ) {
-        Options::setZoomFactor( MINZOOM );
+    Options::setZoomFactor( newZoom );
+
+    if ( newZoom == MINZOOM )
         actionCollection()->action("zoom_out")->setEnabled (false);
-    }
 
     map()->forceUpdate();
 }
--- branches/kstars/unfrozen/kstars/kstars/kstarsdata.h #823175:823176
@@ -33,10 +33,11 @@
 #include "simclock.h"
 #include "skycomponents/skymapcomposite.h"
 
-#define MINZOOM 200.
+//#define MINZOOM 200.
+#define MINZOOM 250.
 #define MAXZOOM 5000000.
 #define DEFAULTZOOM 2000.
-#define DZOOM 1.10
+#define DZOOM 1.189207115   // 2^(1/4)  
 #define AU_KM 1.49605e8  //km in one AU
 
 #define MINDRAWSTARMAG 6.5 // min. magnitude to load all stars which are needed for constellation lines
--- branches/kstars/unfrozen/kstars/kstars/skymap.h #823175:823176
@@ -833,6 +833,21 @@
     	*/
     bool unusablePoint ( const QPointF &p );
 
+    /** Zoom in a large amount or a small amount depending on the keyboard modifier
+     * @param modifier
+     */
+    void zoomIn( const int modifier );
+
+    /** Zoom in a large amount or a small amount depending on the keyboard modifier 
+     * @param modifier
+     */
+    void zoomOut( const int modifier );
+
+    /** Calculate the zoom factor for the given keyboard modifier
+     * @param modifier
+     */
+    double zoomFactor( const int modifier );
+
     bool mouseButtonDown, midMouseButtonDown;
     bool mouseMoveCursor;  // true if mouseMoveEvent; needed by setMouseMoveCursor
     bool slewing, clockSlewing;
--- branches/kstars/unfrozen/kstars/kstars/skymapevents.cpp #823175:823176
@@ -142,12 +142,14 @@
 
     case Qt::Key_Plus:   //Zoom in
     case Qt::Key_Equal:
-        if ( ks ) ks->slotZoomIn();
+        if ( ks ) 
+            zoomIn( e->modifiers() );
         break;
 
     case Qt::Key_Minus:  //Zoom out
     case Qt::Key_Underscore:
-        if ( ks ) ks->slotZoomOut();
+        if (  ks ) 
+            zoomOut( e->modifiers() );
         break;
 
     //In the following cases, we set slewing=true in order to disengage tracking
@@ -640,8 +642,10 @@
 }
 
 void SkyMap::wheelEvent( QWheelEvent *e ) {
-    if ( ks && e->delta() > 0 ) ks->slotZoomIn();
-    else if ( ks ) ks->slotZoomOut();
+    if ( ks && e->delta() > 0 ) 
+        zoomIn( e->modifiers() );
+    else
+        zoomOut( e->modifiers() );
 }
 
 void SkyMap::mouseReleaseEvent( QMouseEvent * ) {
@@ -868,3 +872,19 @@
     //	kDebug() << QString("Skymap draw took %1 ms").arg(t.elapsed());
 }
 
+double SkyMap::zoomFactor( const int modifier ) {
+    double factor = ( modifier & Qt::ControlModifier) ? DZOOM : 2.0; 
+    if ( modifier & Qt::ShiftModifier ) 
+        factor = sqrt( factor );
+
+    return factor;
+}
+
+void SkyMap::zoomIn( const int modifier) {
+    ks->zoomIn( zoomFactor( modifier) );
+}
+
+void SkyMap::zoomOut( const int modifier) {
+    ks->zoomOut( zoomFactor( modifier ) );
+}
+


More information about the Kstars-devel mailing list