- DataPtr aData = myFeature->data();
- AttributeSelectionListPtr aSelectionListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
- aSelectionListAttr->clear();
+ ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
+
+ // Store shape type
+ AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+ if (aSelectionListAttr.get()) {
+ aSelectionListAttr->setSelectionType(mySelectionType);
+
+ // restore selection in the attribute. Indeed there is only one stored object
+ int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
+ for (int i = 0; i < aCountAppened; i++)
+ aSelectionListAttr->removeLast();
+ }
+ else {
+ AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+ // restore objects in the attribute. Indeed there is only one stored object
+ int aCountAppened = aRefListAttr->size() - mySelectionCount;
+ for (int i = 0; i < aCountAppened; i++)
+ aRefListAttr->removeLast();
+ }