Salome HOME
Fix problem with unit tests on CentOS
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMirror.cpp
index 6381b2bd3dc8f85750cab74f798213a6d37bfb40..80cb647d874e80cae6625eab771336bb4a49107a 100644 (file)
@@ -2,8 +2,8 @@
 
 #include <SketchSolver_ConstraintMirror.h>
 #include <SketchSolver_Error.h>
-#include <SketchSolver_Manager.h>
 
+#include <PlaneGCSSolver_Tools.h>
 #include <PlaneGCSSolver_UpdateFeature.h>
 
 #include <GeomAPI_XY.h>
@@ -62,13 +62,6 @@ void SketchSolver_ConstraintMirror::getAttributes(
       myFeatures.insert(aFeature);
     }
   }
-  // add mirrored features to the list
-  aList = aMirroredRefList->list();
-  for (anIt = aList.begin(); anIt != aList.end(); ++anIt) {
-    FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
-    if (aFeature)
-      myFeatures.insert(aFeature);
-  }
 }
 
 void SketchSolver_ConstraintMirror::process()
@@ -93,18 +86,15 @@ void SketchSolver_ConstraintMirror::process()
 void SketchSolver_ConstraintMirror::update()
 {
   cleanErrorMsg();
-  remove();
-  process();
+  adjustConstraint();
 }
 
 void SketchSolver_ConstraintMirror::adjustConstraint()
 {
-  BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
-
   AttributeRefAttrPtr aMirrLineRefAttr =
       myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
   std::shared_ptr<GeomAPI_Lin2d> aMirrorLine =
-      aBuilder->line(ModelAPI_Feature::feature(aMirrLineRefAttr->object()));
+      PlaneGCSSolver_Tools::line(ModelAPI_Feature::feature(aMirrLineRefAttr->object()));
 
   AttributeRefListPtr aBaseRefList =
       myBaseConstraint->reflist(SketchPlugin_Constraint::ENTITY_B());
@@ -120,6 +110,10 @@ void SketchSolver_ConstraintMirror::adjustConstraint()
     FeaturePtr aBase = ModelAPI_Feature::feature(*aBIt);
     FeaturePtr aMirrored = ModelAPI_Feature::feature(*aMIt);
     mirrorEntities(aMirrorLine, aBase, aMirrored);
+
+    // update mirrored entity if it exists in the storage
+    if (myStorage->entity(aMirrored))
+      myStorage->update(aMirrored);
   }
 }
 
@@ -137,6 +131,16 @@ void SketchSolver_ConstraintMirror::blockEvents(bool isBlocked)
   for (; anIt != myFeatures.end(); ++anIt)
     (*anIt)->data()->blockSendAttributeUpdated(isBlocked);
 
+  AttributeRefListPtr aMirroredRefList =
+      myBaseConstraint->reflist(SketchPlugin_Constraint::ENTITY_C());
+  std::list<ObjectPtr> aMirroredList = aMirroredRefList->list();
+  std::list<ObjectPtr>::iterator aMIt = aMirroredList.begin();
+  for (; aMIt != aMirroredList.end(); ++aMIt) {
+    FeaturePtr aMirrored = ModelAPI_Feature::feature(*aMIt);
+    aMirrored->data()->blockSendAttributeUpdated(isBlocked);
+  }
+
+
   SketchSolver_Constraint::blockEvents(isBlocked);
 }
 
@@ -166,8 +170,8 @@ void mirrorEntities(const std::shared_ptr<GeomAPI_Lin2d>& theMirrorLine,
   // process specific features
   if (theOriginal->getKind() == SketchPlugin_Arc::ID()) {
     // orientation of arc
-    theMirrored->boolean(SketchPlugin_Arc::INVERSED_ID())->setValue(
-        !theOriginal->boolean(SketchPlugin_Arc::INVERSED_ID())->value());
+    theMirrored->boolean(SketchPlugin_Arc::REVERSED_ID())->setValue(
+        !theOriginal->boolean(SketchPlugin_Arc::REVERSED_ID())->value());
   } else if (theOriginal->getKind() == SketchPlugin_Circle::ID()) {
     // radius of the circle
     theMirrored->real(SketchPlugin_Circle::RADIUS_ID())->setValue(