From cb211f4293f1dfd396ed7a9cbd33408afda2c2ef Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 25 Feb 2016 18:41:02 +0300 Subject: [PATCH] #1327 Fatal error when create arc --- .../ModuleBase_OperationFeature.cpp | 14 +++++++----- src/ModuleBase/ModuleBase_OperationFeature.h | 5 +++-- src/PartSet/PartSet_SketcherMgr.cpp | 6 ++++- src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 22 ++++++++++++++++++- src/PartSet/PartSet_SketcherReetntrantMgr.h | 3 +++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 0471bfae7..950a20efa 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -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()); } diff --git a/src/ModuleBase/ModuleBase_OperationFeature.h b/src/ModuleBase/ModuleBase_OperationFeature.h index ab0ce8c90..4f96cd56e 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.h +++ b/src/ModuleBase/ModuleBase_OperationFeature.h @@ -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 diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 583e13298..b261c2ca4 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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) diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 197f4df0f..534ddb465 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -69,6 +69,26 @@ bool PartSet_SketcherReetntrantMgr::isInternalEditActive() const return myIsInternalEditOperation; } +void PartSet_SketcherReetntrantMgr::updateInternalEditActiveState() +{ + if (myIsInternalEditOperation) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (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(); diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.h b/src/PartSet/PartSet_SketcherReetntrantMgr.h index 93691362d..5f68d34ea 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.h +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.h @@ -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 -- 2.39.2