[Kst] extragear/graphics/kst/src/libkstapp

Andrew Walker arwalker at sumusltd.com
Thu Aug 3 22:44:01 CEST 2006


SVN commit 569441 by arwalker:

BUG:131683 No longer draw spurious guidelines. Draw guideline immediately upon pressing shift or control key. Erase the guideline correctly after releasing the shift or control key.

 M  +44 -32    kst2dplot.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #569440:569441
@@ -2395,10 +2395,8 @@
     if (view && GetPlotRegion().contains(_mouse.tracker)) {
       if (gzType == X_ZOOMBOX || gzType == Y_ZOOMBOX) {
         updateXYGuideline(view, QPoint(-1, -1), view->mapFromGlobal(QCursor::pos()), GetPlotRegion(), gzType);
-        _mouse.lastGuideline = view->mapFromGlobal(QCursor::pos());
       } else if (gzType == XY_ZOOMBOX) {
         updateXYGuideline(view, QPoint(-1, -1), view->mapFromGlobal(QCursor::pos()), GetPlotRegion(), gzType);
-        _mouse.lastGuideline = view->mapFromGlobal(QCursor::pos());
       }
     }
   }
@@ -3991,31 +3989,31 @@
   QPen newPen(Qt::black, 1, Qt::DotLine);
   p.setPen(newPen);
   p.setRasterOp(Qt::NotROP);
-  if (gzType == X_ZOOMBOX) {
-    if (pr.contains(oldPos)) {
-      if (_mouse.lastGuidelineType == X_ZOOMBOX) {
-        p.drawLine(oldPos.x(), pr.top(), oldPos.x(), pr.bottom());
-      } else if (_mouse.lastGuidelineType == Y_ZOOMBOX) {
-        p.drawLine(pr.left(), oldPos.y(), pr.right(), oldPos.y());
-      }
+    
+  if (pr.contains(oldPos)) {
+    if (_mouse.lastGuidelineType == X_ZOOMBOX) {
+      p.drawLine(oldPos.x(), pr.top(), oldPos.x(), pr.bottom());
+    } else if (_mouse.lastGuidelineType == Y_ZOOMBOX) {
+      p.drawLine(pr.left(), oldPos.y(), pr.right(), oldPos.y());
     }
-    if (pr.contains(newPos)) {
+  }
+  
+  _mouse.lastGuideline = QPoint(-1, -1);
+
+  if (pr.contains(newPos)) {
+    printf("a\n");
+    if (gzType == X_ZOOMBOX) {
       p.drawLine(newPos.x(), pr.top(), newPos.x(), pr.bottom());
-    }
-  } else {
-    if (pr.contains(oldPos)) {
-      if (_mouse.lastGuidelineType == X_ZOOMBOX) {
-        p.drawLine(oldPos.x(), pr.top(), oldPos.x(), pr.bottom());
-      } else if (_mouse.lastGuidelineType == Y_ZOOMBOX) {
-        p.drawLine(pr.left(), oldPos.y(), pr.right(), oldPos.y());
-      }
-    }
-    if (pr.contains(newPos)) {
+      _mouse.lastGuidelineType = gzType;
+      _mouse.lastGuideline = newPos;    
+    } else if (gzType == Y_ZOOMBOX) {
       p.drawLine(pr.left(), newPos.y(), pr.right(), newPos.y());
+      _mouse.lastGuidelineType = gzType;
+      _mouse.lastGuideline = newPos;    
     }
   }
+  
   p.end();
-  _mouse.lastGuidelineType = gzType;
 }
 
 
@@ -4038,28 +4036,21 @@
     ButtonState s = e->stateAfter();
     if (s == 0) {
       updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, gzType);
-      _mouse.lastGuideline = _mouse.tracker;
     } else if (s & Qt::ShiftButton) {
       updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, Y_ZOOMBOX);
-      _mouse.lastGuideline = _mouse.tracker;
     } else if (s & Qt::ControlButton) {
       updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, X_ZOOMBOX);
-      _mouse.lastGuideline = _mouse.tracker;
     } else {
       updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), pr, gzType);
-      _mouse.lastGuideline = QPoint(-1, -1);
     }
   } else if (gzType == XY_ZOOMBOX) {
-      ButtonState s = e->stateAfter();
+    ButtonState s = e->stateAfter();
     if (s & Qt::ShiftButton) {
       updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, Y_ZOOMBOX);
-      _mouse.lastGuideline = _mouse.tracker;
     } else if (s & Qt::ControlButton) {
       updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, X_ZOOMBOX);
-      _mouse.lastGuideline = _mouse.tracker;
     } else {
       updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), pr, gzType);
-      _mouse.lastGuideline = QPoint(-1, -1);
     }
   }
 
@@ -4445,7 +4436,8 @@
   KstMouseModeType newType = globalZoomType();
   QPoint c = _mouse.lastLocation;
   QRect pr = GetPlotRegion();
-  int x = _mouse.pressLocation.x(), y = _mouse.pressLocation.y();
+  int x = _mouse.pressLocation.x();
+  int y = _mouse.pressLocation.y();
 
   if (newType == Y_ZOOMBOX) {
     if (c.y() > pr.bottom()) {
@@ -4495,6 +4487,13 @@
       p.drawWinFocusRect(_mouse.mouseRect());
     }
   }
+
+  if (e->key() == Key_Shift) {
+    updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), GetPlotRegion(), Y_ZOOMBOX);
+  } else if (e->key() == Key_Control) {
+    updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), GetPlotRegion(), X_ZOOMBOX);
+  }
+    
   setCursorForMode(view, newType, c);
   e->accept();
 }
@@ -5080,7 +5079,8 @@
 void Kst2DPlot::keyPressEvent(QWidget *vw, QKeyEvent *e) {
   KstViewWidget *view = static_cast<KstViewWidget*>(vw);
   bool handled = true;
-
+  bool paint = true;
+  
   ButtonState s = e->stateAfter();
   QPoint cursorPos = _mouse.tracker;
   switch (e->key()) {
@@ -5213,13 +5213,25 @@
         setDirty();
       }
       break;
+    case Key_Shift:
+      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), Y_ZOOMBOX);
+      setCursorForMode(view, Y_ZOOMBOX, _mouse.tracker);
+      paint = false;
+      break;
+    case Key_Control:
+      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), X_ZOOMBOX);
+      setCursorForMode(view, X_ZOOMBOX, _mouse.tracker);
+      paint = false;
+      break;
     default:
       handled = false;
       break;
   }
 
   if (handled) {
-    view->paint();
+    if (paint) {
+      view->paint();
+    }
     e->accept();
     //emit modified();
     return;


More information about the Kst mailing list