X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Listener.cpp;h=f66ac66b4d4c9b85bf70c37870dbe73d5b2ecc92;hb=2833d61c7ee9a9d8b3f212e8b06fbd5375197c0a;hp=dcddad6076aa6a080a5ea21ecbf662c660861be6;hpb=7a2548dc3e5e536f6325d0e8c9913c7fd53da4e3;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index dcddad607..f66ac66b4 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -5,15 +5,18 @@ #include #include +#include +#include #include #include +#include + +#include #include #include -#include - #ifdef _DEBUG #include #endif @@ -21,10 +24,10 @@ using namespace std; PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) -: myModule(theModule) + : myModule(theModule) { Events_Loop* aLoop = Events_Loop::loop(); - aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_UPDATED)); + 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)); } @@ -34,41 +37,52 @@ PartSet_Listener::~PartSet_Listener() } //****************************************************** -void PartSet_Listener::processEvent(const Events_Message* theMessage) +void PartSet_Listener::processEvent(const boost::shared_ptr& theMessage) { + 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_UPDATED || - aType == EVENT_OBJECT_CREATED) - { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); - std::set aFeatures = aUpdMsg->objects(); - std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + if (aType == EVENT_OBJECT_CREATED) { + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); + std::set aFeatures = aUpdMsg->objects(); + + PartSet_OperationSketch* aSketchOp = + dynamic_cast(myModule->workshop()->operationMgr()->currentOperation()); + + 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->visualizePreview(aFeature->firstResult(), true, false); - //if (aType == EVENT_OBJECT_CREATED) - myModule->activateFeature(aFeature, true); - } + ObjectPtr aObj = (*anIt); + aDisplayer->deactivate(aObj); + boost::shared_ptr aFeature = + boost::dynamic_pointer_cast(aObj); + if (aFeature && (aFeature->getKind() == "Sketch")) // Activate sketcher for planes selection + myModule->activateFeature(aFeature, false); + // If current operation is Sketch then there is no active sketching operation + // and possible the object was created by Redo operatgion + else if (aSketchOp) { + XGUI_Displayer* aDisplayer = myModule->workshop()->displayer(); + // Very possible it is not displayed + aDisplayer->display(aObj, false); + std::list aModes = aSketchOp->getSelectionModes(aObj); + aDisplayer->activateInLocalContext(aObj, aModes, false); } } - myModule->workshop()->displayer()->updateViewer(); - } - if (aType == EVENT_OBJECT_DELETED) - { - const ModelAPI_ObjectDeletedMessage* aDelMsg = - dynamic_cast(theMessage); + + } 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(SKETCH_KIND) == 0) { // Update only Sketch group + if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group myModule->workshop()->displayer()->eraseDeletedResults(); myModule->updateCurrentPreview(aGroup); }