]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #308: Do not select same object for boolean operation
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 5 Dec 2014 15:14:38 +0000 (18:14 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 5 Dec 2014 15:14:38 +0000 (18:14 +0300)
src/FeaturesPlugin/boolean_widget.xml
src/PartSet/PartSet_Validators.cpp

index af4822c2c848784f950bbf54d3726034ccd4ccda..e64a63b4cb801ae24117f078fca5ae487c235fb2 100644 (file)
@@ -11,8 +11,9 @@
     icon=":icons/cut_tool.png" 
     tooltip="Select a tool"
     shape_types="solid"
-    concealment="true"
-  />
+    concealment="true" >
+       <validator id="PartSet_DifferentObjects"/>
+  </shape_selector>
   <choice id="bool_type" 
     label="Type" 
     tooltip="Type of boolean operation"
index f35b3ae05158f7ca8f4b125776f5eb274fd0a0d2..31fd4c048b0f9587e26b76c1e86e0cf63a1bd3d8 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeReference.h>
 
 #include <list>
 
@@ -130,6 +131,20 @@ bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
       }
     }
   }
+  // Check selection attributes
+  anAttrs = theFeature->data()->attributes(ModelAPI_AttributeReference::type());
+  if (anAttrs.size() > 0) {
+    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+    for(; anAttr != anAttrs.end(); anAttr++) {
+      if (*anAttr) {
+        std::shared_ptr<ModelAPI_AttributeReference> aRef = 
+          std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
+        // check the object is already presented
+        if (aRef->isInitialized() && aRef->value() == theObject)
+          return false;
+      }
+    }
+  }
   return true;
 }