Salome HOME
Created a new event that features were reordered due to the "move to end" action
[modules/shaper.git] / src / ModelAPI / ModelAPI_ShapeValidator.cpp
index fb03f459fbacc878155c6b552d2a9c37d3f0898f..2348819b0a986bee02e7017aaa4960841486c70d 100644 (file)
 #include "ModelAPI_Object.h"
 
 bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
-                                       const std::list<std::string>& theArguments) const
+                                      const std::list<std::string>& theArguments,
+                                      std::string& theError) const
 {
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeSelectionPtr aSelectionAttribute = 
                      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
   GeomShapePtr aShape = aSelectionAttribute->value();
+  if (!aShape.get()) {
+    ResultPtr aResult = aSelectionAttribute->context();
+    if (aResult.get())
+      aShape = aResult->shape();
+  }
 
   std::string aCurrentAttributeId = theAttribute->id();
   // get all feature attributes
@@ -27,11 +33,19 @@ bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
       AttributePtr anAttribute = *anAttr;
       // take into concideration only other attributes
       if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
-        AttributeSelectionPtr aSelectionAttribute = 
+        aSelectionAttribute = 
           std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
         // the shape of the attribute should be not the same
-        if (aSelectionAttribute.get() != NULL && aShape->isEqual(aSelectionAttribute->value())) {
-          return false;
+        if (aSelectionAttribute.get() != NULL) {
+          GeomShapePtr anAttrShape = aSelectionAttribute->value();
+          if (!anAttrShape.get()) {
+            ResultPtr aResult = aSelectionAttribute->context();
+            if (aResult.get())
+              anAttrShape = aResult->shape();
+            }
+            if (aShape->isEqual(anAttrShape)) {
+            return false;
+          }
         }
       }
     }