+
+QList<ActionInfo>
+ ModuleBase_WidgetMultiSelector::actionsList(ModuleBase_ActionType theActionType) const
+{
+ QList<ActionInfo> aList;
+ if (myCurrentHistoryIndex > -1) {
+ int i = 0;
+ QString aTitle("Selection %1 items");
+ QString aTit("Selection %1 item");
+ QIcon aIcon(":pictures/selection.png");
+ int aNb;
+ switch (theActionType) {
+ case ActionUndo:
+ i = 1;
+ while (i <= myCurrentHistoryIndex) {
+ aNb = mySelectedHistoryValues.at(i).count();
+ if (aNb == 1) {
+ ActionInfo aInfo(aIcon, aTit.arg(aNb));
+ aList.insert(0, aInfo);
+ } else {
+ ActionInfo aInfo(aIcon, aTitle.arg(aNb));
+ aList.insert(0, aInfo);
+ }
+ i++;
+ }
+ break;
+ case ActionRedo:
+ i = mySelectedHistoryValues.length() - 1;
+ while (i > myCurrentHistoryIndex) {
+ aNb = mySelectedHistoryValues.at(i).count();
+ if (aNb == 1) {
+ ActionInfo aInfo(aIcon, aTit.arg(mySelectedHistoryValues.at(i).count()));
+ aList.insert(0, aInfo);
+ } else {
+ ActionInfo aInfo(aIcon, aTitle.arg(mySelectedHistoryValues.at(i).count()));
+ aList.insert(0, aInfo);
+ }
+ i--;
+ }
+ break;
+ default: // [to avoid compilation warning]
+ break;
+ }
+ }
+ return aList;
+}
+
+
+void ModuleBase_WidgetMultiSelector::onFeatureAccepted()
+{
+ defaultValues[myFeatureId + attributeID()] = myDefMode;
+}
+
+void ModuleBase_WidgetMultiSelector::onListActivated()
+{
+ //focusTo();
+ emitFocusInWidget();
+}
+
+void ModuleBase_WidgetMultiSelector::onSameTopology(bool theOn)
+{
+ AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+ std::string aType = anAttribute->attributeType();
+ if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+ aSelectionListAttr->setGeometricalSelection(theOn);
+ updateObject(myFeature);
+ }
+}
+
+void ModuleBase_WidgetMultiSelector::onShowOnly(bool theChecked)
+{
+ std::list<ResultPtr> aResults = myFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ if (theChecked) {
+ myVisibleObjects = myWorkshop->displayedObjects();
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+ myVisibleObjects.removeAll(*aIt);
+ }
+ myWorkshop->module()->disableCustomMode(ModuleBase_IModule::CustomizeArguments);
+ }
+ else
+ myWorkshop->module()->enableCustomModes();
+
+ foreach(ObjectPtr aObj, myVisibleObjects) {
+ aObj->setDisplayed(!theChecked);
+ }
+
+ if (!theChecked) {
+ // Hide and show the group result in order to make it above all objects
+ bool aOldState = myWorkshop->enableUpdateViewer(false);
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+ (*aIt)->setDisplayed(false);
+ }
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+ (*aIt)->setDisplayed(true);
+ }
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ myWorkshop->enableUpdateViewer(aOldState);
+
+ myVisibleObjects.clear();
+ } else
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ myWorkshop->viewer()->update();
+}
+
+bool ModuleBase_WidgetMultiSelector::isModified() const
+{
+ return myListView->getControl()->count() > 0;
+}
+
+
+void ModuleBase_WidgetMultiSelector::setReadOnly(bool isReadOnly)
+{
+ ModuleBase_WidgetSelector::setReadOnly(isReadOnly);
+ if (myShowOnlyBtn)
+ myShowOnlyBtn->hide();
+ if (myFiltersWgt) {
+ myFiltersWgt->hide();
+
+ AttributeSelectionListPtr aAttrList = feature()->selectionList(attributeID());
+ if (aAttrList.get()) {
+ FiltersFeaturePtr aFilters = aAttrList->filters();
+ if (aFilters.get()) {
+ ModuleBase_WidgetSelectionFilter::SelectorFeature = feature();
+ ModuleBase_WidgetSelectionFilter::AttributeId = attributeID();
+
+ std::string aXmlCfg, aDescription;
+ myWorkshop->module()->getXMLRepresentation(myUseFilters, aXmlCfg, aDescription);
+
+ ModuleBase_WidgetSelectionFilter* aWgt =
+ new ModuleBase_WidgetSelectionFilter(this, myWorkshop,
+ new Config_WidgetAPI(aDescription), true);
+ aWgt->setFeature(aFilters);
+ aWgt->restoreValue();
+ myMainLayout->addWidget(aWgt);
+ }
+ }
+ }
+}