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 activate(anAISIO, 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 // this check is not necessary anymore because the selection store/restore is realized
227 // before and after the values modification.
228 // Moreother, this check avoids customize and redisplay presentation if the presentable
229 // parameter is changed.
230 /*ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
231 if (aResult.get() != NULL) {
232 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
233 if (!aShapePrs.IsNull()) {
234 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
235 if (aShapePtr.get()) {
236 const TopoDS_Shape& aShape = aShapePrs->Shape();
237 std::shared_ptr<GeomAPI_Shape> anAISShapePtr(new GeomAPI_Shape());
238 anAISShapePtr->setImpl(new TopoDS_Shape(aShape));
240 if (aShapePtr->isEqual(anAISShapePtr))
245 // Customization of presentation
246 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
247 if (aFeature.get() != NULL) {
248 GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
249 if (aCustPrs.get() != NULL)
250 aCustPrs->customisePresentation(aAISObj);
253 aContext->Redisplay(aAISIO, false);
259 void XGUI_Displayer::deactivate(ObjectPtr theObject)
261 if (isVisible(theObject)) {
262 Handle(AIS_InteractiveContext) aContext = AISContext();
263 if (aContext.IsNull())
266 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
267 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
268 aContext->Deactivate(anAIS);
272 /*void XGUI_Displayer::activate(ObjectPtr theFeature)
274 activate(theFeature, myActiveSelectionModes);
277 void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
279 #ifdef DEBUG_ACTIVATE
280 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
282 if (aFeature.get() != NULL) {
284 getModesOfActivation(theObject, aModes);
287 qDebug(QString("activate feature: %1, theModes: %2, myActiveSelectionModes: %3, getModesOf: %4").
288 arg(aFeature->data()->name().c_str()).
289 arg(theModes.size()).
290 arg(myActiveSelectionModes.size()).
291 arg(aModes.size()).toStdString().c_str());
295 if (isVisible(theObject)) {
296 Handle(AIS_InteractiveContext) aContext = AISContext();
297 if (aContext.IsNull())
300 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
301 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
303 activate(anAIS, theModes);
307 void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
309 if (!isVisible(theObject))
312 Handle(AIS_InteractiveContext) aContext = AISContext();
313 if (aContext.IsNull())
316 AISObjectPtr aAISObj = getAISObject(theObject);
318 if (aAISObj.get() != NULL) {
319 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
320 TColStd_ListOfInteger aTColModes;
321 aContext->ActivatedModes(anAISIO, aTColModes);
322 TColStd_ListIteratorOfListOfInteger itr( aTColModes );
323 for (; itr.More(); itr.Next() ) {
324 theModes.append(itr.Value());
329 void XGUI_Displayer::activateObjects(const QIntList& theModes)
331 #ifdef DEBUG_ACTIVATE
332 qDebug(QString("activate all features: theModes: %2, myActiveSelectionModes: %3").
333 arg(theModes.size()).
334 arg(myActiveSelectionModes.size()).
335 toStdString().c_str());
337 // In order to avoid doblications of selection modes
339 foreach (int aMode, theModes) {
340 if (!aNewModes.contains(aMode))
341 aNewModes.append(aMode);
343 myActiveSelectionModes = aNewModes;
344 Handle(AIS_InteractiveContext) aContext = AISContext();
345 if (aContext.IsNull())
347 // Open local context if there is no one
348 if (!aContext->HasOpenedContext())
351 //aContext->UseDisplayedObjects();
352 //myUseExternalObjects = true;
354 AIS_ListOfInteractive aPrsList;
355 ::displayedObjects(aContext, aPrsList);
357 Handle(AIS_Trihedron) aTrihedron;
358 AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
359 Handle(AIS_InteractiveObject) anAISIO;
360 for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
361 anAISIO = aLIt.Value();
362 activate(anAISIO, myActiveSelectionModes);
367 void XGUI_Displayer::deactivateObjects()
369 myActiveSelectionModes.clear();
370 Handle(AIS_InteractiveContext) aContext = AISContext();
371 // Open local context if there is no one
372 if (!aContext->HasOpenedContext())
375 //aContext->NotUseDisplayedObjects();
376 AIS_ListOfInteractive aPrsList;
377 ::displayedObjects(aContext, aPrsList);
379 AIS_ListIteratorOfListOfInteractive aLIt;
380 //Handle(AIS_Trihedron) aTrihedron;
381 Handle(AIS_InteractiveObject) anAISIO;
382 for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
383 anAISIO = aLIt.Value();
384 aContext->Deactivate(anAISIO);
388 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
390 Handle(AIS_InteractiveContext) aContext = AISContext();
391 if (aContext.IsNull())
393 if (!isVisible(theObject))
396 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
397 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
399 TColStd_ListOfInteger aModes;
400 aContext->ActivatedModes(anAIS, aModes);
401 return aModes.Extent() > 0;
404 void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer)
406 Handle(AIS_InteractiveContext) aContext = AISContext();
407 if (aContext.IsNull())
409 if (aContext->HasOpenedContext()) {
410 aContext->UnhilightSelected();
411 aContext->ClearSelected();
412 foreach(ObjectPtr aResult, theResults) {
413 if (isVisible(aResult)) {
414 AISObjectPtr anObj = myResult2AISObjectMap[aResult];
415 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
417 aContext->SetSelected(anAIS, false);
421 aContext->UnhilightCurrents();
422 aContext->ClearCurrents();
423 foreach(ObjectPtr aResult, theResults) {
424 if (isVisible(aResult)) {
425 AISObjectPtr anObj = myResult2AISObjectMap[aResult];
426 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
428 aContext->SetCurrentObject(anAIS, false);
437 void XGUI_Displayer::clearSelected()
439 Handle(AIS_InteractiveContext) aContext = AISContext();
441 aContext->UnhilightCurrents(false);
442 aContext->ClearSelected();
446 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
448 Handle(AIS_InteractiveContext) aContext = AISContext();
449 if (!aContext.IsNull()) {
450 foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
452 Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
454 aContext->Remove(anIO, false);
459 myResult2AISObjectMap.clear();
462 void XGUI_Displayer::openLocalContext()
464 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
465 if (aContext.IsNull())
467 // Open local context if there is no one
468 if (!aContext->HasOpenedContext()) {
469 // Preserve selected objects
470 //AIS_ListOfInteractive aAisList;
471 //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
472 // aAisList.Append(aContext->Current());
474 // get the filters from the global context and append them to the local context
475 // a list of filters in the global context is not cleared and should be cleared here
476 SelectMgr_ListOfFilter aFilters;
477 aFilters.Assign(aContext->Filters());
478 // it is important to remove the filters in the global context, because there is a code
479 // in the closeLocalContex, which restore the global context filters
480 aContext->RemoveFilters();
482 //aContext->ClearCurrents();
483 aContext->OpenLocalContext();
484 //aContext->NotUseDisplayedObjects();
486 //myUseExternalObjects = false;
488 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
489 for (;aIt.More(); aIt.Next()) {
490 aContext->AddFilter(aIt.Value());
493 //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
494 //for(; aIt2.More(); aIt2.Next()) {
495 // aContext->SetSelected(aIt2.Value(), false);
500 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
502 Handle(AIS_InteractiveContext) aContext = AISContext();
503 if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
504 // Preserve selected objects
505 //AIS_ListOfInteractive aAisList;
506 //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
507 // aAisList.Append(aContext->SelectedInteractive());
509 // get the filters from the local context and append them to the global context
510 // a list of filters in the local context is cleared
511 SelectMgr_ListOfFilter aFilters;
512 aFilters.Assign(aContext->Filters());
514 //aContext->ClearSelected();
515 aContext->CloseAllContexts(false);
517 // Redisplay all object if they were displayed in localContext
518 Handle(AIS_InteractiveObject) aAISIO;
519 foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
520 aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
521 if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
522 aContext->Display(aAISIO, false);
523 aContext->SetDisplayMode(aAISIO, Shading, false);
527 // Append the filters from the local selection in the global selection context
528 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
529 for (;aIt.More(); aIt.Next()) {
530 Handle(SelectMgr_Filter) aFilter = aIt.Value();
531 aContext->AddFilter(aFilter);
536 //myUseExternalObjects = false;
539 //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
540 //for(; aIt2.More(); aIt2.Next()) {
541 // if (aContext->IsDisplayed(aIt2.Value()))
542 // aContext->SetCurrentObject(aIt2.Value(), false);
547 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
550 if (myResult2AISObjectMap.contains(theObject))
551 anIO = myResult2AISObjectMap[theObject];
555 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
557 Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
558 return getObject(aRefAIS);
561 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
564 foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
565 AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
566 Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
573 bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
575 bool aWasEnabled = myEnableUpdateViewer;
577 myEnableUpdateViewer = isEnabled;
582 void XGUI_Displayer::updateViewer()
584 Handle(AIS_InteractiveContext) aContext = AISContext();
585 if (!aContext.IsNull() && myEnableUpdateViewer)
586 aContext->UpdateCurrentViewer();
589 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
591 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
592 if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
593 aContext->OpenLocalContext();
598 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
600 Handle(AIS_InteractiveContext) aContext = AISContext();
601 if (myAndFilter.IsNull() && !aContext.IsNull()) {
602 myAndFilter = new SelectMgr_AndFilter();
603 aContext->AddFilter(myAndFilter);
608 void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
610 Handle(AIS_InteractiveContext) aContext = AISContext();
611 if (aContext.IsNull())
613 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
614 if (!anAISIO.IsNull()) {
615 aContext->Display(anAISIO, isUpdate);
616 if (aContext->HasOpenedContext()) {
617 //if (myUseExternalObjects) {
618 if (myActiveSelectionModes.size() == 0)
619 aContext->Activate(anAISIO);
621 foreach(int aMode, myActiveSelectionModes) {
622 aContext->Activate(anAISIO, aMode);
630 void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
632 Handle(AIS_InteractiveContext) aContext = AISContext();
633 if (aContext.IsNull())
635 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
636 if (!anAISIO.IsNull()) {
637 aContext->Remove(anAISIO, isUpdate);
642 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate)
644 if (theMode == NoMode)
647 Handle(AIS_InteractiveContext) aContext = AISContext();
648 if (aContext.IsNull())
651 AISObjectPtr aAISObj = getAISObject(theObject);
655 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
656 bool aCanBeShaded = ::canBeShaded(aAISIO);
657 // In order to avoid extra closing/opening context
658 SelectMgr_IndexedMapOfOwner aSelectedOwners;
660 myWorkshop->selector()->selection()->selectedOwners(aSelectedOwners);
661 closeLocalContexts(false);
663 aContext->SetDisplayMode(aAISIO, theMode, false);
666 activateObjects(myActiveSelectionModes);
667 myWorkshop->selector()->setSelectedOwners(aSelectedOwners, false);
673 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
675 Handle(AIS_InteractiveContext) aContext = AISContext();
676 if (aContext.IsNull())
679 AISObjectPtr aAISObj = getAISObject(theObject);
683 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
684 return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
687 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
689 Handle(AIS_InteractiveContext) aContext = AISContext();
690 if (aContext.IsNull())
692 const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
693 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
694 for (; aIt.More(); aIt.Next()) {
695 if (theFilter.Access() == aIt.Value().Access())
698 GetFilter()->Add(theFilter);
701 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
703 Handle(AIS_InteractiveContext) aContext = AISContext();
704 if (aContext.IsNull())
706 GetFilter()->Remove(theFilter);
709 void XGUI_Displayer::removeFilters()
711 Handle(AIS_InteractiveContext) aContext = AISContext();
712 if (aContext.IsNull())
714 GetFilter()->Clear();
717 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
719 QObjectPtrList aDispList = myResult2AISObjectMap.keys();
720 foreach(ObjectPtr aObj, aDispList) {
721 if (!theList.contains(aObj))
724 foreach(ObjectPtr aObj, theList) {
725 if (!isVisible(aObj))
726 display(aObj, false);
731 bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
733 if (!isVisible(theObject))
736 AISObjectPtr aAISObj = getAISObject(theObject);
737 if (aAISObj.get() == NULL)
740 Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
741 return ::canBeShaded(anAIS);
744 void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
745 const QIntList& theModes) const
747 Handle(AIS_InteractiveContext) aContext = AISContext();
748 if (aContext.IsNull() || theIO.IsNull())
751 aContext->Load(theIO, -1, true);
752 aContext->Deactivate(theIO);
753 Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
754 //Deactivate trihedron which can be activated in local selector
755 if (aTrihedron.IsNull()) {
756 //aContext->Load(anAISIO, -1, true);
757 // In order to clear active modes list
758 if (theModes.size() == 0) {
759 //aContext->Load(anAISIO, 0, true);
760 aContext->Activate(theIO);
762 foreach(int aMode, theModes) {
763 //aContext->Load(anAISIO, aMode, true);
764 aContext->Activate(theIO, aMode);