From e1c9a103113b4be8567eadb2197abe4d978a8a41 Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 23 Apr 2020 23:47:11 +0300 Subject: [PATCH] 0031519: Visualization, AIS_ViewController - add AIS_MouseGesture_ZoomWindow gesture AIS_ViewController now supports AIS_MouseGesture_ZoomWindow gesture, which displays zooming window via Rubber-Band rectangle. --- src/AIS/AIS_MouseGesture.hxx | 11 +++++-- src/AIS/AIS_ViewController.cxx | 51 ++++++++++++++++++++++----------- src/AIS/AIS_ViewInputBuffer.hxx | 3 +- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/AIS/AIS_MouseGesture.hxx b/src/AIS/AIS_MouseGesture.hxx index ab28f1327f..22c9086693 100644 --- a/src/AIS/AIS_MouseGesture.hxx +++ b/src/AIS/AIS_MouseGesture.hxx @@ -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 diff --git a/src/AIS/AIS_ViewController.cxx b/src/AIS/AIS_ViewController.cxx index d4e79f7a48..0d345201a1 100644 --- a/src/AIS/AIS_ViewController.cxx +++ b/src/AIS/AIS_ViewController.cxx @@ -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); + } } } } diff --git a/src/AIS/AIS_ViewInputBuffer.hxx b/src/AIS/AIS_ViewInputBuffer.hxx index 48d2705e6c..c73b163105 100644 --- a/src/AIS/AIS_ViewInputBuffer.hxx +++ b/src/AIS/AIS_ViewInputBuffer.hxx @@ -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.