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

0033542: Visualization, AIS_ViewController - New AIS_DragAction for when drag interaction is confirmed

Added AIS_DragAction_Confirmed drag action, which will be called by AIS_ViewController when the drag interaction is confirmed (mouse moved more than click threshold).
This commit is contained in:
rodrlyra 2023-12-04 17:17:23 +00:00 committed by vglukhik
parent e8605596c9
commit 6ef56849a5
5 changed files with 43 additions and 11 deletions

View File

@ -17,10 +17,11 @@
//! Dragging action. //! Dragging action.
enum AIS_DragAction enum AIS_DragAction
{ {
AIS_DragAction_Start, //!< (try) start dragging object AIS_DragAction_Start, //!< (try) start dragging object
AIS_DragAction_Update, //!< perform dragging (update position) AIS_DragAction_Confirmed, //!< dragging interaction is confirmed.
AIS_DragAction_Stop, //!< stop dragging (save position) AIS_DragAction_Update, //!< perform dragging (update position)
AIS_DragAction_Abort, //!< abort dragging (restore initial position) AIS_DragAction_Stop, //!< stop dragging (save position)
AIS_DragAction_Abort, //!< abort dragging (restore initial position)
}; };
#endif // _AIS_DragAction_HeaderFile #endif // _AIS_DragAction_HeaderFile

View File

@ -259,6 +259,10 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
myLocTrsfStart = LocalTransformation(); myLocTrsfStart = LocalTransformation();
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Confirmed:
{
return Standard_True;
}
case AIS_DragAction_Update: case AIS_DragAction_Update:
{ {
mySensSphere->ResetLastDetectedPoint(); mySensSphere->ResetLastDetectedPoint();

View File

@ -661,6 +661,10 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
} }
break; break;
} }
case AIS_DragAction_Confirmed:
{
return Standard_True;
}
case AIS_DragAction_Update: case AIS_DragAction_Update:
{ {
Transform (theDragTo.x(), theDragTo.y(), theView); Transform (theDragTo.x(), theDragTo.y(), theView);

View File

@ -332,6 +332,11 @@ void AIS_ViewController::flushBuffers (const Handle(AIS_InteractiveContext)& ,
myGL.Dragging.ToStart = true; myGL.Dragging.ToStart = true;
myGL.Dragging.PointStart = myUI.Dragging.PointStart; myGL.Dragging.PointStart = myUI.Dragging.PointStart;
} }
if (myUI.Dragging.ToConfirm)
{
myUI.Dragging.ToConfirm = false;
myGL.Dragging.ToConfirm = true;
}
if (myUI.Dragging.ToMove) if (myUI.Dragging.ToMove)
{ {
myUI.Dragging.ToMove = false; myUI.Dragging.ToMove = false;
@ -928,6 +933,7 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
myMouseClickCounter = 0; myMouseClickCounter = 0;
myMouseSingleButton = -1; myMouseSingleButton = -1;
myMouseStopDragOnUnclick = true; myMouseStopDragOnUnclick = true;
myUI.Dragging.ToConfirm = true;
} }
} }
@ -2738,6 +2744,17 @@ void AIS_ViewController::OnObjectDragged (const Handle(AIS_InteractiveContext)&
} }
return; return;
} }
case AIS_DragAction_Confirmed:
{
if (myDragObject.IsNull())
{
return;
}
myDragObject->ProcessDragging (theCtx, theView, myDragOwner, myGL.Dragging.PointStart,
myGL.Dragging.PointTo, theAction);
return;
}
case AIS_DragAction_Update: case AIS_DragAction_Update:
{ {
if (myDragObject.IsNull()) if (myDragObject.IsNull())
@ -3057,6 +3074,10 @@ void AIS_ViewController::handleDynamicHighlight (const Handle(AIS_InteractiveCon
} }
else if (myGL.Dragging.ToMove) else if (myGL.Dragging.ToMove)
{ {
if (myGL.Dragging.ToConfirm)
{
OnObjectDragged (theCtx, theView, AIS_DragAction_Confirmed);
}
OnObjectDragged (theCtx, theView, AIS_DragAction_Update); OnObjectDragged (theCtx, theView, AIS_DragAction_Update);
myGL.OrbitRotation.ToRotate = false; myGL.OrbitRotation.ToRotate = false;
myGL.ViewRotation .ToRotate = false; myGL.ViewRotation .ToRotate = false;

View File

@ -87,13 +87,14 @@ public:
struct _draggingParams struct _draggingParams
{ {
bool ToStart; //!< start dragging bool ToStart; //!< start dragging
bool ToConfirm; //!< confirm dragging
bool ToMove; //!< perform dragging bool ToMove; //!< perform dragging
bool ToStop; //!< stop dragging bool ToStop; //!< stop dragging
bool ToAbort; //!< abort dragging (restore previous position) bool ToAbort; //!< abort dragging (restore previous position)
Graphic3d_Vec2i PointStart; //!< drag start point Graphic3d_Vec2i PointStart; //!< drag start point
Graphic3d_Vec2i PointTo; //!< drag end point Graphic3d_Vec2i PointTo; //!< drag end point
_draggingParams() : ToStart (false), ToMove (false), ToStop (false), ToAbort (false) {} _draggingParams() : ToStart (false), ToConfirm (false), ToMove (false), ToStop (false), ToAbort (false) {}
} Dragging; } Dragging;
struct _orbitRotation struct _orbitRotation
@ -139,12 +140,13 @@ public:
Selection.ToApplyTool = false; Selection.ToApplyTool = false;
IsNewGesture = false; IsNewGesture = false;
ZoomActions.Clear(); ZoomActions.Clear();
Panning.ToStart = false; Panning.ToStart = false;
Panning.ToPan = false; Panning.ToPan = false;
Dragging.ToStart = false; Dragging.ToStart = false;
Dragging.ToMove = false; Dragging.ToConfirm = false;
Dragging.ToStop = false; Dragging.ToMove = false;
Dragging.ToAbort = false; Dragging.ToStop = false;
Dragging.ToAbort = false;
OrbitRotation.ToStart = false; OrbitRotation.ToStart = false;
OrbitRotation.ToRotate = false; OrbitRotation.ToRotate = false;
ViewRotation.ToStart = false; ViewRotation.ToStart = false;