+ return true;
+}
+
+//==================================================================================================
+bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ AttributeSelectionListPtr anAttrSelectionList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if(!anAttrSelectionList.get()) {
+ theError = "Error: This validator can only work with selection list in \"Partition\" feature.";
+ return false;
+ }
+
+ for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelectAttr = anAttrSelectionList->value(anIndex);
+
+ //GeomValidators_BodyShapes aBodyValidator;
+ //if(aBodyValidator.isValid(aSelectAttr, theArguments, theError)) {
+ // continue;
+ //}
+
+ GeomValidators_FeatureKind aFeatureKindValidator;
+ if(aFeatureKindValidator.isValid(aSelectAttr, theArguments, theError)) {
+ continue;
+ }
+
+ ResultPtr aContext = aSelectAttr->context();
+ ResultConstructionPtr aResultConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ if(aResultConstruction.get()) {
+ theError = "Error: Only body shapes and construction planes are allowed for selection.";
+ return false;
+ }
+
+ ResultCompSolidPtr aResultCompsolid =
+ std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
+ if(aResultCompsolid.get()) {
+ continue;
+ }
+
+ theError = "Error: Only body shapes and construction planes are allowed for selection.";
+ return false;
+ }
+
+ theError = "";
+ return true;
+}
+
+//==================================================================================================
+bool FeaturesPlugin_ValidatorRemoveSubShapesSelection::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ AttributeSelectionListPtr aSubShapesAttrList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if(!aSubShapesAttrList.get()) {
+ theError =
+ "Error: This validator can only work with selection list in \"Remove Sub-Shapes\" feature.";
+ return false;
+ }
+
+ static const std::string aBaseShapeID = "base_shape";
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ AttributeSelectionPtr aShapeAttrSelection = aFeature->selection(aBaseShapeID);
+
+ if(!aShapeAttrSelection.get()) {
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aBaseShapeID);
+ return false;
+ }
+
+ GeomShapePtr aBaseShape = aShapeAttrSelection->value();
+ ResultPtr aContext = aShapeAttrSelection->context();
+ if(!aContext.get()) {
+ theError = "Error: Empty context.";
+ return false;
+ }
+ if(!aBaseShape.get()) {
+ aBaseShape = aContext->shape();
+ }
+ if(!aBaseShape.get()) {
+ theError = "Error: Empty base shape.";
+ return false;
+ }
+
+ for(int anIndex = 0; anIndex < aSubShapesAttrList->size(); ++anIndex) {
+ bool isSameFound = false;
+ AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
+ GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
+ for(GeomAPI_ShapeIterator anIt(aBaseShape); anIt.more(); anIt.next()) {
+ if(anIt.current()->isEqual(aShapeToAdd)) {
+ isSameFound = true;
+ break;