1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ModuleBase_WidgetSelectionFilter.h"
21 #include "ModuleBase_Tools.h"
22 #include "ModuleBase_IWorkshop.h"
23 #include "ModuleBase_ISelectionActivate.h"
24 #include "ModuleBase_IModule.h"
25 #include "ModuleBase_IViewer.h"
26 #include "ModuleBase_IPropertyPanel.h"
27 #include "ModuleBase_PageWidget.h"
28 #include "ModuleBase_WidgetMultiSelector.h"
29 #include "ModuleBase_ResultPrs.h"
30 #include "ModuleBase_WidgetFactory.h"
32 #include <ModelAPI_Session.h>
33 #include <ModelAPI_AttributeSelectionList.h>
34 #include <ModelAPI_Events.h>
35 #include <ModelAPI_FiltersFactory.h>
36 #include <ModelAPI_ResultBody.h>
37 #include <GeomAPI_ShapeExplorer.h>
39 #include <Events_Loop.h>
40 #include <Config_ValidatorReader.h>
42 #include <AIS_InteractiveContext.hxx>
43 #include <StdSelect_BRepOwner.hxx>
44 #include <TopoDS_Compound.hxx>
45 #include <BRep_Builder.hxx>
48 #include <QPushButton>
53 #include <QToolButton>
56 static FeaturePtr SelectorFeature;
57 static std::string AttributeId;
60 GeomAPI_Shape::ShapeType selectionType(const QString& theType)
62 QString aType = theType.toUpper();
63 if ((aType == "VERTEX") || (aType == "VERTICES"))
64 return GeomAPI_Shape::VERTEX;
65 else if ((aType == "EDGE") || (aType == "EDGES"))
66 return GeomAPI_Shape::EDGE;
67 else if ((aType == "WIRE") || (aType == "WIRES"))
68 return GeomAPI_Shape::WIRE;
69 else if ((aType == "FACE") || (aType == "FACES"))
70 return GeomAPI_Shape::FACE;
71 else if ((aType == "SHELL") || (aType == "SHELLS"))
72 return GeomAPI_Shape::SHELL;
73 else if ((aType == "SOLID") || (aType == "SOLIDS"))
74 return GeomAPI_Shape::SOLID;
75 else if ((aType == "COMPSOLID") || (aType == "COMPSOLIDS"))
76 return GeomAPI_Shape::COMPSOLID;
77 else if ((aType == "COMPOUND") || (aType == "COMPOUNDS"))
78 return GeomAPI_Shape::COMPOUND;
80 return GeomAPI_Shape::SHAPE;
84 ModuleBase_FilterStarter::ModuleBase_FilterStarter(const std::string& theFeature,
85 QWidget* theParent, ModuleBase_IWorkshop* theWorkshop)
87 myFeatureName(theFeature),
88 myWorkshop(theWorkshop)
90 QHBoxLayout* aMainLayout = new QHBoxLayout(this);
91 ModuleBase_Tools::adjustMargins(aMainLayout);
93 aMainLayout->addStretch(1);
94 QPushButton* aLaunchBtn = new QPushButton(tr("Selection by filters"), this);
95 connect(aLaunchBtn, SIGNAL(clicked()), SLOT(onFiltersLaunch()));
96 aMainLayout->addWidget(aLaunchBtn);
99 void ModuleBase_FilterStarter::onFiltersLaunch()
101 ModuleBase_Operation* aParentOp = myWorkshop->currentOperation();
102 ModuleBase_OperationFeature* aFeatureOp = dynamic_cast<ModuleBase_OperationFeature*>(aParentOp);
104 // Open transaction on filters operation finish
105 aFeatureOp->openTransactionOnResume();
107 QWidget* aParent = parentWidget();
108 ModuleBase_WidgetMultiSelector* aSelector =
109 dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);
111 aParent = aParent->parentWidget();
112 aSelector = dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);
116 SelectorFeature = aSelector->feature();
117 AttributeId = aSelector->attributeID();
119 // Launch Filters operation
120 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
121 (myWorkshop->module()->createOperation(myFeatureName));
123 AttributeSelectionListPtr aAttrList = SelectorFeature->selectionList(AttributeId);
124 FiltersFeaturePtr aFilters = aAttrList->filters();
126 aFOperation->setFeature(aFilters);
127 myWorkshop->processLaunchOperation(aFOperation);
130 //*****************************************************************************
131 //*****************************************************************************
132 //*****************************************************************************
133 ModuleBase_FilterItem::ModuleBase_FilterItem(
134 const std::string& theFilter, ModuleBase_WidgetSelectionFilter* theParent)
135 : QWidget(theParent->filtersWidget()), myFilterID(theFilter),
136 mySelection(std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theParent->feature()))
138 std::string aXmlString =
139 ModelAPI_Session::get()->filters()->filter(theFilter)->xmlRepresentation();
140 if (aXmlString.length() == 0)
143 ModuleBase_WidgetFactory aFactory(aXmlString, theParent->workshop());
144 Config_ValidatorReader aValidatorReader(aXmlString, true);
145 aValidatorReader.setFeatureId(mySelection->getKind());
146 aValidatorReader.readAll();
148 QVBoxLayout* aLayout = new QVBoxLayout(this);
149 ModuleBase_Tools::zeroMargins(aLayout);
151 QWidget* aItemRow = new QWidget(this);
152 addItemRow(aItemRow);
153 aLayout->addWidget(aItemRow);
155 ModuleBase_PageWidget* aParamsWgt = new ModuleBase_PageWidget(this);
156 aParamsWgt->setFrameStyle(QFrame::Box | QFrame::Raised);
157 aFactory.createWidget(aParamsWgt);
158 ModuleBase_Tools::zeroMargins(aParamsWgt->layout());
159 myWidgets = aFactory.getModelWidgets();
160 foreach(ModuleBase_ModelWidget* aWidget, myWidgets) {
161 aWidget->setFeature(theParent->feature());
162 connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
163 theParent, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)));
164 connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
165 theParent, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)));
166 connect(aWidget, SIGNAL(objectUpdated()), theParent, SLOT(onObjectUpdated()));
168 aLayout->addWidget(aParamsWgt);
172 void ModuleBase_FilterItem::addItemRow(QWidget* theParent)
174 QHBoxLayout* aLayout = new QHBoxLayout(theParent);
175 ModuleBase_Tools::zeroMargins(aLayout);
177 // Reverse filter button
178 myRevBtn = new QToolButton(theParent);
179 myRevBtn->setCheckable(true);
180 bool isReversed = mySelection->isReversed(myFilterID);
181 myRevBtn->setChecked(isReversed);
182 myRevBtn->setAutoRaise(true);
184 myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
186 myRevBtn->setIcon(QIcon(":pictures/add.png"));
187 myRevBtn->setToolTip(tr("Reverse the filter"));
188 connect(myRevBtn, SIGNAL(toggled(bool)), SLOT(onReverse(bool)));
189 aLayout->addWidget(myRevBtn);
191 const std::string& aFilterName = ModelAPI_Session::get()->filters()->filter(myFilterID)->name();
192 aLayout->addWidget(new QLabel(aFilterName.c_str(), theParent), 1);
194 QToolButton* aDelBtn = new QToolButton(theParent);
195 aDelBtn->setIcon(QIcon(":pictures/delete.png"));
196 aDelBtn->setAutoRaise(true);
197 aDelBtn->setToolTip(tr("Delete the filter"));
198 connect(aDelBtn, SIGNAL(clicked(bool)), SLOT(onDelete()));
199 aLayout->addWidget(aDelBtn);
202 void ModuleBase_FilterItem::onReverse(bool theCheck)
204 mySelection->setReversed(myFilterID, theCheck);
206 myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
208 myRevBtn->setIcon(QIcon(":pictures/add.png"));
209 emit reversedItem(this);
212 void ModuleBase_FilterItem::onDelete()
214 emit deleteItem(this);
218 //*****************************************************************************
219 //*****************************************************************************
220 //*****************************************************************************
221 ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theParent,
222 ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData)
223 : ModuleBase_ModelWidget(theParent, theData),
224 myWorkshop(theWorkshop),
225 mySelectorFeature(SelectorFeature),
226 mySelectorAttribute(AttributeId)
228 // Clear Old selection
229 AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute);
230 mySelectionType = selectionType(aAttrList->selectionType().c_str());
234 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
235 ModuleBase_Tools::adjustMargins(aMainLayout);
237 QGroupBox* aFiltersGroup = new QGroupBox(tr("Filters"), this);
238 QVBoxLayout* aGroupLayout = new QVBoxLayout(aFiltersGroup);
239 aGroupLayout->setContentsMargins(0, 0, 0, 0);
240 aGroupLayout->setSpacing(0);
242 myFiltersWgt = new QWidget();
243 myFiltersLayout = new QVBoxLayout(myFiltersWgt);
244 myFiltersLayout->setContentsMargins(0, 0, 0, 0);
245 aGroupLayout->addWidget(myFiltersWgt);
247 myFiltersCombo = new QComboBox(aFiltersGroup);
248 myFiltersCombo->addItem(tr("Add new filter..."));
249 SessionPtr aSession = ModelAPI_Session::get();
250 std::list<FilterPtr> allFilters =
251 aSession->filters()->filters((GeomAPI_Shape::ShapeType) mySelectionType);
253 std::list<FilterPtr>::const_iterator aIt;
254 for (aIt = allFilters.cbegin(); aIt != allFilters.cend(); aIt++) {
255 aItems.push_back((*aIt)->name().c_str());
256 myFilters.push_back(aSession->filters()->id(*aIt));
258 myFiltersCombo->addItems(aItems);
259 connect(myFiltersCombo, SIGNAL(currentIndexChanged(int)), SLOT(onAddFilter(int)));
261 aGroupLayout->addWidget(myFiltersCombo);
262 aMainLayout->addWidget(aFiltersGroup);
265 QWidget* aBtnWgt = new QWidget(this);
266 QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnWgt);
267 ModuleBase_Tools::adjustMargins(aBtnLayout);
269 aBtnLayout->addStretch(1);
271 mySelectBtn = new QPushButton(tr("Select"), aBtnWgt);
272 connect(mySelectBtn, SIGNAL(clicked()), SLOT(onSelect()));
273 aBtnLayout->addWidget(mySelectBtn);
275 aMainLayout->addWidget(aBtnWgt);
278 QWidget* aLblWgt = new QWidget(this);
279 QHBoxLayout* aLblLayout = new QHBoxLayout(aLblWgt);
280 ModuleBase_Tools::zeroMargins(aLblLayout);
282 aLblLayout->addWidget(new QLabel(tr("Number of selected objects:"), aLblWgt));
284 myNbLbl = new QLabel("0", aLblWgt);
285 aLblLayout->addWidget(myNbLbl);
288 myShowBtn = new QCheckBox(tr("Show only"), this);
289 connect(myShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool)));
290 aLblLayout->addWidget(myShowBtn);
292 aMainLayout->addWidget(aLblWgt);
294 aMainLayout->addStretch(1);
299 ModuleBase_WidgetSelectionFilter::~ModuleBase_WidgetSelectionFilter()
302 if (!myPreview.IsNull()) {
303 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
304 aCtx->Remove(myPreview, false);
306 if (myListIO.Size() > 0) {
307 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
308 AIS_ListOfInteractive::const_iterator aIt;
309 Handle(AIS_Shape) aShapeIO;
310 for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) {
311 aShapeIO = Handle(AIS_Shape)::DownCast(*aIt);
312 if (!aShapeIO.IsNull()) {
313 aCtx->Display(aShapeIO, false);
314 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
315 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO));
316 myWorkshop->applyCurrentSelectionModes(anAISObj);
320 myShowBtn->setChecked(false);
322 aCtx->UpdateCurrentViewer();
324 SelectorFeature = FeaturePtr();
328 void ModuleBase_WidgetSelectionFilter::onAddFilter(int theIndex)
333 std::list<std::string>::iterator aIt;
336 for (aIt = myFilters.begin(), i = 0; aIt != myFilters.cend(); i++, aIt++) {
337 if (i == (theIndex - 1)) {
342 ModuleBase_FilterItem* aItem = onAddFilter(aFilter);
343 FiltersFeaturePtr aFiltersFeature =
344 std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
345 aFiltersFeature->addFilter(aFilter);
347 myFiltersCombo->setCurrentIndex(0);
348 myFiltersCombo->removeItem(theIndex);
349 updateObject(myFeature);
351 if (aItem && (aItem->widgets().size() > 0))
352 aItem->widgets().first()->emitFocusInWidget();
357 ModuleBase_FilterItem* ModuleBase_WidgetSelectionFilter::onAddFilter(const std::string& theFilter)
359 if (theFilter.length() == 0)
361 std::list<std::string>::const_iterator aIt;
362 for (aIt = myUseFilters.cbegin(); aIt != myUseFilters.cend(); aIt++) {
363 if (theFilter == (*aIt))
366 myFilters.remove(theFilter);
367 myUseFilters.push_back(theFilter);
368 ModuleBase_FilterItem* aItem = new ModuleBase_FilterItem(theFilter, this);
369 connect(aItem, SIGNAL(deleteItem(ModuleBase_FilterItem*)),
370 SLOT(onDeleteItem(ModuleBase_FilterItem*)));
371 connect(aItem, SIGNAL(reversedItem(ModuleBase_FilterItem*)),
372 SLOT(onReverseItem(ModuleBase_FilterItem*)));
373 myFiltersLayout->addWidget(aItem);
376 clearCurrentSelection(true);
377 updateNumberSelected();
381 void ModuleBase_WidgetSelectionFilter::onDeleteItem(ModuleBase_FilterItem* theItem)
383 std::string aFilter = theItem->filter();
384 QList<ModuleBase_ModelWidget*> aWidgets = theItem->widgets();
385 foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
388 myFiltersLayout->removeWidget(theItem);
389 theItem->deleteLater();
391 myUseFilters.remove(aFilter);
392 myFilters.push_back(aFilter);
393 myFiltersCombo->addItem(ModelAPI_Session::get()->filters()->filter(aFilter)->name().c_str());
395 FiltersFeaturePtr aFiltersFeature =
396 std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
397 aFiltersFeature->removeFilter(aFilter);
400 clearCurrentSelection(true);
401 updateNumberSelected();
403 myWorkshop->deactivateCurrentSelector();
404 myWorkshop->selectionActivate()->updateSelectionModes();
405 myWorkshop->selectionActivate()->updateSelectionFilters();
408 updateObject(myFeature);
412 void ModuleBase_WidgetSelectionFilter::redisplayFeature()
414 static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
415 ModelAPI_EventCreator::get()->sendUpdated(myFeature, aDispEvent);
416 Events_Loop::loop()->flush(aDispEvent);
419 void ModuleBase_WidgetSelectionFilter::onReverseItem(ModuleBase_FilterItem* theItem)
422 clearCurrentSelection(true);
423 updateNumberSelected();
426 void ModuleBase_WidgetSelectionFilter::onSelect()
428 if (myUseFilters.size() == 0)
430 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
434 clearCurrentSelection();
436 BRep_Builder aBuilder;
437 TopoDS_Compound aComp;
438 aBuilder.MakeCompound(aComp);
440 DocumentPtr aDoc = myFeature->document();
441 int aNb = aDoc->size(ModelAPI_ResultBody::group());
445 for (int i = 0; i < aNb; i++) {
446 aObj = aDoc->object(ModelAPI_ResultBody::group(), i);
447 aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
448 GeomShapePtr aShape = aBody->shape();
449 std::list<GeomShapePtr> aSubShapes =
450 aShape->subShapes((GeomAPI_Shape::ShapeType)mySelectionType);
451 TopTools_MapOfShape alreadyThere;
452 std::list<GeomShapePtr>::const_iterator aShapesIt;
453 for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) {
454 GeomShapePtr aShape = (*aShapesIt);
455 TopoDS_Shape aTShape = aShape->impl<TopoDS_Shape>();
456 if (!alreadyThere.Add(aTShape))
458 static SessionPtr aSession = ModelAPI_Session::get();
459 bool isValid = aSession->filters()->isValid(myFeature, aBody, aShape);
461 aBuilder.Add(aComp, aTShape);
462 ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aShape));
463 myValues.append(aValue);
468 if (myValues.size() > 0)
469 updatePreview(aComp);
470 updateNumberSelected();
471 updateObject(myFeature);
474 void ModuleBase_WidgetSelectionFilter::updatePreview(const TopoDS_Shape& theShape)
476 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
480 if (myPreview.IsNull()) {
481 myPreview = new AIS_Shape(theShape);
482 myPreview->SetDisplayMode(AIS_Shaded);
483 myPreview->SetColor(Quantity_NOC_BLUE1);
484 Handle(Prs3d_Drawer) aDrawer = myPreview->Attributes();
485 if (aDrawer->HasOwnPointAspect()) {
486 aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_STAR);
487 aDrawer->PointAspect()->SetColor(Quantity_NOC_BLUE1);
488 aDrawer->PointAspect()->SetScale(2.);
491 aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_O_STAR, Quantity_NOC_BLUE1, 2.));
492 myPreview->SetTransparency();
493 aCtx->Display(myPreview, true);
494 aCtx->Deactivate(myPreview);
497 myPreview->Set(theShape);
498 aCtx->Redisplay(myPreview, true);
503 void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theShow)
505 if (myPreview.IsNull())
507 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
511 aCtx->DisplayedObjects(AIS_KOI_Shape, -1, myListIO);
512 myListIO.Remove(myPreview);
514 AIS_ListOfInteractive::const_iterator aIt;
515 Handle(AIS_Shape) aShapeIO;
516 for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) {
517 aShapeIO = Handle(AIS_Shape)::DownCast(*aIt);
518 if (!aShapeIO.IsNull()) {
520 aCtx->Erase(aShapeIO, false);
522 aCtx->Display(aShapeIO, false);
523 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
524 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO));
525 myWorkshop->applyCurrentSelectionModes(anAISObj);
529 aCtx->UpdateCurrentViewer();
532 void ModuleBase_WidgetSelectionFilter::updateSelectBtn()
534 mySelectBtn->setEnabled(myUseFilters.size() > 0);
537 void ModuleBase_WidgetSelectionFilter::updateNumberSelected()
539 int aNb = myValues.size();
540 myNbLbl->setText(QString::number(aNb));
541 //QString aErr = () ? tr("Selection is empty") : "";
543 myFeature->setError(tr("Selection is empty").toStdString(), false, false);
545 myFeature->setError("", false, false);
546 myFeature->data()->execState(ModelAPI_StateDone);
550 QList<QWidget*> ModuleBase_WidgetSelectionFilter::getControls() const
552 QList<QWidget*> aWidgets;
553 aWidgets.append(myFiltersCombo);
557 void ModuleBase_WidgetSelectionFilter::clearCurrentSelection(bool toUpdate)
560 if (!myPreview.IsNull()) {
561 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
562 aCtx->Remove(myPreview, toUpdate);
567 void ModuleBase_WidgetSelectionFilter::onFeatureAccepted()
569 AttributePtr aAttr = mySelectorFeature->attribute(mySelectorAttribute);
570 AttributeSelectionListPtr aSelListAttr =
571 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aAttr);
572 aSelListAttr->clear();
573 foreach(ModuleBase_ViewerPrsPtr aPrs, myValues) {
574 aSelListAttr->append(aPrs->object(), aPrs->shape());
578 bool ModuleBase_WidgetSelectionFilter::storeValueCustom()
580 ModuleBase_ModelWidget* aActive = myWorkshop->propertyPanel()->activeWidget();
582 return aActive->storeValue();
583 updateObject(myFeature);
587 bool ModuleBase_WidgetSelectionFilter::restoreValueCustom()
589 ModelAPI_FiltersFactory* aFactory = ModelAPI_Session::get()->filters();
590 FiltersFeaturePtr aFiltersFeature = std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
591 std::list<std::string> aFilters = aFiltersFeature->filters();
592 std::list<std::string>::const_iterator aIt;
593 for (aIt = aFilters.cbegin(); aIt != aFilters.cend(); aIt++) {
594 std::string aStr = (*aIt);
596 FilterPtr aFilterObj = aFactory->filter(aStr);
597 int aId = myFiltersCombo->findText(aFilterObj->name().c_str());
599 myFiltersCombo->removeItem(aId);
601 // Init filters member of the parent attribute
602 AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute);
603 if (aAttrList->filters() != aFiltersFeature) {
604 aAttrList->setFilters(aFiltersFeature);
607 QList<QWidget*> aWidgets;
608 QList<ModuleBase_FilterItem*> aItems = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
609 foreach(ModuleBase_FilterItem* aItem, aItems) {
610 QList<ModuleBase_ModelWidget*> aSubList = aItem->widgets();
611 foreach(ModuleBase_ModelWidget* aWgt, aSubList) {
612 aWgt->restoreValue();
618 QString ModuleBase_WidgetSelectionFilter::getError(const bool theValueStateChecked) const
620 QString aErrorMsg = ModuleBase_ModelWidget::getError(theValueStateChecked);
621 if (aErrorMsg.isEmpty()) {
622 if (myValues.size() == 0)
623 aErrorMsg = tr("Selection is empty");
628 void ModuleBase_WidgetSelectionFilter::onObjectUpdated()
630 myShowBtn->setChecked(false);
631 clearCurrentSelection(true);
632 updateNumberSelected();
634 QList<ModuleBase_FilterItem*> aItemsList = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
635 foreach(ModuleBase_FilterItem* aItem, aItemsList) {
636 QList<ModuleBase_ModelWidget*> aWidgetsList = aItem->widgets();
637 foreach(ModuleBase_ModelWidget* aWidget, aWidgetsList) {
638 if (!aWidget->feature().get())
639 aWidget->setFeature(myFeature);
640 aWidget->restoreValue();
643 updateObject(myFeature);
645 // Redisplay the feature on order to Customize presentations from filters with selectors
646 static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
647 ModelAPI_EventCreator::get()->sendUpdated(myFeature, EVENT_DISP);
648 Events_Loop::loop()->flush(EVENT_DISP);