]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Immediate Selection mode.
authorouv <ouv@opencascade.com>
Mon, 8 Jul 2013 08:52:19 +0000 (08:52 +0000)
committerouv <ouv@opencascade.com>
Mon, 8 Jul 2013 08:52:19 +0000 (08:52 +0000)
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_Viewer.cxx

index 6eab70e08ea138159c19965222b140037c2564f4..026932eeb433750d9fd24e256dceb5d78ff9940b 100644 (file)
@@ -151,7 +151,8 @@ GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent )
   setInteractionFlags( EditFlags );
   //setInteractionFlag( TraceBoundingRect );
   //setInteractionFlag( DraggingByMiddleButton );
-  //setInteractionFlag( ImmediateSelection );
+  //setInteractionFlag( ImmediateContextMenu );
+  setInteractionFlag( ImmediateSelection );
 
   // background
   setBackgroundBrush( QBrush( Qt::white ) );
index 7261e4b86f36478b21081a9540e82573b4f72ed9..a37ea0157ce7428894f8a9165b4241a60388f3d2 100644 (file)
@@ -56,7 +56,8 @@ public:
     // advanced flags
     TraceBoundingRect      = 0x0008,
     DraggingByMiddleButton = 0x0010,
-    ImmediateSelection     = 0x0020
+    ImmediateContextMenu   = 0x0020,
+    ImmediateSelection     = 0x0040,
   };
   Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag )
 
index 4321fc9bcf99fb8b13c6cc11b370c2c8a2179b31..62caf9136ae009b11c382deefc5f14c7514f9ad6 100644 (file)
@@ -374,16 +374,8 @@ void GraphicsView_Viewer::handleMousePress( QGraphicsSceneMouseEvent* e )
   {
     if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() )
     {
-      if( e->button() == Qt::RightButton &&
-          aViewPort->hasInteractionFlag( GraphicsView_ViewPort::ImmediateSelection ) &&
-          aViewPort->nbSelected() < 1 )
-      {
-        // If the 'immediate selection' mode is enabled,
-        // try to perform selection before invoking context menu
-        bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
-        getSelector()->select( QRectF(), append );
-      }
-      else if( e->button() == Qt::LeftButton &&
+      bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
+      if( e->button() == Qt::LeftButton &&
                aViewPort->hasInteractionFlag( GraphicsView_ViewPort::Pulling ) &&
                !aViewPort->isSelectByRect() && 
                !aViewPort->isDragging() &&
@@ -400,6 +392,23 @@ void GraphicsView_Viewer::handleMousePress( QGraphicsSceneMouseEvent* e )
         QPoint p = aViewPort->mapFromScene( e->scenePos() );
         aViewPort->startSelectByRect( p.x(), p.y() );
       }
+      else if( !append &&
+               e->button() != Qt::MidButton &&
+               aViewPort->hasInteractionFlag( GraphicsView_ViewPort::ImmediateSelection ) &&
+               aViewPort->nbSelected() < 2 )
+      {
+        // Do not perform 'immediate selection' if the multiple objects are already selected
+        getSelector()->select( QRectF(), append );
+      }
+      else if( e->button() == Qt::RightButton &&
+               aViewPort->hasInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu ) &&
+               aViewPort->nbSelected() < 1 )
+      {
+        // If the 'immediate context menu' mode is enabled,
+        // try to perform selection before invoking context menu
+        //bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
+        getSelector()->select( QRectF(), append );
+      }
     }
   }
 }