X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Listener.cpp;h=be392c0097207ca07c38d6ac1f2fa3f302bf005e;hb=02bc870879ae19215d5ef6f721acd5b12d245473;hp=3e1c4886a78f352827be6aadb1a0727f45f02a33;hpb=719f3932991137a0c1d054ee9051fd1ae4eac3ac;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 3e1c4886a..be392c009 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -5,11 +5,18 @@ #include #include +#include #include +#include +#include + +#include #include -#include +#include + +#include #ifdef _DEBUG #include @@ -18,11 +25,12 @@ using namespace std; PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) -: myModule(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_OBJECT_TO_REDISPLAY)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); } PartSet_Listener::~PartSet_Listener() @@ -30,13 +38,40 @@ PartSet_Listener::~PartSet_Listener() } //****************************************************** -void PartSet_Listener::processEvent(const Events_Message* theMessage) +void PartSet_Listener::processEvent(const boost::shared_ptr& theMessage) { - if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_UPDATED) - { - const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); - boost::shared_ptr aFeature = aUpdMsg->feature(); - if (myModule->workshop()->displayer()->IsVisible(aFeature)) - myModule->visualizePreview(aFeature, true); + ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation(); + PartSet_OperationSketchBase* aSketchOp = dynamic_cast(anOperation); + if (!aSketchOp) + return; + + XGUI_Displayer* aDisplayer = myModule->workshop()->displayer(); + QString aType = QString(theMessage->eventID().eventText()); + if (aType == EVENT_OBJECT_CREATED) { + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); + std::set aFeatures = aUpdMsg->objects(); + std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + for (; anIt != aLast; anIt++) { + aDisplayer->deactivate(*anIt); + FeaturePtr aFeature = boost::dynamic_pointer_cast(*anIt); + if (aFeature) + myModule->activateFeature(aFeature, false); + } + + } else if (aType == EVENT_OBJECT_DELETED) { + boost::shared_ptr aDelMsg = + boost::dynamic_pointer_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(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group + myModule->workshop()->displayer()->eraseDeletedResults(); + myModule->updateCurrentPreview(aGroup); + } + } } }