]> OCCT Git - occt.git/commitdiff
0032604: Visualization, AIS_LightSource - improve dragging robustness
authorkgv <kgv@opencascade.com>
Mon, 4 Oct 2021 10:26:35 +0000 (13:26 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 8 Oct 2021 17:24:43 +0000 (20:24 +0300)
src/AIS/AIS_LightSource.cxx
src/AIS/AIS_LightSource.hxx
src/Select3D/Select3D_SensitiveSphere.hxx

index c48e80528f5e17432814e659a67750dca486740d..91ae697643ad35dd4f55a4deb1b1aa8d855eabfe 100644 (file)
@@ -257,27 +257,29 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
   {
     case AIS_DragAction_Start:
     {
-      myStartTransform = theDragFrom;
       myLocTrsfStart = LocalTransformation();
       return Standard_True;
     }
     case AIS_DragAction_Update:
     {
-      theCtx->MainSelector()->Pick (myStartTransform.x(), myStartTransform.y(), theView);
+      mySensSphere->ResetLastDetectedPoint();
+      SetLocalTransformation (myLocTrsfStart);
+      theCtx->MainSelector()->Pick (theDragFrom.x(), theDragFrom.y(), theView);
       gp_Pnt aStartPosition = mySensSphere->LastDetectedPoint();
+
+      mySensSphere->ResetLastDetectedPoint();
       theCtx->MainSelector()->Pick (theDragTo.x(), theDragTo.y(), theView);
       gp_Pnt aCurrPosition = mySensSphere->LastDetectedPoint();
-      if (aCurrPosition.X() != RealLast() && aStartPosition.Distance (aCurrPosition) > Precision::Confusion())
+      if (aCurrPosition.X() != RealLast()
+       && aStartPosition.Distance (aCurrPosition) > Precision::Confusion())
       {
         gp_Quaternion aQRot;
         aQRot.SetRotation (gp_Vec (gp_Pnt (0, 0, 0), aStartPosition), gp_Vec (gp_Pnt (0, 0, 0), aCurrPosition));
         gp_Trsf aTrsf;
         aTrsf.SetRotation (aQRot);
         SetLocalTransformation (myLocTrsfStart * aTrsf);
-        myLocTrsfStart = LocalTransformation();
-        myStartTransform = theDragTo;
-        theOwner->Selectable()->ClearDynamicHighlight (theCtx->MainPrsMgr());
-        theCtx->HilightWithColor (this, Handle(Prs3d_Drawer)(), false);
+        const Standard_Integer aHiMod = HasHilightMode() ? HilightMode() : 0;
+        theOwner->UpdateHighlightTrsf (theCtx->CurrentViewer(), theCtx->MainPrsMgr(), aHiMod);
       }
       return Standard_True;
     }
@@ -475,7 +477,7 @@ void AIS_LightSource::updateLightLocalTransformation()
 // =======================================================================
 void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
 {
-  const gp_Trsf aTrsf = theTrsf->Transformation();
+  const gp_Trsf aTrsf = !theTrsf.IsNull() ? theTrsf->Transformation() : gp_Trsf();
   switch (myLightSource->Type())
   {
     case Graphic3d_TypeOfLightSource_Ambient:
index 0e6dbc6bfa929bc883f9db62a610bf4d46208731..c2da38840cff6fc28b2a3f414fd052427473b314 100644 (file)
@@ -259,7 +259,6 @@ protected:
   Aspect_TypeOfMarker              myCodirMarkerType;       //!< icon of arrow co-directional to camera direction (look from)
   Aspect_TypeOfMarker              myOpposMarkerType;       //!< icon of arrow opposite to camera direction (look at)
 
-  Graphic3d_Vec2i  myStartTransform;    //!< position of starting transformation
   gp_Trsf          myLocTrsfStart;      //!< object transformation before transformation
   Standard_Real    mySize;              //!< presentation size
   Standard_Integer myNbArrows;          //!< number of directional light arrows
index 3202401b3c12559d0228233fae3b1a9c00ad00e3..765d6276e150b502f66234a1cd40d0eff9949d53 100644 (file)
@@ -58,6 +58,12 @@ public:
   //! Returns the position of detected point on the sphere.
   const gp_Pnt& LastDetectedPoint() const { return myLastDetectedPoint; }
 
+  //! Invalidate the position of detected point on the sphere.
+  void ResetLastDetectedPoint()
+  {
+    myLastDetectedPoint = gp_Pnt (RealLast(), RealLast(), RealLast());
+  }
+
 protected:
   gp_Pnt        myCenter;
   gp_Pnt        myLastDetectedPoint;