Salome HOME
Fix for the issue #2693 : groups in error after loading dump (3-holes plate)
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_ValidatorTransform.cpp
index 37ba9149fe9e80dbc9cce1ef93da35b6a656f0c3..694915de7ed847a676e92e267d98f8f2a761610d 100755 (executable)
@@ -1,4 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include "FeaturesPlugin_ValidatorTransform.h"
 
@@ -7,7 +25,6 @@
 #include "ModelAPI_AttributeSelectionList.h"
 #include "ModelAPI_ResultPart.h"
 #include "ModelAPI_ResultBody.h"
-#include "ModelAPI_ResultCompSolid.h"
 #include "ModelAPI_Session.h"
 
 bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute,
@@ -34,14 +51,25 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute
     std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
     ResultPtr aResult = aSelAttribute->context();
     if (!aResult) {
+      // this could be a whole feature selected
+      FeaturePtr aFeature = aSelAttribute->contextFeature();
+      if (aFeature.get() && aFeature->results().size() > 0) {
+        if (aFeature->firstResult()->groupName() != ModelAPI_ResultBody::group()) {
+          anErrorGroupName = aFeature->firstResult()->groupName();
+          aValid = false;
+          break;
+        }
+        continue;
+      }
       theError = "Invalid selection.";
       return false;
-    } if (isPartSetDocument) // PartSet document: Result Part is valid
+    }
+    if (isPartSetDocument) // PartSet document: Result Part is valid
       aValid = aResult->groupName() == ModelAPI_ResultPart::group();
     else { // Part document: Result CompSolid is valid
       aValid = aResult->groupName() == ModelAPI_ResultBody::group();
       if (aValid) {
-        ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+        ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
         aValid = aComp.get() != NULL;
       }
     }