Salome HOME
Remove French translations
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSelector.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 9642a37..59e836e
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  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
 //
 // 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<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <ModuleBase_WidgetSelector.h>
@@ -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<TopoDS_Shape>();
-    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,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
@@ -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<ModelAPI_AttributeSelectionList>(anAttribute);
+    if (aSelAttr.get())
+      return aSelAttr->isWholeResultAllowed();
+  }
+  return false;
+}