From 5634b7fa55dde2f2d2e5b3e4535516cb50464d8e Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 15 Jul 2014 17:55:51 +0400 Subject: [PATCH] Call redisplay for results change and delete --- src/Model/Model_Document.cpp | 36 ++++++++++++++++++++++++++++++++---- src/Model/Model_Update.cpp | 9 ++++++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index ed3846d73..210195844 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -425,6 +425,15 @@ void Model_Document::removeFeature(FeaturePtr theFeature) // 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 >& aResults = theFeature->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + boost::shared_ptr aRes = *aRIter; + aRes->setData(boost::shared_ptr()); // deleted flag + ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); + } } /// returns the object group name by the object label @@ -594,9 +603,10 @@ void Model_Document::setUniqueName(FeaturePtr theFeature) 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(object(ModelAPI_Feature::group(), a))-> + if (boost::dynamic_pointer_cast(myObjs[ModelAPI_Feature::group()][a])-> getKind() == theFeature->getKind()) aNumObjects++; } @@ -606,8 +616,17 @@ void Model_Document::setUniqueName(FeaturePtr theFeature) aName = aNameStream.str(); // check this is unique, if not, increase index by 1 for(a = 0; a < aSize;) { - if (boost::dynamic_pointer_cast(object(ModelAPI_Feature::group(), a)) - ->data()->name() == aName) { + FeaturePtr aFeature = + boost::dynamic_pointer_cast(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 >& aResults = aFeature->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + isSameName = (*aRIter)->isInHistory() && (*aRIter)->data()->name() == aName; + } + } + if (isSameName) { aNumObjects++; std::stringstream aNameStream; aNameStream<getKind()<<"_"<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 >& aResults = boost::dynamic_pointer_cast(anObj)->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + boost::shared_ptr aRes = *aRIter; + aRes->setData(boost::shared_ptr()); // 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(); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 25ecbbeb5..15b8139ec 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include using namespace std; @@ -84,8 +85,14 @@ bool Model_Update::updateObject(boost::shared_ptr theObject) 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 >& aResults = aRealFeature->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + boost::shared_ptr aRes = *aRIter; + ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); + } } } myUpdated[theObject] = anExecute; -- 2.39.2