Salome HOME
b0d1781962014a899fc6459d4c88711e5325e781
[modules/shaper.git] / src / XGUI / XGUI_FacesPanel.cpp
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "XGUI_FacesPanel.h"
21 #include "XGUI_ObjectsBrowser.h"
22 #include "XGUI_SelectionMgr.h"
23 #include "XGUI_Selection.h"
24 #include "XGUI_Tools.h"
25 #include "XGUI_Workshop.h"
26 #include "XGUI_Displayer.h"
27 #include "XGUI_ViewerProxy.h"
28
29 #include <ModuleBase_IModule.h>
30 #include <ModuleBase_ISelection.h>
31 #include <ModuleBase_IWorkshop.h>
32 #include <ModuleBase_IViewer.h>
33 #include <ModuleBase_ListView.h>
34 #include <ModuleBase_ResultPrs.h>
35 #include <ModuleBase_Tools.h>
36 #include <ModuleBase_ViewerPrs.h>
37 #include <ModuleBase_SelectionFilterType.h>
38
39 #include <Config_PropManager.h>
40 #include <Events_Loop.h>
41 #include <GeomAlgoAPI_CompoundBuilder.h>
42 #include <GeomAPI_Shape.h>
43
44 #include <ModelAPI_Events.h>
45 #include <ModelAPI_AttributeSelectionList.h>
46
47 #include <QAction>
48 #include <QCheckBox>
49 #include <QFocusEvent>
50 #include <QGridLayout>
51 #include <QListWidget>
52 #include <QMainWindow>
53
54 static const int LayoutMargin = 3;
55
56 //********************************************************************
57 bool getGroup(ModuleBase_ViewerPrsPtr thePrs, ResultGroupPtr& theResGroup,
58   FeaturePtr& theGroupFeature)
59 {
60   ObjectPtr anObject = thePrs->object();
61   if (!anObject.get())
62     return false;
63
64   theResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
65   if (theResGroup.get()) {
66     theGroupFeature = ModelAPI_Feature::feature(theResGroup);
67   }
68   else {
69     theGroupFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
70     if (theGroupFeature.get())
71       theResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(theGroupFeature->firstResult());
72   }
73   return true;
74 }
75
76 //********************************************************************
77 XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop)
78   : QDockWidget(theParent), myIsActive(false), myWorkshop(theWorkshop)
79 {
80   setWindowTitle(tr("Hide Faces"));
81   QAction* aViewAct = toggleViewAction();
82   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
83
84   QWidget* aContent = new QWidget(this);
85   QGridLayout* aMainLayout = new QGridLayout(aContent);
86   aMainLayout->setContentsMargins(LayoutMargin, LayoutMargin, LayoutMargin, LayoutMargin);
87   setWidget(aContent);
88
89   myHiddenOrTransparent = new QCheckBox(tr("Transparent"), aContent);
90   connect(myHiddenOrTransparent, SIGNAL(toggled(bool)), SLOT(onTransparencyChanged()));
91
92   myListView = new ModuleBase_ListView(aContent, "", "Hidden/transparent faces in 3D view");
93   connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem()));
94
95   aMainLayout->addWidget(myHiddenOrTransparent, 0, 0);
96   aMainLayout->addWidget(myListView->getControl(), 1, 0);
97
98   myListView->getControl()->setFocusPolicy(Qt::StrongFocus);
99   myListView->getControl()->viewport()->installEventFilter(this);
100 }
101
102 //********************************************************************
103 void XGUI_FacesPanel::reset(const bool isToFlushRedisplay)
104 {
105   if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset
106     return;
107
108   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
109   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
110   QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
111   for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
112     getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
113   }
114
115   std::set<ObjectPtr> aObjects;
116   TopoDS_ListOfShape anEmpty;
117   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
118   for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
119     aObjects.insert(aPrsIt->first);
120     aPrsIt->second->setSubShapeHidden(anEmpty);
121   }
122   std::set<std::shared_ptr<ModelAPI_Object> >::const_iterator aGrpIt;
123   for (aGrpIt = myHiddenGroups.cbegin(); aGrpIt != myHiddenGroups.cend(); aGrpIt++)
124     (*aGrpIt)->setDisplayed(true);
125   myHiddenGroups.clear();
126
127   if (redisplayObjects(aObjects))
128     flushRedisplay();
129
130   // clear internal containers
131   myListView->getControl()->clear();
132   myItems.clear();
133   updateProcessedObjects(myItems, myItemObjects);
134   myLastItemIndex = 0; // it should be after redisplay as flag used in customize
135   myHiddenObjects.clear();
136 }
137
138 //********************************************************************
139 bool XGUI_FacesPanel::isEmpty() const
140 {
141   return myItems.size() == 0;
142 }
143
144 //********************************************************************
145 void XGUI_FacesPanel::selectionModes(QIntList& theModes)
146 {
147   theModes.append(TopAbs_FACE);
148 }
149
150 //********************************************************************
151 void XGUI_FacesPanel::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
152 {
153   ModuleBase_IModule* aModule = myWorkshop->module();
154   QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
155
156   // The global filter makes problem for groups selection when any operation is launched
157   // theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter));
158   theSelectionFilters.Append(aModule->selectionFilter(SF_FilterInfinite));
159   theSelectionFilters.Append(aModule->selectionFilter(SF_ResultGroupNameFilter));
160 }
161
162 //********************************************************************
163 bool XGUI_FacesPanel::eventFilter(QObject* theObject, QEvent *theEvent)
164 {
165   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
166   if (theEvent->type() == QEvent::MouseButtonRelease)
167   {
168     if (myListView->getControl()->viewport() == aWidget)
169       setActivePanel(true);
170   }
171   // pass the event on to the parent class
172   return QObject::eventFilter(theObject, theEvent);
173 }
174
175 //********************************************************************
176 void XGUI_FacesPanel::setActivePanel(const bool theIsActive)
177 {
178   if (myIsActive == theIsActive)
179     return;
180
181   ModuleBase_Tools::setShadowEffect(myListView->getControl(), theIsActive);
182   myIsActive = theIsActive;
183
184   if (myIsActive) {
185     emit activated();
186     // selection should be cleared after emit of signal to do not process selection change
187     // event by the previous selector
188     // the selection is cleared by activating selection control
189     myWorkshop->selector()->clearSelection();
190   }
191   else
192     emit deactivated();
193 }
194
195 //********************************************************************
196 bool XGUI_FacesPanel::useTransparency() const
197 {
198   return myHiddenOrTransparent->isChecked();
199 }
200
201 //********************************************************************
202 double XGUI_FacesPanel::transparency() const
203 {
204   return useTransparency() ?
205     Config_PropManager::real("Visualization", "hidden_face_transparency") : 1;
206 }
207
208
209 //********************************************************************
210 void XGUI_FacesPanel::restoreObjects(const std::set<ObjectPtr>& theHiddenObjects)
211 {
212   std::set<int> anIndicesToBeRemoved;
213   for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anItemsIt = myItems.begin();
214     anItemsIt != myItems.end(); anItemsIt++)
215   {
216     ModuleBase_ViewerPrsPtr aPrs = anItemsIt.value();
217     ObjectPtr anObject = aPrs->object();
218     if (theHiddenObjects.find(anObject) == theHiddenObjects.end()) // not found
219       continue;
220     anIndicesToBeRemoved.insert(anItemsIt.key());
221   }
222
223   // remove from myItes container
224   for (std::set<int>::const_iterator aToBeRemovedIt = anIndicesToBeRemoved.begin();
225     aToBeRemovedIt != anIndicesToBeRemoved.end(); aToBeRemovedIt++)
226   {
227     myItems.remove(*aToBeRemovedIt);
228   }
229   if (!anIndicesToBeRemoved.empty()) // means that myItems has been changed
230     updateProcessedObjects(myItems, myItemObjects);
231   myListView->removeItems(anIndicesToBeRemoved);
232
233   // remove from container of hidden objects
234   for (std::set<ObjectPtr>::const_iterator aHiddenIt = theHiddenObjects.begin();
235     aHiddenIt != theHiddenObjects.end(); aHiddenIt++)
236   {
237     if (myHiddenObjects.find(*aHiddenIt) != myHiddenObjects.end()) /// found objects
238       myHiddenObjects.erase(*aHiddenIt);
239   }
240 }
241
242 //********************************************************************
243 bool XGUI_FacesPanel::processAction(ModuleBase_ActionType theActionType)
244 {
245   switch (theActionType) {
246     //case ActionEnter:
247     //  return processEnter();
248     case ActionEscape:
249       setActivePanel(false);
250       return true;
251     case ActionDelete:
252       return processDelete();
253     //case ActionUndo:
254     //case ActionRedo:
255     default:
256       return false;
257   }
258 }
259
260 //********************************************************************
261 void XGUI_FacesPanel::getObjectsMapFromResult(ResultGroupPtr theResGroup, FeaturePtr theGroupFeature,
262   std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
263   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
264 {
265   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
266   // Process a grouip result
267   AttributeSelectionListPtr aSelectionList = theGroupFeature->selectionList("group_list");
268   AISObjectPtr aPrs;
269   for (int i = 0; i < aSelectionList->size(); i++) {
270     AttributeSelectionPtr aSelection = aSelectionList->value(i);
271     ResultPtr aRes = aSelection->context();
272     aPrs = aDisplayer->getAISObject(aRes);
273     if (aPrs.get()) {
274       Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
275         aPrs->impl<Handle(AIS_InteractiveObject)>());
276       if (!aResultPrs.IsNull()) {
277         GeomShapePtr aShape = aSelection->value();
278         if (theObjectToShapes.find(aRes) != theObjectToShapes.end())
279           theObjectToShapes.at(aRes).Append(aShape->impl<TopoDS_Shape>());
280         else {
281           TopoDS_ListOfShape aListOfShapes;
282           aListOfShapes.Append(aShape->impl<TopoDS_Shape>());
283           theObjectToShapes[aRes] = aListOfShapes;
284           theObjectToPrs[aRes] = aResultPrs;
285         }
286       }
287     }
288   }
289 }
290
291 //********************************************************************
292 void objectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
293   std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
294   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
295 {
296   ObjectPtr anObject = thePrs->object();
297   if (!anObject.get())
298     return;
299
300   // Process bodies
301   Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
302     thePrs->interactive());
303   if (aResultPrs.IsNull())
304     return;
305
306   if (theObjectToShapes.find(anObject) != theObjectToShapes.end())
307     theObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(thePrs));
308   else {
309     TopoDS_ListOfShape aListOfShapes;
310     aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(thePrs));
311     theObjectToShapes[anObject] = aListOfShapes;
312     theObjectToPrs[anObject] = aResultPrs;
313   }
314 }
315
316 //********************************************************************
317 void XGUI_FacesPanel::getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
318   std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
319   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
320 {
321   ResultGroupPtr aResGroup;
322   FeaturePtr aGroupFeature;
323   if (getGroup(thePrs, aResGroup, aGroupFeature))
324     getObjectsMapFromResult(aResGroup, aGroupFeature, theObjectToShapes, theObjectToPrs);
325   else
326     objectsMapFromPrs(thePrs, theObjectToShapes, theObjectToPrs);
327 }
328
329 //********************************************************************
330 void XGUI_FacesPanel::processSelection()
331 {
332   QList<ModuleBase_ViewerPrsPtr> aSelected =
333     myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::AllControls);
334
335   if (aSelected.size() == 0)
336     return;
337
338   bool isModified = false;
339   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
340
341   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
342   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
343   std::set<int> aToRemove;
344
345   for (int i = 0; i < aSelected.size(); i++) {
346     ModuleBase_ViewerPrsPtr aPrs = aSelected[i];
347     ObjectPtr anObject = aPrs->object();
348     if (!anObject.get())
349       continue;
350
351     ResultGroupPtr aResGroup;
352     FeaturePtr aGroupFeature;
353     if (getGroup(aPrs, aResGroup, aGroupFeature)) {
354       AttributeSelectionListPtr aSelectionListAttr =
355         aGroupFeature->data()->selectionList("group_list");
356       std::string aType = aSelectionListAttr->selectionType();
357       if (aType != "Faces")
358         continue;
359     }
360     else {
361       GeomShapePtr aShapePtr = aPrs->shape();
362       if (!aShapePtr.get() || !aShapePtr->isFace())
363         continue;
364     }
365
366     QString aItemName = aResGroup.get()?
367       aResGroup->data()->name().c_str() : XGUI_Tools::generateName(aPrs);
368     if (myListView->hasItem(aItemName))
369       continue;
370
371     if (aResGroup.get()) {
372       if (aResGroup->isDisplayed()) {
373         aResGroup->setDisplayed(false);
374         myHiddenGroups.insert(aResGroup);
375       }
376       getObjectsMapFromResult(aResGroup, aGroupFeature, anObjectToShapes, anObjectToPrs);
377     }
378     else
379       objectsMapFromPrs(aPrs, anObjectToShapes, anObjectToPrs);
380
381     // The code is dedicated to remove already selected items if they are selected twice
382     // It can happen in case of groups selection
383     QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator aIt;
384     for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
385       ModuleBase_ViewerPrsPtr aPrs = aIt.value();
386       ObjectPtr aObject = aPrs->object();
387       ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObject);
388       if (aResGroup.get())
389         continue;
390       if (anObjectToShapes.find(aObject) != anObjectToShapes.end()) {
391         TopoDS_ListOfShape aShapes = anObjectToShapes[aObject];
392         GeomShapePtr aShapePtr = aPrs->shape();
393         if (aShapes.Contains(aShapePtr->impl<TopoDS_Shape>())) {
394           aToRemove.insert(aIt.key());
395         }
396       }
397     }
398
399     myItems.insert(myLastItemIndex, aPrs);
400     myListView->addItem(aItemName, myLastItemIndex);
401     myLastItemIndex++;
402     isModified = true;
403   }
404
405   // Hide fully hidden shapes
406   std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator anIt;
407   for (anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
408     ObjectPtr anObject = anIt->first;
409     if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
410       continue;
411     Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject);
412
413     if (!aResultPrs->hasSubShapeVisible(anIt->second)) { // redisplay
414       // erase object because it is entirely hidden
415       anObject->setDisplayed(false);
416       myHiddenObjects.insert(anObject);
417     }
418     ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
419   }
420
421   // Process selected presentations
422   double aTransp = transparency();
423   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::iterator aPrsIt;
424   for (aPrsIt = anObjectToPrs.begin(); aPrsIt != anObjectToPrs.end(); aPrsIt++) {
425     ObjectPtr anObject = aPrsIt->first;
426     Handle(ModuleBase_ResultPrs) aPrs = aPrsIt->second;
427     TopoDS_ListOfShape aAlreadyHidden = aPrs->hiddenSubShapes();
428     TopoDS_ListOfShape aListOfShapes = anObjectToShapes[anObject];
429     TopoDS_ListOfShape::Iterator aShapesIt(aListOfShapes);
430     for (; aShapesIt.More(); aShapesIt.Next()) {
431       if (!aAlreadyHidden.Contains(aShapesIt.Value()))
432         aAlreadyHidden.Append(aShapesIt.Value());
433     }
434     aPrs->setSubShapeHidden(aAlreadyHidden);
435     aPrs->setHiddenSubShapeTransparency(aTransp);
436   }
437
438   // Remove duplicate items
439   if (aToRemove.size() > 0) {
440     myListView->removeItems(aToRemove);
441     std::set<int>::const_iterator aIntIt;
442     for (aIntIt = aToRemove.cbegin(); aIntIt != aToRemove.cend(); aIntIt++)
443       myItems.remove(*aIntIt);
444   }
445   if (isModified) {
446     updateProcessedObjects(myItems, myItemObjects);
447     flushRedisplay();
448   }
449 }
450
451 //********************************************************************
452 bool XGUI_FacesPanel::processDelete()
453 {
454   //appendFirstSelectionInHistory();
455   QModelIndexList anIndices = myListView->getControl()->selectionModel()->selectedIndexes();
456
457   std::set<int> aSelectedIds;
458   myListView->getSelectedIndices(aSelectedIds);
459   if (aSelectedIds.empty())
460     return false;
461
462   bool isModified = false;
463   std::set<ModuleBase_ViewerPrsPtr> aRestored;
464   std::set<int>::const_iterator anIt;
465   for (anIt = aSelectedIds.begin(); anIt != aSelectedIds.end(); anIt++) {
466     ModuleBase_ViewerPrsPtr aPrs = myItems[*anIt];
467     if (aRestored.find(aPrs) == aRestored.end()) {
468       aRestored.insert(aPrs);
469       myItems.remove(*anIt);
470       isModified = true;
471     }
472   }
473   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
474   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
475
476   std::set<ModuleBase_ViewerPrsPtr>::const_iterator aIt;
477   for (aIt = aRestored.cbegin(); aIt != aRestored.cend(); aIt++) {
478     getObjectsMapFromPrs((*aIt), anObjectToShapes, anObjectToPrs);
479     ResultGroupPtr aResGroup;
480     FeaturePtr aGroupFeature;
481     if (getGroup((*aIt), aResGroup, aGroupFeature)) {
482       std::set<std::shared_ptr<ModelAPI_Object> >::iterator aGrpIt = myHiddenGroups.find(aResGroup);
483       if (aGrpIt != myHiddenGroups.end()) {
484         aResGroup->setDisplayed(true);
485         myHiddenGroups.erase(aGrpIt);
486       }
487     }
488   }
489
490   std::set<ObjectPtr> aRestoredObjects;
491   std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator aShapesIt;
492   for (aShapesIt = anObjectToShapes.begin(); aShapesIt != anObjectToShapes.end(); aShapesIt++) {
493     TopoDS_ListOfShape aShapes = aShapesIt->second;
494     aRestoredObjects.insert(aShapesIt->first);
495     Handle(ModuleBase_ResultPrs) aPrs = anObjectToPrs[aShapesIt->first];
496     TopoDS_ListOfShape aHiddenShapes = aPrs->hiddenSubShapes();
497     TopoDS_ListOfShape::Iterator aSubShapesIt(aShapes);
498     for (; aSubShapesIt.More(); aSubShapesIt.Next()) {
499       if (aHiddenShapes.Contains(aSubShapesIt.Value()))
500         aHiddenShapes.Remove(aSubShapesIt.Value());
501     }
502     aPrs->setSubShapeHidden(aHiddenShapes);
503   }
504   if (redisplayObjects(aRestoredObjects))
505     flushRedisplay();
506
507   myListView->removeSelectedItems();
508   return true;
509 }
510
511 //********************************************************************
512 bool XGUI_FacesPanel::redisplayObjects(
513   const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects)
514 {
515   if (theObjects.empty())
516     return false;
517
518   bool isModified = false;
519   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
520   for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(); anIt != theObjects.end();
521        anIt++)
522   {
523     ObjectPtr anObject = *anIt;
524     if (!anObject->isDisplayed())
525       continue;
526     ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
527     isModified = true;
528   }
529   return isModified;
530 }
531
532 //********************************************************************
533 void XGUI_FacesPanel::updateProcessedObjects(QMap<int, ModuleBase_ViewerPrsPtr> theItems,
534                                              std::set<ObjectPtr>& theObjects)
535 {
536   theObjects.clear();
537   for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = theItems.begin();
538        anIt != theItems.end(); anIt++) {
539     ModuleBase_ViewerPrsPtr aPrs = anIt.value();
540     ObjectPtr anObject = aPrs.get() ? aPrs->object() : ObjectPtr();
541     if (anObject.get()) {
542       ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
543       if (aResGroup.get()) {
544         FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup);
545         AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
546         for (int i = 0; i < aSelectionList->size(); i++) {
547           AttributeSelectionPtr aSelection = aSelectionList->value(i);
548           ResultPtr aRes = aSelection->context();
549           if (theObjects.find(aRes) == theObjects.end())
550             theObjects.insert(aRes);
551         }
552       }
553       else {
554         if (theObjects.find(anObject) == theObjects.end())
555           theObjects.insert(anObject);
556       }
557     }
558   }
559 }
560
561 //********************************************************************
562 void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent)
563 {
564   QDockWidget::closeEvent(theEvent);
565   emit closed();
566 }
567
568 //********************************************************************
569 void XGUI_FacesPanel::onDeleteItem()
570 {
571   processDelete();
572 }
573
574 //********************************************************************
575 void XGUI_FacesPanel::onTransparencyChanged()
576 {
577   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
578   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
579   QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
580   for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
581     getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
582   }
583
584   double aTransp = Config_PropManager::real("Visualization", "hidden_face_transparency");
585   std::set<ObjectPtr> aObjects;
586   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
587   for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
588     aObjects.insert(aPrsIt->first);
589     aPrsIt->second->setHiddenSubShapeTransparency(useTransparency()? aTransp : 1);
590   }
591   if (redisplayObjects(aObjects))
592     flushRedisplay();
593 }
594
595 //********************************************************************
596 void XGUI_FacesPanel::onClosed()
597 {
598   setActivePanel(false);
599   reset(true);
600 }
601
602 //********************************************************************
603 void XGUI_FacesPanel::flushRedisplay() const
604 {
605   Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
606   // Necessary for update visibility icons in ObjectBrowser
607   XGUI_ObjectsBrowser* anObjectBrowser = myWorkshop->objectBrowser();
608   if (anObjectBrowser)
609     anObjectBrowser->updateAllIndexes();
610   myWorkshop->viewer()->update();
611 }