0031519: Visualization, AIS_ViewController - add AIS_MouseGesture_ZoomWindow gesture
authorkgv <kgv@opencascade.com>
Thu, 23 Apr 2020 20:47:11 +0000 (23:47 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 24 Apr 2020 17:03:50 +0000 (20:03 +0300)
AIS_ViewController now supports AIS_MouseGesture_ZoomWindow gesture,
which displays zooming window via Rubber-Band rectangle.

src/AIS/AIS_MouseGesture.hxx
src/AIS/AIS_ViewController.cxx
src/AIS/AIS_ViewInputBuffer.hxx

index ab28f13..22c9086 100644 (file)
@@ -21,10 +21,15 @@ enum AIS_MouseGesture
 {
   AIS_MouseGesture_NONE,            //!< no active gesture
   //
-  AIS_MouseGesture_SelectRectangle, //!< rectangular selection
-  AIS_MouseGesture_SelectLasso,     //!< polygonal   selection
+  AIS_MouseGesture_SelectRectangle, //!< rectangular selection;
+                                    //!  press button to start, move mouse to define rectangle, release to finish
+  AIS_MouseGesture_SelectLasso,     //!< polygonal selection;
+                                    //!  press button to start, move mouse to define polygonal path, release to finish
   //
-  AIS_MouseGesture_Zoom,            //!< view zoom gesture
+  AIS_MouseGesture_Zoom,            //!< view zoom gesture;
+                                    //!  move mouse left to zoom-out, and to the right to zoom-in
+  AIS_MouseGesture_ZoomWindow,      //!< view zoom by window gesture;
+                                    //!  press button to start, move mouse to define rectangle, release to finish
   AIS_MouseGesture_Pan,             //!< view panning gesture
   AIS_MouseGesture_RotateOrbit,     //!< orbit rotation gesture
   AIS_MouseGesture_RotateView,      //!< view  rotation gesture
index d4e79f7..0d34520 100644 (file)
@@ -721,6 +721,7 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
           break;
         }
         case AIS_MouseGesture_Zoom:
+        case AIS_MouseGesture_ZoomWindow:
         {
           if (!myToAllowZooming)
           {
@@ -756,7 +757,8 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
   if (aPrevGesture != myMouseActiveGesture)
   {
     if (aPrevGesture == AIS_MouseGesture_SelectRectangle
-     || aPrevGesture == AIS_MouseGesture_SelectLasso)
+     || aPrevGesture == AIS_MouseGesture_SelectLasso
+     || aPrevGesture == AIS_MouseGesture_ZoomWindow)
     {
       myUI.Selection.ToApplyTool = true;
     }
@@ -828,8 +830,13 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
   switch (myMouseActiveGesture)
   {
     case AIS_MouseGesture_SelectRectangle:
+    case AIS_MouseGesture_ZoomWindow:
     {
       UpdateRubberBand (myMousePressPoint, thePoint);
+      if (myMouseActiveGesture == AIS_MouseGesture_ZoomWindow)
+      {
+        myUI.Selection.Tool = AIS_ViewSelectionTool_ZoomWindow;
+      }
       toUpdateView = true;
       break;
     }
@@ -2113,14 +2120,16 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
 {
   // rubber-band & window polygon selection
   if (myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand
-   || myGL.Selection.Tool == AIS_ViewSelectionTool_Polygon)
+   || myGL.Selection.Tool == AIS_ViewSelectionTool_Polygon
+   || myGL.Selection.Tool == AIS_ViewSelectionTool_ZoomWindow)
   {
     if (!myGL.Selection.Points.IsEmpty())
     {
       myRubberBand->ClearPoints();
       myRubberBand->SetToUpdate();
 
-      const bool anIsRubber = myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand;
+      const bool anIsRubber = myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand
+                           || myGL.Selection.Tool == AIS_ViewSelectionTool_ZoomWindow;
       if (anIsRubber)
       {
         myRubberBand->SetRectangle (myGL.Selection.Points.First().x(), -myGL.Selection.Points.First().y(),
@@ -2184,20 +2193,28 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
         {
           const Graphic3d_Vec2i aPnt1 (aPoints.Value (1).x(), -aPoints.Value (1).y());
           const Graphic3d_Vec2i aPnt2 (aPoints.Value (3).x(), -aPoints.Value (3).y());
-          theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
-          if (myGL.Selection.IsXOR)
+          if (myGL.Selection.Tool == AIS_ViewSelectionTool_ZoomWindow)
           {
-            theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
-                                 Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
-                                 theView, false);
+            theView->WindowFitAll (aPnt1.x(), aPnt1.y(), aPnt2.x(), aPnt2.y());
+            theView->Invalidate();
           }
           else
           {
-            theCtx->Select (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
-                            Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
-                            theView, false);
+            theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
+            if (myGL.Selection.IsXOR)
+            {
+              theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
+                                   Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
+                                   theView, false);
+            }
+            else
+            {
+              theCtx->Select (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
+                              Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
+                              theView, false);
+            }
+            theCtx->MainSelector()->AllowOverlapDetection (false);
           }
-          theCtx->MainSelector()->AllowOverlapDetection (false);
         }
         else if (aPoints.Length() >= 3)
         {
@@ -2222,11 +2239,13 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
         }
       }
 
-      // selection affects all Views
-      theView->Viewer()->Invalidate();
-
       myRubberBand->ClearPoints();
-      OnSelectionChanged (theCtx, theView);
+      if (myGL.Selection.Tool != AIS_ViewSelectionTool_ZoomWindow)
+      {
+        // selection affects all Views
+        theView->Viewer()->Invalidate();
+        OnSelectionChanged (theCtx, theView);
+      }
     }
   }
 }
index 48d2705..c73b163 100644 (file)
@@ -25,7 +25,8 @@ enum AIS_ViewSelectionTool
 {
   AIS_ViewSelectionTool_Picking,    //!< pick to select
   AIS_ViewSelectionTool_RubberBand, //!< rubber-band to select
-  AIS_ViewSelectionTool_Polygon     //!< polyline to select
+  AIS_ViewSelectionTool_Polygon,    //!< polyline to select
+  AIS_ViewSelectionTool_ZoomWindow, //!< zoom-in window (no selection)
 };
 
 //! Input buffer type.