From: nds Date: Wed, 2 Mar 2016 07:25:40 +0000 (+0300) Subject: #1352 Selection mode is invalid on edit Partition X-Git-Tag: V_2.2.0~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=25c99292ac7bb39e381dfb486cdaf537ba1820ee;p=modules%2Fshaper.git #1352 Selection mode is invalid on edit Partition --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 88062dbad..40518a2ca 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -479,12 +479,12 @@ void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum aShapeTypeName = myTypeCombo->itemText(idx); TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName); if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) { - activateSelectionAndFilters(false); + bool aWasActivated = activateSelectionAndFilters(false); bool isBlocked = myTypeCombo->blockSignals(true); myTypeCombo->setCurrentIndex(idx); myTypeCombo->blockSignals(isBlocked); - - activateSelectionAndFilters(true); + if (aWasActivated) + activateSelectionAndFilters(true); break; } } diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 53a7b5da8..e8c609343 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -115,7 +115,7 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, } //******************************************************************** -void ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate) +bool ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate) { updateSelectionName(); @@ -124,7 +124,7 @@ void ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate) } else { myWorkshop->deactivateSubShapesSelection(); } - activateFilters(toActivate); + return activateFilters(toActivate); } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index e44a2dde3..9756b3633 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -44,7 +44,8 @@ Q_OBJECT virtual bool isViewerSelector() { return true; } /// Activate or deactivate selection and selection filters - virtual void activateSelectionAndFilters(bool toActivate); + /// \return true if the selection filter of the widget is activated in viewer context + virtual bool activateSelectionAndFilters(bool toActivate); /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 995c66717..6e4873753 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -202,17 +202,21 @@ bool ModuleBase_WidgetValidated::isFilterActivated() const return aViewer->hasSelectionFilter(aSelFilter); } -void ModuleBase_WidgetValidated::activateFilters(const bool toActivate) +bool ModuleBase_WidgetValidated::activateFilters(const bool toActivate) { ModuleBase_IViewer* aViewer = myWorkshop->viewer(); Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter(); + bool aHasSelectionFilter = aViewer->hasSelectionFilter(aSelFilter); + if (toActivate) aViewer->addSelectionFilter(aSelFilter); else { aViewer->removeSelectionFilter(aSelFilter); clearValidState(); } + + return aHasSelectionFilter; } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index ecd107e99..e7c84a942 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -124,7 +124,8 @@ protected: /// It obtains selection filters from the workshop and activates them in the active viewer /// \param toActivate a flag about activation or deactivation the filters - void activateFilters(const bool toActivate); + /// \return true if the selection filter of the widget is activated in viewer context + bool activateFilters(const bool toActivate); /// Block the model flush of update and intialization of attribute /// \param theToBlock flag whether the model is blocked or unblocked diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index 305337337..6f841163a 100755 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -42,15 +42,17 @@ PartSet_WidgetShapeSelector::~PartSet_WidgetShapeSelector() } //******************************************************************** -void PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate) +bool PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate) { - ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate); + bool aHasSelectionFilter = ModuleBase_WidgetShapeSelector::activateSelectionAndFilters + (toActivate); if (!myUseSketchPlane) { XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop); PartSet_Module* aModule = dynamic_cast(aWorkshop->module()); bool isUsePlaneFilterOnly = !toActivate; aModule->sketchMgr()->activatePlaneFilter(isUsePlaneFilterOnly); } + return aHasSelectionFilter; } //******************************************************************** diff --git a/src/PartSet/PartSet_WidgetShapeSelector.h b/src/PartSet/PartSet_WidgetShapeSelector.h index 9af349389..93cf342d7 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.h +++ b/src/PartSet/PartSet_WidgetShapeSelector.h @@ -44,7 +44,7 @@ Q_OBJECT /// Activate or deactivate selection and selection filters /// \param toActivate boolean state whether it should be activated/deactivated - virtual void activateSelectionAndFilters(bool toActivate); + virtual bool activateSelectionAndFilters(bool toActivate); protected: /// Checks the widget validity. By default, it returns true.