]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
refs #1468: patch to customize dragging of several selected objects with left mouse...
authormkr <mkr@opencascade.com>
Tue, 5 Dec 2017 15:23:37 +0000 (18:23 +0300)
committermkr <mkr@opencascade.com>
Tue, 5 Dec 2017 15:23:37 +0000 (18:23 +0300)
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_Viewer.cxx

index 93e75b461dba58878b061181b951015a6478b8ea..f18cd1e6c75cc66a67c78b383f4db81742e604ea 100644 (file)
@@ -147,6 +147,7 @@ GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent )
   myIsSketchingByPath( false ),
   myIsDragging( false ),
   myIsDragPositionInitialized( false ),
+  myDraggingSelectedByLeftButton( false ),
   myIsPulling( false ),
   myPullingObject( 0 ),
   myStoredCursor( Qt::ArrowCursor ),
@@ -1508,6 +1509,15 @@ bool GraphicsView_ViewPort::isSketching( bool* theIsPath ) const
   return myIsSketching;
 }
 
+//================================================================
+// Function : setDraggingSelectedByLeftButton
+// Purpose  : 
+//================================================================
+void GraphicsView_ViewPort::setDraggingSelectedByLeftButton( const bool& theValue )
+{
+  myDraggingSelectedByLeftButton = theValue;
+}
+
 //================================================================
 // Function : dragObjects
 // Purpose  : 
@@ -1535,8 +1545,9 @@ void GraphicsView_ViewPort::dragObjects( QGraphicsSceneMouseEvent* e )
     else
       anObjectsToMove.append( anObject );
   }
-  else if( hasInteractionFlag( DraggingByMiddleButton ) &&
-           nbSelected() && ( e->buttons() & Qt::MidButton ) )
+  else if( ( hasInteractionFlag( DraggingByMiddleButton ) && ( e->buttons() & Qt::MidButton ) ||
+             isDraggingSelectedByLeftButton() && ( e->buttons() & Qt::LeftButton ) ) &&
+           nbSelected() )
   {
     for( initSelected(); moreSelected(); nextSelected() )
       if( GraphicsView_Object* aMovingObject = selectedObject() )
@@ -1731,8 +1742,9 @@ void GraphicsView_ViewPort::onMouseEvent( QGraphicsSceneMouseEvent* e )
         if( ( getHighlightedObject() &&
               getHighlightedObject()->isMovable() &&
               !( anAccel || e->button() != Qt::LeftButton ) ) ||
-            ( hasInteractionFlag( DraggingByMiddleButton ) &&
-              nbSelected() && !anAccel && e->button() == Qt::MidButton ) )
+            ( ( hasInteractionFlag( DraggingByMiddleButton ) && e->button() == Qt::MidButton ||
+                isDraggingSelectedByLeftButton() && e->button() == Qt::LeftButton ) &&
+              nbSelected() && !anAccel ) )
         {
           myIsDragging = true;
           myStoredCursor = cursor();
index 51b3f53dedcf6e92922f49f2132bf62dda8e40b1..1d66b0ac260c14ef4dca5d0667fef204c2a50818 100644 (file)
@@ -205,6 +205,9 @@ public:
   // dragging
   bool                             isDragging() { return myIsDragging; }
 
+  bool                             isDraggingSelectedByLeftButton() const { return myDraggingSelectedByLeftButton; }
+  void                             setDraggingSelectedByLeftButton( const bool& theValue );
+
   // pulling
   bool                             startPulling( const QPointF& );
   void                             drawPulling( const QPointF& );
@@ -327,6 +330,7 @@ private:
   int                              myIsDragging;
   QPointF                          myDragPosition;
   bool                             myIsDragPositionInitialized;
+  bool                             myDraggingSelectedByLeftButton;
 
   // pulling
   bool                             myIsPulling;
index 9b51d00190055ac75bd399b2dea08ca93250fc07..9cdb2d74d6ce70aeb5598cb9ab6c410aead4786d 100644 (file)
@@ -404,7 +404,9 @@ void GraphicsView_Viewer::handleMousePress( QGraphicsSceneMouseEvent* e )
       }
       else if( e->button() == Qt::LeftButton &&
                !( aViewPort->currentBlock() & GraphicsView_ViewPort::BS_Selection ) &&
-               !aViewPort->getHighlightedObject() )
+               !aViewPort->getHighlightedObject() &&
+               ( !aViewPort->isDraggingSelectedByLeftButton() ||
+                 aViewPort->isDraggingSelectedByLeftButton() && aViewPort->nbSelected() == 0 ) )
       {
         // Start rectangular selection if pulling was not started
         QPoint p = aViewPort->mapFromScene( e->scenePos() );