From: nds Date: Fri, 4 Dec 2015 15:58:30 +0000 (+0300) Subject: Construction of vertices/edges/faces on the base of sketch: sketch attribute X-Git-Tag: V_2.1.0~213 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e682dfb39c7f322a49f2e8bae4ea520fbc48ab0;p=modules%2Fshaper.git Construction of vertices/edges/faces on the base of sketch: sketch attribute --- diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 9b4aa471d..acb34da8f 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -550,6 +550,21 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute, } } } + if (anAttributeType == ModelAPI_AttributeSelection::typeId()) { + AttributeSelectionPtr aSelectAttr = + std::dynamic_pointer_cast(theAttribute); + ObjectPtr anObject = aSelectAttr->context(); + // a context of the selection attribute is a feature result. It can be a case when the result + // of the feature is null, e.g. the feature is modified and has not been executed yet. + // The validator returns an invalid result here. The case is an extrusion built on a sketch + // feature. A new sketch element creation leads to an empty result. + if (!anObject.get()) + isSketchEntities = false; + else { + FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end(); + } + } if (anAttributeType == ModelAPI_AttributeRefList::typeId()) { AttributeRefListPtr aRefListAttr = std::dynamic_pointer_cast(theAttribute); diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp index 0b45548c4..71f918cd2 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp +++ b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp @@ -6,6 +6,7 @@ #include "SketchShapePlugin_Feature.h" +#include #include #include @@ -16,6 +17,7 @@ SketchShapePlugin_Feature::SketchShapePlugin_Feature() void SketchShapePlugin_Feature::initAttributes() { + data()->addAttribute(SKETCH_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(VERTEX_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(VERTEX_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId()); } diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.h b/src/SketchShapePlugin/SketchShapePlugin_Feature.h index 6e38662a2..9ed0150d4 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_Feature.h +++ b/src/SketchShapePlugin/SketchShapePlugin_Feature.h @@ -29,6 +29,13 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature return MY_SKETCH_SHAPE_ID; } + /// Sketch feature + inline static const std::string& SKETCH_ID() + { + static const std::string MY_SKETCH_ID("Sketch"); + return MY_SKETCH_ID; + } + /// List of vertices to be extracted inline static const std::string& VERTEX_LIST_ID() { diff --git a/src/SketchShapePlugin/plugin-SketchShape.xml b/src/SketchShapePlugin/plugin-SketchShape.xml index 016198101..4a9b54ccb 100755 --- a/src/SketchShapePlugin/plugin-SketchShape.xml +++ b/src/SketchShapePlugin/plugin-SketchShape.xml @@ -4,6 +4,13 @@ + + +