From 1aec7553fb552bb5e88babe7313bb783b407abb0 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 16 Oct 2019 10:24:34 +0300 Subject: [PATCH] Issue #3041: SIGSEGV when changing sketch plane Update direction for horizontal/vertical distance. --- .../SketcherPrs_LengthDimension.cpp | 20 +++++++++++++------ src/SketcherPrs/SketcherPrs_LengthDimension.h | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 6f1179f59..d4178917e 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -122,12 +122,7 @@ SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theCo SetDimensionAspect(createDimensionAspect()); myStyleListener = new SketcherPrs_DimensionStyleListener(); -#ifdef OCCT_28850_FIXED - if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID()) - SetDirection(plane()->dirX()->impl(), true); - else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID()) - SetDirection(plane()->dirY()->impl(), true); -#endif + setDirection(theConstraint, plane()); } SketcherPrs_LengthDimension::~SketcherPrs_LengthDimension() @@ -166,6 +161,8 @@ void SketcherPrs_LengthDimension::Compute( else anAttributeValue = aData->real(SketchPlugin_Constraint::VALUE()); myValue.init(anAttributeValue); + + setDirection(myConstraint, plane()); } // compute flyout distance @@ -318,3 +315,14 @@ void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Select SetSelToleranceForText2d(SketcherPrs_Tools::getArrowSize()/5.); AIS_LengthDimension::ComputeSelection(aSelection, aMode); } + +void SketcherPrs_LengthDimension::setDirection(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane) +{ +#ifdef OCCT_28850_FIXED + if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID()) + SetDirection(thePlane->dirX()->impl(), true); + else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID()) + SetDirection(thePlane->dirY()->impl(), true); +#endif +} diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.h b/src/SketcherPrs/SketcherPrs_LengthDimension.h index 469a63c3d..43a27c717 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.h +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.h @@ -83,6 +83,10 @@ private: const std::shared_ptr& thePlane, gp_Pnt& thePnt1, gp_Pnt& thePnt2); + /// Set the direction for horizontal/vertical constraint + void setDirection(ModelAPI_Feature* theConstraint, + const std::shared_ptr& thePlane); + /// Constraint feature ModelAPI_Feature* myConstraint; -- 2.39.2