[Kst] extragear/graphics/kst/kst

Andrew Walker arwalker at sumusltd.com
Wed Nov 23 00:44:08 CET 2005


SVN commit 482454 by arwalker:

Ensure that the resizing of newly created notation objects is the same as for resizing existing notation objects. In essence this keeps newly created objects within the plot region, so that an assert on this in KstViewObject is not triggered.

 M  +1 -1      kstgfxarrowmousehandler.cpp  
 M  +1 -1      kstgfxarrowmousehandler.h  
 M  +2 -1      kstgfxellipsemousehandler.cpp  
 M  +1 -1      kstgfxellipsemousehandler.h  
 M  +1 -1      kstgfxlinemousehandler.cpp  
 M  +1 -1      kstgfxlinemousehandler.h  
 M  +2 -1      kstgfxpicturemousehandler.cpp  
 M  +1 -1      kstgfxpicturemousehandler.h  
 M  +3 -2      kstgfxrectanglemousehandler.cpp  
 M  +1 -1      kstgfxrectanglemousehandler.h  
 M  +4 -9      ksttoplevelview.cpp  


--- trunk/extragear/graphics/kst/kst/kstgfxarrowmousehandler.cpp #482453:482454
@@ -45,7 +45,7 @@
 }
 
 
-void KstGfxArrowMouseHandler::pressMove(const QPoint& pos, bool shift) {
+void KstGfxArrowMouseHandler::pressMove(const QPoint& pos, bool shift, const QRect& geom) {
   if (_cancelled || !_mouseDown) {
     return;  
   }
--- trunk/extragear/graphics/kst/kst/kstgfxarrowmousehandler.h #482453:482454
@@ -26,7 +26,7 @@
     KstGfxArrowMouseHandler(KstTopLevelViewPtr top);
     ~KstGfxArrowMouseHandler();
     
-    void pressMove(const QPoint& pos, bool shift);
+    void pressMove(const QPoint& pos, bool shift, const QRect& geom);
     void releasePress(const QPoint& pos, bool shift);
 
 };
--- trunk/extragear/graphics/kst/kst/kstgfxellipsemousehandler.cpp #482453:482454
@@ -42,7 +42,7 @@
 }
 
 
