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