X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetSelector.cpp;h=831fc4cb4c481ef3d1d188d3c4032d1dad688938;hb=374a366d81778aa27ed32cc080c0f95bdb03f1c5;hp=9642a37afab51e5f8a0a88d82978011536c26dee;hpb=1e2eaa713f139d2617c80eba9ede62d4e9976bb7;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp old mode 100755 new mode 100644 index 9642a37af..831fc4cb4 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -135,7 +134,9 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, return aValid; } // when the SHAPE type is provided by XML as Object, the whole result shape should be selected. - if (!aShape.get() && aShapeTypes.contains(ModuleBase_ResultPrs::Sel_Result)) { + //if (!aShape.get() && aShapeTypes.contains(ModuleBase_ResultPrs::Sel_Result)) { + // In case of selection of a feature aShape could be not NULL, but result has to be selected + if (aShapeTypes.contains(ModuleBase_ResultPrs::Sel_Result)) { aValid = true; return aValid; } @@ -148,11 +149,13 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, if (aShape.get()) { // Check that the selection corresponds to selection type TopoDS_Shape aTopoShape = aShape->impl(); - aShapeType = aTopoShape.ShapeType(); - // for compounds check sub-shapes: it may be compound of needed type: - // Booleans may produce compounds of Solids - if (aShapeType == TopAbs_COMPOUND) { - aShapeType = ModuleBase_Tools::getCompoundSubType(aTopoShape); + if (!aTopoShape.IsNull()) { + aShapeType = aTopoShape.ShapeType(); + // for compounds check sub-shapes: it may be compound of needed type: + // Booleans may produce compounds of Solids + if (aShapeType == TopAbs_COMPOUND) { + aShapeType = ModuleBase_Tools::getCompoundSubType(aTopoShape); + } } } @@ -206,11 +209,13 @@ 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 - ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); + aResult = myWorkshop->selection()->getResult(thePrs); FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aResult); aValid = aSelectedFeature != myFeature; } @@ -249,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; +}