Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / Model / Model_AttributeSelectionList.cpp
index 4a2012a3323ec367dcbdb404f54d706023ce442a..0643a520bb91a23e620d37c64fefe8413ba3da90 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeSelectionList.h
 // Created:     22 Oct 2014
 // Author:      Mikhail PONIKAROV
 #include "Model_Data.h"
 
 #include <TDF_ChildIterator.hxx>
+#include <TopAbs_ShapeEnum.hxx>
 
 using namespace std;
 
 void Model_AttributeSelectionList::append(
-    const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape)
+    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
   int aNewTag = mySize->Get() + 1;
   TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
 
-  boost::shared_ptr<Model_AttributeSelection> aNewAttr = 
-    boost::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aNewLab));
+  std::shared_ptr<Model_AttributeSelection> aNewAttr = 
+    std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aNewLab));
   if (owner()) {
     aNewAttr->setObject(owner());
   }
@@ -28,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<Model_AttributeSelection> aNewAttr = 
+    std::shared_ptr<Model_AttributeSelection>(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();
@@ -43,15 +75,15 @@ void Model_AttributeSelectionList::setSelectionType(int theType)
   mySelectionType->Set((double) theType);
 }
 
-boost::shared_ptr<ModelAPI_AttributeSelection> 
+std::shared_ptr<ModelAPI_AttributeSelection> 
   Model_AttributeSelectionList::value(const int theIndex)
 {
   TDF_Label aLabel = mySize->Label().FindChild(theIndex + 1);
   // create a new attribute each time, by demand
   // supporting of old attributes is too slow (synch each time) and buggy on redo
   // (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid)
-  boost::shared_ptr<Model_AttributeSelection> aNewAttr = 
-    boost::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLabel));
+  std::shared_ptr<Model_AttributeSelection> aNewAttr = 
+    std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLabel));
   if (owner()) {
     aNewAttr->setObject(owner());
   }