]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Displayer.cpp
Salome HOME
09bc3494f32fff71799e3cb536fcdd108b87348a
[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     aContext->Redisplay(aAISIO, isUpdateViewer);
200   }
201 }
202
203 void XGUI_Displayer::deactivate(ObjectPtr theObject)
204 {
205   if (isVisible(theObject)) {
206     Handle(AIS_InteractiveContext) aContext = AISContext();
207     if (aContext.IsNull())
208       return;
209
210     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
211     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
212     aContext->Deactivate(anAIS);
213     qDebug("### Deactivate obj %i", (long)anAIS.Access());
214   }
215 }
216
217 void XGUI_Displayer::activate(ObjectPtr theFeature)
218 {
219   activate(theFeature, myActiveSelectionModes);
220 }
221
222 void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
223 {
224   if (isVisible(theObject)) {
225     Handle(AIS_InteractiveContext) aContext = AISContext();
226     if (aContext.IsNull())
227       return;
228
229     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
230     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
231     aContext->Deactivate(anAIS);
232     aContext->Load(anAIS, -1, true);
233     // In order to clear active modes list
234     if (theModes.size() > 0) {
235       foreach(int aMode, theModes) {
236         //aContext->Load(anAIS, aMode, true);
237         aContext->Activate(anAIS, aMode);
238         qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode);
239       }
240     } else {
241       //aContext->Load(anAIS, 0, true);
242       aContext->Activate(anAIS);
243       qDebug("### 2. Activate obj %i", (long)anAIS.Access());
244     }
245   }
246 }
247
248 void XGUI_Displayer::activateObjects(const QIntList& theModes)
249 {
250   // In order to avoid doblications of selection modes
251   QIntList aNewModes;
252   foreach (int aMode, theModes) {
253     if (!aNewModes.contains(aMode))
254       aNewModes.append(aMode);
255   }
256   myActiveSelectionModes = aNewModes;
257   Handle(AIS_InteractiveContext) aContext = AISContext();
258   // Open local context if there is no one
259   if (!aContext->HasOpenedContext()) 
260     return;
261
262   //aContext->UseDisplayedObjects();
263   //myUseExternalObjects = true;
264
265   AIS_ListOfInteractive aPrsList;
266   displayedObjects(aContext, aPrsList);
267
268   Handle(AIS_Trihedron) aTrihedron;
269   AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
270   Handle(AIS_InteractiveObject) anAISIO;
271   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
272     anAISIO = aLIt.Value();
273     aContext->Load(anAISIO, -1, true);
274     aContext->Deactivate(anAISIO);
275     aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
276     //Deactivate trihedron which can be activated in local selector
277     if (aTrihedron.IsNull()) {
278       //aContext->Load(anAISIO, -1, true);
279       // In order to clear active modes list
280       if (myActiveSelectionModes.size() == 0) {
281         //aContext->Load(anAISIO, 0, true);
282         aContext->Activate(anAISIO);
283         qDebug("### 2. Activate all %i", (long)anAISIO.Access());
284       } else {
285         foreach(int aMode, myActiveSelectionModes) {
286           //aContext->Load(anAISIO, aMode, true);
287           aContext->Activate(anAISIO, aMode);
288           qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode);
289         }
290       }
291     }
292   }
293 }
294
295
296 void XGUI_Displayer::deactivateObjects()
297 {
298   myActiveSelectionModes.clear();
299   Handle(AIS_InteractiveContext) aContext = AISContext();
300   // Open local context if there is no one
301   if (!aContext->HasOpenedContext()) 
302     return;
303
304   //aContext->NotUseDisplayedObjects();
305   AIS_ListOfInteractive aPrsList;
306   displayedObjects(aContext, aPrsList);
307
308   AIS_ListIteratorOfListOfInteractive aLIt;
309   //Handle(AIS_Trihedron) aTrihedron;
310   Handle(AIS_InteractiveObject) anAISIO;
311   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
312     anAISIO = aLIt.Value();
313     aContext->Deactivate(anAISIO);
314     //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
315     //if (aTrihedron.IsNull()) {
316     //  qDebug("### Deactivate all %i", (long)anAISIO.Access());
317     //  //aContext->Activate(anAISIO);
318     //}
319   }
320 }
321
322 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
323 {
324   Handle(AIS_InteractiveContext) aContext = AISContext();
325   if (aContext.IsNull())
326     return false;
327   if (!isVisible(theObject))
328     return false;
329     
330   AISObjectPtr anObj = myResult2AISObjectMap[theObject];
331   Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
332
333   TColStd_ListOfInteger aModes;
334   aContext->ActivatedModes(anAIS, aModes);
335   return aModes.Extent() > 0;
336 }
337
338 void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer)
339 {
340   Handle(AIS_InteractiveContext) aContext = AISContext();
341   if (aContext.IsNull())
342     return;
343   if (aContext->HasOpenedContext()) {
344     aContext->UnhilightSelected();
345     aContext->ClearSelected();
346     foreach(ObjectPtr aResult, theResults) {
347       if (isVisible(aResult)) {
348         AISObjectPtr anObj = myResult2AISObjectMap[aResult];
349         Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
350         if (!anAIS.IsNull())
351           aContext->SetSelected(anAIS, false);
352       }
353     }
354   } else {
355     aContext->UnhilightCurrents();
356     aContext->ClearCurrents();
357     foreach(ObjectPtr aResult, theResults) {
358       if (isVisible(aResult)) {
359         AISObjectPtr anObj = myResult2AISObjectMap[aResult];
360         Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
361         if (!anAIS.IsNull())
362           aContext->SetCurrentObject(anAIS, false);
363       }
364     }
365   }
366   if (isUpdateViewer)
367     updateViewer();
368 }
369
370
371 void XGUI_Displayer::clearSelected()
372 {
373   Handle(AIS_InteractiveContext) aContext = AISContext();
374   if (aContext) {
375     aContext->UnhilightCurrents(false);
376     aContext->ClearSelected();
377   }
378 }
379
380 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
381 {
382   Handle(AIS_InteractiveContext) aContext = AISContext();
383   if (aContext.IsNull())
384     return;
385
386    foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
387      // erase an object
388      Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
389      if (!anIO.IsNull())
390        aContext->Remove(anIO, false);
391    }
392    myResult2AISObjectMap.clear();
393    if (isUpdateViewer)
394      updateViewer();
395  }
396
397 void XGUI_Displayer::openLocalContext()
398 {
399   Handle(AIS_InteractiveContext) aContext = AISContext();
400   if (aContext.IsNull())
401     return;
402   // Open local context if there is no one
403   if (!aContext->HasOpenedContext()) {
404     // Preserve selected objects
405     //AIS_ListOfInteractive aAisList;
406     //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
407     //  aAisList.Append(aContext->Current());
408
409     // get the filters from the global context and append them to the local context
410     // a list of filters in the global context is not cleared and should be cleared here
411     SelectMgr_ListOfFilter aFilters;
412     aFilters.Assign(aContext->Filters());
413     // it is important to remove the filters in the global context, because there is a code
414     // in the closeLocalContex, which restore the global context filters
415     aContext->RemoveFilters();
416
417     //aContext->ClearCurrents();
418     aContext->OpenLocalContext();
419     qDebug("### Open context");
420     //aContext->NotUseDisplayedObjects();
421
422     //myUseExternalObjects = false;
423
424     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
425     for (;aIt.More(); aIt.Next()) {
426       aContext->AddFilter(aIt.Value());
427     }
428     // Restore selection
429     //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
430     //for(; aIt2.More(); aIt2.Next()) {
431     //  aContext->SetSelected(aIt2.Value(), false);
432     //}
433   }
434 }
435
436 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
437 {
438   Handle(AIS_InteractiveContext) aContext = AISContext();
439   if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
440     // Preserve selected objects
441     //AIS_ListOfInteractive aAisList;
442     //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
443     //  aAisList.Append(aContext->SelectedInteractive());
444
445     // get the filters from the local context and append them to the global context
446     // a list of filters in the local context is cleared
447     SelectMgr_ListOfFilter aFilters;
448     aFilters.Assign(aContext->Filters());
449
450     //aContext->ClearSelected();
451     aContext->CloseAllContexts(false);
452     qDebug("### Close context");
453
454     // Redisplay all object if they were displayed in localContext
455     Handle(AIS_InteractiveObject) aAISIO;
456     foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
457       aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
458       if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
459         aContext->Display(aAISIO, false);
460         aContext->SetDisplayMode(aAISIO, Shading, false);
461       }
462     }
463
464     // Append the filters from the local selection in the global selection context
465     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
466     for (;aIt.More(); aIt.Next()) {
467       Handle(SelectMgr_Filter) aFilter = aIt.Value();
468       aContext->AddFilter(aFilter);
469     }
470
471     if (isUpdateViewer)
472       updateViewer();
473     //myUseExternalObjects = false;
474
475     // Restore selection
476     //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
477     //for(; aIt2.More(); aIt2.Next()) {
478     //  if (aContext->IsDisplayed(aIt2.Value()))
479     //    aContext->SetCurrentObject(aIt2.Value(), false);
480     //}
481   }
482 }
483
484 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
485 {
486   AISObjectPtr anIO;
487   if (myResult2AISObjectMap.contains(theObject))
488     anIO = myResult2AISObjectMap[theObject];
489   return anIO;
490 }
491
492 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
493 {
494   Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
495   return getObject(aRefAIS);
496 }
497
498 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
499 {
500   ObjectPtr aFeature;
501   foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
502     AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
503     Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
504     if (anAIS == theIO)
505       return anObj;
506   }
507   return aFeature;
508 }
509
510 void XGUI_Displayer::updateViewer()
511 {
512   Handle(AIS_InteractiveContext) aContext = AISContext();
513   if (!aContext.IsNull())
514     aContext->UpdateCurrentViewer();
515 }
516
517 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
518 {
519   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
520   if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
521     aContext->OpenLocalContext();
522     qDebug("### Open context");
523   }
524   return aContext;
525 }
526
527 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
528 {
529   Handle(AIS_InteractiveContext) aContext = AISContext();
530   if (myAndFilter.IsNull() && !aContext.IsNull()) {
531     myAndFilter = new SelectMgr_AndFilter();
532     aContext->AddFilter(myAndFilter);
533   }
534   return myAndFilter;
535 }
536
537 void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
538 {
539   Handle(AIS_InteractiveContext) aContext = AISContext();
540   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
541   if (!anAISIO.IsNull()) {
542     aContext->Display(anAISIO, isUpdate);
543     if (aContext->HasOpenedContext()) {
544       //if (myUseExternalObjects) {
545         if (myActiveSelectionModes.size() == 0)
546           aContext->Activate(anAISIO);
547         else {
548           foreach(int aMode, myActiveSelectionModes) {
549             aContext->Activate(anAISIO, aMode);
550           }
551         }
552       //}
553     }
554   }
555 }
556
557 void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
558 {
559   Handle(AIS_InteractiveContext) aContext = AISContext();
560   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
561   if (!anAISIO.IsNull()) {
562     aContext->Remove(anAISIO, isUpdate);
563   }
564 }
565
566
567 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate)
568 {
569   if (theMode == NoMode)
570     return;
571
572   Handle(AIS_InteractiveContext) aContext = AISContext();
573   if (aContext.IsNull())
574     return;
575
576   AISObjectPtr aAISObj = getAISObject(theObject);
577   if (!aAISObj)
578     return;
579
580   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
581   aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
582 }
583
584 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
585 {
586   Handle(AIS_InteractiveContext) aContext = AISContext();
587   if (aContext.IsNull())
588     return NoMode;
589
590   AISObjectPtr aAISObj = getAISObject(theObject);
591   if (!aAISObj)
592     return NoMode;
593
594   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
595   return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
596 }
597
598 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
599 {
600   Handle(AIS_InteractiveContext) aContext = AISContext();
601   if (aContext.IsNull())
602     return;
603   const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
604   SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
605   for (; aIt.More(); aIt.Next()) {
606     if (theFilter.Access() == aIt.Value().Access())
607       return;
608   }
609   GetFilter()->Add(theFilter);
610 }
611
612 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
613 {
614   Handle(AIS_InteractiveContext) aContext = AISContext();
615   if (aContext.IsNull())
616     return;
617   GetFilter()->Remove(theFilter);
618 }
619
620 void XGUI_Displayer::removeFilters()
621 {
622   Handle(AIS_InteractiveContext) aContext = AISContext();
623   if (aContext.IsNull())
624     return;
625   GetFilter()->Clear();
626 }
627
628 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
629 {
630   QObjectPtrList aDispList = myResult2AISObjectMap.keys();
631   foreach(ObjectPtr aObj, aDispList) {
632     if (!theList.contains(aObj))
633       erase(aObj, false);
634   }
635   foreach(ObjectPtr aObj, theList) {
636     if (!isVisible(aObj))
637       display(aObj, false);
638   }
639   updateViewer();
640 }