]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue 396: removed constraint did not disappear in the viewer
authormpv <mpv@opencascade.com>
Tue, 17 Feb 2015 11:03:53 +0000 (14:03 +0300)
committermpv <mpv@opencascade.com>
Tue, 17 Feb 2015 11:03:53 +0000 (14:03 +0300)
src/Model/Model_Document.cpp
src/ModelAPI/ModelAPI_CompositeFeature.h
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index 762dff5fa852d28b61d29b066954bba52def6e91..fe4a17309aa4b432fa244af8b4a55000730981e9 100644 (file)
@@ -651,17 +651,32 @@ void Model_Document::removeFeature(FeaturePtr theFeature/*, const bool theCheck*
       myObjs.UnBind(aFeatureLabel);
     else
       return;  // not found feature => do not remove
+
+    // checking that the sub-element of composite feature is removed: if yes, inform the owner
+    std::set<std::shared_ptr<ModelAPI_Feature> > aRefs;
+    refsToFeature(theFeature, aRefs, false);
+    std::set<std::shared_ptr<ModelAPI_Feature> >::iterator aRefIter = aRefs.begin();
+    for(; aRefIter != aRefs.end(); aRefIter++) {
+      std::shared_ptr<ModelAPI_CompositeFeature> aComposite = 
+        std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*aRefIter);
+      if (aComposite.get()) {
+        aComposite->removeFeature(theFeature);
+      }
+    }
+
     // erase fields
     theFeature->erase();
+    static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+    ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
     // erase all attributes under the label of feature
     aFeatureLabel.ForgetAllAttributes();
     // remove it from the references array
     if (theFeature->isInHistory()) {
       RemoveFromRefArray(featuresLabel(), aFeatureLabel);
     }
+    // event: feature is deleted
+    ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
   }
-  // event: feature is deleted
-  ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
 }
 
 FeaturePtr Model_Document::feature(TDF_Label& theLabel) const
index df78236d98e2a124d40c7ad632fb35e559821329..f243cb3338bec21e2e6728846c097efc249f054b 100644 (file)
@@ -35,6 +35,10 @@ public:
 
   /// Returns true if feature or reuslt belong to this composite feature as subs
   virtual bool isSub(ObjectPtr theObject) const = 0;
+
+  /// This method to inform that sub-feature is removed and must be removed from the internal data
+  /// structures of the owner (the remove from the document will be done outside just after)
+  virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
 };
 
 //! Pointer on the composite feature object
index 7a50ef4e3369b1cc7b372a6ff1c36be91012851e..549586efb5b139f0a2af3585d66a5f4715bad7d7 100644 (file)
@@ -78,16 +78,6 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
     //  thePrs->setPointMarker(6, 2.);
   }
 
-  /// removes also all sub-sketch elements
-  SKETCHPLUGIN_EXPORT virtual void erase()
-  {
-    /*SketchPlugin_Sketch* aSketch = sketch();
-    if (aSketch)
-      aSketch->removeFeature(this);
-      */
-    ModelAPI_Feature::erase();
-  }
-
   /// Returns the sketch of this feature
   SketchPlugin_Sketch* sketch();
 protected:
index 67fd1be899f23b7c4835f135abe87ed7b749f1b7..624ac16ab6d48455065bc0c226959764e7b0483a 100644 (file)
@@ -133,7 +133,7 @@ std::shared_ptr<ModelAPI_Feature> SketchPlugin_Sketch::addFeature(std::string th
   return aNew;
 }
 
-void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature)
+void SketchPlugin_Sketch::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
 {
   if (!data().get()) // sketch is already removed (case on undo of sketch), sync is not needed
     return;
@@ -143,7 +143,7 @@ void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature)
   bool aHasEmtpyFeature = false;
   for(; aSubIt != aLastIt && !isRemoved; aSubIt++) {
     std::shared_ptr<ModelAPI_Feature> aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aSubIt);
-    if (aFeature.get() != NULL && aFeature.get() == theFeature) {
+    if (aFeature.get() != NULL && aFeature == theFeature) {
       data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(aFeature);
       isRemoved = true;
     }
index cb3efbea6864f5cdc90751c99b056ed842421587..801b866c98c7437515ca1f190cd119baa989cac8 100644 (file)
@@ -110,8 +110,8 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I
   /// appends a feature to the sketch sub-elements container
   SKETCHPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
 
-  /// appends a feature from the sketch sub-elements container
-  SKETCHPLUGIN_EXPORT virtual void removeFeature(ModelAPI_Feature* theFeature);
+  /// Just to synchronise the container of sub-features
+  virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
 
   /// Returns the number of sub-elements
   SKETCHPLUGIN_EXPORT virtual int numberOfSubs() const;