1 // File: Model_AttributeSelectionList.h
2 // Created: 22 Oct 2014
3 // Author: Mikhail PONIKAROV
5 #include "Model_AttributeSelectionList.h"
6 #include "Model_AttributeSelection.h"
7 #include "Model_Application.h"
8 #include "Model_Events.h"
9 #include "Model_Data.h"
11 #include <TDF_ChildIterator.hxx>
15 void Model_AttributeSelectionList::append(
16 const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape)
18 int aNewTag = mySize->Get() + 1;
19 TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
20 mySubs.push_back(boost::shared_ptr<Model_AttributeSelection>(
21 new Model_AttributeSelection(aNewLab)));
25 int Model_AttributeSelectionList::size()
30 boost::shared_ptr<ModelAPI_AttributeSelection>
31 Model_AttributeSelectionList::value(const int theIndex)
33 return mySubs[theIndex];
36 void Model_AttributeSelectionList::clear()
39 TDF_ChildIterator aSubIter(mySize->Label());
40 for(; aSubIter.More(); aSubIter.Next()) {
41 aSubIter.Value().ForgetAllAttributes(Standard_True);
45 Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel)
47 myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;
48 if (!myIsInitialized) {
49 mySize = TDataStd_Integer::Set(theLabel, 0);
50 } else { // recollect mySubs
51 int aNum = mySize->Get();
52 TDF_ChildIterator aSubIter(theLabel);
53 for(; aSubIter.More(), aNum != 0; aSubIter.Next(), aNum--) {
54 TDF_Label aChildLab = aSubIter.Value();
55 boost::shared_ptr<Model_AttributeSelection> aNewAttr =
56 boost::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aChildLab));
58 aNewAttr->setObject(owner());
59 mySubs.push_back(aNewAttr);
64 void Model_AttributeSelectionList::setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
66 ModelAPI_AttributeSelectionList::setObject(theObject);
67 std::vector<boost::shared_ptr<Model_AttributeSelection> >::iterator aSubIter = mySubs.begin();
68 for(; aSubIter != mySubs.end(); aSubIter++) {
69 (*aSubIter)->setObject(theObject);