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 aFOperation->setHelpFileName("FiltersPlugin.html");
128 myWorkshop->processLaunchOperation(aFOperation);
131 //*****************************************************************************
132 //*****************************************************************************
133 //*****************************************************************************
134 ModuleBase_FilterItem::ModuleBase_FilterItem(
135 const std::string& theFilter, ModuleBase_WidgetSelectionFilter* theParent)
136 : QWidget(theParent->filtersWidget()), myFilterID(theFilter),
137 mySelection(std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theParent->feature()))
139 std::string aXmlString =
140 ModelAPI_Session::get()->filters()->filter(theFilter)->xmlRepresentation();
141 if (aXmlString.length() == 0)
144 ModuleBase_WidgetFactory aFactory(aXmlString, theParent->workshop());
145 Config_ValidatorReader aValidatorReader(aXmlString, true);
146 aValidatorReader.setFeatureId(mySelection->getKind());
147 aValidatorReader.readAll();
149 QVBoxLayout* aLayout = new QVBoxLayout(this);
150 ModuleBase_Tools::zeroMargins(aLayout);
152 QWidget* aItemRow = new QWidget(this);
153 addItemRow(aItemRow);
154 aLayout->addWidget(aItemRow);
156 ModuleBase_PageWidget* aParamsWgt = new ModuleBase_PageWidget(this);
157 aParamsWgt->setFrameStyle(QFrame::Box | QFrame::Raised);
158 aFactory.createWidget(aParamsWgt);
159 ModuleBase_Tools::zeroMargins(aParamsWgt->layout());
160 myWidgets = aFactory.getModelWidgets();
161 foreach(ModuleBase_ModelWidget* aWidget, myWidgets) {
162 aWidget->setFeature(theParent->feature());
163 connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
164 theParent, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)));
165 connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
166 theParent, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)));
167 connect(aWidget, SIGNAL(objectUpdated()), theParent, SLOT(onObjectUpdated()));
169 aLayout->addWidget(aParamsWgt);
173 void ModuleBase_FilterItem::addItemRow(QWidget* theParent)
175 QHBoxLayout* aLayout = new QHBoxLayout(theParent);
176 ModuleBase_Tools::zeroMargins(aLayout);
178 // Reverse filter button
179 myRevBtn = new QToolButton(theParent);
180 myRevBtn->setCheckable(true);
181 bool isReversed = mySelection->isReversed(myFilterID);
182 myRevBtn->setChecked(isReversed);
183 myRevBtn->setAutoRaise(true);
185 myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
187 myRevBtn->setIcon(QIcon(":pictures/add.png"));
188 myRevBtn->setToolTip(tr("Reverse the filter"));
189 connect(myRevBtn, SIGNAL(toggled(bool)), SLOT(onReverse(bool)));
190 aLayout->addWidget(myRevBtn);
192 const std::string& aFilterName = ModelAPI_Session::get()->filters()->filter(myFilterID)->name();
193 aLayout->addWidget(new QLabel(aFilterName.c_str(), theParent), 1);
195 QToolButton* aDelBtn = new QToolButton(theParent);
196 aDelBtn->setIcon(QIcon(":pictures/delete.png"));
197 aDelBtn->setAutoRaise(true);
198 aDelBtn->setToolTip(tr("Delete the filter"));
199 connect(aDelBtn, SIGNAL(clicked(bool)), SLOT(onDelete()));
200 aLayout->addWidget(aDelBtn);
203 void ModuleBase_FilterItem::onReverse(bool theCheck)
205 mySelection->setReversed(myFilterID, theCheck);
207 myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
209 myRevBtn->setIcon(QIcon(":pictures/add.png"));
210 emit reversedItem(this);
213 void ModuleBase_FilterItem::onDelete()
215 emit deleteItem(this);
219 //*****************************************************************************
220 //*****************************************************************************
221 //*****************************************************************************
222 ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theParent,
223 ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData)
224 : ModuleBase_ModelWidget(theParent, theData),
225 myWorkshop(theWorkshop),
226 mySelectorFeature(SelectorFeature),
227 mySelectorAttribute(AttributeId)
229 // Clear Old selection
230 AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute);
231 mySelectionType = selectionType(aAttrList->selectionType().c_str());
235 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
236 ModuleBase_Tools::adjustMargins(aMainLayout);
238 QGroupBox* aFiltersGroup = new QGroupBox(tr("Filters"), this);
239 QVBoxLayout* aGroupLayout = new QVBoxLayout(aFiltersGroup);
240 aGroupLayout->setContentsMargins(0, 0, 0, 0);
241 aGroupLayout->setSpacing(0);
243 myFiltersWgt = new QWidget();
244 myFiltersLayout = new QVBoxLayout(myFiltersWgt);
245 myFiltersLayout->setContentsMargins(0, 0, 0, 0);
246 aGroupLayout->addWidget(myFiltersWgt);
248 myFiltersCombo = new QComboBox(aFiltersGroup);
249 myFiltersCombo->addItem(tr("Add new filter..."));
250 SessionPtr aSession = ModelAPI_Session::get();
251 std::list<FilterPtr> allFilters =
252 aSession->filters()->filters((GeomAPI_Shape::ShapeType) mySelectionType);
254 std::list<FilterPtr>::const_iterator aIt;
255 for (aIt = allFilters.cbegin(); aIt != allFilters.cend(); aIt++) {
256 aItems.push_back((*aIt)->name().c_str());
257 myFilters.push_back(aSession->filters()->id(*aIt));
259 myFiltersCombo->addItems(aItems);
260 connect(myFiltersCombo, SIGNAL(currentIndexChanged(int)), SLOT(onAddFilter(int)));
262 aGroupLayout->addWidget(myFiltersCombo);
263 aMainLayout->addWidget(aFiltersGroup);
266 QWidget* aBtnWgt = new QWidget(this);
267 QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnWgt);
268 ModuleBase_Tools::adjustMargins(aBtnLayout);
270 aBtnLayout->addStretch(1);
272 mySelectBtn = new QPushButton(tr("Select"), aBtnWgt);
273 connect(mySelectBtn, SIGNAL(clicked()), SLOT(onSelect()));
274 aBtnLayout->addWidget(mySelectBtn);
276 aMainLayout->addWidget(aBtnWgt);
279 QWidget* aLblWgt = new QWidget(this);
280 QHBoxLayout* aLblLayout = new QHBoxLayout(aLblWgt);
281 ModuleBase_Tools::zeroMargins(aLblLayout);
283 aLblLayout->addWidget(new QLabel(tr("Number of selected objects:"), aLblWgt));
285 myNbLbl = new QLabel("0", aLblWgt);
286 aLblLayout->addWidget(myNbLbl);
289 myShowBtn = new QCheckBox(tr("Show only"), this);
290 connect(myShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool)));
291 aLblLayout->addWidget(myShowBtn);
293 aMainLayout->addWidget(aLblWgt);
295 aMainLayout->addStretch(1);
300 ModuleBase_WidgetSelectionFilter::~ModuleBase_WidgetSelectionFilter()
303 if (!myPreview.IsNull()) {
304 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
305 aCtx->Remove(myPreview, false);
307 if (myListIO.Size() > 0) {
308 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
309 AIS_ListOfInteractive::const_iterator aIt;
310 Handle(AIS_Shape) aShapeIO;
311 for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) {
312 aShapeIO = Handle(AIS_Shape)::DownCast(*aIt);
313 if (!aShapeIO.IsNull()) {
314 aCtx->Display(aShapeIO, false);
315 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
316 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO));
317 myWorkshop->applyCurrentSelectionModes(anAISObj);
321 myShowBtn->setChecked(false);
323 aCtx->UpdateCurrentViewer();
325 SelectorFeature = FeaturePtr();
329 void ModuleBase_WidgetSelectionFilter::onAddFilter(int theIndex)
334 std::list<std::string>::iterator aIt;
337 for (aIt = myFilters.begin(), i = 0; aIt != myFilters.cend(); i++, aIt++) {
338 if (i == (theIndex - 1)) {
343 ModuleBase_FilterItem* aItem = onAddFilter(aFilter);
344 FiltersFeaturePtr aFiltersFeature =
345 std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
346 aFiltersFeature->addFilter(aFilter);
348 myFiltersCombo->setCurrentIndex(0);
349 myFiltersCombo->removeItem(theIndex);
350 updateObject(myFeature);
352 if (aItem && (aItem->widgets().size() > 0))
353 aItem->widgets().first()->emitFocusInWidget();
358 ModuleBase_FilterItem* ModuleBase_WidgetSelectionFilter::onAddFilter(const std::string& theFilter)
360 if (theFilter.length() == 0)
362 std::list<std::string>::const_iterator aIt;
363 for (aIt = myUseFilters.cbegin(); aIt != myUseFilters.cend(); aIt++) {
364 if (theFilter == (*aIt))
367 myFilters.remove(theFilter);
368 myUseFilters.push_back(theFilter);
369 ModuleBase_FilterItem* aItem = new ModuleBase_FilterItem(theFilter, this);
370 connect(aItem, SIGNAL(deleteItem(ModuleBase_FilterItem*)),
371 SLOT(onDeleteItem(ModuleBase_FilterItem*)));
372 connect(aItem, SIGNAL(reversedItem(ModuleBase_FilterItem*)),
373 SLOT(onReverseItem(ModuleBase_FilterItem*)));
374 myFiltersLayout->addWidget(aItem);
377 clearCurrentSelection(true);
378 updateNumberSelected();
382 void ModuleBase_WidgetSelectionFilter::onDeleteItem(ModuleBase_FilterItem* theItem)
384 std::string aFilter = theItem->filter();
385 QList<ModuleBase_ModelWidget*> aWidgets = theItem->widgets();
386 foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
389 myFiltersLayout->removeWidget(theItem);
390 theItem->deleteLater();
392 myUseFilters.remove(aFilter);
393 myFilters.push_back(aFilter);
394 myFiltersCombo->addItem(ModelAPI_Session::get()->filters()->filter(aFilter)->name().c_str());
396 FiltersFeaturePtr aFiltersFeature =
397 std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
398 aFiltersFeature->removeFilter(aFilter);
401 clearCurrentSelection(true);
402 updateNumberSelected();
404 myWorkshop->deactivateCurrentSelector();
405 myWorkshop->selectionActivate()->updateSelectionModes();
406 myWorkshop->selectionActivate()->updateSelectionFilters();
409 updateObject(myFeature);
413 void ModuleBase_WidgetSelectionFilter::redisplayFeature()
415 static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
416 ModelAPI_EventCreator::get()->sendUpdated(myFeature, aDispEvent);
417 Events_Loop::loop()->flush(aDispEvent);
420 void ModuleBase_WidgetSelectionFilter::onReverseItem(ModuleBase_FilterItem* theItem)
423 clearCurrentSelection(true);
424 updateNumberSelected();
427 void ModuleBase_WidgetSelectionFilter::onSelect()
429 if (myUseFilters.size() == 0)
431 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
435 clearCurrentSelection();
437 BRep_Builder aBuilder;
438 TopoDS_Compound aComp;
439 aBuilder.MakeCompound(aComp);
441 DocumentPtr aDoc = myFeature->document();
442 int aNb = aDoc->size(ModelAPI_ResultBody::group());
446 for (int i = 0; i < aNb; i++) {
447 aObj = aDoc->object(ModelAPI_ResultBody::group(), i);
448 aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
449 GeomShapePtr aShape = aBody->shape();
450 std::list<GeomShapePtr> aSubShapes =
451 aShape->subShapes((GeomAPI_Shape::ShapeType)mySelectionType);
452 TopTools_MapOfShape alreadyThere;
453 std::list<GeomShapePtr>::const_iterator aShapesIt;
454 for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) {
455 GeomShapePtr aShape = (*aShapesIt);
456 TopoDS_Shape aTShape = aShape->impl<TopoDS_Shape>();
457 if (!alreadyThere.Add(aTShape))
459 static SessionPtr aSession = ModelAPI_Session::get();
460 bool isValid = aSession->filters()->isValid(myFeature, aBody, aShape);
462 aBuilder.Add(aComp, aTShape);
463 ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aShape));
464 myValues.append(aValue);
469 if (myValues.size() > 0)
470 updatePreview(aComp);
471 updateNumberSelected();
472 updateObject(myFeature);
473 onShowOnly(myShowBtn->isChecked());
476 void ModuleBase_WidgetSelectionFilter::updatePreview(const TopoDS_Shape& theShape)
478 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
482 if (myPreview.IsNull()) {
483 myPreview = new AIS_Shape(theShape);
484 myPreview->SetDisplayMode(AIS_Shaded);
485 myPreview->SetColor(Quantity_NOC_BLUE1);
486 Handle(Prs3d_Drawer) aDrawer = myPreview->Attributes();
487 if (aDrawer->HasOwnPointAspect()) {
488 aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_STAR);
489 aDrawer->PointAspect()->SetColor(Quantity_NOC_BLUE1);
490 aDrawer->PointAspect()->SetScale(2.);
493 aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_O_STAR, Quantity_NOC_BLUE1, 2.));
494 myPreview->SetTransparency();
495 aCtx->Display(myPreview, true);
496 aCtx->Deactivate(myPreview);
499 myPreview->Set(theShape);
500 aCtx->Redisplay(myPreview, true);
505 void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theShow)
507 if (myPreview.IsNull())
509 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
512 AIS_ListOfInteractive aList;
513 aCtx->DisplayedObjects(AIS_KOI_Shape, -1, aList);
514 aList.Remove(myPreview);
515 if (aList.Size() > 0)
518 AIS_ListOfInteractive::const_iterator aIt;
519 Handle(AIS_Shape) aShapeIO;
520 for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) {
521 aShapeIO = Handle(AIS_Shape)::DownCast(*aIt);
522 if (!aShapeIO.IsNull()) {
524 aCtx->Erase(aShapeIO, false);
526 aCtx->Display(aShapeIO, false);
527 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
528 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO));
529 myWorkshop->applyCurrentSelectionModes(anAISObj);
533 aCtx->UpdateCurrentViewer();
536 void ModuleBase_WidgetSelectionFilter::updateSelectBtn()
538 mySelectBtn->setEnabled(myUseFilters.size() > 0);
541 void ModuleBase_WidgetSelectionFilter::updateNumberSelected()
543 int aNb = myValues.size();
544 myNbLbl->setText(QString::number(aNb));
545 //QString aErr = () ? tr("Selection is empty") : "";
547 myFeature->setError(tr("Selection is empty").toStdString(), false, false);
549 myFeature->setError("", false, false);
550 myFeature->data()->execState(ModelAPI_StateDone);
554 QList<QWidget*> ModuleBase_WidgetSelectionFilter::getControls() const
556 QList<QWidget*> aWidgets;
557 aWidgets.append(myFiltersCombo);
561 void ModuleBase_WidgetSelectionFilter::clearCurrentSelection(bool toUpdate)
564 if (!myPreview.IsNull()) {
565 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
566 aCtx->Remove(myPreview, toUpdate);
571 void ModuleBase_WidgetSelectionFilter::onFeatureAccepted()
573 AttributePtr aAttr = mySelectorFeature->attribute(mySelectorAttribute);
574 AttributeSelectionListPtr aSelListAttr =
575 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aAttr);
576 aSelListAttr->clear();
577 foreach(ModuleBase_ViewerPrsPtr aPrs, myValues) {
578 aSelListAttr->append(aPrs->object(), aPrs->shape());
582 bool ModuleBase_WidgetSelectionFilter::storeValueCustom()
584 ModuleBase_ModelWidget* aActive = myWorkshop->propertyPanel()->activeWidget();
586 return aActive->storeValue();
587 updateObject(myFeature);
591 bool ModuleBase_WidgetSelectionFilter::restoreValueCustom()
593 ModelAPI_FiltersFactory* aFactory = ModelAPI_Session::get()->filters();
594 FiltersFeaturePtr aFiltersFeature = std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
595 std::list<std::string> aFilters = aFiltersFeature->filters();
596 std::list<std::string>::const_iterator aIt;
597 for (aIt = aFilters.cbegin(); aIt != aFilters.cend(); aIt++) {
598 std::string aStr = (*aIt);
600 FilterPtr aFilterObj = aFactory->filter(aStr);
601 int aId = myFiltersCombo->findText(aFilterObj->name().c_str());
603 myFiltersCombo->removeItem(aId);
605 // Init filters member of the parent attribute
606 AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute);
607 if (aAttrList->filters() != aFiltersFeature) {
608 aAttrList->setFilters(aFiltersFeature);
611 QList<QWidget*> aWidgets;
612 QList<ModuleBase_FilterItem*> aItems = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
613 foreach(ModuleBase_FilterItem* aItem, aItems) {
614 QList<ModuleBase_ModelWidget*> aSubList = aItem->widgets();
615 foreach(ModuleBase_ModelWidget* aWgt, aSubList) {
616 aWgt->restoreValue();
622 QString ModuleBase_WidgetSelectionFilter::getError(const bool theValueStateChecked) const
624 QString aErrorMsg = ModuleBase_ModelWidget::getError(theValueStateChecked);
625 if (aErrorMsg.isEmpty()) {
626 if (myValues.size() == 0)
627 aErrorMsg = tr("Selection is empty");
632 void ModuleBase_WidgetSelectionFilter::onObjectUpdated()
634 myShowBtn->setChecked(false);
635 clearCurrentSelection(true);
636 updateNumberSelected();
638 QList<ModuleBase_FilterItem*> aItemsList = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
639 foreach(ModuleBase_FilterItem* aItem, aItemsList) {
640 QList<ModuleBase_ModelWidget*> aWidgetsList = aItem->widgets();
641 foreach(ModuleBase_ModelWidget* aWidget, aWidgetsList) {
642 if (!aWidget->feature().get())
643 aWidget->setFeature(myFeature);
644 aWidget->restoreValue();
647 updateObject(myFeature);
649 // Redisplay the feature on order to Customize presentations from filters with selectors
650 static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
651 ModelAPI_EventCreator::get()->sendUpdated(myFeature, EVENT_DISP);
652 Events_Loop::loop()->flush(EVENT_DISP);