From 7850a95ad1efe835c2266230bdab39bf2e856789 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 8 Dec 2015 18:57:38 +0300 Subject: [PATCH] #1109 Sketch entities preview red lines stayed in the viewer after Sketch is applyed. --- src/ModuleBase/ModuleBase_IModule.h | 8 ++++++++ src/PartSet/PartSet_Module.cpp | 30 ++++++++++++++++++----------- src/PartSet/PartSet_Module.h | 8 ++++++++ src/XGUI/XGUI_OperationMgr.cpp | 6 ++++++ 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 11e7949cf..acd6b49ac 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -212,6 +212,14 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param thePreviousAttributeID an index of the previous active attribute virtual bool processEnter(const std::string& thePreviousAttributeID) { return false; }; + /// Performs some GUI actions after an operation transaction is opened + /// Default realization is empty + virtual void beforeOperationStarted(ModuleBase_Operation* theOperation) {}; + + /// Performs some GUI actions before an operation transaction is stopped + /// Default realization is empty + virtual void beforeOperationStopped(ModuleBase_Operation* theOperation) {}; + signals: /// Signal which is emitted when operation is launched void operationLaunched(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 9b380a839..1f0598bb4 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -275,19 +275,16 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation) { bool isModified = myCustomPrs->deactivate(false); - if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { - mySketchMgr->stopSketch(theOperation); - } - else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) { + if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) { mySketchMgr->stopNestedSketch(theOperation); } //VSV: Viewer is updated on feature update and redisplay - //if (isModified) { - // XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - // XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - // aDisplayer->updateViewer(); - //} + if (isModified) { + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + aDisplayer->updateViewer(); + } mySketchMgr->onShowConstraintsToggle(myHasConstraintShown); } @@ -485,7 +482,6 @@ void PartSet_Module::onOperationActivatedByPreselection() if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) { // Set final definitions if they are necessary //propertyPanelDefined(aOperation); - /// Commit sketcher operations automatically anOperation->commit(); } @@ -512,7 +508,7 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th aPointWgt->setSketch(mySketchMgr->activeSketch()); connect(aPointWgt, SIGNAL(vertexSelected()), sketchReentranceMgr(), SLOT(onVertexSelected())); aWgt = aPointWgt; - } else if (theType == "sketch-2dpoint_flyout_selector") { + }else if (theType == "sketch-2dpoint_flyout_selector") { PartSet_WidgetPoint2DFlyout* aPointWgt = new PartSet_WidgetPoint2DFlyout(theParent, aWorkshop, theWidgetApi, theParentId); aPointWgt->setSketch(mySketchMgr->activeSketch()); @@ -1024,6 +1020,18 @@ bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID) return mySketchReentrantMgr->processEnter(thePreviousAttributeID); } +//****************************************************** +void PartSet_Module::beforeOperationStarted(ModuleBase_Operation* theOperation) +{ +} + +//****************************************************** +void PartSet_Module::beforeOperationStopped(ModuleBase_Operation* theOperation) +{ + if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { + mySketchMgr->stopSketch(theOperation); + } +} //****************************************************** void PartSet_Module::onBooleanOperationChange(int theOperation) diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 470294bdb..f074786d3 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -219,6 +219,14 @@ public: /// \param thePreviousAttributeID an index of the previous active attribute virtual bool processEnter(const std::string& thePreviousAttributeID); + /// Performs some GUI actions after an operation transaction is opened + /// Default realization is empty + virtual void beforeOperationStarted(ModuleBase_Operation* theOperation); + + /// Performs some GUI actions before an operation transaction is stopped + /// Default realization is empty + virtual void beforeOperationStopped(ModuleBase_Operation* theOperation); + public slots: /// Redefines the parent method in order to customize the next case: /// If the sketch nested operation is active and the presentation is not visualized in the viewer, diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 5d89fcab1..9015698d5 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -431,6 +431,9 @@ void XGUI_OperationMgr::onBeforeOperationStarted() qDebug(QString("\tdocument->currentFeature(false) = %1").arg( ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); #endif + ModuleBase_IModule* aModule = myWorkshop->module(); + if (aModule) + aModule->beforeOperationStarted(aFOperation); } } @@ -487,6 +490,9 @@ void XGUI_OperationMgr::onBeforeOperationCommitted() qDebug(QString("\tdocument->currentFeature(false) = %1").arg( ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); #endif + ModuleBase_IModule* aModule = myWorkshop->module(); + if (aModule) + aModule->beforeOperationStopped(aFOperation); } } -- 2.39.2