From f8e4bce82fd4f03e1652dba3df6dd6874c93f00e Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 5 Dec 2014 18:14:38 +0300 Subject: [PATCH] Issue #308: Do not select same object for boolean operation --- src/FeaturesPlugin/boolean_widget.xml | 5 +++-- src/PartSet/PartSet_Validators.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index af4822c2c..e64a63b4c 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -11,8 +11,9 @@ icon=":icons/cut_tool.png" tooltip="Select a tool" shape_types="solid" - concealment="true" - /> + concealment="true" > + + #include +#include #include @@ -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 >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) { + if (*anAttr) { + std::shared_ptr aRef = + std::dynamic_pointer_cast(*anAttr); + // check the object is already presented + if (aRef->isInitialized() && aRef->value() == theObject) + return false; + } + } + } return true; } -- 2.39.2