+ // Clear current selection in order to avoid updating of object browser with obsolete indexes
+ // which can appear because of results deletetion after changing a type of selection
+ QString aSelectionType = myTypeCtrl->textValue();
+ QList<ModuleBase_ViewerPrsPtr> aEmptyList;
+ myWorkshop->setSelected(aEmptyList);
+
+ updateSelectionModesAndFilters(true);
+ myWorkshop->selectionActivate()->updateSelectionModes();
+
+ if (!myFeature)
+ return;
+ /// store the selected type
+ AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+ std::string aType = anAttribute->attributeType();
+ if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+ aSelectionListAttr->setSelectionType(aSelectionType.toStdString());
+ }
+
+ // clear attribute values
+ DataPtr aData = myFeature->data();
+ 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();
+ }
+
+ // update object is necessary to flush update signal. It leads to objects references map update
+ // and the operation presentation will not contain deleted items visualized as parameters of
+ // the feature.
+ updateObject(myFeature);
+ restoreValue();
+ myWorkshop->setSelected(getAttributeSelection());
+ // may be the feature's result is not displayed, but attributes should be
+ myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+ true); /// hope that something is redisplayed by object updated
+ // clear history should follow after set selected to do not increase history by setSelected
+ clearSelectedHistory();
+
+ if (myWorkshop->propertyPanel()->activeWidget() != this)
+ myWorkshop->propertyPanel()->activateWidget(this);
+}
+
+//********************************************************************
+bool ModuleBase_WidgetMultiSelector::processSelection()
+{
+ if (!myIsNeutralPointClear) {
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
+ // do not clear selected object
+ if (aSelected.size() == 0) {
+ if (!getAttributeSelection().empty()) {
+ // Restore selection in the viewer by the attribute selection list
+ // it should be postponed to exit from the selectionChanged processing
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
+ ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
+ Events_Loop::loop()->flush(anEvent);
+ return true;
+ }
+ }
+ }
+ appendFirstSelectionInHistory();
+ bool aDone = ModuleBase_WidgetSelector::processSelection();
+ appendSelectionInHistory();
+ return aDone;
+}
+
+void ModuleBase_WidgetMultiSelector::appendFirstSelectionInHistory()
+{
+ if (mySelectedHistoryValues.empty()) {
+ myCurrentHistoryIndex++;
+ mySelectedHistoryValues.append(getAttributeSelection());
+
+#ifdef DEBUG_UNDO_REDO
+ printHistoryInfo("appendSelectionInHistory", myCurrentHistoryIndex, mySelectedHistoryValues);
+#endif
+ }
+}
+
+void ModuleBase_WidgetMultiSelector::appendSelectionInHistory()
+{
+ while (myCurrentHistoryIndex != mySelectedHistoryValues.count() - 1)
+ mySelectedHistoryValues.removeLast();
+
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
+ myCurrentHistoryIndex++;
+ mySelectedHistoryValues.append(aSelected);
+ myWorkshop->updateCommandStatus();
+
+#ifdef DEBUG_UNDO_REDO
+ printHistoryInfo("appendSelectionInHistory", myCurrentHistoryIndex, mySelectedHistoryValues);
+#endif
+}
+
+void ModuleBase_WidgetMultiSelector::clearSelectedHistory()
+{
+ mySelectedHistoryValues.clear();
+ myCurrentHistoryIndex = -1;
+ myWorkshop->updateCommandStatus();
+
+#ifdef DEBUG_UNDO_REDO
+ printHistoryInfo("clearSelectedHistory", myCurrentHistoryIndex, mySelectedHistoryValues);
+#endif