]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Add global pan
authorCHEMIN Sebastien <sc236498@is245491.intra.cea.fr>
Mon, 18 Mar 2024 13:25:33 +0000 (14:25 +0100)
committerCHEMIN Sebastien <sc236498@is245491.intra.cea.fr>
Mon, 18 Mar 2024 13:25:33 +0000 (14:25 +0100)
src/GraphicsView/GraphicsView_ViewFrame.cxx
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_Viewer.cxx
src/GraphicsView/GraphicsView_Viewer.h

index c97c62ec1a189cdf80d291c037d3cd73363ed70f..9c40eaad3c785839995a1dbfc0c1845b390a2360 100644 (file)
@@ -341,7 +341,7 @@ void GraphicsView_ViewFrame::onViewFitSelect()
 //================================================================
 void GraphicsView_ViewFrame::onViewGlobalPan()
 {
-//  myViewer->activateTransform( GraphicsView_Viewer::PanGlobal );
+  myViewer->globalPan();
 }
 
 //================================================================
@@ -350,7 +350,6 @@ void GraphicsView_ViewFrame::onViewGlobalPan()
 //================================================================
 void GraphicsView_ViewFrame::onViewReset()
 {
-//  myViewer->activateTransform( GraphicsView_Viewer::Reset );
 }
 
 //================================================================
index 44f7966ab5a1df4e2111f194dc1d758eb473d73e..41c6535f8651386a5c6c76bbb10d13d3d97567da 100644 (file)
@@ -58,6 +58,7 @@ GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent )
   previousPos = QPoint();
 
   panning = false;
+  globalPanning = false;
   
   SUIT_ResourceMgr* rmgr = SUIT_Session::session()->resourceMgr();
   zoomCursor = new QCursor( rmgr->loadPixmap( "GraphicsView", tr( "ICON_GV_CURSOR_ZOOM" ) ) );
@@ -162,11 +163,20 @@ void GraphicsView_ViewPort::updateSceneRect(const QRectF &rect)
 
 void GraphicsView_ViewPort::mousePressEvent(QMouseEvent *event)
 { 
if (!zooming && !panning && items(event->pos()).count()==0 && (event->buttons() & Qt::LeftButton))
 if (!zooming && !panning && !globalPanning && items(event->pos()).count()==0 && (event->buttons() & Qt::LeftButton))
     {
       startDrawingRect(event->pos().x(), event->pos().y());
     }
+
+  if (globalPanning)
+    {
+      QPoint p0 = viewport()->rect().center();
+      QPoint p1 = event->pos();
+      double deltaX = p0.x() - p1.x();
+      double deltaY = p0.y() - p1.y();
+
+      pan(deltaX, -deltaY);
+    }
   QGraphicsView::mousePressEvent(event);
   emit vpMouseEvent(event);
 }
@@ -267,6 +277,7 @@ void GraphicsView_ViewPort::clearActions()
   fittingArea = false;
   zooming = false;
   panning  = false;
+  globalPanning = false;
   previousPos = QPoint();
 }
   
@@ -275,6 +286,7 @@ void GraphicsView_ViewPort::activateZoomAction()
   zooming = true;
   fittingArea = false;
   panning  = false;
+  globalPanning = false;
   setCursor(*zoomCursor); 
 }
 
@@ -283,6 +295,7 @@ void GraphicsView_ViewPort::activateFitAreaAction()
   fittingArea = true;
   zooming = false;
   panning  = false;
+  globalPanning = false;
   setCursor(Qt::PointingHandCursor);
 }
 
@@ -291,9 +304,19 @@ void GraphicsView_ViewPort::activatePanAction()
   panning = true; 
   fittingArea = false;
   zooming = false;
+  globalPanning = false;
   setCursor(Qt::SizeAllCursor);
 }
 
+void GraphicsView_ViewPort::activateGlobalPanAction() 
+{
+  globalPanning = true;
+  panning = false; 
+  fittingArea = false;
+  zooming = false;
+  setCursor(Qt::CrossCursor);
+}
+
 void GraphicsView_ViewPort::pan( double theDX, double theDY )
 {
   if( QScrollBar* aHBar = horizontalScrollBar() )
index 46db685b43bbc2d34971c2bab6d52aeb1eb18138..5387c52698f71f6ccc8c56084c44bf7a1976d697 100644 (file)
@@ -52,6 +52,7 @@ public:
   void activateZoomAction();
   void activateFitAreaAction(); 
   void activatePanAction(); 
+  void activateGlobalPanAction();
   void pan( double theDX, double theDY );
 
 
@@ -87,6 +88,7 @@ private:
   bool fittingArea;
   bool zooming;
   bool panning;
+  bool globalPanning;
   QPoint previousPos;
   QCursor* zoomCursor;
 };
index ca910ea810183ff5a84e108f8697298f095cd740..87a3d22519efa41ad57220f84a269cc05cc37f74 100644 (file)
@@ -301,3 +301,12 @@ void GraphicsView_Viewer::pan()
   if (GraphicsView_ViewPort* aViewPort = getActiveViewPort())
     aViewPort->activatePanAction();
 }
+
+void GraphicsView_Viewer::globalPan()
+{
+  if (GraphicsView_ViewPort* aViewPort = getActiveViewPort())
+    {
+      aViewPort->fitAll();
+      aViewPort->activateGlobalPanAction();
+    }
+}
index ba2dfa99720b9cb03363b1af4b90abddcb36e98f..a0fe51abdbf149b564ea7510c2ec463c7b9961cf 100644 (file)
@@ -66,6 +66,7 @@ public:
   void fitArea();
   void zoom();
   void pan();
+  void globalPan();
 
 signals:
   void selectionChanged();