From: nds Date: Tue, 4 Apr 2017 11:23:11 +0000 (+0300) Subject: Issue #2024 Redesign of circle and arc of circle: message of reentrant Line should... X-Git-Tag: V_2.7.0~85 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2ec923d13396d1aad7994d719fa1b03f9cbbc97d;p=modules%2Fshaper.git Issue #2024 Redesign of circle and arc of circle: message of reentrant Line should not be processed in Horizontal reentrant feature --- diff --git a/src/ModelAPI/ModelAPI_EventReentrantMessage.h b/src/ModelAPI/ModelAPI_EventReentrantMessage.h index ded9c8b99..381b4a9bd 100644 --- a/src/ModelAPI/ModelAPI_EventReentrantMessage.h +++ b/src/ModelAPI/ModelAPI_EventReentrantMessage.h @@ -26,7 +26,7 @@ class ModelAPI_EventReentrantMessage : public Events_Message public: /// Creates an empty message MODELAPI_EXPORT ModelAPI_EventReentrantMessage(const Events_ID theID, - const void* theSender = 0); + const void* theSender); /// The virtual destructor MODELAPI_EXPORT virtual ~ModelAPI_EventReentrantMessage() {} /// Static. Returns EventID of the message. diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index 1eff37835..d0de78c04 100755 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -12,10 +12,12 @@ #include #include +#include "XGUI_CustomPrs.h" +#include "XGUI_Displayer.h" #include "XGUI_ModuleConnector.h" +#include "XGUI_OperationMgr.h" +#include "XGUI_Tools.h" #include "XGUI_Workshop.h" -#include "XGUI_Displayer.h" -#include "XGUI_CustomPrs.h" #include "SketcherPrs_SymbolPrs.h" #include "SketchPlugin_SketchEntity.h" @@ -154,9 +156,34 @@ void PartSet_OverconstraintListener::processEvent( } else if (anEventID == ModelAPI_EventReentrantMessage::eventId() || anEventID == SketchPlugin_MacroArcReentrantMessage::eventId()) { - PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); - PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr(); - aReentrantMgr->setReentrantMessage(theMessage); + // the message is sent to sketcher reentrant manager only if the kind of feature + // sender is equal to kind of the current operation. E.g. Horizontal create operation + // is active. Sketch Line feature is changed, so execute is called, it will send message + // This Line's message should not be processed, as the reentrant operation is not for Line + std::string aCurrentFeatureKind; + ModuleBase_Operation* anOperation = + XGUI_Tools::workshop(myWorkshop)->operationMgr()->currentOperation(); + if (anOperation) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (anOperation); + if (aFOperation) { + FeaturePtr aFeature = aFOperation->feature(); + if (aFeature.get()) + aCurrentFeatureKind = aFeature->getKind(); + } + } + if (theMessage->sender()) { + ModelAPI_Object* aSender = static_cast(theMessage->sender()); + if (aSender) { + FeaturePtr aFeatureSender = + std::dynamic_pointer_cast(aSender->data()->owner()); + if (aFeatureSender.get() && aFeatureSender->getKind() == aCurrentFeatureKind) { + PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); + PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr(); + aReentrantMgr->setReentrantMessage(theMessage); + } + } + } } #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 5760a866f..7c3f528d5 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -70,7 +70,7 @@ void SketchPlugin_Line::execute() static Events_ID anId = ModelAPI_EventReentrantMessage::eventId(); std::shared_ptr aMessage = std::shared_ptr - (new ModelAPI_EventReentrantMessage(anId, 0)); + (new ModelAPI_EventReentrantMessage(anId, this)); aMessage->setCreatedFeature(ModelAPI_Feature::feature( data()->attribute(START_ID())->owner())); Events_Loop::loop()->send(aMessage); diff --git a/src/SketchPlugin/SketchPlugin_MacroArc.cpp b/src/SketchPlugin/SketchPlugin_MacroArc.cpp index e963cfe14..54c2f64b7 100644 --- a/src/SketchPlugin/SketchPlugin_MacroArc.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroArc.cpp @@ -355,7 +355,7 @@ void SketchPlugin_MacroArc::execute() // message to init reentrant operation static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId(); std::shared_ptr aMessage = std::shared_ptr - (new SketchPlugin_MacroArcReentrantMessage(anId, 0)); + (new SketchPlugin_MacroArcReentrantMessage(anId, this)); std::string anEditArcType = string(EDIT_ARC_TYPE_ID())->value(); aMessage->setTypeOfCreation(!anEditArcType.empty() ? anEditArcType : anArcType); diff --git a/src/SketchPlugin/SketchPlugin_MacroArcReentrantMessage.h b/src/SketchPlugin/SketchPlugin_MacroArcReentrantMessage.h index 5ad9a8ca1..942e9f9c3 100644 --- a/src/SketchPlugin/SketchPlugin_MacroArcReentrantMessage.h +++ b/src/SketchPlugin/SketchPlugin_MacroArcReentrantMessage.h @@ -21,7 +21,7 @@ class SketchPlugin_MacroArcReentrantMessage : public ModelAPI_EventReentrantMess public: /// Creates an empty message SKETCHPLUGIN_EXPORT SketchPlugin_MacroArcReentrantMessage(const Events_ID theID, - const void* theSender = 0) + const void* theSender) : ModelAPI_EventReentrantMessage(theID, theSender) {} /// The virtual destructor SKETCHPLUGIN_EXPORT virtual ~SketchPlugin_MacroArcReentrantMessage() {} diff --git a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp index 047b5aea8..3af61c721 100644 --- a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp @@ -97,7 +97,7 @@ void SketchPlugin_MacroCircle::execute() // message to init reentrant operation static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId(); std::shared_ptr aMessage = std::shared_ptr - (new SketchPlugin_MacroArcReentrantMessage(anId, 0)); + (new SketchPlugin_MacroArcReentrantMessage(anId, this)); std::string anEditType = string(EDIT_CIRCLE_TYPE())->value(); aMessage->setTypeOfCreation(!anEditType.empty() ? anEditType : aType); diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index 986b99b30..4e6066837 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -467,7 +467,7 @@ void SketchPlugin_Trim::execute() if (aPreviewObject.get()) { std::shared_ptr aMessage = std::shared_ptr (new ModelAPI_EventReentrantMessage( - ModelAPI_EventReentrantMessage::eventId(), 0)); + ModelAPI_EventReentrantMessage::eventId(), this)); aMessage->setSelectedObject(aPreviewObject); Events_Loop::loop()->send(aMessage); }