X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Listener.cpp;h=af017fbbaa54d542bd1b7d1d79a53c552ddeeda6;hb=09360d321e48c3749afa582c0958a28ea7bf9200;hp=06af416d2126fd71e46db484992169a55ae4e3f5;hpb=cd942c062815dd044cf0625fc987d3244d7954c7;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 06af416d2..af017fbba 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -7,9 +7,12 @@ #include #include +#include #include -#include +#include + +#include #ifdef _DEBUG #include @@ -21,9 +24,9 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) : myModule(theModule) { Events_Loop* aLoop = Events_Loop::loop(); - 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)); + aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); } PartSet_Listener::~PartSet_Listener() @@ -34,27 +37,40 @@ PartSet_Listener::~PartSet_Listener() void PartSet_Listener::processEvent(const Events_Message* theMessage) { QString aType = QString(theMessage->eventID().eventText()); - if (aType == EVENT_FEATURE_UPDATED || - aType == EVENT_FEATURE_CREATED) + if (aType == EVENT_OBJECT_UPDATED || + aType == EVENT_OBJECT_CREATED) { - const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); - boost::shared_ptr aFeature = aUpdMsg->feature(); - if (myModule->workshop()->displayer()->IsVisible(aFeature) || - aType == EVENT_FEATURE_CREATED) { - myModule->visualizePreview(aFeature, true, false); - myModule->activateFeature(aFeature, true); - myModule->workshop()->displayer()->UpdateViewer(); + const ModelAPI_ObjectUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); + std::set aFeatures = aUpdMsg->objects(); + std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + for (; anIt != aLast; anIt++) { + ObjectPtr aObject = *anIt; + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); + if (aFeature) { + if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) || + aType == EVENT_OBJECT_CREATED) { + myModule->activateFeature(aFeature, true); + // TODO myModule->visualizePreview(aFeature, true, false); + } + } } + myModule->workshop()->displayer()->updateViewer(); } - if (aType == EVENT_FEATURE_DELETED) + if (aType == EVENT_OBJECT_DELETED) { - const Model_FeatureDeletedMessage* aDelMsg = dynamic_cast(theMessage); + const ModelAPI_ObjectDeletedMessage* aDelMsg = + dynamic_cast(theMessage); boost::shared_ptr aDoc = aDelMsg->document(); - std::string aGroup = aDelMsg->group(); - if (aDelMsg->group().compare("Sketch") == 0) { // Update only Sketch group - myModule->workshop()->displayer()->EraseDeletedFeatures(); - myModule->updateCurrentPreview(aGroup); + 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(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group + myModule->workshop()->displayer()->eraseDeletedResults(); + myModule->updateCurrentPreview(aGroup); + } } } }