]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomValidators/GeomValidators_BodyShapes.cpp
Salome HOME
Issue #1366: Remove Sub-Shapes feature added.
[modules/shaper.git] / src / GeomValidators / GeomValidators_BodyShapes.cpp
index 13e95ace0ffc8bbb0be3a5178414575bced770c8..18bd9918a59949e9634eda8708923eb10f27695a 100644 (file)
@@ -15,24 +15,34 @@ bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
                                         std::string& theError) const
 {
   std::string anAttributeType = theAttribute->attributeType();
-  if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
-    AttributeSelectionListPtr aSelectionListAttr = 
-                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
-    // all context objects should not be sketch entities
-    for(int anIndex = 0, aSize = aSelectionListAttr->size(); anIndex < aSize; ++anIndex) {
-      AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(anIndex);
-      ResultPtr aContext = aSelectAttr->context();
-      if(!aContext.get()) {
-        theError = "Error: Context is empty.";
-        return false;
-      }
+  if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+    AttributeSelectionPtr anAttrSelection =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+    ResultPtr aContext = anAttrSelection->context();
+    if(!aContext.get()) {
+      theError = "Error: Context is empty.";
+      return false;
+    }
+
+    ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+    if(aResultConstruction.get()) {
+      theError = "Error: Result construction selected.";
+      return false;
+    }
+  } else if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr anAttrSelectionList =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
 
-      ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
-      if(aResultConstruction.get()) {
-        theError = "Error: Result construction selected.";
+    // All objects should not be result constructions.
+    for(int anIndex = 0, aSize = anAttrSelectionList->size(); anIndex < aSize; ++anIndex) {
+      AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
+      if(!isValid(anAttrSelection, theArguments, theError)) {
         return false;
       }
     }
+  } else {
+    theError = "Error: Attribute \"" + anAttributeType + "\" does not supported by this validator.";
+    return false;
   }
 
   return true;