void Model_Document::removeFeature(FeaturePtr theFeature)
{
+ // check the feature: it must have no depended objects on it
+ std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
+ for(; aResIter != theFeature->results().cend(); aResIter++) {
+ if (myConcealedResults.find(*aResIter) != myConcealedResults.end()) {
+ Events_Error::send("Feature '" + theFeature->data()->name() + "' is used and can not be deleted");
+ return;
+ }
+ }
boost::shared_ptr<Model_Data> aData = boost::static_pointer_cast<Model_Data>(theFeature->data());
TDF_Label aFeatureLabel = aData->label().Father();
if (myObjs.IsBound(aFeatureLabel))
myObjs.UnBind(aFeatureLabel);
else
return; // not found feature => do not remove
-
+ // erase fields
+ theFeature->erase();
// erase all attributes under the label of feature
aFeatureLabel.ForgetAllAttributes();
// remove it from the references array
// event: feature is deleted
ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
+ /* this is in "erase"
// results of this feature must be redisplayed
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName());
}
+ */
}
FeaturePtr Model_Document::feature(TDF_Label& theLabel)
static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+ /*
for (; aRIter != aResults.cend(); aRIter++) {
boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
//aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
ModelAPI_EventCreator::get()->sendDeleted(aThis, aRes->groupName());
}
+ */
// redisplay also removed feature (used for sketch and AISObject)
ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP);
+ aFeature->erase();
} else
aFIter.Next();
}
boost::shared_ptr<ModelAPI_Document> aThis =
Model_Application::getApplication()->getDocument(myID);
ModelAPI_EventCreator::get()->sendDeleted(aThis, ModelAPI_ResultBody::group());
+
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+ aECreator->sendUpdated(aResult, EVENT_DISP);
}
}
}
if (aResult) {
std::set<ResultPtr>::iterator aFind = myConcealedResults.find(aResult);
if (aFind != myConcealedResults.end()) {
+ ResultPtr aFeature = *aFind;
myConcealedResults.erase(aFind);
boost::shared_ptr<ModelAPI_Document> aThis =
Model_Application::getApplication()->getDocument(myID);
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
- ModelAPI_EventCreator::get()->sendUpdated(*aFind, anEvent, false);
+ ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent, false);
} else {
Events_Error::send(std::string("The object '") + aResult->data()->name() +
"' was not referenced '");