X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Validators.cpp;h=6426d94739bba43533d8efb7910e3ad6f1be5298;hb=2a2f4487370c6f7be90aa398fd1a205cc7ea96df;hp=44de21fb5ffc40aa01ab76d7432e6a4a2bf01a98;hpb=3c987a8d1b88765224e3ac1388afb91eae17e4d3;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 44de21fb5..6426d9473 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -1742,9 +1742,6 @@ bool FeaturesPlugin_ValidatorBooleanFuseArguments::isValid( if (anObjectsNb + aToolsNb < 2) { theError = "Not enough arguments for Fuse operation."; return false; - } else if (isAllInSameCompSolid) { - theError = "Operations only between sub-shapes of the same shape not allowed."; - return false; } return true; @@ -1880,3 +1877,42 @@ bool FeaturesPlugin_ValidatorBooleanCommonArguments::isNotObligatory( return false; } // LCOV_EXCL_STOP + +//================================================================================================== +bool FeaturesPlugin_ValidatorDefeaturingSelection::isValid( + const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const +{ + AttributeSelectionListPtr anAttrSelectionList = + std::dynamic_pointer_cast(theAttribute); + if (!anAttrSelectionList.get()) { + // LCOV_EXCL_START + theError = "Error: This validator can only work with selection list attributes."; + return false; + // LCOV_EXCL_STOP + } + + // Check selected entities are sub-shapes of solid or compsolid + GeomShapePtr aBaseSolid; + for (int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) { + AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex); + if (!anAttrSelection.get()) { + theError = "Error: Empty attribute selection."; + return false; + } + ResultPtr aContext = anAttrSelection->context(); + if (!aContext.get()) { + theError = "Error: Empty selection context."; + return false; + } + + GeomShapePtr aContextShape = aContext->shape(); + if (aContextShape->shapeType() != GeomAPI_Shape::SOLID) { + theError = "Error: Not all selected shapes are sub-shapes of solids."; + return false; + } + } + + return true; +}