Salome HOME
Some optimizations for the issue #2569
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include "XGUI_Displayer.h"
22
23 #include "XGUI_CustomPrs.h"
24 #include "XGUI_FacesPanel.h"
25 #include "XGUI_Selection.h"
26 #include "XGUI_SelectionActivate.h"
27 #include "XGUI_SelectionMgr.h"
28 #include "XGUI_ViewerProxy.h"
29 #include "XGUI_Workshop.h"
30
31 #ifndef HAVE_SALOME
32 #include <AppElements_Viewer.h>
33 #endif
34
35 #include <ModelAPI_Document.h>
36 #include <ModelAPI_Data.h>
37 #include <ModelAPI_Object.h>
38 #include <ModelAPI_Tools.h>
39 #include <ModelAPI_AttributeIntArray.h>
40 #include <ModelAPI_ResultCompSolid.h>
41
42 #include <ModuleBase_BRepOwner.h>
43 #include <ModuleBase_IModule.h>
44 #include <ModuleBase_Preferences.h>
45 #include <ModuleBase_ResultPrs.h>
46 #include <ModuleBase_Tools.h>
47 #include <ModuleBase_ViewerPrs.h>
48 #include <ModuleBase_IViewer.h>
49
50 #include <GeomAPI_Shape.h>
51 #include <GeomAPI_IPresentable.h>
52 #include <GeomAPI_ICustomPrs.h>
53
54 #include <SUIT_ResourceMgr.h>
55
56 #include <AIS_InteractiveContext.hxx>
57 #include <AIS_ListOfInteractive.hxx>
58 #include <AIS_ListIteratorOfListOfInteractive.hxx>
59 #include <AIS_DimensionSelectionMode.hxx>
60 #include <AIS_Shape.hxx>
61 #include <AIS_Dimension.hxx>
62 #include <AIS_Trihedron.hxx>
63 #ifdef BEFORE_TRIHEDRON_PATCH
64 #include <AIS_Axis.hxx>
65 #include <AIS_Plane.hxx>
66 #include <AIS_Point.hxx>
67 #endif
68 #include <AIS_Selection.hxx>
69 #include <Prs3d_Drawer.hxx>
70 #include <Prs3d_IsoAspect.hxx>
71 #include <SelectMgr_ListOfFilter.hxx>
72 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
73 #include <SelectMgr_SelectionManager.hxx>
74 #include <TColStd_ListIteratorOfListOfInteger.hxx>
75
76 #include <StdSelect_ViewerSelector3d.hxx>
77
78 #include <TColStd_MapOfTransient.hxx>
79 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
80
81 #ifdef TINSPECTOR
82 #include <inspector/VInspectorAPI_CallBack.hxx>
83 #endif
84
85 #include <Events_Loop.h>
86 #include <ModelAPI_Events.h>
87
88 #include <set>
89
90 /// defines the local context mouse selection sensitivity
91 const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
92
93 //#define DEBUG_DISPLAY
94 //#define DEBUG_FEATURE_REDISPLAY
95 //#define DEBUG_SELECTION_FILTERS
96
97 //#define DEBUG_COMPOSILID_DISPLAY
98
99 //#define DEBUG_OCCT_SHAPE_SELECTION
100
101 #define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
102
103 //#define DEBUG_VIEWER_BLOCKED_COUNT
104
105 //**************************************************************
106 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
107 {
108   // Get from null point
109   theAIS->DisplayedObjects(theList, true);
110 }
111
112 QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QString(", "))
113 {
114   QStringList anInfo;
115   QIntList::const_iterator anIt = theValues.begin(), aLast = theValues.end();
116   for (; anIt != aLast; anIt++) {
117     anInfo.append(QString::number(*anIt));
118   }
119   return anInfo.join(theSeparator);
120 }
121
122 //**************************************************************
123 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
124 : myWorkshop(theWorkshop), myNeedUpdate(false),
125   myViewerBlockedRecursiveCount(0), myIsFirstAISContextUse(true)
126 {
127   myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
128 }
129
130 //**************************************************************
131 XGUI_Displayer::~XGUI_Displayer()
132 {
133 }
134
135 //**************************************************************
136 bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
137 {
138   return myResult2AISObjectMap.contains(theObject);
139 }
140
141 //**************************************************************
142 bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
143 {
144   bool aDisplayed = false;
145   if (isVisible(theObject)) {
146 #ifdef DEBUG_COMPOSILID_DISPLAY
147     ResultCompSolidPtr aCompsolidResult =
148       std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
149     if (aCompsolidResult.get()) {
150       for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
151         ResultPtr aSubResult = aCompsolidResult->subResult(i);
152         if (aSubResult.get())
153           redisplay(aSubResult, false);
154       }
155       if (theUpdateViewer)
156         updateViewer();
157     }
158     else
159 #endif
160     aDisplayed = redisplay(theObject, theUpdateViewer);
161   } else {
162     AISObjectPtr anAIS;
163     GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
164     bool isShading = false;
165     if (aPrs.get() != NULL) {
166       anAIS = aPrs->getAISObject(anAIS);
167       if (anAIS.get()) {
168         // correct deviation coefficient for
169         /*Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
170         if (!anAISPrs.IsNull()) {
171           Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
172           if (!aShapePrs.IsNull()) {
173             TopoDS_Shape aShape = aShapePrs->Shape();
174             if (!aShape.IsNull())
175               //ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
176           }
177         }*/
178       }
179     } else {
180       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
181       if (aResult.get() != NULL) {
182 #ifdef DEBUG_COMPOSILID_DISPLAY
183         ResultCompSolidPtr aCompsolidResult =
184           std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
185         if (aCompsolidResult.get()) {
186           for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
187             ResultPtr aSubResult = aCompsolidResult->subResult(i);
188             if (aSubResult.get())
189               display(aSubResult, false);
190           }
191           if (theUpdateViewer)
192             updateViewer();
193         }
194         else {
195 #endif
196         std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
197         if (aShapePtr.get() != NULL) {
198           anAIS = AISObjectPtr(new GeomAPI_AISObject());
199           Handle(AIS_InteractiveObject) anAISPrs =
200             myWorkshop->module()->createPresentation(aResult);
201           if (anAISPrs.IsNull())
202             anAISPrs = new ModuleBase_ResultPrs(aResult);
203           else {
204             Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
205             if (!aShapePrs.IsNull())
206               ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*) aShapePrs.get());
207           }
208           anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
209           //anAIS->createShape(aShapePtr);
210           isShading = true;
211         }
212 #ifdef DEBUG_COMPOSILID_DISPLAY
213         } // close else
214 #endif
215       }
216     }
217     if (anAIS)
218       aDisplayed = display(theObject, anAIS, isShading, theUpdateViewer);
219   }
220   return aDisplayed;
221 }
222
223 //**************************************************************
224 bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule)
225 {
226   Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS);
227   if (!aShapePrs.IsNull()) {
228     TopoDS_Shape aShape = aShapePrs->Shape();
229     if (aShape.IsNull())
230       return false;
231     TopAbs_ShapeEnum aType = aShape.ShapeType();
232     if ((aType == TopAbs_VERTEX) || (aType == TopAbs_EDGE) || (aType == TopAbs_WIRE))
233       return false;
234     else {
235       // Check that the presentation is not a sketch
236       return theModule->canBeShaded(theAIS);
237     }
238   }
239   return false;
240 }
241
242 //**************************************************************
243 bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
244                              bool isShading, bool theUpdateViewer)
245 {
246   bool aDisplayed = false;
247
248   Handle(AIS_InteractiveContext) aContext = AISContext();
249   if (aContext.IsNull())
250     return aDisplayed;
251
252   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
253   if (!anAISIO.IsNull()) {
254     appendResultObject(theObject, theAIS);
255
256     bool isCustomized = customizeObject(theObject);
257
258     int aDispMode = isShading? Shading : Wireframe;
259     if (isShading)
260       anAISIO->Attributes()->SetFaceBoundaryDraw( Standard_True );
261     anAISIO->SetDisplayMode(aDispMode);
262     aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed);
263     #ifdef TINSPECTOR
264     if (getCallBack()) getCallBack()->Display(anAISIO);
265     #endif
266     aDisplayed = true;
267
268     emit objectDisplayed(theObject, theAIS);
269     selectionActivate()->activate(anAISIO, theUpdateViewer);
270   }
271   if (theUpdateViewer)
272     updateViewer();
273
274   return aDisplayed;
275 }
276
277 //**************************************************************
278 bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer)
279 {
280   bool aErased = false;
281   if (!isVisible(theObject))
282     return aErased;
283
284   Handle(AIS_InteractiveContext) aContext = AISContext();
285   if (aContext.IsNull())
286     return aErased;
287
288   AISObjectPtr anObject = myResult2AISObjectMap[theObject];
289   if (anObject) {
290     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
291     if (!anAIS.IsNull()) {
292       emit beforeObjectErase(theObject, anObject);
293       aContext->Remove(anAIS, false/*update viewer*/);
294       #ifdef TINSPECTOR
295       if (getCallBack()) getCallBack()->Remove(anAIS);
296       #endif
297       aErased = true;
298     }
299   }
300   myResult2AISObjectMap.remove(theObject);
301
302 #ifdef DEBUG_DISPLAY
303   std::ostringstream aPtrStr;
304   aPtrStr << theObject.get();
305   qDebug(QString("erase object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str());
306   qDebug(getResult2AISObjectMapInfo().c_str());
307 #endif
308
309   if (theUpdateViewer)
310     updateViewer();
311
312   return aErased;
313 }
314
315 //**************************************************************
316 bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
317 {
318   bool aRedisplayed = false;
319   if (!isVisible(theObject))
320     return aRedisplayed;
321
322   AISObjectPtr aAISObj = getAISObject(theObject);
323   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
324
325   GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
326   if (aPrs) {
327     AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
328     if (!aAIS_Obj) {
329       aRedisplayed = erase(theObject, theUpdateViewer);
330       return aRedisplayed;
331     }
332     if (aAIS_Obj != aAISObj) {
333       appendResultObject(theObject, aAIS_Obj);
334     }
335     aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
336   }
337
338   Handle(AIS_InteractiveContext) aContext = AISContext();
339   if (!aContext.IsNull() && !aAISIO.IsNull()) {
340     // Check that the visualized shape is the same and the redisplay is not necessary
341     // Redisplay of AIS object leads to this object selection compute and the selection
342     // in the browser is lost
343     // this check is not necessary anymore because the selection store/restore is realized
344     // before and after the values modification.
345     // Moreother, this check avoids customize and redisplay presentation if the presentable
346     // parameter is changed.
347     bool isEqualShapes = false;
348     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
349     if (aResult.get() != NULL) {
350       Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
351       if (!aShapePrs.IsNull()) {
352         std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
353         if (aShapePtr.get()) {
354           const TopoDS_Shape& aOldShape = aShapePrs->Shape();
355           if (!aOldShape.IsNull())
356             isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
357         }
358       }
359     }
360     // Customization of presentation
361     bool isCustomized = customizeObject(theObject);
362     #ifdef DEBUG_FEATURE_REDISPLAY
363       qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3").
364         arg(!isEqualShapes || isCustomized).arg(isEqualShapes)
365         .arg(isCustomized).toStdString().c_str());
366     #endif
367     if (!isEqualShapes || isCustomized) {
368       /// if shapes are equal and presentation are customized, selection should be restored
369       bool aNeedToRestoreSelection = isEqualShapes && isCustomized;
370       if (aNeedToRestoreSelection)
371         myWorkshop->module()->storeSelection();
372
373 #ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
374       myWorkshop->selector()->deselectPresentation(aAISIO);
375 #endif
376       aContext->Redisplay(aAISIO, false);
377
378       #ifdef TINSPECTOR
379       if (getCallBack()) getCallBack()->Redisplay(aAISIO);
380       #endif
381
382       if (aNeedToRestoreSelection)
383         myWorkshop->module()->restoreSelection();
384
385       aRedisplayed = true;
386       #ifdef DEBUG_FEATURE_REDISPLAY
387         qDebug("  Redisplay happens");
388       #endif
389       if (theUpdateViewer)
390         updateViewer();
391     }
392   }
393   return aRedisplayed;
394 }
395
396 //**************************************************************
397 void XGUI_Displayer::redisplayObjects()
398 {
399   // redisplay objects visualized in the viewer
400   static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
401   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
402   QObjectPtrList aDisplayed = myWorkshop->displayer()->displayedObjects();
403   QObjectPtrList::const_iterator anIt = aDisplayed.begin(), aLast = aDisplayed.end();
404   for (; anIt != aLast; anIt++) {
405     aECreator->sendUpdated(*anIt, EVENT_DISP);
406   }
407   Events_Loop::loop()->flush(EVENT_DISP);
408 }
409
410 //**************************************************************
411 void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
412                                        const bool theUpdateViewer)
413 {
414   //Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
415   //if (!aTrihedron.IsNull())
416   //  deactivateAIS(aTrihedron);
417
418   QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
419   for (; anIt != aLast; anIt++) {
420     selectionActivate()->deactivate(*anIt, false);
421   }
422   //VSV It seems that there is no necessity to update viewer on deactivation
423   //if (theUpdateViewer)
424   //  updateViewer();
425 }
426
427 //**************************************************************
428 bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
429 {
430   bool aVisible = false;
431   GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
432   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
433   if (aPrs.get() || aResult.get()) {
434     aVisible = theDisplayer->isVisible(theObject);
435     // compsolid is not visualized in the viewer,
436     // but should have presentation when all sub solids are
437     // visible. It is useful for highlight presentation where compsolid shape is selectable
438     if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
439       ResultCompSolidPtr aCompsolidResult =
440         std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
441       if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
442         bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
443         for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
444           anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
445         }
446         aVisible = anAllSubsVisible;
447       }
448     }
449   }
450   // it is possible that feature is presentable and has results, so we should check visibility
451   // of results if presentation is not shown (e.g. Sketch Circle/Arc features)
452   if (!aVisible) {
453     // check if all results of the feature are visible
454     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
455     std::list<ResultPtr> aResults;
456     ModelAPI_Tools::allResults(aFeature, aResults);
457     std::list<ResultPtr>::const_iterator aIt;
458     aVisible = !aResults.empty();
459     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
460       aVisible = aVisible && theDisplayer->isVisible(*aIt);
461     }
462   }
463   return aVisible;
464 }
465
466 //**************************************************************
467 void XGUI_Displayer::setSelected(const  QList<ModuleBase_ViewerPrsPtr>& theValues,
468                                  bool theUpdateViewer)
469 {
470   Handle(AIS_InteractiveContext) aContext = AISContext();
471   if (aContext.IsNull())
472     return;
473   aContext->UnhilightSelected(false);
474   aContext->ClearSelected(false);
475   #ifdef TINSPECTOR
476   if (getCallBack()) getCallBack()->ClearSelected();
477   #endif
478   NCollection_DataMap<TopoDS_Shape, NCollection_Map<Handle(AIS_InteractiveObject)>>
479     aShapesToBeSelected;
480
481   foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
482     const GeomShapePtr& aGeomShape = aPrs->shape();
483     if (aGeomShape.get() && !aGeomShape->isNull()) {
484       const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
485 #ifdef DEBUG_OCCT_SHAPE_SELECTION
486       // problem 1: performance
487       // problem 2: IO is not specified, so the first found owner is selected, as a result
488       // it might belong to another result
489       aContext->AddOrRemoveSelected(aShape, false);
490       #ifdef TINSPECTOR
491       if (getCallBack()) getCallBack()->AddOrRemoveSelected(aShape);
492       #endif
493 #else
494       NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations;
495       if (aShapesToBeSelected.IsBound(aShape))
496         aPresentations = aShapesToBeSelected.Find(aShape);
497       ObjectPtr anObject = aPrs->object();
498       getPresentations(anObject, aPresentations);
499
500       aShapesToBeSelected.Bind(aShape, aPresentations);
501 #endif
502     } else {
503       ObjectPtr anObject = aPrs->object();
504       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
505       if (aResult.get() && isVisible(aResult)) {
506         AISObjectPtr anObj = myResult2AISObjectMap[aResult];
507         Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
508         if (!anAIS.IsNull()) {
509           // The methods are replaced in order to provide multi-selection, e.g. restore selection
510           // by activating multi selector widget. It also gives an advantage that the multi
511           // selection in OB gives multi-selection in the viewer
512           //aContext->SetSelected(anAIS, false);
513           // The selection in the context was cleared, so the method sets the objects are selected
514           aContext->AddOrRemoveSelected(anAIS, false);
515           #ifdef TINSPECTOR
516           if (getCallBack()) getCallBack()->AddOrRemoveSelected(anAIS);
517           #endif
518         }
519       }
520     }
521   }
522   if (!aShapesToBeSelected.IsEmpty())
523     XGUI_Displayer::AddOrRemoveSelectedShapes(aContext, aShapesToBeSelected);
524
525   if (theUpdateViewer)
526     updateViewer();
527 }
528
529 //**************************************************************
530 void XGUI_Displayer::clearSelected(const bool theUpdateViewer)
531 {
532   Handle(AIS_InteractiveContext) aContext = AISContext();
533   if (!aContext.IsNull()) {
534     aContext->UnhilightSelected(false);//UnhilightCurrents(false);
535     aContext->ClearSelected(theUpdateViewer);
536     #ifdef TINSPECTOR
537     if (getCallBack()) getCallBack()->ClearSelected();
538     #endif
539   }
540 }
541
542 //**************************************************************
543 bool XGUI_Displayer::eraseAll(const bool theUpdateViewer)
544 {
545   bool aErased = false;
546   Handle(AIS_InteractiveContext) aContext = AISContext();
547   if (!aContext.IsNull()) {
548     foreach (ObjectPtr aObj, myResult2AISObjectMap.keys()) {
549       AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
550       // erase an object
551       Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
552       if (!anIO.IsNull()) {
553         emit beforeObjectErase(aObj, aAISObj);
554         aContext->Remove(anIO, false/*update viewer*/);
555         #ifdef TINSPECTOR
556         if (getCallBack()) getCallBack()->Remove(anIO);
557         #endif
558         aErased = true;
559       }
560     }
561     if (theUpdateViewer)
562       updateViewer();
563   }
564   myResult2AISObjectMap.clear();
565 #ifdef DEBUG_DISPLAY
566   qDebug("eraseAll");
567   qDebug(getResult2AISObjectMapInfo().c_str());
568 #endif
569   return aErased;
570 }
571
572
573 //**************************************************************
574 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
575 {
576   AISObjectPtr anIO;
577   if (myResult2AISObjectMap.contains(theObject))
578     anIO = myResult2AISObjectMap[theObject];
579   return anIO;
580 }
581
582 //**************************************************************
583 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
584 {
585   Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
586   return getObject(aRefAIS);
587 }
588
589 //**************************************************************
590 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
591 {
592   ObjectPtr anObject;
593   ResultToAISMap::const_iterator aMapIter = myResult2AISObjectMap.cbegin();
594   for (; aMapIter != myResult2AISObjectMap.cend(); aMapIter++) {
595     const AISObjectPtr& aAIS = aMapIter.value();
596     Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
597     if (anAIS == theIO)
598       anObject = aMapIter.key();
599     if (anObject.get())
600       break;
601   }
602   if (!anObject.get()) {
603     std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
604     if (!theIO.IsNull()) {
605       anAISObj->setImpl(new Handle(AIS_InteractiveObject)(theIO));
606     }
607     anObject = myWorkshop->module()->findPresentedObject(anAISObj);
608   }
609   return anObject;
610 }
611
612 //**************************************************************
613 bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
614 {
615   bool aWasEnabled = isUpdateEnabled();
616   if (isEnabled)
617     myViewerBlockedRecursiveCount--;
618   else
619     myViewerBlockedRecursiveCount++;
620
621 #ifdef DEBUG_VIEWER_BLOCKED_COUNT
622   std::cout << "myViewerBlockedRecursiveCount = " << myViewerBlockedRecursiveCount << std::endl;
623 #endif
624
625   if (myNeedUpdate && isUpdateEnabled()) {
626     updateViewer();
627     myNeedUpdate = false;
628   }
629   return aWasEnabled;
630 }
631
632 //**************************************************************
633 bool XGUI_Displayer::isUpdateEnabled() const
634 {
635   return myViewerBlockedRecursiveCount == 0;
636 }
637
638 //**************************************************************
639 void XGUI_Displayer::updateViewer() const
640 {
641   Handle(AIS_InteractiveContext) aContext = AISContext();
642
643 #ifdef DEBUG_VIEWER_BLOCKED_COUNT
644   std::cout << "updateViewer: " << (myViewerBlockedRecursiveCount == 0 ? " done" : " later")
645             << std::endl;
646 #endif
647
648   if (!aContext.IsNull() && isUpdateEnabled()) {
649     //myWorkshop->viewer()->Zfitall();
650     aContext->UpdateCurrentViewer();
651   } else {
652     myNeedUpdate = true;
653   }
654 }
655
656 //**************************************************************
657 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
658 {
659   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
660   if (!aContext.IsNull() && myIsFirstAISContextUse/*&& !aContext->HasOpenedContext()*/) {
661     XGUI_Displayer* aDisplayer = (XGUI_Displayer*)this;
662     aDisplayer->myIsFirstAISContextUse = false;
663     if (!myWorkshop->selectionActivate()->isTrihedronActive())
664       selectionActivate()->deactivateTrihedron(true);
665     aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
666     aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
667     ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle();
668   }
669   return aContext;
670 }
671
672 //**************************************************************
673 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
674 {
675   Handle(AIS_InteractiveContext) aContext = AISContext();
676   if (!aContext.IsNull() && myAndFilter.IsNull()) {
677     myAndFilter = new SelectMgr_AndFilter();
678     aContext->AddFilter(myAndFilter);
679   }
680   return myAndFilter;
681 }
682
683 //**************************************************************
684 bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
685                                 const Standard_Integer theDisplayMode, bool theUpdateViewer)
686 {
687   bool aDisplayed = false;
688   Handle(AIS_InteractiveContext) aContext = AISContext();
689   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
690   if (!aContext.IsNull() && !anAISIO.IsNull()) {
691     aContext->Display(anAISIO, theDisplayMode, 0, false/*update viewer*/, true, AIS_DS_Displayed);
692     #ifdef TINSPECTOR
693     if (getCallBack()) getCallBack()->Display(anAISIO);
694     #endif
695     aDisplayed = true;
696     aContext->Deactivate(anAISIO);
697     #ifdef TINSPECTOR
698     if (getCallBack()) getCallBack()->Deactivate(anAISIO);
699     #endif
700     aContext->Load(anAISIO);
701     #ifdef TINSPECTOR
702     if (getCallBack()) getCallBack()->Load(anAISIO);
703     #endif
704     if (toActivateInSelectionModes)
705       myWorkshop->selectionActivate()->activateOnDisplay(anAISIO, theUpdateViewer);
706
707     if (theUpdateViewer)
708       updateViewer();
709   }
710   return aDisplayed;
711 }
712
713 //**************************************************************
714 bool XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool theUpdateViewer)
715 {
716   bool aErased = false;
717   Handle(AIS_InteractiveContext) aContext = AISContext();
718   if (!aContext.IsNull()) {
719     Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
720     if (!anAISIO.IsNull() && aContext->IsDisplayed(anAISIO)) {
721       aContext->Remove(anAISIO, false/*update viewer*/);
722       #ifdef TINSPECTOR
723       if (getCallBack()) getCallBack()->Remove(anAISIO);
724       #endif
725       aErased = true;
726     }
727   }
728   if (aErased && theUpdateViewer)
729     updateViewer();
730   return aErased;
731 }
732
733 //**************************************************************
734 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer)
735 {
736   if (theMode == NoMode)
737     return;
738
739   Handle(AIS_InteractiveContext) aContext = AISContext();
740   if (aContext.IsNull())
741     return;
742
743   AISObjectPtr aAISObj = getAISObject(theObject);
744   if (!aAISObj)
745     return;
746
747   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
748   aContext->SetDisplayMode(aAISIO, theMode, false);
749   // Redisplay in order to update new mode because it could be not computed before
750   if (theUpdateViewer)
751     updateViewer();
752 }
753
754 //**************************************************************
755 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
756 {
757   Handle(AIS_InteractiveContext) aContext = AISContext();
758   if (aContext.IsNull())
759     return NoMode;
760
761   AISObjectPtr aAISObj = getAISObject(theObject);
762   if (!aAISObj)
763     return NoMode;
764
765   Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
766   return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
767 }
768
769 //**************************************************************
770 void XGUI_Displayer::deactivateSelectionFilters(const bool theAddFilterOnly)
771 {
772   Handle(AIS_InteractiveContext) aContext = AISContext();
773   if (!myAndFilter.IsNull()) {
774     bool aFound = false;
775     if (!aContext.IsNull()) {
776       const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
777       SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
778       for (; anIt.More() && !aFound; anIt.Next()) {
779         Handle(SelectMgr_Filter) aFilter = anIt.Value();
780         aFound = aFilter == myAndFilter;
781       }
782       if (aFound)
783         aContext->RemoveFilter(myAndFilter);
784     }
785     myAndFilter.Nullify();
786   }
787 }
788
789 //**************************************************************
790 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
791 {
792   Handle(AIS_InteractiveContext) aContext = AISContext();
793   if (aContext.IsNull() || hasSelectionFilter(theFilter))
794     return;
795
796   Handle(SelectMgr_CompositionFilter) aCompositeFilter = GetFilter();
797   if (!aCompositeFilter.IsNull()) {
798     aCompositeFilter->Add(theFilter);
799 #ifdef DEBUG_SELECTION_FILTERS
800     int aCount = aCompositeFilter->StoredFilters().Extent();
801     qDebug(QString("addSelectionFilter: filters.count() = %1").arg(aCount).toStdString().c_str());
802 #endif
803   }
804 }
805
806 //**************************************************************
807 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
808 {
809   Handle(AIS_InteractiveContext) aContext = AISContext();
810   if (aContext.IsNull())
811     return;
812
813   Handle(SelectMgr_AndFilter) aCompositeFilter = GetFilter();
814   if (!aCompositeFilter.IsNull() && aCompositeFilter->IsIn(theFilter)) {
815     aCompositeFilter->Remove(theFilter);
816 #ifdef DEBUG_SELECTION_FILTERS
817     int aCount = aCompositeFilter->StoredFilters().Extent();
818     qDebug(QString("removeSelectionFilter: filters.count() = %1")
819       .arg(aCount).toStdString().c_str());
820 #endif
821   }
822 }
823
824 //**************************************************************
825 bool XGUI_Displayer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
826 {
827   bool aFilterFound = false;
828
829   Handle(AIS_InteractiveContext) aContext = AISContext();
830   if (aContext.IsNull())
831     return aFilterFound;
832   const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
833   SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
834   for (; aIt.More() && !aFilterFound; aIt.Next()) {
835     if (theFilter.get() == aIt.Value().get())
836       aFilterFound = true;
837   }
838   Handle(SelectMgr_CompositionFilter) aCompositeFilter = GetFilter();
839   if (!aCompositeFilter.IsNull()) {
840     const SelectMgr_ListOfFilter& aStoredFilters = aCompositeFilter->StoredFilters();
841     for (aIt.Initialize(aStoredFilters); aIt.More() && !aFilterFound; aIt.Next()) {
842       if (theFilter.get() == aIt.Value().get())
843         aFilterFound = true;
844     }
845   }
846   return aFilterFound;
847 }
848
849 //**************************************************************
850 void XGUI_Displayer::removeFilters()
851 {
852   Handle(AIS_InteractiveContext) aContext = AISContext();
853   if (aContext.IsNull())
854     return;
855
856   Handle(SelectMgr_CompositionFilter) aCompositeFilter = GetFilter();
857   if (!aCompositeFilter.IsNull())
858     aCompositeFilter->Clear();
859 }
860
861 //**************************************************************
862 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
863 {
864   QObjectPtrList aDispList = myResult2AISObjectMap.keys();
865   foreach(ObjectPtr aObj, aDispList) {
866     if (!theList.contains(aObj))
867       erase(aObj, false);
868   }
869   foreach(ObjectPtr aObj, theList) {
870     if (!isVisible(aObj))
871       display(aObj, false);
872   }
873   updateViewer();
874 }
875
876 //**************************************************************
877 bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
878 {
879   if (!isVisible(theObject))
880     return false;
881
882   AISObjectPtr aAISObj = getAISObject(theObject);
883   if (aAISObj.get() == NULL)
884     return false;
885
886   Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
887   return ::canBeShaded(anAIS, myWorkshop->module());
888 }
889
890 //**************************************************************
891 bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
892 {
893   AISObjectPtr anAISObj = getAISObject(theObject);
894   // correct the result's color it it has the attribute
895   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
896
897   // Customization of presentation
898   GeomCustomPrsPtr aCustomPrs;
899   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
900   if (aFeature.get() != NULL) {
901     GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
902     if (aCustPrs.get() != NULL)
903       aCustomPrs = aCustPrs;
904   }
905   if (aCustomPrs.get() == NULL) {
906     GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
907     // we ignore presentable not customized objects
908     if (aPrs.get() == NULL)
909       aCustomPrs = myCustomPrs;
910   }
911   bool isCustomized = aCustomPrs.get() &&
912                       aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
913   isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs)
914                  || isCustomized;
915
916   // update presentation state if faces panel is active
917   if (anAISObj.get() && myWorkshop->facesPanel())
918     isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized;
919
920   return isCustomized;
921 }
922
923 //**************************************************************
924 QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject,
925                                       const QColor& theColor,
926                                       bool theUpdateViewer)
927 {
928   if (!isVisible(theObject))
929     return Qt::black;
930
931   AISObjectPtr anAISObj = getAISObject(theObject);
932   int aR, aG, aB;
933   anAISObj->getColor(aR, aG, aB);
934   anAISObj->setColor(theColor.red(), theColor.green(), theColor.blue());
935   if (theUpdateViewer)
936     updateViewer();
937   return QColor(aR, aG, aB);
938 }
939
940 //**************************************************************
941 void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS)
942 {
943   myResult2AISObjectMap[theObject] = theAIS;
944
945 #ifdef DEBUG_DISPLAY
946   std::ostringstream aPtrStr;
947   aPtrStr << theObject.get();
948   qDebug(QString("display object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str());
949   qDebug(getResult2AISObjectMapInfo().c_str());
950 #endif
951 }
952
953 #ifdef _DEBUG
954 //**************************************************************
955 std::string XGUI_Displayer::getResult2AISObjectMapInfo() const
956 {
957   QStringList aContent;
958   foreach (ObjectPtr aObj, myResult2AISObjectMap.keys()) {
959     AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
960     std::ostringstream aPtrStr;
961     aPtrStr << "aObj = " << aObj.get() << ":";
962     aPtrStr << "anAIS = " << aAISObj.get() << ":";
963     aPtrStr << "[" << ModuleBase_Tools::objectInfo(aObj).toStdString().c_str() << "]";
964
965     aContent.append(aPtrStr.str().c_str());
966   }
967   return QString("myResult2AISObjectMap: size = %1\n%2\n").arg(myResult2AISObjectMap.size()).
968                                             arg(aContent.join("\n")).toStdString().c_str();
969 }
970 #endif
971
972 //**************************************************************
973 void XGUI_Displayer::getPresentations(const ObjectPtr& theObject,
974                                   NCollection_Map<Handle(AIS_InteractiveObject)>& thePresentations)
975 {
976   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
977   if (aResult.get()) {
978     AISObjectPtr aAISObj = getAISObject(aResult);
979     if (aAISObj.get() == NULL) {
980       // if result is a result of a composite feature, it is visualized by visualization of
981       // composite children, so we should get one of this presentations
982       ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
983       if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) {
984         aAISObj = getAISObject(aCompSolid->subResult(0));
985       }
986     }
987     if (aAISObj.get() != NULL) {
988       Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
989       if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
990         thePresentations.Add(anAIS);
991     }
992   }
993   else {
994     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
995     // find presentation of the feature
996     AISObjectPtr aAISObj = getAISObject(aFeature);
997     if (aAISObj.get() != NULL) {
998       Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
999       if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
1000         thePresentations.Add(anAIS);
1001     }
1002     // find presentations of the feature results
1003     std::list<ResultPtr> aResults;
1004     ModelAPI_Tools::allResults(aFeature, aResults);
1005     std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
1006     for (; anIt != aLast; ++anIt) {
1007       AISObjectPtr aAISObj = getAISObject(*anIt);
1008       if (aAISObj.get() != NULL) {
1009         Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1010         if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
1011           thePresentations.Add(anAIS);
1012       }
1013     }
1014   }
1015 }
1016
1017 //**************************************************************
1018 void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
1019 {
1020   Handle(AIS_InteractiveContext) aContext = AISContext();
1021   if (aContext.IsNull())
1022     return;
1023
1024   Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron();
1025
1026   XGUI_SelectionActivate* aSelectionActive = selectionActivate();
1027   if (theToDisplay) {
1028     if (!aContext->IsDisplayed(aTrihedron))
1029       aContext->Display(aTrihedron,
1030                         0 /*wireframe*/,
1031                         -1 /* selection mode */,
1032                         Standard_True /* update viewer*/,
1033                         Standard_False /* allow decomposition */,
1034                         AIS_DS_Displayed /* xdisplay status */);
1035     #ifdef TINSPECTOR
1036     if (getCallBack()) getCallBack()->Display(aTrihedron);
1037     #endif
1038
1039     if (!aSelectionActive->isTrihedronActive())
1040       aSelectionActive->deactivateTrihedron(false);
1041     else
1042       aSelectionActive->activate(aTrihedron, false);
1043   } else {
1044     aSelectionActive->deactivateTrihedron(false);
1045
1046     aContext->Erase(aTrihedron, Standard_True);
1047     #ifdef TINSPECTOR
1048     if (getCallBack()) getCallBack()->Remove(aTrihedron);
1049     #endif
1050   }
1051
1052   updateViewer();
1053 }
1054
1055 //**************************************************************
1056 void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
1057                            const NCollection_DataMap<TopoDS_Shape,
1058                            NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected)
1059 {
1060   NCollection_Map<Handle(AIS_InteractiveObject)> aCompsolidPresentations;
1061   NCollection_Map<Handle(AIS_InteractiveObject)> aSelectedPresentations;
1062
1063   NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
1064   theContext->MainSelector()->ActiveOwners(anActiveOwners);
1065   NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
1066   Handle(SelectMgr_EntityOwner) anOwner;
1067
1068   /// It is very important to check that the owner is processed only once and has a map of
1069   /// processed owners because SetSelected works as a switch.
1070   /// If count of calls setSelectec is even, the object stays in the previous state
1071   /// (selected, deselected)
1072   /// OCCT: to write about the problem that active owners method returns one owner several times
1073   QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
1074   for (; anOwnersIt.More(); anOwnersIt.Next()) {
1075     anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
1076     if (aSelectedIds.contains((long)anOwner.get()))
1077       continue;
1078     aSelectedIds.append((long)anOwner.get());
1079
1080     Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
1081     if (!BROwnr.IsNull() && BROwnr->HasShape()) {
1082       const TopoDS_Shape& aShape = BROwnr->Shape();
1083       if (aShape.IsNull())
1084         continue;
1085
1086       Handle(ModuleBase_BRepOwner) aCustomOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner);
1087
1088       NCollection_DataMap<TopoDS_Shape, NCollection_Map<Handle(AIS_InteractiveObject)> >
1089                                              ::Iterator aShapeIt(theShapesToBeSelected);
1090       for (; aShapeIt.More(); aShapeIt.Next()) {
1091         const TopoDS_Shape& aParameterShape = aShapeIt.Key();
1092         // isSame should be used here as it does not check orientation of shapes
1093         // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
1094         // different for Edges shapes in model shape and owner even if this is the same shape
1095         if (aParameterShape.IsSame(aShape)) {
1096           Handle(AIS_InteractiveObject) anOwnerPresentation =
1097                             Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
1098           NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
1099                                       theShapesToBeSelected.Find(aParameterShape);
1100           if (aPresentations.Contains(anOwnerPresentation)) {
1101             theContext->AddOrRemoveSelected(anOwner, Standard_False);
1102             anOwner->SetSelected (Standard_True);
1103             // collect selected presentations to do not select them if compsolid is selected
1104             if (!aSelectedPresentations.Contains(anOwnerPresentation))
1105               aSelectedPresentations.Add(anOwnerPresentation);
1106           }
1107         }
1108         else if (!aCustomOwner.IsNull()) { // CompSolid processing #2219
1109           // shape of owner is compound, but shape to be selected is compsolid, so
1110           // we need to compare shape to AIS presentation of owner(rule of the owner creation)
1111           Handle(AIS_Shape) anOwnerPresentation =
1112                             Handle(AIS_Shape)::DownCast(anOwner->Selectable());
1113           const TopoDS_Shape& aPresentationShape = anOwnerPresentation->Shape();
1114           if (aParameterShape.IsSame(anOwnerPresentation->Shape()) &&
1115               !aCompsolidPresentations.Contains(anOwnerPresentation))
1116             aCompsolidPresentations.Add(anOwnerPresentation);
1117         }
1118       }
1119     }
1120   }
1121   // select CompSolid presentations if their owners was not selected yet
1122   NCollection_Map<Handle(AIS_InteractiveObject)>::Iterator anIt (aCompsolidPresentations);
1123   for (; anIt.More(); anIt.Next()) {
1124     if (aSelectedPresentations.Contains(anIt.Value()))
1125       continue;
1126     theContext->AddOrRemoveSelected(anIt.Value(), Standard_False);
1127   }
1128 }
1129
1130 //**************************************************************
1131 XGUI_SelectionActivate* XGUI_Displayer::selectionActivate() const
1132 {
1133   return myWorkshop->selectionActivate();
1134 }