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
/// 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
// 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:
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;
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;
}
/// 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;