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

James Bowlin bowlin at mindspring.com
Sun Jun 22 21:53:16 CEST 2008


SVN commit 823199 by jbowlin:

Can now adjust the magnitude limit using mouse wheel or "-" and "=" keys by
using the Alt key modifier.  The Ctrl and Shift modifiers work in a similar
fashion to what they do with zooming.

The default mag step is 1.0.

The Shift modifier reduces the step to 0.5.  

The Ctrl modifier reduces it to 0.2.

Combined, they reduce it to 0.1.

Also changed the factor in the maglim formula from 4.444 to 3.5 to match
the summer branch.


CCMAIL:kstars-devel at kde.org


 M  +1 -1      skycomponents/starcomponent.cpp  
 M  +32 -0     skymap.h  
 M  +47 -5     skymapevents.cpp  


--- branches/kstars/unfrozen/kstars/kstars/skycomponents/starcomponent.cpp #823198:823199
@@ -217,7 +217,7 @@
     double lgz = log10(Options::zoomFactor());
 
     
-    float maglim = 4.444 * ( lgz - lgmin ) + Options::magLimitDrawStarZoomOut();
+    float maglim = 3.5 * ( lgz - lgmin ) + Options::magLimitDrawStarZoomOut();
 
     m_zoomMagLimit = maglim;
 
--- branches/kstars/unfrozen/kstars/kstars/skymap.h #823198:823199
@@ -848,6 +848,38 @@
      */
     double zoomFactor( const int modifier );
 
+    /** calculate the magnitude factor (1, .5, .2, or .1) for the given
+     * keyboard modifier.
+     * @param modifier
+     */
+    double magFactor( const int modifier );
+
+    /** Decrease the magnitude limit by a step size determined by the
+     * keyboard modifier.
+     * @param modifier
+     */
+    void decMagLimit( const int modifier );
+
+     /** Increase the magnitude limit by a step size determined by the
+     * keyboard modifier.
+     * @param modifier
+     */
+    void incMagLimit( const int modifier );
+
+    /** Convenience routine to either zoom in or incraase mag limit
+     * depending on the Alt modifier.  The Shift and Control modiifers
+     * will adjust the size of the zoom or the mag step.
+     * @param modifier 
+     */
+    void zoomInOrMagStep( const int modifier );
+
+    /** Convenience routine to either zoom out or decraase mag limit
+     * depending on the Alt modifier.  The Shift and Control modiifers
+     * will adjust the size of the zoom or the mag step.
+     * @param modifier 
+     */
+    void zoomOutOrMagStep( const int modifier );
+
     bool mouseButtonDown, midMouseButtonDown;
     bool mouseMoveCursor;  // true if mouseMoveEvent; needed by setMouseMoveCursor
     bool slewing, clockSlewing;
--- branches/kstars/unfrozen/kstars/kstars/skymapevents.cpp #823198:823199
@@ -143,13 +143,13 @@
     case Qt::Key_Plus:   //Zoom in
     case Qt::Key_Equal:
         if ( ks ) 
-            zoomIn( e->modifiers() );
+            zoomInOrMagStep( e->modifiers() );
         break;
 
     case Qt::Key_Minus:  //Zoom out
     case Qt::Key_Underscore:
         if (  ks ) 
-            zoomOut( e->modifiers() );
+            zoomOutOrMagStep( e->modifiers() );
         break;
 
     //In the following cases, we set slewing=true in order to disengage tracking
@@ -642,10 +642,11 @@
 }
 
 void SkyMap::wheelEvent( QWheelEvent *e ) {
-    if ( ks && e->delta() > 0 ) 
-        zoomIn( e->modifiers() );
+    if ( ! ks ) return;
+    if ( e->delta() > 0 ) 
+        zoomInOrMagStep ( e->modifiers() );
     else
-        zoomOut( e->modifiers() );
+        zoomOutOrMagStep( e->modifiers() );
 }
 
 void SkyMap::mouseReleaseEvent( QMouseEvent * ) {
@@ -880,6 +881,21 @@
     return factor;
 }
 
+void SkyMap::zoomInOrMagStep( const int modifier ) {
+    if ( modifier & Qt::AltModifier )
+        incMagLimit( modifier );
+    else
+        ks->zoomIn( zoomFactor( modifier ) );
+}
+
+    
+void SkyMap::zoomOutOrMagStep( const int modifier ) {
+    if ( modifier & Qt::AltModifier )
+        decMagLimit( modifier );
+    else
+        ks->zoomOut( zoomFactor (modifier ) );
+}
+
 void SkyMap::zoomIn( const int modifier) {
     ks->zoomIn( zoomFactor( modifier) );
 }
@@ -888,3 +904,29 @@
     ks->zoomOut( zoomFactor( modifier ) );
 }
 
+double SkyMap::magFactor( const int modifier ) {
+    double factor = ( modifier & Qt::ControlModifier) ? 0.2 : 1.0; 
+    if ( modifier & Qt::ShiftModifier ) 
+        factor /= 2.0;
+
+    return factor;
+}
+
+void SkyMap::incMagLimit( const int modifier ) {
+    double limit = Options::magLimitDrawStarZoomOut();
+    limit += magFactor( modifier );
+    if ( limit > 9.0 ) limit = 9.0;
+    Options::setMagLimitDrawStarZoomOut( limit );
+    //printf("maglim set to %3.1f\n", limit);
+    forceUpdate();
+}
+
+void SkyMap::decMagLimit( const int modifier ) {
+    double limit = Options::magLimitDrawStarZoomOut();
+    limit -= magFactor( modifier );
+    if ( limit < 1.0 ) limit = 1.0;
+    Options::setMagLimitDrawStarZoomOut( limit );
+    //printf("maglim set to %3.1f\n", limit);
+    forceUpdate();
+}
+


More information about the Kstars-devel mailing list