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>
57 static FeaturePtr SelectorFeature;
58 static std::string AttributeId;
61 GeomAPI_Shape::ShapeType selectionType(const QString& theType)
63 QString aType = theType.toUpper();
64 if ((aType == "VERTEX") || (aType == "VERTICES"))
65 return GeomAPI_Shape::VERTEX;
66 else if ((aType == "EDGE") || (aType == "EDGES"))
67 return GeomAPI_Shape::EDGE;
68 else if ((aType == "WIRE") || (aType == "WIRES"))
69 return GeomAPI_Shape::WIRE;
70 else if ((aType == "FACE") || (aType == "FACES"))
71 return GeomAPI_Shape::FACE;
72 else if ((aType == "SHELL") || (aType == "SHELLS"))
73 return GeomAPI_Shape::SHELL;
74 else if ((aType == "SOLID") || (aType == "SOLIDS"))
75 return GeomAPI_Shape::SOLID;
76 else if ((aType == "COMPSOLID") || (aType == "COMPSOLIDS"))
77 return GeomAPI_Shape::COMPSOLID;
78 else if ((aType == "COMPOUND") || (aType == "COMPOUNDS"))
79 return GeomAPI_Shape::COMPOUND;
81 return GeomAPI_Shape::SHAPE;
85 ModuleBase_FilterStarter::ModuleBase_FilterStarter(const std::string& theFeature,
86 QWidget* theParent, ModuleBase_IWorkshop* theWorkshop)
88 myFeatureName(theFeature),
89 myWorkshop(theWorkshop)
91 QHBoxLayout* aMainLayout = new QHBoxLayout(this);
92 ModuleBase_Tools::adjustMargins(aMainLayout);
94 aMainLayout->addStretch(1);
95 QPushButton* aLaunchBtn = new QPushButton(tr("Selection by filters"), this);
96 connect(aLaunchBtn, SIGNAL(clicked()), SLOT(onFiltersLaunch()));
97 aMainLayout->addWidget(aLaunchBtn);
100 void ModuleBase_FilterStarter::onFiltersLaunch()
102 static QString aHelpFileName = QString("FiltersPlugin") + QDir::separator() +
103 QString("FiltersPlugin.html");
105 ModuleBase_Operation* aParentOp = myWorkshop->currentOperation();
106 ModuleBase_OperationFeature* aFeatureOp = dynamic_cast<ModuleBase_OperationFeature*>(aParentOp);
108 // Open transaction on filters operation finish
109 aFeatureOp->openTransactionOnResume();
111 QWidget* aParent = parentWidget();
112 ModuleBase_WidgetMultiSelector* aSelector =
113 dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);
115 aParent = aParent->parentWidget();
116 aSelector = dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);
120 SelectorFeature = aSelector->feature();
121 AttributeId = aSelector->attributeID();
123 // Launch Filters operation
124 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
125 (myWorkshop->module()->createOperation(myFeatureName));
127 AttributeSelectionListPtr aAttrList = SelectorFeature->selectionList(AttributeId);
128 FiltersFeaturePtr aFilters = aAttrList->filters();
130 aFOperation->setFeature(aFilters);
131 aFOperation->setHelpFileName(aHelpFileName);
132 myWorkshop->processLaunchOperation(aFOperation);
135 //*****************************************************************************
136 //*****************************************************************************
137 //*****************************************************************************
138 ModuleBase_FilterItem::ModuleBase_FilterItem(
139 const std::string& theFilter, ModuleBase_WidgetSelectionFilter* theParent)
140 : QWidget(theParent->filtersWidget()), myFilterID(theFilter),
141 mySelection(std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theParent->feature()))
143 std::string aXmlString =
144 ModelAPI_Session::get()->filters()->filter(theFilter)->xmlRepresentation();
145 if (aXmlString.length() == 0)
148 ModuleBase_WidgetFactory aFactory(aXmlString, theParent->workshop());
149 Config_ValidatorReader aValidatorReader(aXmlString, true);
150 aValidatorReader.setFeatureId(mySelection->getKind());
151 aValidatorReader.readAll();
153 QVBoxLayout* aLayout = new QVBoxLayout(this);
154 ModuleBase_Tools::zeroMargins(aLayout);
156 QWidget* aItemRow = new QWidget(this);
157 addItemRow(aItemRow);
158 aLayout->addWidget(aItemRow);
160 ModuleBase_PageWidget* aParamsWgt = new ModuleBase_PageWidget(this);
161 aParamsWgt->setFrameStyle(QFrame::Box | QFrame::Raised);
162 aFactory.createWidget(aParamsWgt);
163 ModuleBase_Tools::zeroMargins(aParamsWgt->layout());
164 myWidgets = aFactory.getModelWidgets();
165 foreach(ModuleBase_ModelWidget* aWidget, myWidgets) {
166 aWidget->setFeature(theParent->feature());
167 connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
168 theParent, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)));
169 connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
170 theParent, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)));
171 connect(aWidget, SIGNAL(objectUpdated()), theParent, SLOT(onObjectUpdated()));
173 aLayout->addWidget(aParamsWgt);
177 void ModuleBase_FilterItem::addItemRow(QWidget* theParent)
179 QHBoxLayout* aLayout = new QHBoxLayout(theParent);
180 ModuleBase_Tools::zeroMargins(aLayout);
182 // Reverse filter button
183 myRevBtn = new QToolButton(theParent);
184 myRevBtn->setCheckable(true);
185 bool isReversed = mySelection->isReversed(myFilterID);
186 myRevBtn->setChecked(isReversed);
187 myRevBtn->setAutoRaise(true);
189 myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
191 myRevBtn->setIcon(QIcon(":pictures/add.png"));
192 myRevBtn->setToolTip(tr("Reverse the filter"));
193 connect(myRevBtn, SIGNAL(toggled(bool)), SLOT(onReverse(bool)));
194 aLayout->addWidget(myRevBtn);
196 const std::string& aFilterName = ModelAPI_Session::get()->filters()->filter(myFilterID)->name();
197 aLayout->addWidget(new QLabel(aFilterName.c_str(), theParent), 1);
199 QToolButton* aDelBtn = new QToolButton(theParent);
200 aDelBtn->setIcon(QIcon(":pictures/delete.png"));
201 aDelBtn->setAutoRaise(true);
202 aDelBtn->setToolTip(tr("Delete the filter"));
203 connect(aDelBtn, SIGNAL(clicked(bool)), SLOT(onDelete()));
204 aLayout->addWidget(aDelBtn);
207 void ModuleBase_FilterItem::onReverse(bool theCheck)
209 mySelection->setReversed(myFilterID, theCheck);
211 myRevBtn->setIcon(QIcon(":pictures/reverce.png"));
213 myRevBtn->setIcon(QIcon(":pictures/add.png"));
214 emit reversedItem(this);
217 void ModuleBase_FilterItem::onDelete()
219 emit deleteItem(this);
223 //*****************************************************************************
224 //*****************************************************************************
225 //*****************************************************************************
226 ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theParent,
227 ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData)
228 : ModuleBase_ModelWidget(theParent, theData),
229 myWorkshop(theWorkshop),
230 mySelectorFeature(SelectorFeature),
231 mySelectorAttribute(AttributeId)
233 // Clear Old selection
234 AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute);
235 mySelectionType = selectionType(aAttrList->selectionType().c_str());
239 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
240 ModuleBase_Tools::adjustMargins(aMainLayout);
242 QGroupBox* aFiltersGroup = new QGroupBox(tr("Filters"), this);
243 QVBoxLayout* aGroupLayout = new QVBoxLayout(aFiltersGroup);
244 aGroupLayout->setContentsMargins(0, 0, 0, 0);
245 aGroupLayout->setSpacing(0);
247 myFiltersWgt = new QWidget();
248 myFiltersLayout = new QVBoxLayout(myFiltersWgt);
249 myFiltersLayout->setContentsMargins(0, 0, 0, 0);
250 aGroupLayout->addWidget(myFiltersWgt);
252 myFiltersCombo = new QComboBox(aFiltersGroup);
253 myFiltersCombo->addItem(tr("Add new filter..."));
254 SessionPtr aSession = ModelAPI_Session::get();
255 std::list<FilterPtr> allFilters =
256 aSession->filters()->filters((GeomAPI_Shape::ShapeType) mySelectionType);
258 std::list<FilterPtr>::const_iterator aIt;
259 for (aIt = allFilters.cbegin(); aIt != allFilters.cend(); aIt++) {
260 aItems.push_back((*aIt)->name().c_str());
261 myFilters.push_back(aSession->filters()->id(*aIt));
263 myFiltersCombo->addItems(aItems);
264 connect(myFiltersCombo, SIGNAL(currentIndexChanged(int)), SLOT(onAddFilter(int)));
266 aGroupLayout->addWidget(myFiltersCombo);
267 aMainLayout->addWidget(aFiltersGroup);
270 QWidget* aBtnWgt = new QWidget(this);
271 QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnWgt);
272 ModuleBase_Tools::adjustMargins(aBtnLayout);
274 aBtnLayout->addStretch(1);
276 mySelectBtn = new QPushButton(tr("Select"), aBtnWgt);
277 connect(mySelectBtn, SIGNAL(clicked()), SLOT(onSelect()));
278 aBtnLayout->addWidget(mySelectBtn);
280 aMainLayout->addWidget(aBtnWgt);
283 QWidget* aLblWgt = new QWidget(this);
284 QHBoxLayout* aLblLayout = new QHBoxLayout(aLblWgt);
285 ModuleBase_Tools::zeroMargins(aLblLayout);
287 aLblLayout->addWidget(new QLabel(tr("Number of selected objects:"), aLblWgt));
289 myNbLbl = new QLabel("0", aLblWgt);
290 aLblLayout->addWidget(myNbLbl);
293 myShowBtn = new QCheckBox(tr("Show only"), this);
294 connect(myShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool)));
295 aLblLayout->addWidget(myShowBtn);
297 aMainLayout->addWidget(aLblWgt);
299 aMainLayout->addStretch(1);
304 ModuleBase_WidgetSelectionFilter::~ModuleBase_WidgetSelectionFilter()
307 if (!myPreview.IsNull()) {
308 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
309 aCtx->Remove(myPreview, false);
311 if (myListIO.Size() > 0) {
312 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
313 AIS_ListOfInteractive::const_iterator aIt;
314 Handle(AIS_Shape) aShapeIO;
315 for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) {
316 aShapeIO = Handle(AIS_Shape)::DownCast(*aIt);
317 if (!aShapeIO.IsNull()) {
318 aCtx->Display(aShapeIO, false);
319 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
320 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO));
321 myWorkshop->applyCurrentSelectionModes(anAISObj);
325 myShowBtn->setChecked(false);
327 aCtx->UpdateCurrentViewer();
329 SelectorFeature = FeaturePtr();
333 void ModuleBase_WidgetSelectionFilter::onAddFilter(int theIndex)
338 std::list<std::string>::iterator aIt;
341 for (aIt = myFilters.begin(), i = 0; aIt != myFilters.cend(); i++, aIt++) {
342 if (i == (theIndex - 1)) {
347 ModuleBase_FilterItem* aItem = onAddFilter(aFilter);
348 FiltersFeaturePtr aFiltersFeature =
349 std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
350 aFiltersFeature->addFilter(aFilter);
352 myFiltersCombo->setCurrentIndex(0);
353 myFiltersCombo->removeItem(theIndex);
354 updateObject(myFeature);
356 if (aItem && (aItem->widgets().size() > 0))
357 aItem->widgets().first()->emitFocusInWidget();
362 ModuleBase_FilterItem* ModuleBase_WidgetSelectionFilter::onAddFilter(const std::string& theFilter)
364 if (theFilter.length() == 0)
366 std::list<std::string>::const_iterator aIt;
367 for (aIt = myUseFilters.cbegin(); aIt != myUseFilters.cend(); aIt++) {
368 if (theFilter == (*aIt))
371 myFilters.remove(theFilter);
372 myUseFilters.push_back(theFilter);
373 ModuleBase_FilterItem* aItem = new ModuleBase_FilterItem(theFilter, this);
374 connect(aItem, SIGNAL(deleteItem(ModuleBase_FilterItem*)),
375 SLOT(onDeleteItem(ModuleBase_FilterItem*)));
376 connect(aItem, SIGNAL(reversedItem(ModuleBase_FilterItem*)),
377 SLOT(onReverseItem(ModuleBase_FilterItem*)));
378 myFiltersLayout->addWidget(aItem);
381 clearCurrentSelection(true);
382 updateNumberSelected();
386 void ModuleBase_WidgetSelectionFilter::onDeleteItem(ModuleBase_FilterItem* theItem)
388 std::string aFilter = theItem->filter();
389 QList<ModuleBase_ModelWidget*> aWidgets = theItem->widgets();
390 foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
393 myFiltersLayout->removeWidget(theItem);
394 theItem->deleteLater();
396 myUseFilters.remove(aFilter);
397 myFilters.push_back(aFilter);
398 myFiltersCombo->addItem(ModelAPI_Session::get()->filters()->filter(aFilter)->name().c_str());
400 FiltersFeaturePtr aFiltersFeature =
401 std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
402 aFiltersFeature->removeFilter(aFilter);
405 clearCurrentSelection(true);
406 updateNumberSelected();
408 myWorkshop->deactivateCurrentSelector();
409 myWorkshop->selectionActivate()->updateSelectionModes();
410 myWorkshop->selectionActivate()->updateSelectionFilters();
413 updateObject(myFeature);
417 void ModuleBase_WidgetSelectionFilter::redisplayFeature()
419 static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
420 ModelAPI_EventCreator::get()->sendUpdated(myFeature, aDispEvent);
421 Events_Loop::loop()->flush(aDispEvent);
424 void ModuleBase_WidgetSelectionFilter::onReverseItem(ModuleBase_FilterItem* theItem)
427 clearCurrentSelection(true);
428 updateNumberSelected();
431 void ModuleBase_WidgetSelectionFilter::onSelect()
433 if (myUseFilters.size() == 0)
435 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
439 clearCurrentSelection();
441 BRep_Builder aBuilder;
442 TopoDS_Compound aComp;
443 aBuilder.MakeCompound(aComp);
445 DocumentPtr aDoc = myFeature->document();
446 int aNb = aDoc->size(ModelAPI_ResultBody::group());
450 for (int i = 0; i < aNb; i++) {
451 aObj = aDoc->object(ModelAPI_ResultBody::group(), i);
452 aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
453 GeomShapePtr aShape = aBody->shape();
454 std::list<GeomShapePtr> aSubShapes =
455 aShape->subShapes((GeomAPI_Shape::ShapeType)mySelectionType);
456 TopTools_MapOfShape alreadyThere;
457 std::list<GeomShapePtr>::const_iterator aShapesIt;
458 for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) {
459 GeomShapePtr aShape = (*aShapesIt);
460 TopoDS_Shape aTShape = aShape->impl<TopoDS_Shape>();
461 if (!alreadyThere.Add(aTShape))
463 static SessionPtr aSession = ModelAPI_Session::get();
464 bool isValid = aSession->filters()->isValid(myFeature, aBody, aShape);
466 aBuilder.Add(aComp, aTShape);
467 ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aShape));
468 myValues.append(aValue);
473 if (myValues.size() > 0)
474 updatePreview(aComp);
475 updateNumberSelected();
476 updateObject(myFeature);
477 onShowOnly(myShowBtn->isChecked());
480 void ModuleBase_WidgetSelectionFilter::updatePreview(const TopoDS_Shape& theShape)
482 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
486 if (myPreview.IsNull()) {
487 myPreview = new AIS_Shape(theShape);
488 myPreview->SetDisplayMode(AIS_Shaded);
489 myPreview->SetColor(Quantity_NOC_BLUE1);
490 Handle(Prs3d_Drawer) aDrawer = myPreview->Attributes();
491 if (aDrawer->HasOwnPointAspect()) {
492 aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_STAR);
493 aDrawer->PointAspect()->SetColor(Quantity_NOC_BLUE1);
494 aDrawer->PointAspect()->SetScale(2.);
497 aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_O_STAR, Quantity_NOC_BLUE1, 2.));
498 myPreview->SetTransparency();
499 aCtx->Display(myPreview, true);
500 aCtx->Deactivate(myPreview);
503 myPreview->Set(theShape);
504 aCtx->Redisplay(myPreview, true);
509 void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theShow)
511 if (myPreview.IsNull())
513 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
516 AIS_ListOfInteractive aList;
517 aCtx->DisplayedObjects(AIS_KOI_Shape, -1, aList);
518 aList.Remove(myPreview);
519 if (aList.Size() > 0)
522 AIS_ListOfInteractive::const_iterator aIt;
523 Handle(AIS_Shape) aShapeIO;
524 for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) {
525 aShapeIO = Handle(AIS_Shape)::DownCast(*aIt);
526 if (!aShapeIO.IsNull()) {
528 aCtx->Erase(aShapeIO, false);
530 aCtx->Display(aShapeIO, false);
531 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
532 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aShapeIO));
533 myWorkshop->applyCurrentSelectionModes(anAISObj);
537 aCtx->UpdateCurrentViewer();
540 void ModuleBase_WidgetSelectionFilter::updateSelectBtn()
542 mySelectBtn->setEnabled(myUseFilters.size() > 0);
545 void ModuleBase_WidgetSelectionFilter::updateNumberSelected()
547 int aNb = myValues.size();
548 myNbLbl->setText(QString::number(aNb));
549 //QString aErr = () ? tr("Selection is empty") : "";
551 myFeature->setError(tr("Selection is empty").toStdString(), false, false);
553 myFeature->setError("", false, false);
554 myFeature->data()->execState(ModelAPI_StateDone);
558 QList<QWidget*> ModuleBase_WidgetSelectionFilter::getControls() const
560 QList<QWidget*> aWidgets;
561 aWidgets.append(myFiltersCombo);
565 void ModuleBase_WidgetSelectionFilter::clearCurrentSelection(bool toUpdate)
568 if (!myPreview.IsNull()) {
569 Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext();
570 aCtx->Remove(myPreview, toUpdate);
575 void ModuleBase_WidgetSelectionFilter::onFeatureAccepted()
577 AttributePtr aAttr = mySelectorFeature->attribute(mySelectorAttribute);
578 AttributeSelectionListPtr aSelListAttr =
579 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aAttr);
580 aSelListAttr->clear();
581 foreach(ModuleBase_ViewerPrsPtr aPrs, myValues) {
582 aSelListAttr->append(aPrs->object(), aPrs->shape());
586 bool ModuleBase_WidgetSelectionFilter::storeValueCustom()
588 ModuleBase_ModelWidget* aActive = myWorkshop->propertyPanel()->activeWidget();
590 return aActive->storeValue();
591 updateObject(myFeature);
595 bool ModuleBase_WidgetSelectionFilter::restoreValueCustom()
597 ModelAPI_FiltersFactory* aFactory = ModelAPI_Session::get()->filters();
598 FiltersFeaturePtr aFiltersFeature = std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
599 std::list<std::string> aFilters = aFiltersFeature->filters();
600 std::list<std::string>::const_iterator aIt;
601 for (aIt = aFilters.cbegin(); aIt != aFilters.cend(); aIt++) {
602 std::string aStr = (*aIt);
604 FilterPtr aFilterObj = aFactory->filter(aStr);
605 int aId = myFiltersCombo->findText(aFilterObj->name().c_str());
607 myFiltersCombo->removeItem(aId);
609 // Init filters member of the parent attribute
610 AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute);
611 if (aAttrList->filters() != aFiltersFeature) {
612 aAttrList->setFilters(aFiltersFeature);
615 QList<QWidget*> aWidgets;
616 QList<ModuleBase_FilterItem*> aItems = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
617 foreach(ModuleBase_FilterItem* aItem, aItems) {
618 QList<ModuleBase_ModelWidget*> aSubList = aItem->widgets();
619 foreach(ModuleBase_ModelWidget* aWgt, aSubList) {
620 aWgt->restoreValue();
626 QString ModuleBase_WidgetSelectionFilter::getError(const bool theValueStateChecked) const
628 QString aErrorMsg = ModuleBase_ModelWidget::getError(theValueStateChecked);
629 if (aErrorMsg.isEmpty()) {
630 if (myValues.size() == 0)
631 aErrorMsg = tr("Selection is empty");
636 void ModuleBase_WidgetSelectionFilter::onObjectUpdated()
638 myShowBtn->setChecked(false);
639 clearCurrentSelection(true);
640 updateNumberSelected();
642 QList<ModuleBase_FilterItem*> aItemsList = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
643 foreach(ModuleBase_FilterItem* aItem, aItemsList) {
644 QList<ModuleBase_ModelWidget*> aWidgetsList = aItem->widgets();
645 foreach(ModuleBase_ModelWidget* aWidget, aWidgetsList) {
646 if (!aWidget->feature().get())
647 aWidget->setFeature(myFeature);
648 aWidget->restoreValue();
651 updateObject(myFeature);
653 // Redisplay the feature on order to Customize presentations from filters with selectors
654 static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
655 ModelAPI_EventCreator::get()->sendUpdated(myFeature, EVENT_DISP);
656 Events_Loop::loop()->flush(EVENT_DISP);