From b22750964ffd024837e6fa2fca7aeba4804a4666 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 15 Apr 2015 10:06:51 +0300 Subject: [PATCH] Corrections for dimensions --- .../SketcherPrs_LengthDimension.cpp | 61 ++++++++++--------- src/SketcherPrs/SketcherPrs_Radius.cpp | 1 - src/SketcherPrs/SketcherPrs_Tools.cpp | 7 +++ src/SketcherPrs/SketcherPrs_Tools.h | 4 ++ 4 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 17c316afc..d2b062bfd 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -55,36 +55,37 @@ void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManage gp_Pnt aPnt1, aPnt2; if (!getPoints(aPnt1, aPnt2)) return; - DataPtr aData = myConstraint->data(); - - AttributePtr aFlyOutAttribute = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); - if (!aFlyOutAttribute->isInitialized()) { - return; // not possible to show length because points are not defined - } - std::shared_ptr aFlyOutAttr = - std::dynamic_pointer_cast(aFlyOutAttribute); - std::shared_ptr aFlyoutPnt = myPlane->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()); - gp_Pnt aFlyPnt = aFlyoutPnt->impl(); - - double aDistance = aPnt1.Distance(aPnt2); - - double aFlyout = 0; - double aDist = 0.0; - if (aDistance < Precision::Confusion()) - aDist = aPnt1.Distance(aFlyPnt); - else { - gp_Lin aLine(aPnt1, gp_Vec(aPnt1, aPnt2)); - aDist = aLine.Distance(aFlyPnt); - } - - gp_XYZ aLineDir = aPnt2.XYZ().Subtracted(aPnt1.XYZ()); - gp_XYZ aFOutDir = aFlyPnt.XYZ().Subtracted(aPnt1.XYZ()); - gp_XYZ aNorm = myPlane->norm()->xyz()->impl(); - if (aLineDir.Crossed(aFOutDir).Dot(aNorm) < 0) - aDist = -aDist; - aFlyout = aDist; - - SetFlyout(aFlyout); + //DataPtr aData = myConstraint->data(); + + //AttributePtr aFlyOutAttribute = aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); + //if (!aFlyOutAttribute->isInitialized()) { + // return; // not possible to show length because points are not defined + //} + //std::shared_ptr aFlyOutAttr = + // std::dynamic_pointer_cast(aFlyOutAttribute); + //std::shared_ptr aFlyoutPnt = myPlane->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()); + //gp_Pnt aFlyPnt = aFlyoutPnt->impl(); + + //double aDistance = aPnt1.Distance(aPnt2); + + //double aFlyout = 0; + //double aDist = 0.0; + //if (aDistance < Precision::Confusion()) + // aDist = aPnt1.Distance(aFlyPnt); + //else { + // gp_Lin aLine(aPnt1, gp_Vec(aPnt1, aPnt2)); + // aDist = aLine.Distance(aFlyPnt); + //} + + //gp_XYZ aLineDir = aPnt2.XYZ().Subtracted(aPnt1.XYZ()); + //gp_XYZ aFOutDir = aFlyPnt.XYZ().Subtracted(aPnt1.XYZ()); + //gp_XYZ aNorm = myPlane->norm()->xyz()->impl(); + //if (aLineDir.Crossed(aFOutDir).Dot(aNorm) < 0) + // aDist = -aDist; + //aFlyout = aDist; + + //SetFlyout(aFlyout); + SetFlyout(SketcherPrs_Tools::getFlyoutDistance(myConstraint, myPlane)); SetMeasuredGeometry(aPnt1, aPnt2, myPlane->impl()); AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode); } diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index a3643fe08..6f3988036 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -83,7 +83,6 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the std::shared_ptr aNormal = myPlane->norm(); GeomAPI_Circ aCircle(aCenter, aNormal, aRadius); - //gp_Circ aCircle(gp_Ax2(aCenter->impl(), aNormal->impl()), aRadius); std::shared_ptr anAnchor = aCircle.project(aFlyoutPnt); std::shared_ptr anAnchorXYZ = anAnchor->xyz(); diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 8c28de0b0..94b98c295 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -142,4 +142,11 @@ void setArrowSize(double theSize) MyArrowSize = theSize; } +double getFlyoutDistance(const ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane) +{ + return 50; +} + + }; diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index 00a2e9663..bda6b2a73 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -10,6 +10,7 @@ #include "SketcherPrs.h" #include #include +#include #include #include #include @@ -60,6 +61,9 @@ enum SelectionModes { SKETCHERPRS_EXPORT double getArrowSize(); SKETCHERPRS_EXPORT void setArrowSize(double theSize); + + SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane); }; #endif -- 2.39.2