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());
}
- mySubs.push_back(aNewAttr);
mySize->Set(aNewTag);
aNewAttr->setValue(theContext, theSubShape);
owner()->data()->sendAttributeUpdated(this);
return mySize->Get();
}
-boost::shared_ptr<ModelAPI_AttributeSelection>
+int Model_AttributeSelectionList::selectionType()
+{
+ return (int) mySelectionType->Get();
+}
+
+void Model_AttributeSelectionList::setSelectionType(int theType)
+{
+ mySelectionType->Set((double) theType);
+}
+
+std::shared_ptr<ModelAPI_AttributeSelection>
Model_AttributeSelectionList::value(const int theIndex)
{
- return mySubs[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)
+ std::shared_ptr<Model_AttributeSelection> aNewAttr =
+ std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLabel));
+ if (owner()) {
+ aNewAttr->setObject(owner());
+ }
+ return aNewAttr;
}
void Model_AttributeSelectionList::clear()
{
- if (!mySubs.empty()) {
- mySubs.clear();
+ if (mySize->Get() != 0) {
+ mySize->Set(0);
TDF_ChildIterator aSubIter(mySize->Label());
for(; aSubIter.More(); aSubIter.Next()) {
aSubIter.Value().ForgetAllAttributes(Standard_True);
myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;
if (!myIsInitialized) {
mySize = TDataStd_Integer::Set(theLabel, 0);
+ mySelectionType = TDataStd_Real::Set(theLabel, 0);
} else { // recollect mySubs
- int aNum = mySize->Get();
- TDF_ChildIterator aSubIter(theLabel);
- for(; aSubIter.More(), aNum != 0; aSubIter.Next(), aNum--) {
- TDF_Label aChildLab = aSubIter.Value();
- boost::shared_ptr<Model_AttributeSelection> aNewAttr =
- boost::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aChildLab));
- if (owner())
- aNewAttr->setObject(owner());
- mySubs.push_back(aNewAttr);
- }
- }
-}
-
-void Model_AttributeSelectionList::setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
-{
- ModelAPI_AttributeSelectionList::setObject(theObject);
- std::vector<boost::shared_ptr<Model_AttributeSelection> >::iterator aSubIter = mySubs.begin();
- for(; aSubIter != mySubs.end(); aSubIter++) {
- (*aSubIter)->setObject(theObject);
+ theLabel.FindAttribute(TDataStd_Real::GetID(), mySelectionType);
}
}