From: dbv Date: Mon, 23 May 2016 10:21:39 +0000 (+0300) Subject: Fixes for SubShapes feature. X-Git-Tag: V_2.3.1~67 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7dab04315ebe1a219486253795990117b9386114;p=modules%2Fshaper.git Fixes for SubShapes feature. --- diff --git a/src/BuildPlugin/BuildPlugin_SubShapes.cpp b/src/BuildPlugin/BuildPlugin_SubShapes.cpp index d0e1af594..1689fb785 100644 --- a/src/BuildPlugin/BuildPlugin_SubShapes.cpp +++ b/src/BuildPlugin/BuildPlugin_SubShapes.cpp @@ -28,8 +28,8 @@ void BuildPlugin_SubShapes::initAttributes() { data()->addAttribute(BASE_SHAPE_ID(), ModelAPI_AttributeSelection::typeId()); - data()->addAttribute(SUB_SHAPES_ID(), ModelAPI_AttributeSelectionList::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SUB_SHAPES_ID()); + data()->addAttribute(SUBSHAPES_ID(), ModelAPI_AttributeSelectionList::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SUBSHAPES_ID()); } void BuildPlugin_SubShapes::attributeChanged(const std::string& theID) @@ -38,7 +38,7 @@ void BuildPlugin_SubShapes::attributeChanged(const std::string& theID) if(theID == BASE_SHAPE_ID()) { AttributeSelectionPtr aShapeAttrSelection = selection(BASE_SHAPE_ID()); - AttributeSelectionListPtr aSubShapesAttrList = selectionList(SUB_SHAPES_ID()); + AttributeSelectionListPtr aSubShapesAttrList = selectionList(SUBSHAPES_ID()); if(!aShapeAttrSelection.get() || !aSubShapesAttrList.get()) { return; } @@ -80,7 +80,7 @@ void BuildPlugin_SubShapes::execute() { // Get base shape and sub-shapes list. AttributeSelectionPtr aShapeAttrSelection = selection(BASE_SHAPE_ID()); - AttributeSelectionListPtr aSubShapesAttrList = selectionList(SUB_SHAPES_ID()); + AttributeSelectionListPtr aSubShapesAttrList = selectionList(SUBSHAPES_ID()); if(!aShapeAttrSelection.get() || !aSubShapesAttrList.get()) { return; } diff --git a/src/BuildPlugin/BuildPlugin_SubShapes.h b/src/BuildPlugin/BuildPlugin_SubShapes.h index 8910f0c0f..c1f4acc06 100644 --- a/src/BuildPlugin/BuildPlugin_SubShapes.h +++ b/src/BuildPlugin/BuildPlugin_SubShapes.h @@ -35,10 +35,10 @@ public: } /// Attribute name of sub-shapes. - inline static const std::string& SUB_SHAPES_ID() + inline static const std::string& SUBSHAPES_ID() { - static const std::string MY_SUB_SHAPES_ID("sub_shapes"); - return MY_SUB_SHAPES_ID; + static const std::string MY_SUBSHAPES_ID("subshapes"); + return MY_SUBSHAPES_ID; } /// \return the kind of a feature. diff --git a/src/BuildPlugin/BuildPlugin_Validators.cpp b/src/BuildPlugin/BuildPlugin_Validators.cpp index 4027ff1d8..b3ede6d60 100644 --- a/src/BuildPlugin/BuildPlugin_Validators.cpp +++ b/src/BuildPlugin/BuildPlugin_Validators.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -229,9 +230,9 @@ bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAtt const std::list& theArguments, std::string& theError) const { - if(theArguments.size() != 2) { + if(theArguments.size() != 1) { Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection should be used only with " - "2 parameters (ID of base shape; Sketch feature id)."); + "1 parameter(Sketch feature id)."); return false; } @@ -250,8 +251,9 @@ bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAtt } // Get base shape. + const std::string aBaseShapeId = "base_shape"; FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); - AttributeSelectionPtr aShapeAttrSelection = aFeature->selection(theArguments.front()); + AttributeSelectionPtr aShapeAttrSelection = aFeature->selection(aBaseShapeId); if(!aShapeAttrSelection.get()) { theError = "Base shape is empty."; @@ -266,6 +268,10 @@ bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAtt return false; } + GeomAlgoAPI_ShapeBuilder aBuilder; + aBuilder.removeInternal(aBaseShape); + aBaseShape = aBuilder.shape(); + // If selected shape is wire allow to select only vertices. If face - allow vertices and edges. std::set anAllowedTypes; switch(aBaseShape->shapeType()) { @@ -277,18 +283,22 @@ bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAtt // Check selected shapes. GeomValidators_FeatureKind aFeatureKindValidator; std::list anArguments; - anArguments.push_back(theArguments.back()); + anArguments.push_back(theArguments.front()); for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) { AttributeSelectionPtr aSelectionAttrInList = aSelectionList->value(anIndex); if(!aSelectionAttrInList.get()) { theError = "Empty attribute in list."; return false; } - // If context not same check that it is a selection on Sketch. - if(aBaseContext != aSelectionAttrInList->context()) { - if(!aFeatureKindValidator.isValid(aSelectionAttrInList, anArguments, theError)) { - return false; - } + + // If context of selection same skip. + if(aBaseContext == aSelectionAttrInList->context()) { + continue; + } + + // Check that it is a selection on Sketch. + if(!aFeatureKindValidator.isValid(aSelectionAttrInList, anArguments, theError)) { + return false; } // Check shape type. diff --git a/src/BuildPlugin/subshapes_widget.xml b/src/BuildPlugin/subshapes_widget.xml index 7c9dcb5f9..2548d39c5 100644 --- a/src/BuildPlugin/subshapes_widget.xml +++ b/src/BuildPlugin/subshapes_widget.xml @@ -8,12 +8,12 @@ concealment="true"> - - +