1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

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.
This commit is contained in:
kgv 2020-04-23 23:47:11 +03:00 committed by bugmaster
parent 9ad4ff93a0
commit e1c9a10311
3 changed files with 45 additions and 20 deletions

View File

@ -21,10 +21,15 @@ enum AIS_MouseGesture
{ {
AIS_MouseGesture_NONE, //!< no active gesture AIS_MouseGesture_NONE, //!< no active gesture
// //
AIS_MouseGesture_SelectRectangle, //!< rectangular selection AIS_MouseGesture_SelectRectangle, //!< rectangular selection;
AIS_MouseGesture_SelectLasso, //!< polygonal 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_Pan, //!< view panning gesture
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
AIS_MouseGesture_RotateView, //!< view rotation gesture AIS_MouseGesture_RotateView, //!< view rotation gesture

View File

@ -721,6 +721,7 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
break; break;
} }
case AIS_MouseGesture_Zoom: case AIS_MouseGesture_Zoom:
case AIS_MouseGesture_ZoomWindow:
{ {
if (!myToAllowZooming) if (!myToAllowZooming)
{ {
@ -756,7 +757,8 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
if (aPrevGesture != myMouseActiveGesture) if (aPrevGesture != myMouseActiveGesture)
{ {
if (aPrevGesture == AIS_MouseGesture_SelectRectangle if (aPrevGesture == AIS_MouseGesture_SelectRectangle
|| aPrevGesture == AIS_MouseGesture_SelectLasso) || aPrevGesture == AIS_MouseGesture_SelectLasso
|| aPrevGesture == AIS_MouseGesture_ZoomWindow)
{ {
myUI.Selection.ToApplyTool = true; myUI.Selection.ToApplyTool = true;
} }
@ -828,8 +830,13 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
switch (myMouseActiveGesture) switch (myMouseActiveGesture)
{ {
case AIS_MouseGesture_SelectRectangle: case AIS_MouseGesture_SelectRectangle:
case AIS_MouseGesture_ZoomWindow:
{ {
UpdateRubberBand (myMousePressPoint, thePoint); UpdateRubberBand (myMousePressPoint, thePoint);
if (myMouseActiveGesture == AIS_MouseGesture_ZoomWindow)
{
myUI.Selection.Tool = AIS_ViewSelectionTool_ZoomWindow;
}
toUpdateView = true; toUpdateView = true;
break; break;
} }
@ -2113,14 +2120,16 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
{ {
// rubber-band & window polygon selection // rubber-band & window polygon selection
if (myGL.Selection.Tool == AIS_ViewSelectionTool_RubberBand 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()) if (!myGL.Selection.Points.IsEmpty())
{ {
myRubberBand->ClearPoints(); myRubberBand->ClearPoints();
myRubberBand->SetToUpdate(); 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) if (anIsRubber)
{ {
myRubberBand->SetRectangle (myGL.Selection.Points.First().x(), -myGL.Selection.Points.First().y(), 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 aPnt1 (aPoints.Value (1).x(), -aPoints.Value (1).y());
const Graphic3d_Vec2i aPnt2 (aPoints.Value (3).x(), -aPoints.Value (3).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.Tool == AIS_ViewSelectionTool_ZoomWindow)
if (myGL.Selection.IsXOR)
{ {
theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()), theView->WindowFitAll (aPnt1.x(), aPnt1.y(), aPnt2.x(), aPnt2.y());
Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()), theView->Invalidate();
theView, false);
} }
else else
{ {
theCtx->Select (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()), theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()), if (myGL.Selection.IsXOR)
theView, false); {
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) 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(); myRubberBand->ClearPoints();
OnSelectionChanged (theCtx, theView); if (myGL.Selection.Tool != AIS_ViewSelectionTool_ZoomWindow)
{
// selection affects all Views
theView->Viewer()->Invalidate();
OnSelectionChanged (theCtx, theView);
}
} }
} }
} }

View File

@ -25,7 +25,8 @@ enum AIS_ViewSelectionTool
{ {
AIS_ViewSelectionTool_Picking, //!< pick to select AIS_ViewSelectionTool_Picking, //!< pick to select
AIS_ViewSelectionTool_RubberBand, //!< rubber-band 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. //! Input buffer type.