]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Correct processing parameter given as a value of angle in Python script (issue #1899)
authorazv <azv@opencascade.com>
Mon, 5 Dec 2016 09:11:23 +0000 (12:11 +0300)
committerazv <azv@opencascade.com>
Mon, 5 Dec 2016 09:12:00 +0000 (12:12 +0300)
Change processing of the Angle constraint when parameter is given as its value.

src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchSolver/SketchSolver_ConstraintAngle.cpp
src/SketchSolver/SketchSolver_ConstraintAngle.h

index ffbf1bca9d621efda4b896acdd964e95a6e1dcc7..930828a68d9c3173996620db04c1b182738a9237 100644 (file)
@@ -492,7 +492,7 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngle(
   fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
       aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
   // fill the value before llines to avoid calculation of angle value by the Angle feature
-  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
+  fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
   aFeature->execute();
index e363ba32b14ee046fc487c36a42ee4f92b30dbf1..9743e651172399894cb791471910b701f8211752 100644 (file)
@@ -149,9 +149,9 @@ void SketchPlugin_ConstraintAngle::attributeChanged(const std::string& theID)
     myFlyoutUpdate = false;
   }
   else if (theID == SketchPlugin_ConstraintAngle::TYPE_ID()) {
-    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
     double anAngle = calculateAngle();
+    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+      ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::VALUE()));
     aValueAttr->setValue(anAngle);
   }
   else if (theID == SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()) {
@@ -190,11 +190,14 @@ double SketchPlugin_ConstraintAngle::calculateAngle()
   }
   double anAngle = anAng->angleDegree();
   std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::VALUE()));
+      ModelAPI_AttributeDouble>(data()->attribute(VALUE()));
+  std::shared_ptr<ModelAPI_AttributeDouble> anAngleValueAttr = std::dynamic_pointer_cast<
+      ModelAPI_AttributeDouble>(data()->attribute(ANGLE_VALUE_ID()));
   if (!aValueAttr->isInitialized())
     aValueAttr->setValue(anAngle);
   /// an angle value should be corrected by the current angle type
-  anAngle = getAngleForType(anAngle);
+  anAngle = getAngleForType(anAngleValueAttr->text().empty() ?
+                            anAngle : anAngleValueAttr->value());
   boolean(ANGLE_REVERSED_FIRST_LINE_ID())->setValue(anAng->isReversed(0));
   boolean(ANGLE_REVERSED_SECOND_LINE_ID())->setValue(anAng->isReversed(1));
   return anAngle;
index 7a6a4ac0f3efc3d059b2862a147de0abaa3b7dc3..f4207163b241f406bbe39f35116326f883fbaf44 100644 (file)
@@ -8,6 +8,10 @@
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_XY.h>
 
+#include <ModelAPI_AttributeInteger.h>
+
+#include <SketchPlugin_ConstraintAngle.h>
+
 #include <cmath>
 
 void SketchSolver_ConstraintAngle::getAttributes(
@@ -16,6 +20,7 @@ void SketchSolver_ConstraintAngle::getAttributes(
   SketchSolver_Constraint::getAttributes(theValue, theAttributes);
 
   myAngle = theValue;
+  myType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value();
 }
 
 
@@ -30,4 +35,10 @@ void SketchSolver_ConstraintAngle::adjustConstraint()
   myAngle = aConstraint->value();
   aBuilder->adjustConstraint(aConstraint);
   myStorage->addConstraint(myBaseConstraint, aConstraint);
+
+  int aType = myBaseConstraint->integer(SketchPlugin_ConstraintAngle::TYPE_ID())->value();
+  if (aType != myType) {
+    myType = aType;
+    myStorage->setNeedToResolve(true);
+  }
 }
index 3e979aa6d0b05d2f2b60e700709e7660f9f66b62..cff6937c39f2a54ff5e7cb0661e169b9232d5f6e 100644 (file)
@@ -33,6 +33,7 @@ protected:
 
 private:
   double myAngle;
+  int    myType;
 };
 
 #endif