X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Listener.cpp;h=1f3505ee771821645ce24f312f47364718f4e481;hb=ac8b1dc043f53cbf4f9c2a368e0c214669c21176;hp=580186b567b1d3cde612fe1802bb91aa9da2b11a;hpb=8396394eba586fc212fe4cb3e1e838a54ebf4ffe;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 580186b56..1f3505ee7 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -6,9 +6,13 @@ #include +#include + #include #include +#include + #ifdef _DEBUG #include #endif @@ -19,8 +23,9 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) : myModule(theModule) { Events_Loop* aLoop = Events_Loop::loop(); - Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED); - aLoop->registerListener(this, aFeatureUpdatedId); + aLoop->registerListener(this, aLoop->eventByName(EVENT_FEATURE_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); } PartSet_Listener::~PartSet_Listener() @@ -30,8 +35,38 @@ PartSet_Listener::~PartSet_Listener() //****************************************************** void PartSet_Listener::processEvent(const Events_Message* theMessage) { - if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_UPDATED) + QString aType = QString(theMessage->eventID().eventText()); + if (aType == EVENT_FEATURE_UPDATED || + aType == EVENT_FEATURE_CREATED) { - myModule->visualizePreview(true); + const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast + (theMessage); + std::set aFeatures = aUpdMsg->features(); + std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + for (; anIt != aLast; anIt++) { + FeaturePtr aFeature = *anIt; + if (myModule->workshop()->displayer()->isVisible(aFeature) || + aType == EVENT_FEATURE_CREATED) { + myModule->visualizePreview(aFeature, true, false); + //if (aType == EVENT_FEATURE_CREATED) + myModule->activateFeature(aFeature, true); + } + } + myModule->workshop()->displayer()->updateViewer(); + } + if (aType == EVENT_FEATURE_DELETED) + { + const Model_FeatureDeletedMessage* aDelMsg = dynamic_cast(theMessage); + boost::shared_ptr aDoc = aDelMsg->document(); + + std::set aGroups = aDelMsg->groups(); + std::set::const_iterator anIt = aGroups.begin(), aLast = aGroups.end(); + for (; anIt != aLast; anIt++) { + std::string aGroup = *anIt; + if (aGroup.compare(SKETCH_KIND) == 0) { // Update only Sketch group + myModule->workshop()->displayer()->eraseDeletedFeatures(); + myModule->updateCurrentPreview(aGroup); + } + } } }