]> OCCT Git - occt.git/commitdiff
0033542: Visualization, AIS_ViewController - New AIS_DragAction for when drag interac...
authorrodrlyra <rodrlyra@opencascade.com>
Mon, 4 Dec 2023 17:17:23 +0000 (17:17 +0000)
committervglukhik <vglukhik@opencascade.com>
Fri, 15 Dec 2023 19:51:25 +0000 (19:51 +0000)
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).

src/AIS/AIS_DragAction.hxx
src/AIS/AIS_LightSource.cxx
src/AIS/AIS_Manipulator.cxx
src/AIS/AIS_ViewController.cxx
src/AIS/AIS_ViewInputBuffer.hxx

index cf3bf238ba6cfc4ed47cac5de5c01630bf521930..f74c9922b6a8f8c3191a61627504361c3dce5c2c 100644 (file)
 //! Dragging action.
 enum AIS_DragAction
 {
-  AIS_DragAction_Start,  //!< (try) start dragging object
-  AIS_DragAction_Update, //!< perform dragging (update position)
-  AIS_DragAction_Stop,   //!< stop dragging (save position)
-  AIS_DragAction_Abort,  //!< abort dragging (restore initial position)
+  AIS_DragAction_Start,     //!< (try) start dragging object
+  AIS_DragAction_Confirmed, //!< dragging interaction is confirmed.
+  AIS_DragAction_Update,    //!< perform dragging (update position)
+  AIS_DragAction_Stop,      //!< stop dragging (save position)
+  AIS_DragAction_Abort,     //!< abort dragging (restore initial position)
 };
 
 #endif // _AIS_DragAction_HeaderFile
index f70f4e70d8f6386b24fdbd31d1940995aec1cee0..3a375992c729cc0f58539b0eff6b38c9bc567f7b 100644 (file)
@@ -259,6 +259,10 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
       myLocTrsfStart = LocalTransformation();
       return Standard_True;
     }
+    case AIS_DragAction_Confirmed:
+    {
+      return Standard_True;
+    }
     case AIS_DragAction_Update:
     {
       mySensSphere->ResetLastDetectedPoint();
index 4cd43844b826579ea07d30ba18e827773a80a737..21491cc35a791b5188a834d5bc4049f5d6f83440 100644 (file)
@@ -661,6 +661,10 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
       }
       break;
     }
+    case AIS_DragAction_Confirmed:
+    {
+      return Standard_True;
+    }
     case AIS_DragAction_Update:
     {
       Transform (theDragTo.x(), theDragTo.y(), theView);
index a19519456d928d8c7fcbed5b524a256e96f6d884..78e70074715c324d7c0caa53c61efcd7951d0e40 100644 (file)
@@ -332,6 +332,11 @@ void AIS_ViewController::flushBuffers (const Handle(AIS_InteractiveContext)& ,
       myGL.Dragging.ToStart = true;
       myGL.Dragging.PointStart = myUI.Dragging.PointStart;
     }
+    if (myUI.Dragging.ToConfirm)
+    {
+      myUI.Dragging.ToConfirm = false;
+      myGL.Dragging.ToConfirm = true;
+    }
     if (myUI.Dragging.ToMove)
     {
       myUI.Dragging.ToMove = false;
@@ -928,6 +933,7 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
       myMouseClickCounter = 0;
       myMouseSingleButton = -1;
       myMouseStopDragOnUnclick = true;
+      myUI.Dragging.ToConfirm = true;
     }
   }
 
@@ -2738,6 +2744,17 @@ void AIS_ViewController::OnObjectDragged (const Handle(AIS_InteractiveContext)&
       }
       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:
     {
       if (myDragObject.IsNull())
@@ -3057,6 +3074,10 @@ void AIS_ViewController::handleDynamicHighlight (const Handle(AIS_InteractiveCon
     }
     else if (myGL.Dragging.ToMove)
     {
+      if (myGL.Dragging.ToConfirm)
+      {
+        OnObjectDragged (theCtx, theView, AIS_DragAction_Confirmed);
+      }
       OnObjectDragged (theCtx, theView, AIS_DragAction_Update);
       myGL.OrbitRotation.ToRotate = false;
       myGL.ViewRotation .ToRotate = false;
index afcc4feb0ded95c6d410305679032ee839db6249..c009e9f65e26373d76c47a8226929971895da62f 100644 (file)
@@ -87,13 +87,14 @@ public:
   struct _draggingParams
   {
     bool            ToStart;    //!< start dragging
+    bool            ToConfirm;  //!< confirm dragging
     bool            ToMove;     //!< perform dragging
     bool            ToStop;     //!< stop  dragging
     bool            ToAbort;    //!< abort dragging (restore previous position)
     Graphic3d_Vec2i PointStart; //!< drag start 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;
 
   struct _orbitRotation
@@ -139,12 +140,13 @@ public:
     Selection.ToApplyTool = false;
     IsNewGesture     = false;
     ZoomActions.Clear();
-    Panning.ToStart  = false;
-    Panning.ToPan    = false;
-    Dragging.ToStart = false;
-    Dragging.ToMove  = false;
-    Dragging.ToStop  = false;
-    Dragging.ToAbort = false;
+    Panning.ToStart    = false;
+    Panning.ToPan      = false;
+    Dragging.ToStart   = false;
+    Dragging.ToConfirm = false;
+    Dragging.ToMove    = false;
+    Dragging.ToStop    = false;
+    Dragging.ToAbort   = false;
     OrbitRotation.ToStart  = false;
     OrbitRotation.ToRotate = false;
     ViewRotation.ToStart   = false;