From: nds Date: Fri, 4 Dec 2015 17:31:25 +0000 (+0300) Subject: Construction of vertices/edges/faces on the base of sketch: clear list attribute... X-Git-Tag: V_2.1.0~212 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e7f97125b2198724911564b24b0a30cbd393e3d;p=modules%2Fshaper.git Construction of vertices/edges/faces on the base of sketch: clear list attribute by choice uncheck --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index d3dffd6a2..0d8d976fa 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -61,7 +61,7 @@ public: /// Redefinition of virtual method virtual QSize minimumSizeHint() const { - int aHeight = 2*QFontMetrics( font() ).height(); + int aHeight = 4/*2*/*QFontMetrics( font() ).height(); QSize aSize = QListWidget::minimumSizeHint(); return QSize( aSize.width(), aHeight ); } 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); + } + } + } } diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.h b/src/SketchShapePlugin/SketchShapePlugin_Feature.h index 9ed0150d4..0a59da95d 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_Feature.h +++ b/src/SketchShapePlugin/SketchShapePlugin_Feature.h @@ -36,6 +36,13 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature return MY_SKETCH_ID; } + /// State whether the vertices are selectable + inline static const std::string& VERTEX_CHOICE_ID() + { + static const std::string MY_VERTEX_CHOICE_ID("VertexChoice"); + return MY_VERTEX_CHOICE_ID; + } + /// List of vertices to be extracted inline static const std::string& VERTEX_LIST_ID() { @@ -43,11 +50,32 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature return MY_VERTEX_LIST_ID; } - /// State whether the vertices are selectable - inline static const std::string& VERTEX_CHOICE_ID() + /// State whether the vertices are selectable + inline static const std::string& EDGE_CHOICE_ID() { - static const std::string MY_VERTEX_CHOICE_ID("VertexChoice"); - return MY_VERTEX_CHOICE_ID; + static const std::string MY_EDGE_CHOICE_ID("EdgeChoice"); + return MY_EDGE_CHOICE_ID; + } + + /// List of vertices to be extracted + inline static const std::string& EDGE_LIST_ID() + { + static const std::string MY_EDGE_LIST_ID("EdgeList"); + return MY_EDGE_LIST_ID; + } + + /// State whether the vertices are selectable + inline static const std::string& FACE_CHOICE_ID() + { + static const std::string MY_FACE_CHOICE_ID("FaceChoice"); + return MY_FACE_CHOICE_ID; + } + + /// List of vertices to be extracted + inline static const std::string& FACE_LIST_ID() + { + static const std::string MY_FACE_LIST_ID("FaceList"); + return MY_FACE_LIST_ID; } /// Returns the kind of a feature diff --git a/src/SketchShapePlugin/plugin-SketchShape.xml b/src/SketchShapePlugin/plugin-SketchShape.xml index 4a9b54ccb..6f51667ca 100755 --- a/src/SketchShapePlugin/plugin-SketchShape.xml +++ b/src/SketchShapePlugin/plugin-SketchShape.xml @@ -15,8 +15,28 @@ + + + + + + + + + +