Salome HOME
#1327 Fatal error when create arc
authornds <nds@opencascade.com>
Thu, 25 Feb 2016 15:41:02 +0000 (18:41 +0300)
committernds <nds@opencascade.com>
Thu, 25 Feb 2016 15:41:02 +0000 (18:41 +0300)
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h

index 0471bfae79e26b601075e030af60a165015df91b..950a20efa66a48108f84326212c7ac4af5920d19 100755 (executable)
@@ -49,11 +49,16 @@ ModuleBase_OperationFeature::~ModuleBase_OperationFeature()
   clearPreselection();
 }
 
-void ModuleBase_OperationFeature::setEditOperation(const bool theRestartTransaction)
+void ModuleBase_OperationFeature::setEditOperation(const bool& isEditState
+                                                   /*const bool theRestartTransaction*/)
 {
-  if (isEditOperation())
+  bool isCurrentEditState = isEditOperation();
+  if (isCurrentEditState == isEditState)
     return;
 
+  /*
+  // this case is obsolete as it was not approved for reentrant sketch operation
+  // it was implemented when isEditState did not exist and only edit operation can be set
   if (theRestartTransaction) {
     // finsh previous create operation
     emit beforeCommitted();
@@ -68,9 +73,8 @@ void ModuleBase_OperationFeature::setEditOperation(const bool theRestartTransact
     }
     ModelAPI_Session::get()->startOperation(anId.toStdString());
     emit beforeStarted();
-  }
-  else
-    myIsEditing = true;
+  } else*/
+  myIsEditing = isEditState;
 
   propertyPanel()->setEditingMode(isEditOperation());
 }
index ab0ce8c900ab13485f5ecf6333ff950674daf10b..4f96cd56e284f39548a13f599555d8e5cfe76eda 100755 (executable)
@@ -67,9 +67,10 @@ Q_OBJECT
   /// Change the operation mode from create to edit.
   /// The transaction and the operation name in the model history of transaction are the same.
   /// It updates the edit state in the widgets of property panel
-  /// \param theRestartTransaction if true, the current model transaction is committed and
+  /// \param isEditState boolean state whether the operation should become editing or creating
+  // \param theRestartTransaction if true, the current model transaction is committed and
   /// the new one is started
-  void setEditOperation(const bool theRestartTransaction);
+  void setEditOperation(const bool& isEditState/*const bool theRestartTransaction*/);
 
   /// Returns the operation feature
   /// \return the feature
index 583e132981a1d492063ddf6bb815fcf87c25ed52..b261c2ca4d1b36df03550c836e3f71680f232d7e 100755 (executable)
@@ -310,8 +310,10 @@ void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
 void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
 {
   if (!isNestedEditOperation(getCurrentOperation()) ||
-      myModule->sketchReentranceMgr()->isInternalEditActive())
+      myModule->sketchReentranceMgr()->isInternalEditActive()) {
+    myModule->sketchReentranceMgr()->updateInternalEditActiveState();
     return;
+  }
   // it is necessary to restore current selection in order to restore it after the values are modified
   restoreSelection();
   myCurrentSelection.clear();
@@ -324,6 +326,8 @@ void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
   aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
   aDisplayer->updateViewer();
+
+
 }
 
 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
index 197f4df0f56567cfd7ce4871c8122abffbcd3979..534ddb465fc0fd85f97cf8c7f8fbbb3b55739a66 100755 (executable)
@@ -69,6 +69,26 @@ bool PartSet_SketcherReetntrantMgr::isInternalEditActive() const
   return myIsInternalEditOperation;
 }
 
+void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState()
+{
+  if  (myIsInternalEditOperation) {
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                         (myWorkshop->currentOperation());
+    if (aFOperation) {
+      FeaturePtr aFeature = aFOperation->feature();
+      QString anError = myWorkshop->module()->getFeatureError(aFeature);
+      // stop started internal edit operation as soon as the operation becomes invalid
+      // it is especially important for the sketch tangent arc feature
+      if (!anError.isEmpty()) {
+        aFOperation->setEditOperation(false);
+        //workshop()->operationMgr()->updateApplyOfOperations();
+        beforeStopInternalEdit();
+        myIsInternalEditOperation = false;
+      }
+    }
+  }
+}
+
 bool PartSet_SketcherReetntrantMgr::operationCommitted(ModuleBase_Operation* theOperation)
 {
   bool aProcessed = false;
@@ -350,7 +370,7 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
                                                      (myWorkshop->currentOperation());
 
   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
-    aFOperation->setEditOperation(false);
+    aFOperation->setEditOperation(true/*, false*/);
     workshop()->operationMgr()->updateApplyOfOperations();
 
     createInternalFeature();
index 93691362dff9b37649b07ab448e576101dd0f854..5f68d34ea801da84cd0be655b27c2b820d468092 100755 (executable)
@@ -54,6 +54,9 @@ public:
   /// Return true if the current edit operation is an internal
   bool isInternalEditActive() const;
 
+  /// Stop internal edit if the operation feature is invalid
+  void updateInternalEditActiveState();
+
   /// if the internal flags allow it and the manager is active, it starts an internal edit operation
   /// for the created operation.
   /// \param thePreviousAttributeID an index of the previous active attribute