From d0bc288ac6952be821549a4eafdde2d3e10616e3 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 14 Dec 2017 23:17:44 +0300 Subject: [PATCH] Issue #2352 - Undo list is disabled when change focus from multi-selection to ordinary field Issue #2368 - Fatal error when Undo in Fillet --- src/ModuleBase/ModuleBase_ModelWidget.h | 5 +++++ .../ModuleBase_WidgetMultiSelector.cpp | 21 ++++++++++++------- .../ModuleBase_WidgetMultiSelector.h | 9 +++++--- src/XGUI/XGUI_PropertyPanel.cpp | 8 +++++++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 0c0dddece..61c278353 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -200,6 +200,11 @@ Q_OBJECT /// The method called when widget is deactivated virtual void deactivate(); + /// Opportunity to do something after the active widget of the property panel changed + virtual void updateAfterDeactivation() {} + /// Opportunity to do something after the active widget of the property panel changed + virtual void updateAfterActivation() {} + /// The method called if widget should be activated always virtual bool needToBeActiated() { return false; } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index b3884b496..de224116c 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -150,7 +150,6 @@ void ModuleBase_WidgetMultiSelector::activateCustom() myWorkshop->module()->activateCustomPrs(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects, true); clearSelectedHistory(); - myWorkshop->updateCommandStatus(); } //******************************************************************** @@ -160,6 +159,19 @@ void ModuleBase_WidgetMultiSelector::deactivate() myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true); clearSelectedHistory(); +} + +//******************************************************************** +void ModuleBase_WidgetMultiSelector::updateAfterDeactivation() +{ + // restore previous Undo/Redo workshop state + myWorkshop->updateCommandStatus(); +} + +//******************************************************************** +void ModuleBase_WidgetMultiSelector::updateAfterActivation() +{ + // fill Undo/Redo actions with current information myWorkshop->updateCommandStatus(); } @@ -331,13 +343,6 @@ bool ModuleBase_WidgetMultiSelector::processAction(ModuleBase_ActionType theActi } } -//******************************************************************** -void ModuleBase_WidgetMultiSelector::updateSelectionModesAndFilters(bool toActivate) -{ - myWorkshop->updateCommandStatus(); // update enable state of Undo/Redo application actions - ModuleBase_WidgetSelector::updateSelectionModesAndFilters(toActivate); -} - //******************************************************************** bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 2ea07f58e..f4a155981 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -75,6 +75,12 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// The methiod called when widget is deactivated virtual void deactivate(); + /// Update Undo/Redo actions state + virtual void updateAfterDeactivation(); + + /// Update Undo/Redo actions state + virtual void updateAfterActivation(); + /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values @@ -95,9 +101,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge virtual bool processAction(ModuleBase_ActionType theActionType, const ActionParamPtr& theParam = ActionParamPtr()); - /// Activate or deactivate selection and selection filters - virtual void updateSelectionModesAndFilters(bool toActivate); - /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view /// \return a boolean value diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 737027b35..7c5ac6ed4 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -474,16 +474,19 @@ bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, cons return false; } std::string aPreviosAttributeID; + ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL; if(myActiveWidget) { aPreviosAttributeID = myActiveWidget->attributeID(); myActiveWidget->processValueState(); myActiveWidget->deactivate(); myActiveWidget->setHighlighted(false); + aDeactivatedWidget = myActiveWidget; } if(theWidget) { emit beforeWidgetActivated(theWidget); theWidget->setHighlighted(true); theWidget->activate(); + anActivatedWidget = theWidget; } myActiveWidget = theWidget; @@ -505,6 +508,11 @@ bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, cons myOperationMgr->workshop()->selectionActivate()->updateSelectionModes(); myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters(); + if (aDeactivatedWidget) + aDeactivatedWidget->updateAfterDeactivation(); + if (anActivatedWidget) + anActivatedWidget->updateAfterActivation(); + if (!anIsNoMoreWidgets && myActiveWidget) { // restore widget selection should be done after selection modes of widget activating -- 2.39.2