Salome HOME
Issue #2071 Fatal error when Create box
authornds <nds@opencascade.com>
Thu, 30 Mar 2017 06:54:37 +0000 (09:54 +0300)
committernds <nds@opencascade.com>
Thu, 30 Mar 2017 06:54:37 +0000 (09:54 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/PartSet/PartSet_SketcherReentrantMgr.h
src/PartSet/PartSet_WidgetPoint2d.cpp

index 2d4bc1579a29fd48ae1e8e6b15029bb386f4cdbe..edd895a4089d50860f52b487be3509433a71a010 100755 (executable)
@@ -512,7 +512,7 @@ bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
 {
   bool isEnabledFixed = false;
   if (theActionId == XGUI_ActionsMgr::AcceptAll &&
-      mySketchReentrantMgr->isInternalEditStarted())
+      mySketchReentrantMgr->isInternalEditActive())
     isEnabledFixed = true;
   return isEnabledFixed;
 }
@@ -560,7 +560,7 @@ bool PartSet_Module::isMouseOverWindow()
 bool PartSet_Module::isSketchNeutralPointActivated() const
 {
   bool isNeutralPoint = true;
-  if (sketchReentranceMgr()->isInternalEditStarted())
+  if (sketchReentranceMgr()->isInternalEditActive())
     isNeutralPoint = false;
   if (myIsOperationIsLaunched)
     isNeutralPoint = false;
index 8dd5af2eb002627505ae916c9f95725784f4390f..0e74b06001dd247194d8be3e5d85a91431aedf16 100755 (executable)
@@ -9,6 +9,7 @@
 #include "PartSet_OverconstraintListener.h"
 #include <PartSet_Module.h>
 #include <PartSet_SketcherMgr.h>
+#include <PartSet_SketcherReentrantMgr.h>
 
 #include "XGUI_ModuleConnector.h"
 #include "XGUI_Workshop.h"
@@ -29,7 +30,7 @@
 //#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
 
 PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
-: myWorkshop(theWorkshop), myIsFullyConstrained(false), myIsNeedUpdateCustomColor(false)
+: myWorkshop(theWorkshop), myIsFullyConstrained(false)//, myIsNeedUpdateCustomColor(false)
 {
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
@@ -37,6 +38,8 @@ PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorks
 
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_UNDER_CONSTRAINED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED));
+
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
 }
 
 void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject,
@@ -111,24 +114,35 @@ void PartSet_OverconstraintListener::processEvent(
     myIsFullyConstrained = anEventID == Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED);
 
     if (aPrevFullyConstrained != myIsFullyConstrained) {
-      myIsNeedUpdateCustomColor = true;
+      //myIsNeedUpdateCustomColor = true;
       std::set<ObjectPtr> aModifiedObjects;
       PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
       CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
-      for (int i = 0; i < aSketch->numberOfSubs(); i++) {
-        FeaturePtr aFeature = aSketch->subFeature(i);
-        aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
-        std::list<ResultPtr> aResults = aFeature->results();
-        for (std::list<ResultPtr>::const_iterator aIt = aResults.begin();
-             aIt != aResults.end(); ++aIt) {
-          aModifiedObjects.insert(*aIt);
+      if (aSketch.get()) {
+        for (int i = 0; i < aSketch->numberOfSubs(); i++) {
+          FeaturePtr aFeature = aSketch->subFeature(i);
+          aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
+          std::list<ResultPtr> aResults = aFeature->results();
+          for (std::list<ResultPtr>::const_iterator aIt = aResults.begin();
+               aIt != aResults.end(); ++aIt) {
+            aModifiedObjects.insert(*aIt);
+          }
         }
+        redisplayObjects(aModifiedObjects);
       }
-      redisplayObjects(aModifiedObjects);
-      myIsNeedUpdateCustomColor = false;
+      //myIsNeedUpdateCustomColor = false;
+    }
+  }
+  else if (anEventID == Events_Loop::eventByName(EVENT_OBJECT_CREATED)) {
+    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+    PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
+    if (aReentrantMgr->isInternalEditActive()) {
+      std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+            std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+      std::set<ObjectPtr> anObjects = aUpdMsg->objects();
+      aReentrantMgr->appendCreatedObjects(anObjects);
     }
   }
-
 #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
   aCurrentInfoStr = getObjectsInfo(myConflictingObjects);
   qDebug(QString("RESULT: current objects count = %1:%2\n")
index cab4e9945363d6912af1c7045d259d88ef00109a..488f5660a99f9361880f0c25d393bf3b9159bf90 100644 (file)
@@ -389,9 +389,17 @@ bool PartSet_SketcherReentrantMgr::canBeCommittedByPreselection()
   return !isActiveMgr() || myRestartingMode == RM_None;
 }
 
-bool PartSet_SketcherReentrantMgr::isInternalEditStarted() const
+void PartSet_SketcherReentrantMgr::appendCreatedObjects(const std::set<ObjectPtr>& theObjects)
 {
-  return myIsInternalEditOperation;
+  if (!myIsFlagsBlocked) // we need to collect objects only when launch operation is called
+    return;
+
+  for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin();
+       anIt != theObjects.end(); ++anIt) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+    if (myCreatedFeatures.find(aFeature) != myCreatedFeatures.end())
+      myCreatedFeatures.insert(aFeature);
+  }
 }
 
 bool PartSet_SketcherReentrantMgr::isActiveMgr() const
@@ -618,6 +626,7 @@ void PartSet_SketcherReentrantMgr::resetFlags()
     myIsInternalEditOperation = false;
     updateAcceptAllAction();
     myRestartingMode = RM_None;
+    myCreatedFeatures.clear();
   }
 }
 
index b430c2389479bcef9a2c1a283dc38d60e28b405c..17006c1e482cf8115a09624e0a4b1422e43f9c53 100644 (file)
@@ -101,9 +101,10 @@ public:
   /// Returns false if the reentrant mode of the operation is not empty.
   bool canBeCommittedByPreselection();
 
-  /// returns true if an internal edit operation is started
-  /// \return boolean value
-  bool isInternalEditStarted() const;
+  /// Put information about created objects into a cash. It will be processed in
+  /// restart operation.
+  /// \param theObjects a list of created objects
+  void appendCreatedObjects(const std::set<ObjectPtr>& theObjects);
 
 private slots:
   /// SLOT, that is called by a widget activating in the property panel
@@ -192,6 +193,7 @@ private:
   bool myIsValueChangedBlocked; /// blocked flag to avoid circling by value changed
 
   FeaturePtr myPreviousFeature; /// feature of the previous operation, which is restarted
+  std::set<FeaturePtr> myCreatedFeatures; /// list of created features by restart operation
   FeaturePtr myInternalFeature;
   QWidget* myInternalWidget;
   ModuleBase_ModelWidget* myInternalActiveWidget;
index d82e457a8dbafdebca08a4cdc648461bb2faf4bf..0d296dc097204e2aa7804e2f4b51c375af35107b 100644 (file)
@@ -689,7 +689,7 @@ void PartSet_WidgetPoint2D::mouseMoved(ModuleBase_IViewWindow* theWindow, QMouse
 {
   PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
 
-  if (isEditingMode() || aModule->sketchReentranceMgr()->isInternalEditStarted())
+  if (isEditingMode() || aModule->sketchReentranceMgr()->isInternalEditActive())
     return;
 
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());