From 3be27460fc9186f5dfe074e5cb679aacadb89a92 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 11 Sep 2019 12:09:11 +0300 Subject: [PATCH] Issue #3005: Accept whole result for selection --- src/ModuleBase/ModuleBase_WidgetSelector.cpp | 17 ++++++++++++++++- src/ModuleBase/ModuleBase_WidgetSelector.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 7d701aaf5..59e836e47 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -209,7 +209,9 @@ bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPr { GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs); ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); - bool aValid = acceptSubShape(aShape, aResult); + bool aValid = aResult.get(); + if (!isWholeResultAllowed()) + aValid = acceptSubShape(aShape, aResult); if (aValid) { // In order to avoid selection of the same object @@ -252,3 +254,16 @@ void ModuleBase_WidgetSelector::deactivate() aSelectAttr->removeTemporaryValues(); } } + +//******************************************************************** +bool ModuleBase_WidgetSelector::isWholeResultAllowed() const +{ + AttributePtr anAttribute = attribute(); + if (anAttribute.get()) { + AttributeSelectionListPtr aSelAttr = + std::dynamic_pointer_cast(anAttribute); + if (aSelAttr.get()) + return aSelAttr->isWholeResultAllowed(); + } + return false; +} diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 904647f76..b8e881634 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -81,6 +81,8 @@ Q_OBJECT /// a shape. If the attribute do not uses the shape, it is empty virtual QList> getAttributeSelection() const; + virtual bool isWholeResultAllowed() const; + protected: /// Returns true if envent is processed. The default implementation is empty, returns false. virtual bool processSelection(); -- 2.39.2