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"
12 #include "XGUI_CustomPrs.h"
15 #include <AppElements_Viewer.h>
18 #include <ModelAPI_Document.h>
19 #include <ModelAPI_Data.h>
20 #include <ModelAPI_Object.h>
21 #include <ModelAPI_Tools.h>
22 #include <ModelAPI_AttributeIntArray.h>
23 #include <ModelAPI_ResultCompSolid.h>
25 #include <ModuleBase_ResultPrs.h>
26 #include <ModuleBase_Tools.h>
27 #include <ModuleBase_IModule.h>
28 #include <ModuleBase_ViewerPrs.h>
30 #include <GeomAPI_Shape.h>
31 #include <GeomAPI_IPresentable.h>
32 #include <GeomAPI_ICustomPrs.h>
34 #include <AIS_InteractiveContext.hxx>
35 #include <AIS_LocalContext.hxx>
36 #include <AIS_ListOfInteractive.hxx>
37 #include <AIS_ListIteratorOfListOfInteractive.hxx>
38 #include <AIS_DimensionSelectionMode.hxx>
39 #include <AIS_Shape.hxx>
40 #include <AIS_Dimension.hxx>
41 #include <AIS_Trihedron.hxx>
42 #include <AIS_Axis.hxx>
43 #include <AIS_Plane.hxx>
44 #include <AIS_Point.hxx>
45 #include <AIS_Selection.hxx>
46 #include <TColStd_ListIteratorOfListOfInteger.hxx>
47 #include <SelectMgr_ListOfFilter.hxx>
48 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
49 #include <Prs3d_Drawer.hxx>
50 #include <Prs3d_IsoAspect.hxx>
51 #include <SelectMgr_SelectionManager.hxx>
53 #include <StdSelect_ViewerSelector3d.hxx>
55 #include <TColStd_MapOfTransient.hxx>
56 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
58 #include <Events_Loop.h>
59 #include <ModelAPI_Events.h>
63 const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity
65 //#define DEBUG_ACTIVATE_OBJECTS
66 //#define DEBUG_DEACTIVATE
67 //#define DEBUG_ACTIVATE_AIS
68 //#define DEBUG_DEACTIVATE_AIS
70 //#define DEBUG_DISPLAY
71 //#define DEBUG_FEATURE_REDISPLAY
72 //#define DEBUG_SELECTION_FILTERS
74 //#define DEBUG_COMPOSILID_DISPLAY
75 // Workaround for bug #25637
77 //#define DEBUG_OCCT_SHAPE_SELECTION
79 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
81 // Get from null point
82 theAIS->DisplayedObjects(theList, true);
83 if (theAIS->HasOpenedContext()) {
84 // get from local context
85 const Handle(AIS_LocalContext)& aLC = theAIS->LocalContext();
86 TColStd_MapOfTransient aMap;
87 int NbDisp = aLC->DisplayedObjects(aMap);
88 TColStd_MapIteratorOfMapOfTransient aIt(aMap);
90 Handle(AIS_InteractiveObject) curIO;
91 Handle(Standard_Transient) Tr;
92 for(; aIt.More(); aIt.Next()){
94 curIO = *((Handle(AIS_InteractiveObject)*) &Tr);
95 theList.Append(curIO);
100 QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QString(", "))
103 QIntList::const_iterator anIt = theValues.begin(), aLast = theValues.end();
104 for (; anIt != aLast; anIt++) {
105 anInfo.append(QString::number(*anIt));
107 return anInfo.join(theSeparator);
110 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
111 : myWorkshop(theWorkshop), myNeedUpdate(false),
112 myIsTrihedronActive(false), myViewerBlockedRecursiveCount(0)
114 myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
117 XGUI_Displayer::~XGUI_Displayer()
121 bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
123 return myResult2AISObjectMap.contains(theObject);
126 bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
128 bool aDisplayed = false;
129 if (isVisible(theObject)) {
130 #ifdef DEBUG_COMPOSILID_DISPLAY
131 ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
132 if (aCompsolidResult.get()) {
133 for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
134 ResultPtr aSubResult = aCompsolidResult->subResult(i);
135 if (aSubResult.get())
136 redisplay(aSubResult, false);
143 aDisplayed = redisplay(theObject, theUpdateViewer);
146 GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
147 bool isShading = false;
148 if (aPrs.get() != NULL) {
149 anAIS = aPrs->getAISObject(anAIS);
151 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
152 if (aResult.get() != NULL) {
153 #ifdef DEBUG_COMPOSILID_DISPLAY
154 ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
155 if (aCompsolidResult.get()) {
156 for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
157 ResultPtr aSubResult = aCompsolidResult->subResult(i);
158 if (aSubResult.get())
159 display(aSubResult, false);
166 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
167 if (aShapePtr.get() != NULL) {
168 anAIS = AISObjectPtr(new GeomAPI_AISObject());
169 Handle(AIS_InteractiveObject) anAISPrs = myWorkshop->module()->createPresentation(aResult);
170 if (anAISPrs.IsNull())
171 anAISPrs = new ModuleBase_ResultPrs(aResult);
172 anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
173 //anAIS->createShape(aShapePtr);
176 #ifdef DEBUG_COMPOSILID_DISPLAY
182 aDisplayed = display(theObject, anAIS, isShading, theUpdateViewer);
187 bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule)
189 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS);
190 if (!aShapePrs.IsNull()) {
191 TopoDS_Shape aShape = aShapePrs->Shape();
194 TopAbs_ShapeEnum aType = aShape.ShapeType();
195 if ((aType == TopAbs_VERTEX) || (aType == TopAbs_EDGE) || (aType == TopAbs_WIRE))
198 // Check that the presentation is not a sketch
199 return theModule->canBeShaded(theAIS);
205 bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
206 bool isShading, bool theUpdateViewer)
208 bool aDisplayed = false;
210 Handle(AIS_InteractiveContext) aContext = AISContext();
211 if (aContext.IsNull())
214 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
215 if (!anAISIO.IsNull()) {
216 appendResultObject(theObject, theAIS);
218 bool isCustomized = customizeObject(theObject);
220 int aDispMode = isShading? Shading : Wireframe;
222 anAISIO->Attributes()->SetFaceBoundaryDraw( Standard_True );
223 anAISIO->SetDisplayMode(aDispMode);
224 aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed);
227 emit objectDisplayed(theObject, theAIS);
228 activate(anAISIO, myActiveSelectionModes, theUpdateViewer);
229 // the fix from VPA for more suitable selection of sketcher lines
230 if(anAISIO->Width() > 1) {
231 for(int aModeIdx = 0; aModeIdx < myActiveSelectionModes.length(); ++aModeIdx) {
232 int aMode = myActiveSelectionModes.value(aModeIdx);
233 double aPrecision = (aMode == getSelectionMode(TopAbs_VERTEX))? 20 :
234 (anAISIO->Width() + 2);
235 aContext->SetSelectionSensitivity(anAISIO, aMode, aPrecision);
245 bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer)
247 bool aErased = false;
248 if (!isVisible(theObject))
251 Handle(AIS_InteractiveContext) aContext = AISContext();
252 if (aContext.IsNull())
255 AISObjectPtr anObject = myResult2AISObjectMap[theObject];
257 Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
258 if (!anAIS.IsNull()) {
259 emit beforeObjectErase(theObject, anObject);
260 aContext->Remove(anAIS, false/*update viewer*/);
264 myResult2AISObjectMap.remove(theObject);
267 std::ostringstream aPtrStr;
268 aPtrStr << theObject.get();
269 qDebug(QString("erase object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str());
270 qDebug(getResult2AISObjectMapInfo().c_str());
279 bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
281 bool aRedisplayed = false;
282 if (!isVisible(theObject))
285 AISObjectPtr aAISObj = getAISObject(theObject);
286 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
288 GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
290 AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
292 aRedisplayed = erase(theObject, theUpdateViewer);
295 if (aAIS_Obj != aAISObj) {
296 appendResultObject(theObject, aAIS_Obj);
298 aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
301 Handle(AIS_InteractiveContext) aContext = AISContext();
302 if (!aContext.IsNull() && !aAISIO.IsNull()) {
303 // Check that the visualized shape is the same and the redisplay is not necessary
304 // Redisplay of AIS object leads to this object selection compute and the selection
305 // in the browser is lost
306 // this check is not necessary anymore because the selection store/restore is realized
307 // before and after the values modification.
308 // Moreother, this check avoids customize and redisplay presentation if the presentable
309 // parameter is changed.
310 bool isEqualShapes = false;
311 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
312 if (aResult.get() != NULL) {
313 Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
314 if (!aShapePrs.IsNull()) {
315 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
316 if (aShapePtr.get()) {
317 const TopoDS_Shape& aOldShape = aShapePrs->Shape();
318 if (!aOldShape.IsNull())
319 isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
323 // Customization of presentation
324 bool isCustomized = customizeObject(theObject);
325 #ifdef DEBUG_FEATURE_REDISPLAY
326 qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3").
327 arg(!isEqualShapes || isCustomized).arg(isEqualShapes).arg(isCustomized).toStdString().c_str());
329 if (!isEqualShapes || isCustomized) {
330 /// if shapes are equal and presentation are customized, selection should be restored
331 bool aNeedToRestoreSelection = isEqualShapes && isCustomized;
332 if (aNeedToRestoreSelection)
333 myWorkshop->module()->storeSelection();
335 aContext->Redisplay(aAISIO, false);
337 if (aNeedToRestoreSelection)
338 myWorkshop->module()->restoreSelection();
341 #ifdef DEBUG_FEATURE_REDISPLAY
342 qDebug(" Redisplay happens");
351 void XGUI_Displayer::redisplayObjects()
353 // redisplay objects visualized in the viewer
354 static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
355 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
356 QObjectPtrList aDisplayed = myWorkshop->displayer()->displayedObjects();
357 QObjectPtrList::const_iterator anIt = aDisplayed.begin(), aLast = aDisplayed.end();
358 for (; anIt != aLast; anIt++) {
359 aECreator->sendUpdated(*anIt, EVENT_DISP);
361 Events_Loop::loop()->flush(EVENT_DISP);
364 void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer)
366 #ifdef DEBUG_DEACTIVATE
367 QString anInfoStr = ModuleBase_Tools::objectInfo(theObject);
368 qDebug(QString("deactivate: myActiveSelectionModes[%1]: %2, objects = ").
369 arg(myActiveSelectionModes.size()).arg(qIntListInfo(myActiveSelectionModes)).
371 toStdString().c_str());
373 Handle(AIS_InteractiveContext) aContext = AISContext();
374 if (!aContext.IsNull() && isVisible(theObject)) {
375 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
376 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
378 deactivateAIS(anAIS);
379 // the selection from the previous activation modes should be cleared manually (#26172)
380 aContext->LocalContext()->ClearOutdatedSelection(anAIS, true);
386 void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
387 const bool theUpdateViewer)
389 //Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
390 //if (!aTrihedron.IsNull())
391 // deactivateAIS(aTrihedron);
393 QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
394 for (; anIt != aLast; anIt++) {
395 deactivate(*anIt, false);
397 //VSV It seems that there is no necessity to update viewer on deactivation
398 //if (theUpdateViewer)
402 void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
404 Handle(AIS_InteractiveContext) aContext = AISContext();
405 if (aContext.IsNull() || !isVisible(theObject))
408 AISObjectPtr aAISObj = getAISObject(theObject);
410 if (aAISObj.get() != NULL) {
411 Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
412 TColStd_ListOfInteger aTColModes;
413 aContext->ActivatedModes(anAISIO, aTColModes);
414 TColStd_ListIteratorOfListOfInteger itr( aTColModes );
415 for (; itr.More(); itr.Next() ) {
416 theModes.append(itr.Value());
421 int XGUI_Displayer::getSelectionMode(int theShapeType)
423 return (theShapeType >= TopAbs_SHAPE)? theShapeType :
424 AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
427 bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
429 bool aVisible = false;
430 GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
431 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
432 if (aPrs.get() || aResult.get()) {
433 aVisible = theDisplayer->isVisible(theObject);
434 // compsolid is not visualized in the viewer, but should have presentation when all sub solids are
435 // visible. It is useful for highlight presentation where compsolid shape is selectable
436 if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
437 ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
438 if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
439 bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
440 for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
441 anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
443 aVisible = anAllSubsVisible;
447 // it is possible that feature is presentable and has results, so we should check visibility
448 // of results if presentation is not shown (e.g. Sketch Circle/Arc features)
450 // check if all results of the feature are visible
451 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
452 std::list<ResultPtr> aResults = aFeature->results();
453 std::list<ResultPtr>::const_iterator aIt;
454 aVisible = !aResults.empty();
455 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
456 aVisible = aVisible && theDisplayer->isVisible(*aIt);
463 void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
464 const bool theUpdateViewer)
466 // Convert shape types to selection types
468 foreach(int aType, theModes) {
469 aModes.append(getSelectionMode(aType));
472 #ifdef DEBUG_ACTIVATE_OBJECTS
474 QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
475 for (; anIt != aLast; ++anIt) {
476 anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
478 QString anInfoStr = anInfo.join(", ");
480 qDebug(QString("activateObjects: aModes[%1] = %2, myActiveSelectionModes[%3] = %4, objects = %5").
481 arg(aModes.size()).arg(qIntListInfo(aModes)).
482 arg(myActiveSelectionModes.size()).arg(qIntListInfo(myActiveSelectionModes)).
484 toStdString().c_str());
486 // In order to avoid doblications of selection modes
488 foreach (int aMode, aModes) {
489 if (!aNewModes.contains(aMode))
490 aNewModes.append(aMode);
492 myActiveSelectionModes = aNewModes;
493 Handle(AIS_InteractiveContext) aContext = AISContext();
494 // Open local context if there is no one
495 if (aContext.IsNull() || !aContext->HasOpenedContext())
498 //aContext->UseDisplayedObjects();
499 //myUseExternalObjects = true;
501 Handle(AIS_InteractiveObject) anAISIO;
502 AIS_ListOfInteractive aPrsList;
503 //if (aObjList.isEmpty())
506 foreach(ObjectPtr aObj, theObjList) {
507 if (myResult2AISObjectMap.contains(aObj))
508 aPrsList.Append(myResult2AISObjectMap[aObj]->impl<Handle(AIS_InteractiveObject)>());
512 // Add trihedron because it has to partisipate in selection
513 Handle(AIS_InteractiveObject) aTrihedron;
514 if (isTrihedronActive()) {
515 aTrihedron = getTrihedron();
516 if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron))
517 aPrsList.Append(aTrihedron);
519 if (aPrsList.Extent() == 0)
522 AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
523 bool isActivationChanged = false;
524 for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
525 anAISIO = aLIt.Value();
526 if (activate(anAISIO, myActiveSelectionModes, false))
527 isActivationChanged = true;
529 if (!aTrihedron.IsNull()) {
530 foreach(int aMode, myActiveSelectionModes)
531 aContext->SetSelectionSensitivity(aTrihedron, aMode, 20);
533 // VSV It seems that there is no necessity to update viewer on activation
534 //if (theUpdateViewer && isActivationChanged)
538 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
540 Handle(AIS_InteractiveContext) aContext = AISContext();
541 if (aContext.IsNull() || !isVisible(theObject))
544 AISObjectPtr anObj = myResult2AISObjectMap[theObject];
545 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
547 TColStd_ListOfInteger aModes;
548 aContext->ActivatedModes(anAIS, aModes);
549 return aModes.Extent() > 0;
551 void XGUI_Displayer::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues, bool theUpdateViewer)
553 Handle(AIS_InteractiveContext) aContext = AISContext();
554 if (aContext.IsNull())
556 if (aContext->HasOpenedContext()) {
557 aContext->UnhilightSelected(false);
558 aContext->ClearSelected(false);
559 NCollection_Map<TopoDS_Shape> aShapesToBeSelected;
561 foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
562 const GeomShapePtr& aGeomShape = aPrs->shape();
563 if (aGeomShape.get() && !aGeomShape->isNull()) {
564 const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
565 #ifdef DEBUG_OCCT_SHAPE_SELECTION
566 aContext->AddOrRemoveSelected(aShape, false);
568 aShapesToBeSelected.Add(aShape);
571 ObjectPtr anObject = aPrs->object();
572 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
573 if (aResult.get() && isVisible(aResult)) {
574 AISObjectPtr anObj = myResult2AISObjectMap[aResult];
575 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
576 if (!anAIS.IsNull()) {
577 // The methods are replaced in order to provide multi-selection, e.g. restore selection
578 // by activating multi selector widget. It also gives an advantage that the multi
579 // selection in OB gives multi-selection in the viewer
580 //aContext->SetSelected(anAIS, false);
581 // The selection in the context was cleared, so the method sets the objects are selected
582 aContext->AddOrRemoveSelected(anAIS, false);
587 if (!aShapesToBeSelected.IsEmpty())
588 XGUI_Displayer::AddOrRemoveSelectedShapes(aContext, aShapesToBeSelected);
590 aContext->UnhilightCurrents(false);
591 aContext->ClearCurrents(false);
592 foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
593 ObjectPtr anObject = aPrs->object();
594 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
595 if (aResult.get() && isVisible(aResult)) {
596 AISObjectPtr anObj = myResult2AISObjectMap[aResult];
597 Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
599 aContext->SetCurrentObject(anAIS, false);
607 void XGUI_Displayer::clearSelected()
609 Handle(AIS_InteractiveContext) aContext = AISContext();
610 if (!aContext.IsNull()) {
611 aContext->UnhilightCurrents(false);
612 aContext->ClearSelected();
616 bool XGUI_Displayer::eraseAll(const bool theUpdateViewer)
618 bool aErased = false;
619 Handle(AIS_InteractiveContext) aContext = AISContext();
620 if (!aContext.IsNull()) {
621 foreach (ObjectPtr aObj, myResult2AISObjectMap.keys()) {
622 AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
624 Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
625 if (!anIO.IsNull()) {
626 emit beforeObjectErase(aObj, aAISObj);
627 aContext->Remove(anIO, false/*update viewer*/);
634 myResult2AISObjectMap.clear();
637 qDebug(getResult2AISObjectMapInfo().c_str());
642 void deactivateObject(Handle(AIS_InteractiveContext) theContext,
643 Handle(AIS_InteractiveObject) theObject,
644 const bool theClear = true)
646 if (!theObject.IsNull()) {
647 theContext->Deactivate(theObject);
649 //theObject->ClearSelected();
650 // theContext->LocalContext()->ClearOutdatedSelection(theObject, true);
655 void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const
657 Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
658 Handle(AIS_InteractiveContext) aContext = AISContext();
659 if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) {
660 Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron);
661 deactivateObject(aContext, aTrie);
663 /// #1136 hidden axis are selected in sketch
664 /// workaround for Cascade: there is a crash in AIS_LocalContext::ClearOutdatedSelection
665 /// for Position AIS object in SelectionModes.
666 deactivateObject(aContext, aTrie->XAxis());
667 deactivateObject(aContext, aTrie->YAxis());
668 deactivateObject(aContext, aTrie->Axis());
669 deactivateObject(aContext, aTrie->Position());
671 deactivateObject(aContext, aTrie->XYPlane());
672 deactivateObject(aContext, aTrie->XZPlane());
673 deactivateObject(aContext, aTrie->YZPlane());
680 Handle(AIS_InteractiveObject) XGUI_Displayer::getTrihedron() const
682 return myWorkshop->viewer()->trihedron();
685 void XGUI_Displayer::openLocalContext()
687 Handle(AIS_InteractiveContext) aContext = AISContext();
688 // Open local context if there is no one
689 if (!aContext.IsNull() && !aContext->HasOpenedContext()) {
690 // Preserve selected objects
691 //AIS_ListOfInteractive aAisList;
692 //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
693 // aAisList.Append(aContext->Current());
695 // get the filters from the global context and append them to the local context
696 // a list of filters in the global context is not cleared and should be cleared here
697 SelectMgr_ListOfFilter aFilters;
698 aFilters.Assign(aContext->Filters());
699 // it is important to remove the filters in the global context, because there is a code
700 // in the closeLocalContex, which restore the global context filters
701 aContext->RemoveFilters();
703 //aContext->ClearCurrents();
704 aContext->OpenLocalContext();
705 //deactivateTrihedron();
706 //aContext->NotUseDisplayedObjects();
708 //myUseExternalObjects = false;
710 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
711 for (;aIt.More(); aIt.Next()) {
712 aContext->AddFilter(aIt.Value());
715 //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
716 //for(; aIt2.More(); aIt2.Next()) {
717 // aContext->SetSelected(aIt2.Value(), false);
722 void XGUI_Displayer::closeLocalContexts(const bool theUpdateViewer)
724 Handle(AIS_InteractiveContext) aContext = AISContext();
725 if (!aContext.IsNull() && aContext->HasOpenedContext()) {
726 // Preserve selected objects
727 //AIS_ListOfInteractive aAisList;
728 //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
729 // aAisList.Append(aContext->SelectedInteractive());
731 // get the filters from the local context and append them to the global context
732 // a list of filters in the local context is cleared
733 SelectMgr_ListOfFilter aFilters;
734 aFilters.Assign(aContext->Filters());
736 //aContext->ClearSelected();
737 aContext->CloseAllContexts(false);
739 // From the moment when the AIS_DS_Displayed flag is used in the Display of AIS object,
740 // this code is obsolete. It is temporaty commented and should be removed after
741 // the test campaign.
742 // Redisplay all object if they were displayed in localContext
743 /*Handle(AIS_InteractiveObject) aAISIO;
744 foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
745 aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
746 if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
747 aContext->Display(aAISIO, false);
748 aContext->SetDisplayMode(aAISIO, Shading, false);
752 // Append the filters from the local selection in the global selection context
753 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
754 for (;aIt.More(); aIt.Next()) {
755 Handle(SelectMgr_Filter) aFilter = aIt.Value();
756 aContext->AddFilter(aFilter);
761 //myUseExternalObjects = false;
764 //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
765 //for(; aIt2.More(); aIt2.Next()) {
766 // if (aContext->IsDisplayed(aIt2.Value()))
767 // aContext->SetCurrentObject(aIt2.Value(), false);
772 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
775 if (myResult2AISObjectMap.contains(theObject))
776 anIO = myResult2AISObjectMap[theObject];
780 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
782 Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
783 return getObject(aRefAIS);
786 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
789 foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
790 AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
791 Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
797 if (!anObject.get()) {
798 std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
799 if (!theIO.IsNull()) {
800 anAISObj->setImpl(new Handle(AIS_InteractiveObject)(theIO));
802 anObject = myWorkshop->module()->findPresentedObject(anAISObj);
807 bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
809 bool aWasEnabled = isUpdateEnabled();
811 myViewerBlockedRecursiveCount--;
813 myViewerBlockedRecursiveCount++;
815 if (myNeedUpdate && isUpdateEnabled()) {
817 myNeedUpdate = false;
822 bool XGUI_Displayer::isUpdateEnabled() const
824 return myViewerBlockedRecursiveCount == 0;
827 void XGUI_Displayer::updateViewer() const
829 Handle(AIS_InteractiveContext) aContext = AISContext();
830 if (!aContext.IsNull() && isUpdateEnabled()) {
831 myWorkshop->viewer()->Zfitall();
832 aContext->UpdateCurrentViewer();
838 void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
839 const int theMode, const bool theUpdateViewer) const
841 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
842 if (!aContext.IsNull()) {
843 aContext->Activate(theIO, theMode, false);
845 #ifdef DEBUG_ACTIVATE_AIS
846 ObjectPtr anObject = getObject(theIO);
847 anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
848 qDebug(QString("activateAIS: theMode = %1, object = %2").arg(theMode).arg(anInfo).toStdString().c_str());
855 void XGUI_Displayer::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode) const
857 Handle(AIS_InteractiveContext) aContext = AISContext();
858 if (!aContext.IsNull()) {
860 aContext->Deactivate(theIO);
862 aContext->Deactivate(theIO, theMode);
864 #ifdef DEBUG_DEACTIVATE_AIS
865 ObjectPtr anObject = getObject(theIO);
866 anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
867 qDebug(QString("deactivateAIS: theMode = %1, object = %2").arg(theMode).arg(anInfo).toStdString().c_str());
872 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
874 Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
875 if (!aContext.IsNull() && !aContext->HasOpenedContext()) {
876 aContext->OpenLocalContext();
877 if (!isTrihedronActive())
878 deactivateTrihedron(true);
879 aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
880 aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
885 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
887 Handle(AIS_InteractiveContext) aContext = AISContext();
888 if (!aContext.IsNull() && myAndFilter.IsNull()) {
889 myAndFilter = new SelectMgr_AndFilter();
890 aContext->AddFilter(myAndFilter);
895 bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
896 bool theUpdateViewer)
898 bool aDisplayed = false;
899 Handle(AIS_InteractiveContext) aContext = AISContext();
900 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
901 if (!aContext.IsNull() && !anAISIO.IsNull()) {
902 aContext->Display(anAISIO, 0/*wireframe*/, 0, false/*update viewer*/, true, AIS_DS_Displayed);
904 aContext->Deactivate(anAISIO);
905 aContext->Load(anAISIO);
906 if (toActivateInSelectionModes) {
907 if (aContext->HasOpenedContext()) {
908 if (myActiveSelectionModes.size() == 0)
909 activateAIS(anAISIO, 0, theUpdateViewer);
911 foreach(int aMode, myActiveSelectionModes) {
912 activateAIS(anAISIO, aMode, theUpdateViewer);
923 bool XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool theUpdateViewer)
925 bool aErased = false;
926 Handle(AIS_InteractiveContext) aContext = AISContext();
927 if (!aContext.IsNull()) {
928 Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
929 if (!anAISIO.IsNull() && aContext->IsDisplayed(anAISIO)) {
930 aContext->Remove(anAISIO, false/*update viewer*/);
934 if (aErased && theUpdateViewer)
940 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer)
942 if (theMode == NoMode)
945 Handle(AIS_InteractiveContext) aContext = AISContext();
946 if (aContext.IsNull())
949 AISObjectPtr aAISObj = getAISObject(theObject);
953 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
954 aContext->SetDisplayMode(aAISIO, theMode, false);
955 // Redisplay in order to update new mode because it could be not computed before
960 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
962 Handle(AIS_InteractiveContext) aContext = AISContext();
963 if (aContext.IsNull())
966 AISObjectPtr aAISObj = getAISObject(theObject);
970 Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
971 return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
974 void XGUI_Displayer::deactivateSelectionFilters()
976 Handle(AIS_InteractiveContext) aContext = AISContext();
977 if (!myAndFilter.IsNull()) {
979 if (!aContext.IsNull()) {
980 const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
981 SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
982 for (; anIt.More() && !aFound; anIt.Next()) {
983 Handle(SelectMgr_Filter) aFilter = anIt.Value();
984 aFound = aFilter == myAndFilter;
987 aContext->RemoveFilter(myAndFilter);
989 myAndFilter.Nullify();
993 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
995 Handle(AIS_InteractiveContext) aContext = AISContext();
996 if (aContext.IsNull() || hasSelectionFilter(theFilter))
999 Handle(SelectMgr_CompositionFilter) aCompositeFilter = GetFilter();
1000 if (!aCompositeFilter.IsNull()) {
1001 aCompositeFilter->Add(theFilter);
1002 #ifdef DEBUG_SELECTION_FILTERS
1003 int aCount = aCompositeFilter->StoredFilters().Extent();
1004 qDebug(QString("addSelectionFilter: filters.count() = %1").arg(aCount).toStdString().c_str());
1009 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
1011 Handle(AIS_InteractiveContext) aContext = AISContext();
1012 if (aContext.IsNull())
1015 Handle(SelectMgr_AndFilter) aCompositeFilter = GetFilter();
1016 if (!aCompositeFilter.IsNull() && aCompositeFilter->IsIn(theFilter)) {
1017 aCompositeFilter->Remove(theFilter);
1018 #ifdef DEBUG_SELECTION_FILTERS
1019 int aCount = aCompositeFilter->StoredFilters().Extent();
1020 qDebug(QString("removeSelectionFilter: filters.count() = %1").arg(aCount).toStdString().c_str());
1025 bool XGUI_Displayer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
1027 bool aFilterFound = false;
1029 Handle(AIS_InteractiveContext) aContext = AISContext();
1030 if (aContext.IsNull())
1031 return aFilterFound;
1032 const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
1033 SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
1034 for (; aIt.More() && !aFilterFound; aIt.Next()) {
1035 if (theFilter.Access() == aIt.Value().Access())
1036 aFilterFound = true;
1038 Handle(SelectMgr_CompositionFilter) aCompositeFilter = GetFilter();
1039 if (!aCompositeFilter.IsNull()) {
1040 const SelectMgr_ListOfFilter& aStoredFilters = aCompositeFilter->StoredFilters();
1041 for (aIt.Initialize(aStoredFilters); aIt.More() && !aFilterFound; aIt.Next()) {
1042 if (theFilter.Access() == aIt.Value().Access())
1043 aFilterFound = true;
1046 return aFilterFound;
1049 void XGUI_Displayer::removeFilters()
1051 Handle(AIS_InteractiveContext) aContext = AISContext();
1052 if (aContext.IsNull())
1055 Handle(SelectMgr_CompositionFilter) aCompositeFilter = GetFilter();
1056 if (!aCompositeFilter.IsNull())
1057 aCompositeFilter->Clear();
1060 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
1062 QObjectPtrList aDispList = myResult2AISObjectMap.keys();
1063 foreach(ObjectPtr aObj, aDispList) {
1064 if (!theList.contains(aObj))
1067 foreach(ObjectPtr aObj, theList) {
1068 if (!isVisible(aObj))
1069 display(aObj, false);
1074 bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
1076 if (!isVisible(theObject))
1079 AISObjectPtr aAISObj = getAISObject(theObject);
1080 if (aAISObj.get() == NULL)
1083 Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
1084 return ::canBeShaded(anAIS, myWorkshop->module());
1087 bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
1088 const QIntList& theModes,
1089 const bool theUpdateViewer) const
1091 Handle(AIS_InteractiveContext) aContext = AISContext();
1092 if (aContext.IsNull() || theIO.IsNull())
1095 bool isActivationChanged = false;
1096 // deactivate object in all modes, which are not in the list of activation
1097 // It seems that after the IO deactivation the selected state of the IO's owners
1098 // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
1099 // By this reason, the number of the IO deactivate is decreased and the object is deactivated
1100 // only if there is a difference in the current modes and the parameters modes.
1101 // If the selection problem happens again, it is possible to write a test scenario and create
1102 // a bug. The bug steps are the following:
1103 // Create two IO, activate them in 5 modes, select the first IO, deactivate 3 modes for both,
1104 // with clicked SHIFT select the second object. The result is the selection of the first IO is lost.
1105 TColStd_ListOfInteger aTColModes;
1106 aContext->ActivatedModes(theIO, aTColModes);
1107 TColStd_ListIteratorOfListOfInteger itr( aTColModes );
1108 QIntList aModesActivatedForIO;
1109 bool isDeactivated = false;
1110 for (; itr.More(); itr.Next() ) {
1111 Standard_Integer aMode = itr.Value();
1112 if (!theModes.contains(aMode)) {
1113 deactivateAIS(theIO, aMode);
1114 isDeactivated = true;
1117 aModesActivatedForIO.append(aMode);
1120 if (isDeactivated) {
1121 // the selection from the previous activation modes should be cleared manually (#26172)
1122 theIO->ClearSelected();
1123 aContext->LocalContext()->ClearOutdatedSelection(theIO, true);
1124 // For performance issues
1125 //if (theUpdateViewer)
1127 isActivationChanged = true;
1130 // loading the interactive object allowing the decomposition
1131 if (aTColModes.IsEmpty()) {
1132 aContext->Load(theIO, -1, true);
1135 // trihedron AIS check should be after the AIS loading.
1136 // If it is not loaded, it is steel selectable in the viewer.
1137 Handle(AIS_Trihedron) aTrihedron;
1138 if (!isTrihedronActive())
1139 aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
1140 if (aTrihedron.IsNull()) {
1141 // In order to clear active modes list
1142 if (theModes.size() == 0) {
1143 activateAIS(theIO, 0, theUpdateViewer);
1145 foreach(int aMode, theModes) {
1146 if (!aModesActivatedForIO.contains(aMode)) {
1147 activateAIS(theIO, aMode, theUpdateViewer);
1148 isActivationChanged = true;
1153 return isActivationChanged;
1156 bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
1158 AISObjectPtr anAISObj = getAISObject(theObject);
1159 // correct the result's color it it has the attribute
1160 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
1162 // Customization of presentation
1163 GeomCustomPrsPtr aCustomPrs;
1164 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
1165 if (aFeature.get() != NULL) {
1166 GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
1167 if (aCustPrs.get() != NULL)
1168 aCustomPrs = aCustPrs;
1170 if (aCustomPrs.get() == NULL) {
1171 GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
1172 // we ignore presentable not customized objects
1173 if (aPrs.get() == NULL)
1174 aCustomPrs = myCustomPrs;
1176 bool isCustomized = aCustomPrs.get() &&
1177 aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs);
1178 return isCustomized;
1182 QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject, const QColor& theColor, bool theUpdateViewer)
1184 if (!isVisible(theObject))
1187 AISObjectPtr anAISObj = getAISObject(theObject);
1189 anAISObj->getColor(aR, aG, aB);
1190 anAISObj->setColor(theColor.red(), theColor.green(), theColor.blue());
1191 if (theUpdateViewer)
1193 return QColor(aR, aG, aB);
1196 void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS)
1198 myResult2AISObjectMap[theObject] = theAIS;
1200 #ifdef DEBUG_DISPLAY
1201 std::ostringstream aPtrStr;
1202 aPtrStr << theObject.get();
1203 qDebug(QString("display object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str());
1204 qDebug(getResult2AISObjectMapInfo().c_str());
1208 std::string XGUI_Displayer::getResult2AISObjectMapInfo() const
1210 QStringList aContent;
1211 foreach (ObjectPtr aObj, myResult2AISObjectMap.keys()) {
1212 AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
1213 std::ostringstream aPtrStr;
1214 aPtrStr << "aObj = " << aObj.get() << ":";
1215 aPtrStr << "anAIS = " << aAISObj.get() << ":";
1216 aPtrStr << "[" << ModuleBase_Tools::objectInfo(aObj).toStdString().c_str() << "]";
1218 aContent.append(aPtrStr.str().c_str());
1220 return QString("myResult2AISObjectMap: size = %1\n%2\n").arg(myResult2AISObjectMap.size()).
1221 arg(aContent.join("\n")).toStdString().c_str();
1224 void XGUI_Displayer::activateTrihedron(bool theIsActive)
1226 myIsTrihedronActive = theIsActive;
1227 if (!myIsTrihedronActive) {
1228 deactivateTrihedron(true);
1232 void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
1234 Handle(AIS_InteractiveContext) aContext = AISContext();
1235 if (aContext.IsNull())
1238 Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron();
1241 if (!aContext->IsDisplayed(aTrihedron))
1242 aContext->Display(aTrihedron,
1244 -1 /* selection mode */,
1245 Standard_True /* update viewer*/,
1246 Standard_False /* allow decomposition */,
1247 AIS_DS_Displayed /* xdisplay status */);
1249 if (!isTrihedronActive())
1250 deactivateTrihedron(false);
1252 activate(aTrihedron, myActiveSelectionModes, false);
1254 deactivateTrihedron(false);
1255 //aContext->LocalContext()->ClearOutdatedSelection(aTrihedron, true);
1256 // the selection from the previous activation modes should be cleared manually (#26172)
1258 aContext->Erase(aTrihedron);
1264 QIntList XGUI_Displayer::activeSelectionModes() const
1267 foreach (int aMode, myActiveSelectionModes) {
1268 // aMode < 9 is a Shape Enum values
1269 aModes << ((aMode < 9)? AIS_Shape::SelectionType(aMode) : aMode);
1274 void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
1275 const NCollection_Map<TopoDS_Shape>& theShapesToBeSelected)
1277 Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
1278 TCollection_AsciiString aSelectionName = aLContext->SelectionName();
1279 aLContext->UnhilightPicked(Standard_False);
1281 NCollection_Map<TopoDS_Shape> aShapesSelected;
1283 NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
1284 aLContext->MainSelector()->ActiveOwners(anActiveOwners);
1285 NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
1286 Handle(SelectMgr_EntityOwner) anOwner;
1287 for (; anOwnersIt.More(); anOwnersIt.Next()) {
1288 anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
1289 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
1290 if (!BROwnr.IsNull() && BROwnr->HasShape() && theShapesToBeSelected.Contains(BROwnr->Shape())) {
1291 if (aShapesSelected.Contains(BROwnr->Shape()))
1293 AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
1294 anOwner->SetSelected (Standard_True);
1295 aShapesSelected.Add(BROwnr->Shape());
1298 aLContext->HilightPicked(Standard_False);