Salome HOME
Added geometrical selection flag to attribute selection list.
[modules/shaper.git] / src / Model / Model_AttributeSelectionList.cpp
index bc1c7f1172376ea7164b04ee6d2664a132d494ac..f32fbcf6396c0b6b8cd01a24cd9a6a819d99c203 100644 (file)
@@ -24,6 +24,7 @@
 #include "Model_Events.h"
 #include "Model_Data.h"
 
+#include <GeomAPI_Pnt.h>
 #include <GeomAPI_Shape.h>
 
 #include <TDF_AttributeIterator.hxx>
@@ -78,7 +79,7 @@ void Model_AttributeSelectionList::append(
 }
 
 void Model_AttributeSelectionList::append(
-  const std::string theNamingName, const std::string& theType)
+  const std::string& theNamingName, const std::string& theType)
 {
   int aNewTag = mySize->Get() + 1;
   TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
@@ -95,6 +96,41 @@ void Model_AttributeSelectionList::append(
   owner()->data()->sendAttributeUpdated(this);
 }
 
+void Model_AttributeSelectionList::append(const GeomPointPtr& thePoint, const std::string& theType)
+{
+  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());
+    aNewAttr->setParent(this);
+  }
+  aNewAttr->setID(id());
+  mySize->Set(aNewTag);
+  aNewAttr->selectSubShape(theType, thePoint);
+  owner()->data()->sendAttributeUpdated(this);
+}
+
+void Model_AttributeSelectionList::append(const std::string& theType,
+  const std::string& theContextName, const int theIndex)
+{
+  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());
+    aNewAttr->setParent(this);
+  }
+  aNewAttr->setID(id());
+  mySize->Set(aNewTag);
+  aNewAttr->selectSubShape(theType, theContextName, theIndex);
+  owner()->data()->sendAttributeUpdated(this);
+}
+
 void Model_AttributeSelectionList::removeTemporaryValues()
 {
   if (myTmpAttr.get()) {
@@ -296,11 +332,11 @@ std::shared_ptr<ModelAPI_AttributeSelection>
   // (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid)
   std::shared_ptr<Model_AttributeSelection> aNewAttr =
     std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLabel));
-  aNewAttr->setID(id());
   if (owner()) {
     aNewAttr->setObject(owner());
     aNewAttr->setParent(this);
   }
+  aNewAttr->setID(id());
   return aNewAttr;
 }
 
@@ -335,8 +371,9 @@ bool Model_AttributeSelectionList::isInitialized()
 }
 
 Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel)
+: myLab(theLabel),
+  myIsGeometricalSelection(false)
 {
-  myLab = theLabel;
   reinit();
 }
 
@@ -366,3 +403,11 @@ void Model_AttributeSelectionList::cashValues(const bool theEnabled)
     }
   }
 }
+
+void Model_AttributeSelectionList::setGeometricalSelection(const bool theIsGeometricalSelection)
+{
+  myIsGeometricalSelection = theIsGeometricalSelection;
+  // TODO: update list accodring to the flag:
+  // false - all objects with same geometry must be splited in separate.
+  // true - all objets with same geometry must be combined into single.
+}