]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3041: SIGSEGV when changing sketch plane
authorazv <azv@opencascade.com>
Wed, 16 Oct 2019 07:24:34 +0000 (10:24 +0300)
committerazv <azv@opencascade.com>
Wed, 16 Oct 2019 07:24:34 +0000 (10:24 +0300)
Update direction for horizontal/vertical distance.

src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.h

index 6f1179f59a1263b0c1f8a71b59b6552de8facf51..d4178917e8194b586d8d92e2403940328d23ba04 100644 (file)
@@ -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<gp_Dir>(), true);
-  else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
-    SetDirection(plane()->dirY()->impl<gp_Dir>(), 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<GeomAPI_Ax3>& thePlane)
+{
+#ifdef OCCT_28850_FIXED
+  if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
+    SetDirection(thePlane->dirX()->impl<gp_Dir>(), true);
+  else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
+    SetDirection(thePlane->dirY()->impl<gp_Dir>(), true);
+#endif
+}
index 469a63c3d52646e88c52e36a888292a0db36b758..43a27c71787e7f746145e5b38af1c86f395a7048 100644 (file)
@@ -83,6 +83,10 @@ private:
                              const std::shared_ptr<GeomAPI_Ax3>& thePlane,
                              gp_Pnt& thePnt1, gp_Pnt& thePnt2);
 
+  /// Set the direction for horizontal/vertical constraint
+  void setDirection(ModelAPI_Feature* theConstraint,
+                    const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
   /// Constraint feature
   ModelAPI_Feature* myConstraint;