Salome HOME
Useful commits from master and V8_5_0
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_ValidatorTransform.cpp
index 9722f88361b267612baf4f5264c75aebe2b00975..41dd47afb9751f5bb55b8d04786caf88f0460ebb 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"
 
@@ -17,11 +35,12 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute
   bool aValid = true;
   std::string anAttributeType = theAttribute->attributeType();
   if (anAttributeType != ModelAPI_AttributeSelectionList::typeId()) {
-    theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+    theError = "The attribute with the %1 type is not processed";
+    theError.arg(theAttribute->attributeType());
     return false;
   }
 
-  std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList = 
+  std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList =
                            std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
 
   DocumentPtr aDocument = theAttribute->owner()->document();
@@ -32,7 +51,10 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute
   for(int i = 0; i < aCurSelList->size() && aValid; i++) {
     std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
     ResultPtr aResult = aSelAttribute->context();
-    if (isPartSetDocument) // PartSet document: Result Part is valid
+    if (!aResult) {
+      theError = "Invalid selection.";
+      return false;
+    } 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();
@@ -47,10 +69,9 @@ bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute
   if (!aValid) {
     std::string aResultGroupName = isPartSetDocument ? ModelAPI_ResultPart::group()
                                                      : ModelAPI_ResultBody::group();
-    theError = "Objects from the " + aResultGroupName  +
-                " group can be selected in the " + aDocument->kind() +
-                "document, but an objects from the " + anErrorGroupName +
-                " group is selected.";
+    theError = "Objects from the %1 group can be selected in the %2 document, "
+               "but an objects from the %3 group is selected.";
+    theError.arg(aResultGroupName).arg(aDocument->kind()).arg(anErrorGroupName);
   }
   return aValid;
 }