mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0032879: Visualization, AIS_ViewController - define separate gesture mappings for dragging
This commit is contained in:
@@ -1047,11 +1047,13 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
||||
: 0.0;
|
||||
if (double (Abs (aDelta.x())) > aZoomTol)
|
||||
{
|
||||
if (UpdateZoom (Aspect_ScrollDelta (aDelta.x())))
|
||||
{
|
||||
toUpdateView = true;
|
||||
}
|
||||
UpdateZoom (Aspect_ScrollDelta (aDelta.x()));
|
||||
|
||||
myUI.Dragging.ToMove = true;
|
||||
myUI.Dragging.PointTo = thePoint;
|
||||
|
||||
myMouseProgressPoint = thePoint;
|
||||
toUpdateView = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1075,7 +1077,6 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
||||
}
|
||||
|
||||
aDelta.y() = -aDelta.y();
|
||||
myMouseProgressPoint = thePoint;
|
||||
if (myUI.Panning.ToPan)
|
||||
{
|
||||
myUI.Panning.Delta += aDelta;
|
||||
@@ -1085,6 +1086,11 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
||||
myUI.Panning.ToPan = true;
|
||||
myUI.Panning.Delta = aDelta;
|
||||
}
|
||||
|
||||
myUI.Dragging.ToMove = true;
|
||||
myUI.Dragging.PointTo = thePoint;
|
||||
myMouseProgressPoint = thePoint;
|
||||
|
||||
toUpdateView = true;
|
||||
}
|
||||
break;
|
||||
@@ -3053,6 +3059,8 @@ void AIS_ViewController::handleDynamicHighlight (const Handle(AIS_InteractiveCon
|
||||
OnObjectDragged (theCtx, theView, AIS_DragAction_Update);
|
||||
myGL.OrbitRotation.ToRotate = false;
|
||||
myGL.ViewRotation .ToRotate = false;
|
||||
myGL.Panning .ToPan = false;
|
||||
myGL.ZoomActions.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13910,6 +13910,73 @@ static int VSelBvhBuild (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VMouseGesture
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static int VMouseGesture (Draw_Interpretor& /*theDI*/,
|
||||
Standard_Integer theArgsNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
if (aView.IsNull())
|
||||
{
|
||||
Message::SendFail ("Error: no active viewer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
NCollection_DoubleMap<TCollection_AsciiString, AIS_MouseGesture> aGestureMap;
|
||||
{
|
||||
aGestureMap.Bind ("none", AIS_MouseGesture_NONE);
|
||||
aGestureMap.Bind ("selectrectangle", AIS_MouseGesture_SelectRectangle);
|
||||
aGestureMap.Bind ("selectlasso", AIS_MouseGesture_SelectLasso);
|
||||
aGestureMap.Bind ("zoom", AIS_MouseGesture_Zoom);
|
||||
aGestureMap.Bind ("zoomwindow", AIS_MouseGesture_ZoomWindow);
|
||||
aGestureMap.Bind ("pan", AIS_MouseGesture_Pan);
|
||||
aGestureMap.Bind ("rotateorbit", AIS_MouseGesture_RotateOrbit);
|
||||
aGestureMap.Bind ("rotateview", AIS_MouseGesture_RotateView);
|
||||
aGestureMap.Bind ("drag", AIS_MouseGesture_Drag);
|
||||
}
|
||||
NCollection_DoubleMap<TCollection_AsciiString, Standard_UInteger> aMouseButtonMap;
|
||||
{
|
||||
aMouseButtonMap.Bind ("none", (Standard_UInteger )Aspect_VKeyMouse_NONE);
|
||||
aMouseButtonMap.Bind ("left", (Standard_UInteger )Aspect_VKeyMouse_LeftButton);
|
||||
aMouseButtonMap.Bind ("middle", (Standard_UInteger )Aspect_VKeyMouse_MiddleButton);
|
||||
aMouseButtonMap.Bind ("right", (Standard_UInteger )Aspect_VKeyMouse_RightButton);
|
||||
}
|
||||
|
||||
Standard_UInteger aButton = (Standard_UInteger )Aspect_VKeyMouse_LeftButton;
|
||||
AIS_MouseGesture aGesture = AIS_MouseGesture_RotateOrbit;
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
|
||||
{
|
||||
Standard_CString anArg = theArgVec[anArgIter];
|
||||
TCollection_AsciiString anArgCase (anArg);
|
||||
anArgCase.LowerCase();
|
||||
if (anArgCase == "-button")
|
||||
{
|
||||
TCollection_AsciiString aButtonStr = theArgVec[++anArgIter];
|
||||
aButtonStr.LowerCase();
|
||||
aButton = aMouseButtonMap.Find1 (aButtonStr);
|
||||
}
|
||||
else if (anArgCase == "-gesture")
|
||||
{
|
||||
TCollection_AsciiString aGestureStr = theArgVec[++anArgIter];
|
||||
aGestureStr.LowerCase();
|
||||
aGesture = aGestureMap.Find1 (aGestureStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::SendFail() << "Error: unknown argument '" << anArg << "'";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(ViewerTest_EventManager) aViewMgr = ViewerTest::CurrentEventManager();
|
||||
aViewMgr->ChangeMouseGestureMap().Bind (aButton, aGesture);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewerTest_ExitProc
|
||||
//purpose :
|
||||
@@ -14927,4 +14994,12 @@ Turns on/off prebuilding of BVH within background thread(s).
|
||||
-nbThreads number of threads, 1 by default; if < 1 then used (NbLogicalProcessors - 1);
|
||||
-wait waits for building all of BVH.
|
||||
)" /* [vselbvhbuild] */);
|
||||
|
||||
addCmd ("vmousegesture", VMouseGesture, /* [vmousegesture] */ R"(
|
||||
vmousegesture -button {none|left|middle|right}=left
|
||||
-gesture {none|selectRectangle|selectLasso|zoom|zoomWindow|pan|rotateOrbit|rotateView|drag}=rotateOrbit
|
||||
Changes the gesture for the mouse button.
|
||||
-button the mouse button;
|
||||
-gesture the new gesture for the button.
|
||||
)" /* [vmousegesture] */);
|
||||
}
|
||||
|
43
tests/v3d/manipulator/drag_pan_zoom
Normal file
43
tests/v3d/manipulator/drag_pan_zoom
Normal file
@@ -0,0 +1,43 @@
|
||||
puts "=============================================="
|
||||
puts "0032879: Visualization - Separate pan/zoom and move the object behavior in AIS_ViewController"
|
||||
puts "=============================================="
|
||||
puts ""
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
|
||||
vinit View1
|
||||
pcylinder c1 5 10
|
||||
vdisplay c1
|
||||
vsetdispmode 1
|
||||
vmanipulator m -attach c1 -adjustPosition 1 -adjustSize 0 -enableModes 1 -size 40
|
||||
vfit
|
||||
|
||||
# note: mouse events cannot be emulated here, so the original bug cannot be reproduced by this test case
|
||||
|
||||
# pan for the left mouse button
|
||||
vmousegesture -button left -gesture pan
|
||||
|
||||
set mouse_pick {204 194}
|
||||
set mouse_drag {369 35}
|
||||
|
||||
vmoveto {*}$mouse_pick
|
||||
vselect {*}$mouse_pick
|
||||
vmanipulator m -startTransform {*}$mouse_pick
|
||||
vmanipulator m -transform {*}$mouse_drag
|
||||
vmanipulator m -stopTransform
|
||||
vselect 0 0
|
||||
vdump $imagedir/${casename}_pan.png
|
||||
|
||||
# zoom for the left mouse button
|
||||
vmousegesture -button left -gesture zoom
|
||||
|
||||
set mouse_pick {206 32}
|
||||
set mouse_drag {365 330}
|
||||
|
||||
vmoveto {*}$mouse_pick
|
||||
vselect {*}$mouse_pick
|
||||
vmanipulator m -startTransform {*}$mouse_pick
|
||||
vmanipulator m -transform {*}$mouse_drag
|
||||
vmanipulator m -stopTransform
|
||||
vselect 0 0
|
||||
vdump $imagedir/${casename}_zoom.png
|
Reference in New Issue
Block a user