// event: feature is deleted
ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
+ // 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();
+ 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);
+ }
}
/// returns the object group name by the object label
std::string aName; // result
// first count all objects of such kind to start with index = count + 1
int a, aNumObjects = 0;
- int aSize = size(ModelAPI_Feature::group());
+ int aSize = myObjs.find(ModelAPI_Feature::group()) == myObjs.end() ?
+ 0 : myObjs[ModelAPI_Feature::group()].size();
for(a = 0; a < aSize; a++) {
- if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(ModelAPI_Feature::group(), a))->
+ if (boost::dynamic_pointer_cast<ModelAPI_Feature>(myObjs[ModelAPI_Feature::group()][a])->
getKind() == theFeature->getKind())
aNumObjects++;
}
aName = aNameStream.str();
// check this is unique, if not, increase index by 1
for(a = 0; a < aSize;) {
- if (boost::dynamic_pointer_cast<ModelAPI_Feature>(object(ModelAPI_Feature::group(), a))
- ->data()->name() == aName) {
+ FeaturePtr aFeature =
+ boost::dynamic_pointer_cast<ModelAPI_Feature>(myObjs[ModelAPI_Feature::group()][a]);
+ bool isSameName = aFeature->isInHistory() && aFeature->data()->name() == aName;
+ if (!isSameName) { // check also results to avoid same results names (actual for Parts)
+ 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++) {
+ isSameName = (*aRIter)->isInHistory() && (*aRIter)->data()->name() == aName;
+ }
+ }
+ if (isSameName) {
aNumObjects++;
std::stringstream aNameStream;
aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
}
ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName);
+ // results of this feature must be redisplayed (hided)
+ static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = boost::dynamic_pointer_cast<ModelAPI_Feature>(anObj)->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);
+ }
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
TDF_Label aLab = aLabIter.Value()->Label();
#include <ModelAPI_Events.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Result.h>
#include <Events_Loop.h>
using namespace std;
anExecute = aMustbeUpdated || anExecute;
if (anExecute) {
aRealFeature->execute();
+ // redisplay all results
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(theObject, EVENT_DISP);
+ const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aRealFeature->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;
+ ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
+ }
}
}
myUpdated[theObject] = anExecute;