]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
YACS GUI debug.
authormkr <mkr@opencascade.com>
Fri, 8 Feb 2008 15:01:11 +0000 (15:01 +0000)
committermkr <mkr@opencascade.com>
Fri, 8 Feb 2008 15:01:11 +0000 (15:01 +0000)
src/QxGraph/QxGraph_CanvasView.cxx
src/QxGraph/QxGraph_CanvasView.h

index be0d7dcbf7cfeacf8d2dfc47220dd281ad7f6427..e7f726b13c72f999398e13da96d7aaf0e916c3c4 100644 (file)
@@ -113,7 +113,8 @@ QxGraph_CanvasView::QxGraph_CanvasView(QxGraph_Canvas* theCanvas, QxGraph_ViewWi
   myCurrentItem(0),
   myHilightedItem(0),
   mySelectedItem(0),
-  myMovingDone(false)
+  myMovingDone(false),
+  myCenter(0,0)
 {
   printf("Construct QxGraph_CanvasView\n");
   setName("QxGraph_CanvasView");
@@ -174,6 +175,11 @@ void QxGraph_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
       QPixmap zoomPixmap (imageZoomCursor);
       QCursor zoomCursor (zoomPixmap);
       setCursor(zoomCursor);
+
+      // the center of the view before zooming
+      int aXVCenter = viewport()->width()/2;
+      int aYVCenter = viewport()->height()/2;
+      myCenter = viewportToContents(QPoint(aXVCenter,aYVCenter));
     }
     return;
   }
@@ -213,6 +219,7 @@ void QxGraph_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
     scrollBy(myGlobalPoint.x() - aGlobalPoint.x(),
             myGlobalPoint.y() - aGlobalPoint.y());
     myGlobalPoint = aGlobalPoint;
+    myMovingDone = true;
     return;
   }
 
@@ -243,23 +250,41 @@ void QxGraph_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
 
   if ( myOperation == ZOOMVIEW )
   { // Zoom
+    QCanvasItemList aList = canvas()->allItems();
+    for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it)
+      (*it)->hide();
+
+    int aXContCenter = myCenter.x();
+    int aYContCenter = myCenter.y();
+    
     QWMatrix m = worldMatrix();
 
     double dx = aGlobalPoint.x() - myGlobalPoint.x();
     double s = 1. + fabs(dx)*( (m.m11() < 1) ? m.m11() : 1. )/70.;
     if (dx < 0) s = 1./s;
     
+    int aXContCenterScaled = aXContCenter*s;
+    int aYContCenterScaled = aYContCenter*s;
+    
     m.scale(s, s);
     setWorldMatrix(m);
 
+    center(aXContCenterScaled,aYContCenterScaled);
+
+    myCenter.setX(aXContCenterScaled);
+    myCenter.setY(aYContCenterScaled);
+
     // remember the canvas view's current transformation matrix in all canvas items
-    QCanvasItemList aList = canvas()->allItems();
+    aList = canvas()->allItems();
     for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
       QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
       if ( anActItem ) anActItem->setTMatrix(m);
+      (*it)->show();
     }
        
     myGlobalPoint = aGlobalPoint;
+    myMovingDone = true;
+
     return;
   }
 
@@ -429,6 +454,8 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
     myOperation = NOTHING;
     viewport()->setMouseTracking(true);
     setCursor(myCursor);
+
+    emit viewOperationDone();
   }
 
   if ( myOperation == PANGLOBAL )
@@ -436,6 +463,8 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
     myOperation = NOTHING;
     center( theEvent->x(), theEvent->y() );
     setCursor(myCursor);
+
+    emit viewOperationDone();
   }
 
   if ( myOperation == WINDOWFIT )
@@ -477,6 +506,8 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
     
     viewport()->setMouseTracking(true);
     setCursor(myCursor);
+
+    emit viewOperationDone();
   }
 
   if ( myOperation == ZOOMVIEW )
@@ -484,6 +515,8 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
     myOperation = NOTHING;
     viewport()->setMouseTracking(true);
     setCursor(myCursor);
+
+    emit viewOperationDone();
   }
 
   if ( theEvent->button() == RightButton )
@@ -618,6 +651,8 @@ void QxGraph_CanvasView::activateFitAll()
   
   canvas()->update();
   //myOperation = NOTHING;
+
+  emit viewOperationDone();
 }
 
 void QxGraph_CanvasView::activateFitRect()
@@ -672,6 +707,8 @@ void QxGraph_CanvasView::activateReset()
   }
 
   //myOperation = NOTHING;
+
+  emit viewOperationDone();
 }
 
 void QxGraph_CanvasView::onTimeout() 
index f14e1277e433be85654812520303bd904b829b80..6aa5c3b799068f920cc3efe8aff0baec51c9df35 100644 (file)
@@ -58,6 +58,9 @@ class QXGRAPH_EXPORT QxGraph_CanvasView : public QCanvasView {
   void setSelectedItem( QxGraph_ActiveItem* theItem );
   QxGraph_ActiveItem* getSelectedItem() const;
 
+ signals:
+  void viewOperationDone();
+
  public slots:
   void onTimeout();
    //void changeBackground();
@@ -76,6 +79,7 @@ class QXGRAPH_EXPORT QxGraph_CanvasView : public QCanvasView {
   QPoint            myPoint;
   QPoint            myGlobalPoint;
   bool              myMovingDone;
+  QPoint            myCenter;
   
   // for control toolbar actions
   OperationType     myOperation;