-void ModuleBase_WidgetMultiSelector::storeAttributeValue()
-{
- ModuleBase_WidgetValidated::storeAttributeValue();
-
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = aData->attribute(attributeID());
- std::string aType = anAttribute->attributeType();
- if (aType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
- mySelectionType = aSelectionListAttr->selectionType();
- mySelectionCount = aSelectionListAttr->size();
- }
- else if (aType == ModelAPI_AttributeRefList::typeId()) {
- AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
- mySelectionCount = aRefListAttr->size();
- }
- else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
- AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
- mySelectionCount = aRefAttrListAttr->size();
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool theValid)
-{
- ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
-
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = aData->attribute(attributeID());
- std::string aType = anAttribute->attributeType();
- if (aType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
- 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 if (aType == ModelAPI_AttributeRefList::typeId()) {
- AttributeRefListPtr aRefListAttr = aData->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();
- }
- else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
- AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
- // restore objects in the attribute. Indeed there is only one stored object
- int aCountAppened = aRefAttrListAttr->size() - mySelectionCount;
- for (int i = 0; i < aCountAppened; i++)
- aRefAttrListAttr->removeLast();
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::clearAttribute()
-{
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = aData->attribute(attributeID());
- std::string aType = anAttribute->attributeType();
- if (aType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
- aSelectionListAttr->clear();
- }
- else if (aType == ModelAPI_AttributeRefList::typeId()) {
- AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
- aRefListAttr->clear();
- }
- else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
- AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
- aRefAttrListAttr->clear();
- }
-}
-
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theSelectedObject,
- GeomShapePtr theShape)
-{
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = aData->attribute(attributeID());
- std::string aType = anAttribute->attributeType();
- if (aType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
- aSelectionListAttr->append(aResult, theShape, myIsInValidate);
- }
- else if (aType == ModelAPI_AttributeRefList::typeId()) {
- AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
- aRefListAttr->append(theSelectedObject);
- }
- else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
- AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
-
- AttributePtr anAttribute = myWorkshop->module()->findAttribute(theSelectedObject, theShape);
- if (anAttribute.get())
- aRefAttrListAttr->append(anAttribute);
- else
- aRefAttrListAttr->append(theSelectedObject);
- }
-}
-
-//********************************************************************
-bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,