]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Displayer.cpp
Salome HOME
3b0cbc3e601d47d0116a22974f13d4812092f160
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_Displayer.cpp
4 // Created:     20 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #include "XGUI_Displayer.h"
8 #include "XGUI_Workshop.h"
9 #include "XGUI_ViewerProxy.h"
10
11 #include <AppElements_Viewer.h>
12
13 #include <ModelAPI_Document.h>
14 #include <ModelAPI_Data.h>
15 #include <ModelAPI_Object.h>
16 #include <ModelAPI_Tools.h>
17
18 #include <ModuleBase_ResultPrs.h>
19
20 #include <GeomAPI_Shape.h>
21 #include <GeomAPI_IPresentable.h>
22 #include <GeomAPI_ICustomPrs.h>
23
24 #include <AIS_InteractiveContext.hxx>
25 #include <AIS_LocalContext.hxx>
26 #include <AIS_ListOfInteractive.hxx>
27 #include <AIS_ListIteratorOfListOfInteractive.hxx>
28 #include <AIS_DimensionSelectionMode.hxx>
29 #include <AIS_Shape.hxx>
30 #include <AIS_Dimension.hxx>
31 #include <TColStd_ListIteratorOfListOfInteger.hxx>
32 #include <SelectMgr_ListOfFilter.hxx>
33 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
34
35 #include <TColStd_MapOfTransient.hxx>
36 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
37
38 #include <set>
39
40 const int MOUSE_SENSITIVITY_IN_PIXEL = 10;  ///< defines the local context mouse selection sensitivity
41
42
43 // Workaround for bug #25637
44 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
45 {
46   // Get from null point
47   theAIS->DisplayedObjects(theList, true);
48   if (theAIS->HasOpenedContext()) {
49     // get from local context
50     const Handle(AIS_LocalContext)& aLC = theAIS->LocalContext();
51     TColStd_MapOfTransient aMap;
52     int NbDisp = aLC->DisplayedObjects(aMap);
53     TColStd_MapIteratorOfMapOfTransient aIt(aMap);
54
55     Handle(AIS_InteractiveObject) curIO;
56     Handle(Standard_Transient) Tr;
57     for(; aIt.More(); aIt.Next()){
58       Tr = aIt.Key();
59       curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
60       theList.Append(curIO);
61     }
62   }
63 }
64
65
66 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
67   : myWorkshop(theWorkshop)
68 {
69 }
70
71 XGUI_Displayer::~XGUI_Displayer()
72 {
73 }
74
75 bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
76 {
77   return myResult2AISObjectMap.contains(theObject);
78 }
79
80 void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
81 {
82   if (isVisible(theObject)) {
83     redisplay(theObject, isUpdateViewer);
84   } else {
85     AISObjectPtr anAIS;
86
87     GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
88     bool isShading = false;
89     if (aPrs.get() != NULL) {
90       anAIS = aPrs->getAISObject(AISObjectPtr());
91     } else {
92       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
93       if (aResult.get() != NULL) {
94         std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
95         if (aShapePtr.get() != NULL) {
96           anAIS = AISObjectPtr(new GeomAPI_AISObject());
97           anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
98           //anAIS->createShape(aShapePtr);
99           isShading = true;
100         }
101       }
102     }
103     if (anAIS)
104       display(theObject, anAIS, isShading, isUpdateViewer);
105   }
106 }
107
108 bool canBeShaded(Handle(AIS_InteractiveObject) theAIS)
109 {
110   Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS);
111   if (!aShapePrs.IsNull()) {
112     TopoDS_Shape aShape = aShapePrs->Shape();
113     TopAbs_ShapeEnum aType = aShape.ShapeType();
114     if ((aType == TopAbs_VERTEX) || (aType == TopAbs_EDGE) || (aType == TopAbs_WIRE))
115       return false;
116     else
117       return true;
118   }
119   return false;
120 }
121
122 void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, 
123                              bool isShading, bool isUpdateViewer)
124 {
125   Handle(AIS_InteractiveContext) aContext = AISContext();
126   if (aContext.IsNull())
127     return;
128
129   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
130   if (!anAISIO.IsNull()) {
131     myResult2AISObjectMap[theObject] = theAIS;
132     bool aCanBeShaded = canBeShaded(anAISIO);
133     // In order to avoid extra closing/opening context
134     if (aCanBeShaded)
135       closeLocalContexts(false);
136     aContext->Display(anAISIO, false);
137     qDebug("### Display %i", (long)anAISIO.Access());
138
139     aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
140     // Customization of presentation
141     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
142     if (aFeature.get() != NULL) {
143       GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
144       if (aCustPrs.get() != NULL)
145         aCustPrs->customisePresentation(theAIS);
146     }
147     if (aCanBeShaded) {
148       openLocalContext();
149       activateObjects(myActiveSelectionModes);
150     }
151   }
152   if (isUpdateViewer)
153     updateViewer();
154 }
155
156 void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
157 {
158   if (!isVisible(theObject))
159     return;
160
161   Handle(AIS_InteractiveContext) aContext = AISContext();
162   if (aContext.IsNull())
163     return;
164   AISObjectPtr anObject = myResult2AISObjectMap[theObject];
165   if (anObject) {
166     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
167     if (!anAIS.IsNull()) {
168       aContext->Remove(anAIS, isUpdateViewer);
169     }
170   }
171   myResult2AISObjectMap.remove(theObject);
172 }
173
174 void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
175 {
176   if (!isVisible(theObject))
177     return;
178
179   AISObjectPtr aAISObj = getAISObject(theObject);
180   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
181
182   GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
183   if (aPrs) {
184     AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
185     if (!aAIS_Obj) {
186       erase(theObject, isUpdateViewer);
187       return;
188     }
189     if (aAIS_Obj != aAISObj) {
190       myResult2AISObjectMap[theObject] = aAIS_Obj;
191     }
192     aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
193   }
194
195   if (!aAISIO.IsNull()) {
196     Handle(AIS_InteractiveContext) aContext = AISContext();
197     if (aContext.IsNull())
198       return;
199     bool aToSelect = aContext->IsSelected(aAISIO);
200     aContext->Redisplay(aAISIO, false);
201     // Restore selection state after redisplay
202     if (aToSelect) 
203       aContext->SetSelected(aAISIO);
204     if (isUpdateViewer)
205       updateViewer();
206   }
207 }
208
209 void XGUI_Displayer::deactivate(ObjectPtr theObject)
210 {
211   if (isVisible(theObject)) {
212     Handle(AIS_InteractiveContext) aContext = AISContext();
213     if (aContext.IsNull())
214       return;
215
216     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
217     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
218     aContext->Deactivate(anAIS);
219     qDebug("### Deactivate obj %i", (long)anAIS.Access());
220   }
221 }
222
223 void XGUI_Displayer::activate(ObjectPtr theFeature)
224 {
225   activate(theFeature, myActiveSelectionModes);
226 }
227
228 void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
229 {
230   if (isVisible(theObject)) {
231     Handle(AIS_InteractiveContext) aContext = AISContext();
232     if (aContext.IsNull())
233       return;
234
235     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
236     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
237     aContext->Deactivate(anAIS);
238     aContext->Load(anAIS, -1, true);
239     // In order to clear active modes list
240     if (theModes.size() > 0) {
241       foreach(int aMode, theModes) {
242         //aContext->Load(anAIS, aMode, true);
243         aContext->Activate(anAIS, aMode);
244         qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode);
245       }
246     } else {
247       //aContext->Load(anAIS, 0, true);
248       aContext->Activate(anAIS);
249       qDebug("### 2. Activate obj %i", (long)anAIS.Access());
250     }
251   }
252 }
253
254 void XGUI_Displayer::activateObjects(const QIntList& theModes)
255 {
256   // In order to avoid doblications of selection modes
257   QIntList aNewModes;
258   foreach (int aMode, theModes) {
259     if (!aNewModes.contains(aMode))
260       aNewModes.append(aMode);
261   }
262   myActiveSelectionModes = aNewModes;
263   Handle(AIS_InteractiveContext) aContext = AISContext();
264   // Open local context if there is no one
265   if (!aContext->HasOpenedContext()) 
266     return;
267
268   //aContext->UseDisplayedObjects();
269   //myUseExternalObjects = true;
270
271   AIS_ListOfInteractive aPrsList;
272   displayedObjects(aContext, aPrsList);
273
274   Handle(AIS_Trihedron) aTrihedron;
275   AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
276   Handle(AIS_InteractiveObject) anAISIO;
277   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
278     anAISIO = aLIt.Value();
279     aContext->Load(anAISIO, -1, true);
280     aContext->Deactivate(anAISIO);
281     aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
282     //Deactivate trihedron which can be activated in local selector
283     if (aTrihedron.IsNull()) {
284       //aContext->Load(anAISIO, -1, true);
285       // In order to clear active modes list
286       if (myActiveSelectionModes.size() == 0) {
287         //aContext->Load(anAISIO, 0, true);
288         aContext->Activate(anAISIO);
289         qDebug("### 2. Activate all %i", (long)anAISIO.Access());
290       } else {
291         foreach(int aMode, myActiveSelectionModes) {
292           //aContext->Load(anAISIO, aMode, true);
293           aContext->Activate(anAISIO, aMode);
294           qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode);
295         }
296       }
297     }
298   }
299 }
300
301
302 void XGUI_Displayer::deactivateObjects()
303 {
304   myActiveSelectionModes.clear();
305   Handle(AIS_InteractiveContext) aContext = AISContext();
306   // Open local context if there is no one
307   if (!aContext->HasOpenedContext()) 
308     return;
309
310   //aContext->NotUseDisplayedObjects();
311   AIS_ListOfInteractive aPrsList;
312   displayedObjects(aContext, aPrsList);
313
314   AIS_ListIteratorOfListOfInteractive aLIt;
315   //Handle(AIS_Trihedron) aTrihedron;
316   Handle(AIS_InteractiveObject) anAISIO;
317   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
318     anAISIO = aLIt.Value();
319     aContext->Deactivate(anAISIO);
320     //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
321     //if (aTrihedron.IsNull()) {
322     //  qDebug("### Deactivate all %i", (long)anAISIO.Access());
323     //  //aContext->Activate(anAISIO);
324     //}
325   }
326 }
327
328 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
329 {
330   Handle(AIS_InteractiveContext) aContext = AISContext();
331   if (aContext.IsNull())
332     return false;
333   if (!isVisible(theObject))
334     return false;
335     
336   AISObjectPtr anObj = myResult2AISObjectMap[theObject];
337   Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
338
339   TColStd_ListOfInteger aModes;
340   aContext->ActivatedModes(anAIS, aModes);
341   return aModes.Extent() > 0;
342 }
343
344 void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer)
345 {
346   Handle(AIS_InteractiveContext) aContext = AISContext();
347   if (aContext.IsNull())
348     return;
349   if (aContext->HasOpenedContext()) {
350     aContext->UnhilightSelected();
351     aContext->ClearSelected();
352     foreach(ObjectPtr aResult, theResults) {
353       if (isVisible(aResult)) {
354         AISObjectPtr anObj = myResult2AISObjectMap[aResult];
355         Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
356         if (!anAIS.IsNull())
357           aContext->SetSelected(anAIS, false);
358       }
359     }
360   } else {
361     aContext->UnhilightCurrents();
362     aContext->ClearCurrents();
363     foreach(ObjectPtr aResult, theResults) {
364       if (isVisible(aResult)) {
365         AISObjectPtr anObj = myResult2AISObjectMap[aResult];
366         Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
367         if (!anAIS.IsNull())
368           aContext->SetCurrentObject(anAIS, false);
369       }
370     }
371   }
372   if (isUpdateViewer)
373     updateViewer();
374 }
375
376
377 void XGUI_Displayer::clearSelected()
378 {
379   Handle(AIS_InteractiveContext) aContext = AISContext();
380   if (aContext) {
381     aContext->UnhilightCurrents(false);
382     aContext->ClearSelected();
383   }
384 }
385
386 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
387 {
388   Handle(AIS_InteractiveContext) aContext = AISContext();
389   if (aContext.IsNull())
390     return;
391
392    foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
393      // erase an object
394      Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
395      if (!anIO.IsNull())
396        aContext->Remove(anIO, false);
397    }
398    myResult2AISObjectMap.clear();
399    if (isUpdateViewer)
400      updateViewer();
401  }
402
403 void XGUI_Displayer::openLocalContext()
404 {
405   Handle(AIS_InteractiveContext) aContext = AISContext();
406   if (aContext.IsNull())
407     return;
408   // Open local context if there is no one
409   if (!aContext->HasOpenedContext()) {
410     // Preserve selected objects
411     //AIS_ListOfInteractive aAisList;
412     //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
413     //  aAisList.Append(aContext->Current());
414
415     // get the filters from the global context and append them to the local context
416     // a list of filters in the global context is not cleared and should be cleared here
417     SelectMgr_ListOfFilter aFilters;
418     aFilters.Assign(aContext->Filters());
419     // it is important to remove the filters in the global context, because there is a code
420     // in the closeLocalContex, which restore the global context filters
421     aContext->RemoveFilters();
422
423     //aContext->ClearCurrents();
424     aContext->OpenLocalContext();
425     qDebug("### Open context");
426     //aContext->NotUseDisplayedObjects();
427
428     //myUseExternalObjects = false;
429
430     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
431     for (;aIt.More(); aIt.Next()) {
432       aContext->AddFilter(aIt.Value());
433     }
434     // Restore selection
435     //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
436     //for(; aIt2.More(); aIt2.Next()) {
437     //  aContext->SetSelected(aIt2.Value(), false);
438     //}
439   }
440 }
441
442 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
443 {
444   Handle(AIS_InteractiveContext) aContext = AISContext();
445   if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
446     // Preserve selected objects
447     //AIS_ListOfInteractive aAisList;
448     //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
449     //  aAisList.Append(aContext->SelectedInteractive());
450
451     // get the filters from the local context and append them to the global context
452     // a list of filters in the local context is cleared
453     SelectMgr_ListOfFilter aFilters;
454     aFilters.Assign(aContext->Filters());
455
456     //aContext->ClearSelected();
457     aContext->CloseAllContexts(false);
458     qDebug("### Close context");
459
460     // Redisplay all object if they were displayed in localContext
461     Handle(AIS_InteractiveObject) aAISIO;
462     foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
463       aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
464       if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
465         aContext->Display(aAISIO, false);
466         aContext->SetDisplayMode(aAISIO, Shading, false);
467       }
468     }
469
470     // Append the filters from the local selection in the global selection context
471     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
472     for (;aIt.More(); aIt.Next()) {
473       Handle(SelectMgr_Filter) aFilter = aIt.Value();
474       aContext->AddFilter(aFilter);
475     }
476
477     if (isUpdateViewer)
478       updateViewer();
479     //myUseExternalObjects = false;
480
481     // Restore selection
482     //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
483     //for(; aIt2.More(); aIt2.Next()) {
484     //  if (aContext->IsDisplayed(aIt2.Value()))
485     //    aContext->SetCurrentObject(aIt2.Value(), false);
486     //}
487   }
488 }
489
490 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
491 {
492   AISObjectPtr anIO;
493   if (myResult2AISObjectMap.contains(theObject))
494     anIO = myResult2AISObjectMap[theObject];
495   return anIO;
496 }
497
498 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
499 {
500   Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
501   return getObject(aRefAIS);
502 }
503
504 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
505 {
506   ObjectPtr aFeature;
507   foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
508     AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
509     Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
510     if (anAIS == theIO)
511       return anObj;
512   }
513   return aFeature;
514 }
515
516 void XGUI_Displayer::updateViewer()
517 {
518   Handle(AIS_InteractiveContext) aContext = AISContext();
519   if (!aContext.IsNull())
520     aContext->UpdateCurrentViewer();
521 }
522
523 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
524 {
525   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
526   if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
527     aContext->OpenLocalContext();
528     qDebug("### Open context");
529   }
530   return aContext;
531 }
532
533 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
534 {
535   Handle(AIS_InteractiveContext) aContext = AISContext();
536   if (myAndFilter.IsNull() && !aContext.IsNull()) {
537     myAndFilter = new SelectMgr_AndFilter();
538     aContext->AddFilter(myAndFilter);
539   }
540   return myAndFilter;
541 }
542
543 void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
544 {
545   Handle(AIS_InteractiveContext) aContext = AISContext();
546   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
547   if (!anAISIO.IsNull()) {
548     aContext->Display(anAISIO, isUpdate);
549     if (aContext->HasOpenedContext()) {
550       //if (myUseExternalObjects) {
551         if (myActiveSelectionModes.size() == 0)
552           aContext->Activate(anAISIO);
553         else {
554           foreach(int aMode, myActiveSelectionModes) {
555             aContext->Activate(anAISIO, aMode);
556           }
557         }
558       //}
559     }
560   }
561 }
562
563 void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
564 {
565   Handle(AIS_InteractiveContext) aContext = AISContext();
566   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
567   if (!anAISIO.IsNull()) {
568     aContext->Remove(anAISIO, isUpdate);
569   }
570 }
571
572
573 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate)
574 {
575   if (theMode == NoMode)
576     return;
577
578   Handle(AIS_InteractiveContext) aContext = AISContext();
579   if (aContext.IsNull())
580     return;
581
582   AISObjectPtr aAISObj = getAISObject(theObject);
583   if (!aAISObj)
584     return;
585
586   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
587   aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
588 }
589
590 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
591 {
592   Handle(AIS_InteractiveContext) aContext = AISContext();
593   if (aContext.IsNull())
594     return NoMode;
595
596   AISObjectPtr aAISObj = getAISObject(theObject);
597   if (!aAISObj)
598     return NoMode;
599
600   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
601   return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
602 }
603
604 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
605 {
606   Handle(AIS_InteractiveContext) aContext = AISContext();
607   if (aContext.IsNull())
608     return;
609   const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
610   SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
611   for (; aIt.More(); aIt.Next()) {
612     if (theFilter.Access() == aIt.Value().Access())
613       return;
614   }
615   GetFilter()->Add(theFilter);
616 }
617
618 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
619 {
620   Handle(AIS_InteractiveContext) aContext = AISContext();
621   if (aContext.IsNull())
622     return;
623   GetFilter()->Remove(theFilter);
624 }
625
626 void XGUI_Displayer::removeFilters()
627 {
628   Handle(AIS_InteractiveContext) aContext = AISContext();
629   if (aContext.IsNull())
630     return;
631   GetFilter()->Clear();
632 }
633
634 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
635 {
636   QObjectPtrList aDispList = myResult2AISObjectMap.keys();
637   foreach(ObjectPtr aObj, aDispList) {
638     if (!theList.contains(aObj))
639       erase(aObj, false);
640   }
641   foreach(ObjectPtr aObj, theList) {
642     if (!isVisible(aObj))
643       display(aObj, false);
644   }
645   updateViewer();
646 }