-void KstGfxEllipseMouseHandler::pressMove(const QPoint& pos, bool shift) {
+void KstGfxEllipseMouseHandler::pressMove(const QPoint& pos, bool shift, const QRect& geom) {
   
   if (_cancelled || !_mouseDown) {
     return;  
@@ -79,6 +79,7 @@
   // do the move and resize
   _prevBand.moveTopLeft(newTopLeft);
   _prevBand.setSize(newSize);
+  _prevBand = _prevBand.intersect(geom);
   
   if (old != _prevBand) {
     QPainter p;
--- trunk/extragear/graphics/kst/kst/kstgfxellipsemousehandler.h #482453:482454
@@ -26,7 +26,7 @@
     KstGfxEllipseMouseHandler(KstTopLevelViewPtr top);
     ~KstGfxEllipseMouseHandler();
     
-    void pressMove(const QPoint& pos, bool shift);
+    void pressMove(const QPoint& pos, bool shift, const QRect& geom);
     void releasePress(const QPoint& pos, bool shift);
     
 };
--- trunk/extragear/graphics/kst/kst/kstgfxlinemousehandler.cpp #482453:482454
@@ -45,7 +45,7 @@
 }
 
 
-void KstGfxLineMouseHandler::pressMove(const QPoint& pos, bool shift) {
+void KstGfxLineMouseHandler::pressMove(const QPoint& pos, bool shift, const QRect& geom) {
   if (_cancelled || !_mouseDown) {
     return;  
   }
--- trunk/extragear/graphics/kst/kst/kstgfxlinemousehandler.h #482453:482454
@@ -26,7 +26,7 @@
     KstGfxLineMouseHandler(KstTopLevelViewPtr top);
     ~KstGfxLineMouseHandler();
     
-    void pressMove(const QPoint& pos, bool shift);
+    void pressMove(const QPoint& pos, bool shift, const QRect& geom);
     void releasePress(const QPoint& pos, bool shift);
     
 };
--- trunk/extragear/graphics/kst/kst/kstgfxpicturemousehandler.cpp #482453:482454
@@ -35,7 +35,7 @@
 }
 
 
-void KstGfxPictureMouseHandler::pressMove(const QPoint& pos, bool shift) {
+void KstGfxPictureMouseHandler::pressMove(const QPoint& pos, bool shift, const QRect& geom) {
   if (_cancelled || !_mouseDown) {
     return;  
   }
@@ -43,6 +43,7 @@
   QRect old = _prevBand;
   
   _prevBand = KstGfxMouseHandlerUtils::newRect(pos, _mouseOrigin, shift);
+  _prevBand = _prevBand.intersect(geom);
   
   if (old != _prevBand) {
     QPainter p;
--- trunk/extragear/graphics/kst/kst/kstgfxpicturemousehandler.h #482453:482454
@@ -26,7 +26,7 @@
     KstGfxPictureMouseHandler(KstTopLevelViewPtr top);
     ~KstGfxPictureMouseHandler();
     
-    void pressMove(const QPoint& pos, bool shift);
+    void pressMove(const QPoint& pos, bool shift, const QRect& geom);
     void releasePress(const QPoint& pos, bool shift);
 };
 
--- trunk/extragear/graphics/kst/kst/kstgfxrectanglemousehandler.cpp #482453:482454
@@ -44,7 +44,7 @@
 }
 
 
-void KstGfxRectangleMouseHandler::pressMove(const QPoint& pos, bool shift) {
+void KstGfxRectangleMouseHandler::pressMove(const QPoint& pos, bool shift, const QRect& geom) {
 
   if (_cancelled || !_mouseDown) {
     return;  
@@ -53,7 +53,8 @@
   QRect old = _prevBand;
   
   _prevBand = KstGfxMouseHandlerUtils::newRect(pos, _mouseOrigin, shift);
-  
+  _prevBand = _prevBand.intersect(geom);
+
   if (old != _prevBand) {
     QPainter p;
     p.begin(_top->widget());
--- trunk/extragear/graphics/kst/kst/kstgfxrectanglemousehandler.h #482453:482454
@@ -26,7 +26,7 @@
     KstGfxRectangleMouseHandler(KstTopLevelViewPtr top);
     ~KstGfxRectangleMouseHandler();
     
-    void pressMove(const QPoint& pos, bool shift);
+    void pressMove(const QPoint& pos, bool shift, const QRect& geom);
     void releasePress(const QPoint& pos, bool shift);
 
 };
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #482453:482454
@@ -504,14 +504,14 @@
   
   if (keepAspect) {
     r = correctHeightForRatio(r, aspect, direction, tempRight, tempLeft);
-    return r;
   }
+  
   return resizeSnapToObjects(r, direction);
 }
 
 
 QRect KstTopLevelView::newSizeCentred(const QRect& oldSize, int direction, const QPoint& pos, bool keepAspect) {
-  QPoint centre = QPoint((oldSize.left()+oldSize.right())/2, 
+  QPoint centre = QPoint((oldSize.left() + oldSize.right())/2, 
                           (oldSize.top() + oldSize.bottom())/2);
   QRect rect = oldSize;
   double aspect = (double)oldSize.height()/(double)oldSize.width();
@@ -539,7 +539,6 @@
   
   if (keepAspect) {
     rect = correctWidthForRatio(rect, aspect, direction);
-    // re-centre
     rect.moveCenter(centre);
   }
   
@@ -569,7 +568,6 @@
   if (keepAspect) {
     rect = correctHeightForRatio(rect, aspect, direction, tempRight, tempLeft);
     rect.moveCenter(centre);
-    return rect;
   }
   
   return resizeSnapToObjects(rect, direction);
@@ -671,9 +669,8 @@
 
 // Optimize me: can store, for instance, the painter I think
 void KstTopLevelView::pressMove(const QPoint& pos, bool shift) {
-  
   if (_activeMouseHandler) {
-    _activeMouseHandler->pressMove(pos, shift);  
+    _activeMouseHandler->pressMove(pos, shift, _geom);  
     return;
   }
   
@@ -694,9 +691,7 @@
   _mouseMoved = true;
   
   // handle as in layout mode
-  pressMoveLayoutMode(pos, shift);  
-  return;
-
+  pressMoveLayoutMode(pos, shift);
 }
 
 


More information about the Kst mailing list