]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1822: Set fly out point before moving of points for radial directed objects
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 28 Oct 2016 16:42:37 +0000 (19:42 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 28 Oct 2016 16:42:37 +0000 (19:42 +0300)
src/PartSet/PartSet_SketcherMgr.cpp
src/SketcherPrs/SketcherPrs_Angle.cpp

index 0e2e7a56b6ae16673afd3bb05ef68ff3d9239b6a..5d607f93c7dffb2dbb7ad57fdec62b78ae55aeeb 100755 (executable)
@@ -369,9 +369,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
     // Init flyout point for radius rotation\r
     FeaturePtr aFeature = myCurrentSelection.begin().key();\r
 \r
+    get2dPoint(theWnd, theEvent, myCurrentPoint);\r
     if (isSketcher) {\r
       myIsDragging = true;\r
-      get2dPoint(theWnd, theEvent, myCurrentPoint);\r
       myDragDone = false;\r
 \r
       myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);\r
@@ -382,7 +382,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       if (aFeature.get() != NULL) {\r
         std::shared_ptr<SketchPlugin_Feature> aSPFeature = \r
                   std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);\r
-      if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) {\r
+        if (aSPFeature.get() && \r
+          (aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID() ||\r
+           aSPFeature->getKind() == SketchPlugin_ConstraintAngle::ID())) {\r
           DataPtr aData = aSPFeature->data();\r
           AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());\r
           std::shared_ptr<GeomDataAPI_Point2D> aFPAttr = \r
@@ -395,7 +397,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       aFOperation->commit();\r
 \r
       myIsDragging = true;\r
-      get2dPoint(theWnd, theEvent, myCurrentPoint);\r
       myDragDone = false;\r
 \r
       myPreviousDrawModeEnabled = aViewer->enableDrawMode(false);\r
@@ -403,6 +404,19 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       // selected entities, e.g. selection of point(attribute on a line) should edit the point\r
       restoreSelection();\r
       launchEditing();\r
+      if (aFeature.get() != NULL) {\r
+        std::shared_ptr<SketchPlugin_Feature> aSPFeature = \r
+                  std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);\r
+        if (aSPFeature.get() && \r
+          (aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID() ||\r
+           aSPFeature->getKind() == SketchPlugin_ConstraintAngle::ID())) {\r
+          DataPtr aData = aSPFeature->data();\r
+          AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());\r
+          std::shared_ptr<GeomDataAPI_Point2D> aFPAttr = \r
+            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);\r
+          aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY);\r
+        }\r
+      }\r
       restoreSelection();\r
     }\r
   }\r
@@ -494,10 +508,10 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
 \r
     Handle(V3d_View) aView = theWnd->v3dView();\r
     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);\r
-    double aX, aY;\r
-    PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);\r
-    double dX =  aX - myCurrentPoint.myCurX;\r
-    double dY =  aY - myCurrentPoint.myCurY;\r
+    Point aMousePnt;\r
+    get2dPoint(theWnd, theEvent, aMousePnt);\r
+    double dX =  aMousePnt.myCurX - myCurrentPoint.myCurX;\r
+    double dY =  aMousePnt.myCurY - myCurrentPoint.myCurY;\r
 \r
     ModuleBase_IWorkshop* aWorkshop = myModule->workshop();\r
     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);\r
@@ -565,7 +579,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     aDisplayer->updateViewer();\r
 \r
     myDragDone = true;\r
-    myCurrentPoint.setValue(aX, aY);\r
+    myCurrentPoint = aMousePnt;\r
   }\r
 }\r
 \r
index c481c2873bef0836c60eea38ecd8edd58819a442..25750ff5d77f5411b52e31b728108ecc18ef92f6 100644 (file)
@@ -258,11 +258,12 @@ bool SketcherPrs_Angle::isAnglePlaneReversedToSketchPlane()
 
 double SketcherPrs_Angle::calculateDistanceToFlyoutPoint()
 {
-  gp_Dir aBisector((myFirstPoint.XYZ() + mySecondPoint.XYZ()) * 0.5 - myCenterPoint.XYZ());
-  //gp_Pnt aFlyPnt(aFlyoutPnt->x(), aFlyoutPnt->y(), aFlyoutPnt->z());
-  gp_XYZ aFlyDir = myFlyOutPoint.XYZ() - myCenterPoint.XYZ();
-  double aDistance = aFlyDir.Dot(aBisector.XYZ());
-  // make a positive distance in order to AIS angle presentation is not reversed
-  aDistance = fabs(aDistance);
-  return aDistance;
+  //gp_Dir aBisector = gp_Dir((myFirstPoint.XYZ() + mySecondPoint.XYZ()) * 0.5 - myCenterPoint.XYZ());
+  //gp_XYZ aFlyDir = myFlyOutPoint.XYZ() - myCenterPoint.XYZ();
+
+  //double aDistance = aFlyDir.Dot(aBisector.XYZ());
+  //// make a positive distance in order to AIS angle presentation is not reversed
+  //aDistance = fabs(aDistance);
+  //return aDistance;
+  return myFlyOutPoint.Distance(myCenterPoint);
 }