X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchShapePlugin%2FSketchShapePlugin_Feature.cpp;h=4de0c8de33f3a5e99516b8348288a5b06164e0f2;hb=5403f92db67b8ee3ee88fe27b93e6daa4adf7287;hp=71f918cd2b61523cee8152eda1720e93e59b0f8b;hpb=3e682dfb39c7f322a49f2e8bae4ea520fbc48ab0;p=modules%2Fshaper.git diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp index 71f918cd2..4de0c8de3 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp +++ b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp @@ -10,6 +10,9 @@ #include #include +#include +#include + SketchShapePlugin_Feature::SketchShapePlugin_Feature() : ModelAPI_Feature() { @@ -18,8 +21,18 @@ 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()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERTEX_CHOICE_ID()); + + data()->addAttribute(EDGE_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + data()->addAttribute(EDGE_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EDGE_CHOICE_ID()); + + data()->addAttribute(FACE_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + data()->addAttribute(FACE_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FACE_CHOICE_ID()); } void SketchShapePlugin_Feature::execute() @@ -28,5 +41,35 @@ void SketchShapePlugin_Feature::execute() void SketchShapePlugin_Feature::attributeChanged(const std::string& theID) { + if (theID == VERTEX_CHOICE_ID() || + theID == EDGE_CHOICE_ID() || + theID == FACE_CHOICE_ID()) { + std::string aListAttrId = theID == VERTEX_CHOICE_ID() ? VERTEX_LIST_ID() : ( + theID == EDGE_CHOICE_ID() ? EDGE_LIST_ID() : + FACE_LIST_ID()); + + AttributeBooleanPtr aChoiceAttribute = std::dynamic_pointer_cast( + data()->attribute(theID)); + if (!aChoiceAttribute->value()) { + AttributeSelectionListPtr aListAttribute = + std::dynamic_pointer_cast(data()->attribute(aListAttrId)); + aListAttribute->clear(); + } + } + else if (theID == VERTEX_LIST_ID() || + theID == EDGE_LIST_ID() || + theID == FACE_LIST_ID()) { + AttributeSelectionListPtr aSelectionListAttr = + std::dynamic_pointer_cast(data()->attribute(theID)); + for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) { + AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i); + ObjectPtr anObject = aSelectAttr->context(); + if (!anObject.get()) + continue; + else { + FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + } + } + } }