Salome HOME
Improvement #1140: Display of replicated Sketch entities with thinner line
authordbv <dbv@opencascade.com>
Thu, 24 Dec 2015 14:34:23 +0000 (17:34 +0300)
committerdbv <dbv@opencascade.com>
Thu, 24 Dec 2015 14:34:23 +0000 (17:34 +0300)
Line thickness now restored after constraint delete

src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchPlugin/SketchPlugin_ConstraintMirror.h

index bfcbf14e72d2110bfa7e03e8f800406fc55a0af9..7539c18e38ab868e7a4c6c327130ec435eb141cb 100755 (executable)
@@ -195,6 +195,37 @@ AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePreviou
   return anAIS;
 }
 
+void SketchPlugin_ConstraintMirror::erase()
+{
+  // Set copy attribute to false on all copied features.
+  AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+      data()->attribute(SketchPlugin_Constraint::ENTITY_C()));
+
+  if(aRefListOfMirrored.get()) {
+    static Events_Loop* aLoop = Events_Loop::loop();
+    static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
+    std::list<ObjectPtr> aTargetList = aRefListOfMirrored->list();
+    for(std::list<ObjectPtr>::const_iterator aTargetIt = aTargetList.cbegin(); aTargetIt != aTargetList.cend(); aTargetIt++) {
+      if((*aTargetIt).get()) {
+        ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(*aTargetIt);
+        if(aRes.get()) {
+          FeaturePtr aFeature = aRes->document()->feature(aRes);
+          if(aFeature.get()) {
+            AttributeBooleanPtr aBooleanAttr = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID());
+            if(aBooleanAttr.get()) {
+              aBooleanAttr->setValue(false);
+              // Redisplay object as it is not copy anymore.
+              ModelAPI_EventCreator::get()->sendUpdated(aRes, aRedispEvent);
+            }
+          }
+        }
+      }
+    }
+  }
+
+  SketchPlugin_ConstraintBase::erase();
+}
 
 void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID)
 {
index 5ae07ac19686ea40bc994a5a99481f4af84d22e0..70bb78793ae6ddfb9a0ca4f9045f962ea7a9097a 100644 (file)
@@ -58,6 +58,9 @@ class SketchPlugin_ConstraintMirror : public SketchPlugin_ConstraintBase
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
+  /// removes all fields from this feature: results, data, etc
+  SKETCHPLUGIN_EXPORT virtual void erase();
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintMirror();
 };