From: mpv Date: Mon, 29 Dec 2014 12:52:34 +0000 (+0300) Subject: Allows to append the naming name in the group. X-Git-Tag: V_0.7.0_rc1~17^2~1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3eefbda41672629fb0654e1c6ab1d707d6879686;p=modules%2Fshaper.git Allows to append the naming name in the group. --- diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 14a684a96..0643a520b 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -11,6 +11,7 @@ #include "Model_Data.h" #include +#include using namespace std; @@ -30,6 +31,35 @@ void Model_AttributeSelectionList::append( owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeSelectionList::append(std::string theNamingName) +{ + int aNewTag = mySize->Get() + 1; + TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); + + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aNewLab)); + if (owner()) { + aNewAttr->setObject(owner()); + } + mySize->Set(aNewTag); + TopAbs_ShapeEnum aType = (TopAbs_ShapeEnum)selectionType(); + string aTypeName; + switch(aType) { + case TopAbs_VERTEX: aTypeName = "VERT"; break; + case TopAbs_EDGE: aTypeName = "EDGE"; break; + case TopAbs_WIRE: aTypeName = "WIRE"; break; + case TopAbs_FACE: aTypeName = "FACE"; break; + case TopAbs_SHELL: aTypeName = "SHEL"; break; + case TopAbs_SOLID: aTypeName = "SOLD"; break; + case TopAbs_COMPOUND: aTypeName = "COMP"; break; + case TopAbs_COMPSOLID: aTypeName = "COMS"; break; + default: + return; // invalid case => empty new attribute + }; + aNewAttr->selectSubShape(aTypeName, theNamingName); + owner()->data()->sendAttributeUpdated(this); +} + int Model_AttributeSelectionList::size() { return mySize->Get(); diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index dcfc8b85d..fdae79ee6 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -29,6 +29,10 @@ public: MODEL_EXPORT virtual void append( const ResultPtr& theContext, const std::shared_ptr& theSubShape); + /// Adds the new reference to the end of the list by the naming name of the selected shape + /// The type of shape is taken from the current selection type + MODEL_EXPORT virtual void append(std::string theNamingName); + /// Returns the number ofselection attributes in the list MODEL_EXPORT virtual int size(); diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index fec280f37..dbcdb0bc9 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -23,6 +23,10 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute virtual void append(const ResultPtr& theContext, const GeomShapePtr& theSubShape) = 0; + /// Adds the new reference to the end of the list by the naming name of the selected shape + /// The type of shape is taken from the current selection type + virtual void append(std::string theNamingName) = 0; + /// Returns the number ofselection attributes in the list virtual int size() = 0;