From: mpv Date: Tue, 17 Feb 2015 11:03:53 +0000 (+0300) Subject: Issue 396: removed constraint did not disappear in the viewer X-Git-Tag: V_1.1.0~176^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9e117aef205c7ee70ff7e6342c5b863726e58764;p=modules%2Fshaper.git Issue 396: removed constraint did not disappear in the viewer --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 762dff5fa..fe4a17309 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -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 > aRefs; + refsToFeature(theFeature, aRefs, false); + std::set >::iterator aRefIter = aRefs.begin(); + for(; aRefIter != aRefs.end(); aRefIter++) { + std::shared_ptr aComposite = + std::dynamic_pointer_cast(*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 diff --git a/src/ModelAPI/ModelAPI_CompositeFeature.h b/src/ModelAPI/ModelAPI_CompositeFeature.h index df78236d9..f243cb333 100644 --- a/src/ModelAPI/ModelAPI_CompositeFeature.h +++ b/src/ModelAPI/ModelAPI_CompositeFeature.h @@ -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 theFeature) = 0; }; //! Pointer on the composite feature object diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 7a50ef4e3..549586efb 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -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: diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 67fd1be89..624ac16ab 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -133,7 +133,7 @@ std::shared_ptr SketchPlugin_Sketch::addFeature(std::string th return aNew; } -void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature) +void SketchPlugin_Sketch::removeFeature(std::shared_ptr 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 aFeature = std::dynamic_pointer_cast(*aSubIt); - if (aFeature.get() != NULL && aFeature.get() == theFeature) { + if (aFeature.get() != NULL && aFeature == theFeature) { data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(aFeature); isRemoved = true; } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index cb3efbea6..801b866c9 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -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 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 theFeature); /// Returns the number of sub-elements SKETCHPLUGIN_EXPORT virtual int numberOfSubs() const;