1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: XGUI_Displayer.cpp
4 // Created: 20 Apr 2014
5 // Author: Natalia ERMOLAEVA
7 #include "XGUI_Displayer.h"
8 #include "XGUI_Workshop.h"
9 #include "XGUI_ViewerProxy.h"
10 #include "XGUI_SelectionMgr.h"
11 #include "XGUI_Selection.h"
13 #include <AppElements_Viewer.h>
15 #include <ModelAPI_Document.h>
16 #include <ModelAPI_Data.h>
17 #include <ModelAPI_Object.h>
18 #include <ModelAPI_Tools.h>
20 #include <ModuleBase_ResultPrs.h>
22 #include <GeomAPI_Shape.h>
23 #include <GeomAPI_IPresentable.h>
24 #include <GeomAPI_ICustomPrs.h>
26 #include <AIS_InteractiveContext.hxx>
27 #include <AIS_LocalContext.hxx>
28 #include <AIS_ListOfInteractive.hxx>
29 #include <AIS_ListIteratorOfListOfInteractive.hxx>
30 #include <AIS_DimensionSelectionMode.hxx>
31 #include <AIS_Shape.hxx>
32 #include <AIS_Dimension.hxx>
33 #include <TColStd_ListIteratorOfListOfInteger.hxx>
34 #include <SelectMgr_ListOfFilter.hxx>
35 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
37 #include <TColStd_MapOfTransient.hxx>
38 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
42 const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity
44 //#define DEBUG_DISPLAY
45 //#define DEBUG_ACTIVATE
47 // Workaround for bug #25637
48 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
50 // Get from null point
51 theAIS->DisplayedObjects(theList, true);
52 if (theAIS->HasOpenedContext()) {
53 // get from local context
54 const Handle(AIS_LocalContext)& aLC = theAIS->LocalContext();
55 TColStd_MapOfTransient aMap;
56 int NbDisp = aLC->DisplayedObjects(aMap);
57 TColStd_MapIteratorOfMapOfTransient aIt(aMap);
59 Handle(AIS_InteractiveObject) curIO;
60 Handle(Standard_Transient) Tr;
61 for(; aIt.More(); aIt.Next()){
63 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
64 theList.Append(curIO);
70 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
71 : myWorkshop(theWorkshop)
73 enableUpdateViewer(true);
76 XGUI_Displayer::~XGUI_Displayer()
80 bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
82 return myResult2AISObjectMap.contains(theObject);
85 void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
87 if (isVisible(theObject)) {
88 redisplay(theObject, isUpdateViewer);
91 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
92 if (aFeature.get() != NULL) {
93 qDebug(QString("display feature: %1, displayed: %2").
94 arg(aFeature->data()->name().c_str()).
95 arg(displayedObjects().size()).toStdString().c_str());
100 GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
101 bool isShading = false;
102 if (aPrs.get() != NULL) {
103 anAIS = aPrs->getAISObject(AISObjectPtr());
105 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
106 if (aResult.get() != NULL) {
107 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
108 if (aShapePtr.get() != NULL) {
109 anAIS = AISObjectPtr(new GeomAPI_AISObject());
110 anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
111 //anAIS->createShape(aShapePtr);
117 display(theObject, anAIS, isShading, isUpdateViewer);
121 bool canBeShaded(Handle(AIS_InteractiveObject) theAIS)
123 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS);
124 if (!aShapePrs.IsNull()) {
125 TopoDS_Shape aShape = aShapePrs->Shape();
126 TopAbs_ShapeEnum aType = aShape.ShapeType();
127 if ((aType == TopAbs_VERTEX) || (aType == TopAbs_EDGE) || (aType == TopAbs_WIRE))
130 // Check that the presentation is not a sketch
131 Handle(ModuleBase_ResultPrs) aPrs = Handle(ModuleBase_ResultPrs)::DownCast(theAIS);
133 return !aPrs->isSketchMode();
140 void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
141 bool isShading, bool isUpdateViewer)
143 Handle(AIS_InteractiveContext) aContext = AISContext();
144 if (aContext.IsNull())
147 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
148 if (!anAISIO.IsNull()) {
149 myResult2AISObjectMap[theObject] = theAIS;
150 bool aCanBeShaded = ::canBeShaded(anAISIO);
151 // In order to avoid extra closing/opening context
152 SelectMgr_IndexedMapOfOwner aSelectedOwners;
154 myWorkshop->selector()->selection()->selectedOwners(aSelectedOwners);
155 closeLocalContexts(false);
157 aContext->Display(anAISIO, false);
159 aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
160 // Customization of presentation
161 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
162 if (aFeature.get() != NULL) {
163 GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
164 if (aCustPrs.get() != NULL)
165 aCustPrs->customisePresentation(theAIS);
169 activateObjects(myActiveSelectionModes);
170 myWorkshop->selector()->setSelectedOwners(aSelectedOwners, false);
173 activateObjects(myActiveSelectionModes);
179 void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
181 if (!isVisible(theObject))
184 Handle(AIS_InteractiveContext) aContext = AISContext();
185 if (aContext.IsNull())
187 AISObjectPtr anObject = myResult2AISObjectMap[theObject];
189 Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
190 if (!anAIS.IsNull()) {
191 aContext->Remove(anAIS, isUpdateViewer);
194 myResult2AISObjectMap.remove(theObject);
197 void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
199 if (!isVisible(theObject))
202 AISObjectPtr aAISObj = getAISObject(theObject);
203 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
205 GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
207 AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
209 erase(theObject, isUpdateViewer);
212 if (aAIS_Obj != aAISObj) {
213 myResult2AISObjectMap[theObject] = aAIS_Obj;
215 aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
218 if (!aAISIO.IsNull()) {
219 Handle(AIS_InteractiveContext) aContext = AISContext();
220 if (aContext.IsNull())
222 // Check that the visualized shape is the same and the redisplay is not necessary
223 // Redisplay of AIS object leads to this object selection compute and the selection
224 // in the browser is lost
226 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
227 if (aResult.get() != NULL) {
228 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
229 if (!aShapePrs.IsNull()) {
230 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
231 if (aShapePtr.get()) {
232 const TopoDS_Shape& aShape = aShapePrs->Shape();
233 std::shared_ptr<GeomAPI_Shape> anAISShapePtr(new GeomAPI_Shape());
234 anAISShapePtr->setImpl(new TopoDS_Shape(aShape));
236 if (aShapePtr->isEqual(anAISShapePtr))
241 aContext->Redisplay(aAISIO, false);
247 void XGUI_Displayer::deactivate(ObjectPtr theObject)
249 if (isVisible(theObject)) {
250 Handle(AIS_InteractiveContext) aContext = AISContext();
251 if (aContext.IsNull())
254 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
255 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
256 aContext->Deactivate(anAIS);
260 /*void XGUI_Displayer::activate(ObjectPtr theFeature)
262 activate(theFeature, myActiveSelectionModes);
265 void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
267 #ifdef DEBUG_ACTIVATE
268 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
270 if (aFeature.get() != NULL) {
272 getModesOfActivation(theObject, aModes);
275 qDebug(QString("activate feature: %1, theModes: %2, myActiveSelectionModes: %3, getModesOf: %4").
276 arg(aFeature->data()->name().c_str()).
277 arg(theModes.size()).
278 arg(myActiveSelectionModes.size()).
279 arg(aModes.size()).toStdString().c_str());
284 if (isVisible(theObject)) {
285 Handle(AIS_InteractiveContext) aContext = AISContext();
286 if (aContext.IsNull())
289 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
290 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
291 aContext->Deactivate(anAIS);
292 aContext->Load(anAIS, -1, true);
293 // In order to clear active modes list
294 if (theModes.size() > 0) {
295 foreach(int aMode, theModes) {
296 //aContext->Load(anAIS, aMode, true);
297 aContext->Activate(anAIS, aMode);
300 //aContext->Load(anAIS, 0, true);
301 aContext->Activate(anAIS);
306 void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
308 if (!isVisible(theObject))
311 Handle(AIS_InteractiveContext) aContext = AISContext();
312 if (aContext.IsNull())
315 AISObjectPtr aAISObj = getAISObject(theObject);
317 if (aAISObj.get() != NULL) {
318 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
319 TColStd_ListOfInteger aTColModes;
320 aContext->ActivatedModes(anAISIO, aTColModes);
321 TColStd_ListIteratorOfListOfInteger itr( aTColModes );
322 for (; itr.More(); itr.Next() ) {
323 theModes.append(itr.Value());
328 void XGUI_Displayer::activateObjects(const QIntList& theModes)
330 #ifdef DEBUG_ACTIVATE
331 qDebug(QString("activate all features: theModes: %2, myActiveSelectionModes: %3").
332 arg(theModes.size()).
333 arg(myActiveSelectionModes.size()).
334 toStdString().c_str());
336 // In order to avoid doblications of selection modes
338 foreach (int aMode, theModes) {
339 if (!aNewModes.contains(aMode))
340 aNewModes.append(aMode);
342 myActiveSelectionModes = aNewModes;
343 Handle(AIS_InteractiveContext) aContext = AISContext();
344 if (aContext.IsNull())
346 // Open local context if there is no one
347 if (!aContext->HasOpenedContext())
350 //aContext->UseDisplayedObjects();
351 //myUseExternalObjects = true;
353 AIS_ListOfInteractive aPrsList;
354 ::displayedObjects(aContext, aPrsList);
356 Handle(AIS_Trihedron) aTrihedron;
357 AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
358 Handle(AIS_InteractiveObject) anAISIO;
359 for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
360 anAISIO = aLIt.Value();
361 aContext->Load(anAISIO, -1, true);
362 aContext->Deactivate(anAISIO);
363 aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
364 //Deactivate trihedron which can be activated in local selector
365 if (aTrihedron.IsNull()) {
366 //aContext->Load(anAISIO, -1, true);
367 // In order to clear active modes list
368 if (myActiveSelectionModes.size() == 0) {
369 //aContext->Load(anAISIO, 0, true);
370 aContext->Activate(anAISIO);
372 foreach(int aMode, myActiveSelectionModes) {
373 //aContext->Load(anAISIO, aMode, true);
374 aContext->Activate(anAISIO, aMode);
382 void XGUI_Displayer::deactivateObjects()
384 myActiveSelectionModes.clear();
385 Handle(AIS_InteractiveContext) aContext = AISContext();
386 // Open local context if there is no one
387 if (!aContext->HasOpenedContext())
390 //aContext->NotUseDisplayedObjects();
391 AIS_ListOfInteractive aPrsList;
392 ::displayedObjects(aContext, aPrsList);
394 AIS_ListIteratorOfListOfInteractive aLIt;
395 //Handle(AIS_Trihedron) aTrihedron;
396 Handle(AIS_InteractiveObject) anAISIO;
397 for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
398 anAISIO = aLIt.Value();
399 aContext->Deactivate(anAISIO);
403 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
405 Handle(AIS_InteractiveContext) aContext = AISContext();
406 if (aContext.IsNull())
408 if (!isVisible(theObject))
411 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
412 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
414 TColStd_ListOfInteger aModes;
415 aContext->ActivatedModes(anAIS, aModes);
416 return aModes.Extent() > 0;
419 void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer)
421 Handle(AIS_InteractiveContext) aContext = AISContext();
422 if (aContext.IsNull())
424 if (aContext->HasOpenedContext()) {
425 aContext->UnhilightSelected();
426 aContext->ClearSelected();
427 foreach(ObjectPtr aResult, theResults) {
428 if (isVisible(aResult)) {
429 AISObjectPtr anObj = myResult2AISObjectMap[aResult];
430 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
432 aContext->SetSelected(anAIS, false);
436 aContext->UnhilightCurrents();
437 aContext->ClearCurrents();
438 foreach(ObjectPtr aResult, theResults) {
439 if (isVisible(aResult)) {
440 AISObjectPtr anObj = myResult2AISObjectMap[aResult];
441 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
443 aContext->SetCurrentObject(anAIS, false);
452 void XGUI_Displayer::clearSelected()
454 Handle(AIS_InteractiveContext) aContext = AISContext();
456 aContext->UnhilightCurrents(false);
457 aContext->ClearSelected();
461 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
463 Handle(AIS_InteractiveContext) aContext = AISContext();
464 if (!aContext.IsNull()) {
465 foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
467 Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
469 aContext->Remove(anIO, false);
474 myResult2AISObjectMap.clear();
477 void XGUI_Displayer::openLocalContext()
479 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
480 if (aContext.IsNull())
482 // Open local context if there is no one
483 if (!aContext->HasOpenedContext()) {
484 // Preserve selected objects
485 //AIS_ListOfInteractive aAisList;
486 //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
487 // aAisList.Append(aContext->Current());
489 // get the filters from the global context and append them to the local context
490 // a list of filters in the global context is not cleared and should be cleared here
491 SelectMgr_ListOfFilter aFilters;
492 aFilters.Assign(aContext->Filters());
493 // it is important to remove the filters in the global context, because there is a code
494 // in the closeLocalContex, which restore the global context filters
495 aContext->RemoveFilters();
497 //aContext->ClearCurrents();
498 aContext->OpenLocalContext();
499 //aContext->NotUseDisplayedObjects();
501 //myUseExternalObjects = false;
503 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
504 for (;aIt.More(); aIt.Next()) {
505 aContext->AddFilter(aIt.Value());
508 //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
509 //for(; aIt2.More(); aIt2.Next()) {
510 // aContext->SetSelected(aIt2.Value(), false);
515 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
517 Handle(AIS_InteractiveContext) aContext = AISContext();
518 if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
519 // Preserve selected objects
520 //AIS_ListOfInteractive aAisList;
521 //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
522 // aAisList.Append(aContext->SelectedInteractive());
524 // get the filters from the local context and append them to the global context
525 // a list of filters in the local context is cleared
526 SelectMgr_ListOfFilter aFilters;
527 aFilters.Assign(aContext->Filters());
529 //aContext->ClearSelected();
530 aContext->CloseAllContexts(false);
532 // Redisplay all object if they were displayed in localContext
533 Handle(AIS_InteractiveObject) aAISIO;
534 foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
535 aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
536 if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
537 aContext->Display(aAISIO, false);
538 aContext->SetDisplayMode(aAISIO, Shading, false);
542 // Append the filters from the local selection in the global selection context
543 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
544 for (;aIt.More(); aIt.Next()) {
545 Handle(SelectMgr_Filter) aFilter = aIt.Value();
546 aContext->AddFilter(aFilter);
551 //myUseExternalObjects = false;
554 //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
555 //for(; aIt2.More(); aIt2.Next()) {
556 // if (aContext->IsDisplayed(aIt2.Value()))
557 // aContext->SetCurrentObject(aIt2.Value(), false);
562 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
565 if (myResult2AISObjectMap.contains(theObject))
566 anIO = myResult2AISObjectMap[theObject];
570 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
572 Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
573 return getObject(aRefAIS);
576 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
579 foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
580 AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
581 Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
588 bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
590 bool aWasEnabled = myEnableUpdateViewer;
592 myEnableUpdateViewer = isEnabled;
597 void XGUI_Displayer::updateViewer()
599 Handle(AIS_InteractiveContext) aContext = AISContext();
600 if (!aContext.IsNull() && myEnableUpdateViewer)
601 aContext->UpdateCurrentViewer();
604 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
606 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
607 if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
608 aContext->OpenLocalContext();
613 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
615 Handle(AIS_InteractiveContext) aContext = AISContext();
616 if (myAndFilter.IsNull() && !aContext.IsNull()) {
617 myAndFilter = new SelectMgr_AndFilter();
618 aContext->AddFilter(myAndFilter);
623 void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
625 Handle(AIS_InteractiveContext) aContext = AISContext();
626 if (aContext.IsNull())
628 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
629 if (!anAISIO.IsNull()) {
630 aContext->Display(anAISIO, isUpdate);
631 if (aContext->HasOpenedContext()) {
632 //if (myUseExternalObjects) {
633 if (myActiveSelectionModes.size() == 0)
634 aContext->Activate(anAISIO);
636 foreach(int aMode, myActiveSelectionModes) {
637 aContext->Activate(anAISIO, aMode);
645 void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
647 Handle(AIS_InteractiveContext) aContext = AISContext();
648 if (aContext.IsNull())
650 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
651 if (!anAISIO.IsNull()) {
652 aContext->Remove(anAISIO, isUpdate);
657 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate)
659 if (theMode == NoMode)
662 Handle(AIS_InteractiveContext) aContext = AISContext();
663 if (aContext.IsNull())
666 AISObjectPtr aAISObj = getAISObject(theObject);
670 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
671 bool aCanBeShaded = ::canBeShaded(aAISIO);
672 // In order to avoid extra closing/opening context
673 SelectMgr_IndexedMapOfOwner aSelectedOwners;
675 myWorkshop->selector()->selection()->selectedOwners(aSelectedOwners);
676 closeLocalContexts(false);
678 aContext->SetDisplayMode(aAISIO, theMode, false);
681 activateObjects(myActiveSelectionModes);
682 myWorkshop->selector()->setSelectedOwners(aSelectedOwners, false);
688 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
690 Handle(AIS_InteractiveContext) aContext = AISContext();
691 if (aContext.IsNull())
694 AISObjectPtr aAISObj = getAISObject(theObject);
698 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
699 return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
702 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
704 Handle(AIS_InteractiveContext) aContext = AISContext();
705 if (aContext.IsNull())
707 const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
708 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
709 for (; aIt.More(); aIt.Next()) {
710 if (theFilter.Access() == aIt.Value().Access())
713 GetFilter()->Add(theFilter);
716 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
718 Handle(AIS_InteractiveContext) aContext = AISContext();
719 if (aContext.IsNull())
721 GetFilter()->Remove(theFilter);
724 void XGUI_Displayer::removeFilters()
726 Handle(AIS_InteractiveContext) aContext = AISContext();
727 if (aContext.IsNull())
729 GetFilter()->Clear();
732 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
734 QObjectPtrList aDispList = myResult2AISObjectMap.keys();
735 foreach(ObjectPtr aObj, aDispList) {
736 if (!theList.contains(aObj))
739 foreach(ObjectPtr aObj, theList) {
740 if (!isVisible(aObj))
741 display(aObj, false);
746 bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
748 if (!isVisible(theObject))
751 AISObjectPtr aAISObj = getAISObject(theObject);
752 if (aAISObj.get() == NULL)
755 Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
756 return ::canBeShaded(anAIS);