]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2024 Redesign of circle and arc of circle: message of reentrant Line should...
authornds <nds@opencascade.com>
Tue, 4 Apr 2017 11:23:11 +0000 (14:23 +0300)
committernds <nds@opencascade.com>
Tue, 4 Apr 2017 11:23:11 +0000 (14:23 +0300)
src/ModelAPI/ModelAPI_EventReentrantMessage.h
src/PartSet/PartSet_OverconstraintListener.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_MacroArc.cpp
src/SketchPlugin/SketchPlugin_MacroArcReentrantMessage.h
src/SketchPlugin/SketchPlugin_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_Trim.cpp

index ded9c8b999f85275121531e1292e4f98d29c5d2a..381b4a9bde74c1da1f910aa3e13bd6ca0751a9e3 100644 (file)
@@ -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.
index 1eff378359d69529ff52eba32e640742b7a9a680..d0de78c04d9b6eb02430594c34384ccd382d4b1d 100755 (executable)
 #include <PartSet_SketcherMgr.h>
 #include <PartSet_SketcherReentrantMgr.h>
 
+#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<PartSet_Module*>(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<ModuleBase_OperationFeature*>
+                                                           (anOperation);
+      if (aFOperation) {
+        FeaturePtr aFeature = aFOperation->feature();
+        if (aFeature.get())
+          aCurrentFeatureKind = aFeature->getKind();
+      }
+    }
+    if (theMessage->sender()) {
+      ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theMessage->sender());
+      if (aSender) {
+        FeaturePtr aFeatureSender =
+          std::dynamic_pointer_cast<ModelAPI_Feature>(aSender->data()->owner());
+        if (aFeatureSender.get() && aFeatureSender->getKind() == aCurrentFeatureKind) {
+          PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+          PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
+          aReentrantMgr->setReentrantMessage(theMessage);
+        }
+      }
+    }
   }
 
 #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
index 5760a866f92da39fbd94002d8f7d2299e163c886..7c3f528d50330ded1ed7bf8ad97efefb0100e1a7 100644 (file)
@@ -70,7 +70,7 @@ void SketchPlugin_Line::execute()
 
       static Events_ID anId = ModelAPI_EventReentrantMessage::eventId();
       std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage = std::shared_ptr
-          <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(anId, 0));
+          <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(anId, this));
       aMessage->setCreatedFeature(ModelAPI_Feature::feature(
                                   data()->attribute(START_ID())->owner()));
       Events_Loop::loop()->send(aMessage);
index e963cfe14c33a4cc1a9b2503fda2fdc9e4f6e656..54c2f64b7ac2d928a5c48d28dcdc1a542eb71bab 100644 (file)
@@ -355,7 +355,7 @@ void SketchPlugin_MacroArc::execute()
   // message to init reentrant operation
   static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
   std::shared_ptr<SketchPlugin_MacroArcReentrantMessage> aMessage = std::shared_ptr
-    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, 0));
+    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, this));
 
   std::string anEditArcType = string(EDIT_ARC_TYPE_ID())->value();
   aMessage->setTypeOfCreation(!anEditArcType.empty() ? anEditArcType : anArcType);
index 5ad9a8ca145506005085afdf0a1a5b625082c0fe..942e9f9c3a42f4732f88305240b93c024bce88db 100644 (file)
@@ -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() {}
index 047b5aea8932110037cd12b7152c570e421a6d51..3af61c721b52505313a428b5336377ff8bf5b703 100644 (file)
@@ -97,7 +97,7 @@ void SketchPlugin_MacroCircle::execute()
   // message to init reentrant operation
   static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
   std::shared_ptr<SketchPlugin_MacroArcReentrantMessage> aMessage = std::shared_ptr
-    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, 0));
+    <SketchPlugin_MacroArcReentrantMessage>(new SketchPlugin_MacroArcReentrantMessage(anId, this));
 
   std::string anEditType = string(EDIT_CIRCLE_TYPE())->value();
   aMessage->setTypeOfCreation(!anEditType.empty() ? anEditType : aType);
index 986b99b30d941314868403303847a83dfcf26bc0..4e60668376998ee0c60c7a55317efdd15f1b99d3 100644 (file)
@@ -467,7 +467,7 @@ void SketchPlugin_Trim::execute()
   if (aPreviewObject.get()) {
     std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage = std::shared_ptr
       <ModelAPI_EventReentrantMessage>(new ModelAPI_EventReentrantMessage(
-                                           ModelAPI_EventReentrantMessage::eventId(), 0));
+                                           ModelAPI_EventReentrantMessage::eventId(), this));
     aMessage->setSelectedObject(aPreviewObject);
     Events_Loop::loop()->send(aMessage);
   }