Salome HOME
67e3a5aa34bba9cb54fa0ea0c5e3f0f3cf1a035e
[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,
262   FeaturePtr theGroupFeature,
263   std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
264   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
265 {
266   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
267   // Process a grouip result
268   AttributeSelectionListPtr aSelectionList = theGroupFeature->selectionList("group_list");
269   AISObjectPtr aPrs;
270   for (int i = 0; i < aSelectionList->size(); i++) {
271     AttributeSelectionPtr aSelection = aSelectionList->value(i);
272     ResultPtr aRes = aSelection->context();
273     aPrs = aDisplayer->getAISObject(aRes);
274     if (aPrs.get()) {
275       Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
276         aPrs->impl<Handle(AIS_InteractiveObject)>());
277       if (!aResultPrs.IsNull()) {
278         GeomShapePtr aShape = aSelection->value();
279         if (theObjectToShapes.find(aRes) != theObjectToShapes.end())
280           theObjectToShapes.at(aRes).Append(aShape->impl<TopoDS_Shape>());
281         else {
282           TopoDS_ListOfShape aListOfShapes;
283           aListOfShapes.Append(aShape->impl<TopoDS_Shape>());
284           theObjectToShapes[aRes] = aListOfShapes;
285           theObjectToPrs[aRes] = aResultPrs;
286         }
287       }
288     }
289   }
290 }
291
292 //********************************************************************
293 void objectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
294   std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
295   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
296 {
297   ObjectPtr anObject = thePrs->object();
298   if (!anObject.get())
299     return;
300
301   // Process bodies
302   Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
303     thePrs->interactive());
304   if (aResultPrs.IsNull())
305     return;
306
307   if (theObjectToShapes.find(anObject) != theObjectToShapes.end())
308     theObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(thePrs));
309   else {
310     TopoDS_ListOfShape aListOfShapes;
311     aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(thePrs));
312     theObjectToShapes[anObject] = aListOfShapes;
313     theObjectToPrs[anObject] = aResultPrs;
314   }
315 }
316
317 //********************************************************************
318 void XGUI_FacesPanel::getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
319   std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
320   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
321 {
322   ResultGroupPtr aResGroup;
323   FeaturePtr aGroupFeature;
324   if (getGroup(thePrs, aResGroup, aGroupFeature))
325     getObjectsMapFromResult(aResGroup, aGroupFeature, theObjectToShapes, theObjectToPrs);
326   else
327     objectsMapFromPrs(thePrs, theObjectToShapes, theObjectToPrs);
328 }
329
330 //********************************************************************
331 void XGUI_FacesPanel::processSelection()
332 {
333   QList<ModuleBase_ViewerPrsPtr> aSelected =
334     myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::AllControls);
335
336   if (aSelected.size() == 0)
337     return;
338
339   bool isModified = false;
340   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
341
342   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
343   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
344   std::set<int> aToRemove;
345
346   for (int i = 0; i < aSelected.size(); i++) {
347     ModuleBase_ViewerPrsPtr aPrs = aSelected[i];
348     ObjectPtr anObject = aPrs->object();
349     if (!anObject.get())
350       continue;
351
352     ResultGroupPtr aResGroup;
353     FeaturePtr aGroupFeature;
354     if (getGroup(aPrs, aResGroup, aGroupFeature)) {
355       AttributeSelectionListPtr aSelectionListAttr =
356         aGroupFeature->data()->selectionList("group_list");
357       std::string aType = aSelectionListAttr->selectionType();
358       if (aType != "Faces")
359         continue;
360     }
361     else {
362       GeomShapePtr aShapePtr = aPrs->shape();
363       if (!aShapePtr.get() || !aShapePtr->isFace())
364         continue;
365     }
366
367     QString aItemName = aResGroup.get()?
368       aResGroup->data()->name().c_str() : XGUI_Tools::generateName(aPrs);
369     if (myListView->hasItem(aItemName))
370       continue;
371
372     if (aResGroup.get()) {
373       if (aResGroup->isDisplayed()) {
374         aResGroup->setDisplayed(false);
375         myHiddenGroups.insert(aResGroup);
376       }
377       getObjectsMapFromResult(aResGroup, aGroupFeature, anObjectToShapes, anObjectToPrs);
378     }
379     else
380       objectsMapFromPrs(aPrs, anObjectToShapes, anObjectToPrs);
381
382     // The code is dedicated to remove already selected items if they are selected twice
383     // It can happen in case of groups selection
384     QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator aIt;
385     for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
386       ModuleBase_ViewerPrsPtr aPrs = aIt.value();
387       ObjectPtr aObject = aPrs->object();
388       ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObject);
389       if (aResGroup.get())
390         continue;
391       if (anObjectToShapes.find(aObject) != anObjectToShapes.end()) {
392         TopoDS_ListOfShape aShapes = anObjectToShapes[aObject];
393         GeomShapePtr aShapePtr = aPrs->shape();
394         if (aShapes.Contains(aShapePtr->impl<TopoDS_Shape>())) {
395           aToRemove.insert(aIt.key());
396         }
397       }
398     }
399
400     myItems.insert(myLastItemIndex, aPrs);
401     myListView->addItem(aItemName, myLastItemIndex);
402     myLastItemIndex++;
403     isModified = true;
404   }
405
406   // Hide fully hidden shapes
407   std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator anIt;
408   for (anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
409     ObjectPtr anObject = anIt->first;
410     if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
411       continue;
412     Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject);
413
414     if (!aResultPrs->hasSubShapeVisible(anIt->second)) { // redisplay
415       // erase object because it is entirely hidden
416       anObject->setDisplayed(false);
417       myHiddenObjects.insert(anObject);
418     }
419     ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
420   }
421
422   // Process selected presentations
423   double aTransp = transparency();
424   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::iterator aPrsIt;
425   for (aPrsIt = anObjectToPrs.begin(); aPrsIt != anObjectToPrs.end(); aPrsIt++) {
426     ObjectPtr anObject = aPrsIt->first;
427     Handle(ModuleBase_ResultPrs) aPrs = aPrsIt->second;
428     TopoDS_ListOfShape aAlreadyHidden = aPrs->hiddenSubShapes();
429     TopoDS_ListOfShape aListOfShapes = anObjectToShapes[anObject];
430     TopoDS_ListOfShape::Iterator aShapesIt(aListOfShapes);
431     for (; aShapesIt.More(); aShapesIt.Next()) {
432       if (!aAlreadyHidden.Contains(aShapesIt.Value()))
433         aAlreadyHidden.Append(aShapesIt.Value());
434     }
435     aPrs->setSubShapeHidden(aAlreadyHidden);
436     aPrs->setHiddenSubShapeTransparency(aTransp);
437   }
438
439   // Remove duplicate items
440   if (aToRemove.size() > 0) {
441     myListView->removeItems(aToRemove);
442     std::set<int>::const_iterator aIntIt;
443     for (aIntIt = aToRemove.cbegin(); aIntIt != aToRemove.cend(); aIntIt++)
444       myItems.remove(*aIntIt);
445   }
446   if (isModified) {
447     updateProcessedObjects(myItems, myItemObjects);
448     flushRedisplay();
449   }
450 }
451
452 //********************************************************************
453 bool XGUI_FacesPanel::processDelete()
454 {
455   //appendFirstSelectionInHistory();
456   QModelIndexList anIndices = myListView->getControl()->selectionModel()->selectedIndexes();
457
458   std::set<int> aSelectedIds;
459   myListView->getSelectedIndices(aSelectedIds);
460   if (aSelectedIds.empty())
461     return false;
462
463   bool isModified = false;
464   std::set<ModuleBase_ViewerPrsPtr> aRestored;
465   std::set<int>::const_iterator anIt;
466   for (anIt = aSelectedIds.begin(); anIt != aSelectedIds.end(); anIt++) {
467     ModuleBase_ViewerPrsPtr aPrs = myItems[*anIt];
468     if (aRestored.find(aPrs) == aRestored.end()) {
469       aRestored.insert(aPrs);
470       myItems.remove(*anIt);
471       isModified = true;
472     }
473   }
474   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
475   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
476
477   std::set<ModuleBase_ViewerPrsPtr>::const_iterator aIt;
478   for (aIt = aRestored.cbegin(); aIt != aRestored.cend(); aIt++) {
479     getObjectsMapFromPrs((*aIt), anObjectToShapes, anObjectToPrs);
480     ResultGroupPtr aResGroup;
481     FeaturePtr aGroupFeature;
482     if (getGroup((*aIt), aResGroup, aGroupFeature)) {
483       std::set<std::shared_ptr<ModelAPI_Object> >::iterator aGrpIt = myHiddenGroups.find(aResGroup);
484       if (aGrpIt != myHiddenGroups.end()) {
485         aResGroup->setDisplayed(true);
486         myHiddenGroups.erase(aGrpIt);
487       }
488     }
489   }
490
491   std::set<ObjectPtr> aRestoredObjects;
492   std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator aShapesIt;
493   for (aShapesIt = anObjectToShapes.begin(); aShapesIt != anObjectToShapes.end(); aShapesIt++) {
494     TopoDS_ListOfShape aShapes = aShapesIt->second;
495     aRestoredObjects.insert(aShapesIt->first);
496     Handle(ModuleBase_ResultPrs) aPrs = anObjectToPrs[aShapesIt->first];
497     TopoDS_ListOfShape aHiddenShapes = aPrs->hiddenSubShapes();
498     TopoDS_ListOfShape::Iterator aSubShapesIt(aShapes);
499     for (; aSubShapesIt.More(); aSubShapesIt.Next()) {
500       if (aHiddenShapes.Contains(aSubShapesIt.Value()))
501         aHiddenShapes.Remove(aSubShapesIt.Value());
502     }
503     aPrs->setSubShapeHidden(aHiddenShapes);
504   }
505   if (redisplayObjects(aRestoredObjects))
506     flushRedisplay();
507
508   myListView->removeSelectedItems();
509   return true;
510 }
511
512 //********************************************************************
513 bool XGUI_FacesPanel::redisplayObjects(
514   const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects)
515 {
516   if (theObjects.empty())
517     return false;
518
519   bool isModified = false;
520   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
521   for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(); anIt != theObjects.end();
522        anIt++)
523   {
524     ObjectPtr anObject = *anIt;
525     if (!anObject->isDisplayed())
526       continue;
527     ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
528     isModified = true;
529   }
530   return isModified;
531 }
532
533 //********************************************************************
534 void XGUI_FacesPanel::updateProcessedObjects(QMap<int, ModuleBase_ViewerPrsPtr> theItems,
535                                              std::set<ObjectPtr>& theObjects)
536 {
537   theObjects.clear();
538   for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = theItems.begin();
539        anIt != theItems.end(); anIt++) {
540     ModuleBase_ViewerPrsPtr aPrs = anIt.value();
541     ObjectPtr anObject = aPrs.get() ? aPrs->object() : ObjectPtr();
542     if (anObject.get()) {
543       ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
544       if (aResGroup.get()) {
545         FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup);
546         AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
547         for (int i = 0; i < aSelectionList->size(); i++) {
548           AttributeSelectionPtr aSelection = aSelectionList->value(i);
549           ResultPtr aRes = aSelection->context();
550           if (theObjects.find(aRes) == theObjects.end())
551             theObjects.insert(aRes);
552         }
553       }
554       else {
555         if (theObjects.find(anObject) == theObjects.end())
556           theObjects.insert(anObject);
557       }
558     }
559   }
560 }
561
562 //********************************************************************
563 void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent)
564 {
565   QDockWidget::closeEvent(theEvent);
566   emit closed();
567 }
568
569 //********************************************************************
570 void XGUI_FacesPanel::onDeleteItem()
571 {
572   processDelete();
573 }
574
575 //********************************************************************
576 void XGUI_FacesPanel::onTransparencyChanged()
577 {
578   std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
579   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
580   QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
581   for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
582     getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
583   }
584
585   double aTransp = Config_PropManager::real("Visualization", "hidden_face_transparency");
586   std::set<ObjectPtr> aObjects;
587   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
588   for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
589     aObjects.insert(aPrsIt->first);
590     aPrsIt->second->setHiddenSubShapeTransparency(useTransparency()? aTransp : 1);
591   }
592   if (redisplayObjects(aObjects))
593     flushRedisplay();
594 }
595
596 //********************************************************************
597 void XGUI_FacesPanel::onClosed()
598 {
599   setActivePanel(false);
600   reset(true);
601 }
602
603 //********************************************************************
604 void XGUI_FacesPanel::flushRedisplay() const
605 {
606   Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
607   // Necessary for update visibility icons in ObjectBrowser
608   XGUI_ObjectsBrowser* anObjectBrowser = myWorkshop->objectBrowser();
609   if (anObjectBrowser)
610     anObjectBrowser->updateAllIndexes();
611   myWorkshop->viewer()->update();
612 }