From 9f80e1147dfd3c4ed5ddf695626126d4db3be827 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 28 Oct 2016 19:42:37 +0300 Subject: [PATCH] Issue #1822: Set fly out point before moving of points for radial directed objects --- src/PartSet/PartSet_SketcherMgr.cpp | 30 ++++++++++++++++++++------- src/SketcherPrs/SketcherPrs_Angle.cpp | 15 +++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 0e2e7a56b..5d607f93c 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -369,9 +369,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE // Init flyout point for radius rotation FeaturePtr aFeature = myCurrentSelection.begin().key(); + get2dPoint(theWnd, theEvent, myCurrentPoint); if (isSketcher) { myIsDragging = true; - get2dPoint(theWnd, theEvent, myCurrentPoint); myDragDone = false; myPreviousDrawModeEnabled = aViewer->enableDrawMode(false); @@ -382,7 +382,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE if (aFeature.get() != NULL) { std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aFeature); - if (aSPFeature.get() && aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID()) { + if (aSPFeature.get() && + (aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID() || + aSPFeature->getKind() == SketchPlugin_ConstraintAngle::ID())) { DataPtr aData = aSPFeature->data(); AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); std::shared_ptr aFPAttr = @@ -395,7 +397,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE aFOperation->commit(); myIsDragging = true; - get2dPoint(theWnd, theEvent, myCurrentPoint); myDragDone = false; myPreviousDrawModeEnabled = aViewer->enableDrawMode(false); @@ -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 restoreSelection(); launchEditing(); + if (aFeature.get() != NULL) { + std::shared_ptr aSPFeature = + std::dynamic_pointer_cast(aFeature); + if (aSPFeature.get() && + (aSPFeature->getKind() == SketchPlugin_ConstraintRadius::ID() || + aSPFeature->getKind() == SketchPlugin_ConstraintAngle::ID())) { + DataPtr aData = aSPFeature->data(); + AttributePtr aAttr = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); + std::shared_ptr aFPAttr = + std::dynamic_pointer_cast(aAttr); + aFPAttr->setValue(myCurrentPoint.myCurX, myCurrentPoint.myCurY); + } + } restoreSelection(); } } @@ -494,10 +508,10 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve Handle(V3d_View) aView = theWnd->v3dView(); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - double aX, aY; - PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY); - double dX = aX - myCurrentPoint.myCurX; - double dY = aY - myCurrentPoint.myCurY; + Point aMousePnt; + get2dPoint(theWnd, theEvent, aMousePnt); + double dX = aMousePnt.myCurX - myCurrentPoint.myCurX; + double dY = aMousePnt.myCurY - myCurrentPoint.myCurY; ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); @@ -565,7 +579,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve aDisplayer->updateViewer(); myDragDone = true; - myCurrentPoint.setValue(aX, aY); + myCurrentPoint = aMousePnt; } } diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index c481c2873..25750ff5d 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -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); } -- 2.39.2