1 // Created on: 1996-10-30
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by rob Thu Apr 02 1998
18 // - use of optimisation in SelectMgr_ViewerSelector
19 // -> Best management in detected entities...
21 #define BUC60569 //GG_051199 Enable to select the local context
22 // in any case and especially in multi selection mode.
23 // Note that right now when an hilighted owner is selected
24 // this owner is unhilighted,this permits to see the selection!
25 // Principle : an owner can have 3 state :
26 // 1 : The owner is selected and no more highlightable
27 // 0 : The owner is NOT selected
28 // -1: The owner is selected but stay highlightable (NEW)
30 // IMP230600 //GG Add protection on selection methodes
31 // when nothing is selected
33 #define BUC60726 //GG_040900 When nothing is detected,
34 // Clear the last temporary stuff in any case
36 #define BUC60765 //GG_121000 Avoid to raise when the same selection
37 // is attached to several local context.
39 #define BUC60771 //GG_261000 Avoid to crash after closing a view
40 // containing a selected entity and creating a new one.
42 #define BUC60774 //GG_261000 Returns right select status on
43 // bounding-box selection type.
45 #define BUC60818 //GG_300101 Enable detection even if
46 // SetAutomaticHilight(FALSE) has been used.
48 #define IMP300101 //GG Enable to use polygon highlighting
50 #define BUC60876 //GG_050401 Clear selection always even
51 // if the current highlight mode is not 0.
53 #define BUC60953 //SAV_060701 For Select optimization. Selection by rectangle case.
54 // for single selection no optimization done.
56 #define IMP120701 //SZV made a shape valid for selection
59 #define IMP160701 //SZV Add InitDetected(),MoreDetected(),NextDetected(),
60 // DetectedCurrentShape(),DetectedCurrentObject()
63 #define OCC138 //VTN Avoding infinit loop in AddOrRemoveSelected method.
65 #define OCC189 //SAV: 18/03/02 AIS_Selection::Objects() returns ListOfTransient
68 #define USE_MAP //san : 18/04/03 USE_MAP - additional datamap is used to speed up access
69 //to certain owners in AIS_Selection::myresult list
71 #define OCC9026 //AEL Performance optimization of the FindSelectedOwnerFromShape() method.
73 #include <AIS_LocalContext.jxx>
74 #include <StdSelect_BRepOwner.hxx>
75 #include <TColStd_ListOfInteger.hxx>
76 #include <TColStd_ListIteratorOfListOfInteger.hxx>
77 #include <TColStd_MapOfTransient.hxx>
78 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
79 #include <Prs3d_Presentation.hxx>
80 #include <Prs3d_Drawer.hxx>
81 #include <Prs3d_ShadingAspect.hxx>
82 #include <AIS_LocalStatus.hxx>
83 #include <StdPrs_WFShape.hxx>
84 #include <Graphic3d_ArrayOfTriangles.hxx>
85 #include <Graphic3d_Group.hxx>
86 #include <Select3D_SensitiveTriangulation.hxx>
87 #include <SelectBasics_SensitiveEntity.hxx>
88 #include <TCollection_AsciiString.hxx>
89 #include <NCollection_Map.hxx>
92 #include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
94 #include <SelectMgr_Selection.hxx>
95 #include <SelectMgr_SequenceOfOwner.hxx>
96 #include <OSD_Environment.hxx>
98 #include <Geom_Transformation.hxx>
99 #include <AIS_Selection.hxx>
100 #include <Aspect_Grid.hxx>
102 #include <AIS_Shape.hxx>
106 static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
108 return IO->HasHilightMode() ? IO->HilightMode():0;
111 //==================================================
114 //==================================================
115 AIS_StatusOfDetection AIS_LocalContext::MoveTo (const Standard_Integer theXpix,
116 const Standard_Integer theYpix,
117 const Handle(V3d_View)& theView,
118 const Standard_Boolean theToRedrawImmediate)
120 // check that ViewerSelector gives
121 if (theView->Viewer() != myCTX->CurrentViewer())
123 return AIS_SOD_Error;
126 myAISCurDetected = 0;
127 myAISDetectedSeq.Clear();
130 myDetectedSeq.Clear();
131 myMainVS->Pick (theXpix, theYpix, theView);
133 const Standard_Integer aDetectedNb = myMainVS->NbPicked();
134 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
136 Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (aDetIter);
138 || !myFilters->IsOk (anOwner))
143 myDetectedSeq.Append (aDetIter); // normally they are already arranged in correct order...
144 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
147 myAISDetectedSeq.Append (anObj);
151 // result of courses..
152 if (aDetectedNb == 0 || myDetectedSeq.IsEmpty())
154 if (mylastindex != 0 && mylastindex <= myMapOfOwner.Extent())
156 Unhilight (myMapOfOwner (mylastindex), theView);
157 if (theToRedrawImmediate)
159 theView->RedrawImmediate();
164 return aDetectedNb == 0
169 // all owners detected by the selector are passed to the
170 // filters and correct ones are preserved...
172 Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected));
173 manageDetected (anOwner, theView, theToRedrawImmediate);
174 if (myDetectedSeq.Length() == 1)
176 return aDetectedNb == 1
177 ? AIS_SOD_OnlyOneDetected
178 : AIS_SOD_OnlyOneGood;
182 return AIS_SOD_SeveralGood;
186 //=======================================================================
189 //=======================================================================
190 AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Boolean toUpdateViewer)
194 UnhilightPicked (Standard_False);
197 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
199 Standard_Integer aDetIndex = DetectedIndex();
202 ClearSelected (toUpdateViewer);
203 return (AIS_Selection::Extent() == 0) ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
206 const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (aDetIndex);
208 ClearSelected (Standard_False);
210 if (!anOwner->IsSelected()) // anOwner is not selected
212 anOwner->SetSelected (Standard_True);
213 AIS_Selection::Select (anOwner);
218 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
219 for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
221 Unhilight (anOwner, aViewer->ActiveView());
224 // advanced selection highlighting mechanism
225 if (!anOwner->IsAutoHilight() && anOwner->HasSelectable())
227 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
228 UpdateSelected (anIO, Standard_False);
233 myCTX->CurrentViewer()->Update();
237 return (AIS_Selection::Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected;
240 //=======================================================================
243 //=======================================================================
244 AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Integer theXPMin,
245 const Standard_Integer theYPMin,
246 const Standard_Integer theXPMax,
247 const Standard_Integer theYPMax,
248 const Handle(V3d_View)& theView,
249 const Standard_Boolean toUpdateViewer)
251 if (theView->Viewer() == myCTX->CurrentViewer())
253 myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
256 UnhilightPicked (Standard_False);
259 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
260 Standard_Integer aSelNum = AIS_Selection::Extent();
263 if (!myMainVS->More())
265 ClearSelected (toUpdateViewer);
267 return aSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
270 ClearSelected (Standard_False);
272 for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
274 const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
275 if (myFilters->IsOk (anOwner))
277 // it can be helpful to classify this owner immediately...
278 if (!anOwner->IsSelected())
280 anOwner->SetSelected (Standard_True);
281 AIS_Selection::Select (anOwner);
288 HilightPicked (toUpdateViewer);
292 Standard_Integer aSelNum = AIS_Selection::Extent();
294 return (aSelNum == 1) ? AIS_SOP_OneSelected
295 : (aSelNum > 1) ? AIS_SOP_SeveralSelected
299 //==================================================
301 // Purpose : Selection by polyline
302 //==================================================
303 AIS_StatusOfPick AIS_LocalContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
304 const Handle(V3d_View)& theView,
305 const Standard_Boolean toUpdateViewer)
307 if (theView->Viewer() == myCTX->CurrentViewer())
309 myMainVS->Pick (thePolyline, theView);
311 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
313 Standard_Integer aLastSelNum = AIS_Selection::Extent();
315 if (!myMainVS->More())
317 // Nothing is selected clear selection.
318 ClearSelected (toUpdateViewer);
321 // Return state to know if something was unselected
322 return aLastSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
327 UnhilightPicked (Standard_False);
330 // Clear previous selection without update to process this selection
331 ClearSelected (Standard_False);
333 for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
335 const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
336 if (myFilters->IsOk (anOwner))
338 // it can be helpful to classify this owner immediately...
339 if (!anOwner->IsSelected())
341 AIS_Selection::AddSelect (anOwner);
342 anOwner->SetSelected (Standard_True);
349 HilightPicked (toUpdateViewer);
353 Standard_Integer aSelNum = AIS_Selection::Extent();
354 return (aSelNum == 1) ? AIS_SOP_OneSelected
355 : (aSelNum > 1) ? AIS_SOP_SeveralSelected
359 //=======================================================================
360 //function : ShiftSelect
362 //=======================================================================
363 AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
365 Standard_Integer aDetIndex = DetectedIndex();
366 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
370 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
371 Standard_Integer aSelNum = AIS_Selection::Extent();
372 const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (aDetIndex);
373 Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
374 AIS_Selection::Select (anOwner);
375 anOwner->SetSelected (toSelect);
379 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
380 for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
382 Unhilight (anOwner, aViewer->ActiveView());
385 // advanced selection highlighting mechanism
386 if (!anOwner->IsAutoHilight() && anOwner->HasSelectable())
388 Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
389 UpdateSelected (anIO, Standard_False);
394 myCTX->CurrentViewer()->Update();
399 Standard_Integer NS = AIS_Selection::Extent();
400 if( NS == 1 ) return AIS_SOP_OneSelected;
401 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
402 return aSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
405 return AIS_SOP_Error;
408 //=======================================================================
409 //function : ShiftSelect
411 //=======================================================================
412 AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Integer theXPMin,
413 const Standard_Integer theYPMin,
414 const Standard_Integer theXPMax,
415 const Standard_Integer theYPMax,
416 const Handle(V3d_View)& theView,
417 const Standard_Boolean toUpdateViewer)
419 myMainPM->ClearImmediateDraw();
421 if (theView->Viewer() == myCTX->CurrentViewer())
423 myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
425 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
426 Standard_Integer aLastSelNum = AIS_Selection::Extent();
429 if (!myMainVS->More())
431 // Nothing is selected clear selection, but don't clear the selection
432 // as it is shift selection and previous selection matters.
433 // Return state to know if something was unselected
434 return aLastSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
439 UnhilightPicked (Standard_False);
442 for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
444 const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
445 if(myFilters->IsOk (anOwner))
447 Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
448 AIS_Selection::Select (anOwner);
449 anOwner->SetSelected (toSelect);
455 HilightPicked (toUpdateViewer);
459 Standard_Integer aSelNum = AIS_Selection::Extent();
461 return (aSelNum == 1) ? AIS_SOP_OneSelected
462 : (aSelNum > 1) ? AIS_SOP_SeveralSelected
466 //==================================================
468 // Purpose : Selection by polyline
469 //==================================================
470 AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
471 const Handle(V3d_View)& theView,
472 const Standard_Boolean toUpdateViewer)
474 if (theView->Viewer() == myCTX->CurrentViewer())
476 myMainVS->Pick (thePolyline, theView);
478 AIS_Selection::SetCurrentSelection (mySelName.ToCString());
480 Standard_Integer aLastSelNum = AIS_Selection::Extent();
482 if(!myMainVS->More())
484 // Nothing is selected clear selection, but don't clear the selection
485 // as it is shift selection and previous selection matters.
486 // Return state to know if something was unselected
487 return aLastSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
492 UnhilightPicked (Standard_False);
495 for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
497 const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
498 if (myFilters->IsOk (anOwner))
500 Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
501 AIS_Selection::Select (anOwner);
502 anOwner->SetSelected (toSelect);
507 HilightPicked (toUpdateViewer);
511 Standard_Integer aSelNum = AIS_Selection::Extent();
513 return (aSelNum == 1) ? AIS_SOP_OneSelected
514 : (aSelNum > 1) ? AIS_SOP_SeveralSelected
518 //==================================================
521 //==================================================
522 void AIS_LocalContext::Hilight (const Handle(SelectMgr_EntityOwner)& theOwner,
523 const Handle(V3d_View)& theView)
525 if (theView.IsNull())
530 const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
531 myMainPM->BeginImmediateDraw();
532 theOwner->HilightWithColor (myMainPM, myCTX->HilightColor(), aHilightMode);
533 myMainPM->EndImmediateDraw (theView);
536 //==================================================
537 // Function: Unhilight
539 //==================================================
540 void AIS_LocalContext::Unhilight (const Handle(SelectMgr_EntityOwner)& theOwner,
541 const Handle(V3d_View)& theView)
543 if (theView.IsNull())
548 myMainPM->ClearImmediateDraw();
549 const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
550 if (IsSelected (theOwner))
552 if (theOwner->IsAutoHilight())
554 theOwner->HilightWithColor (myMainPM, myCTX->SelectionColor(), aHilightMode);
559 theOwner->Unhilight (myMainPM, aHilightMode);
563 //=======================================================================
564 //function : HilightPicked
566 //=======================================================================
567 void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
569 Standard_Boolean updMain(Standard_False);
571 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
573 if( Sel.IsNull() ) return;
576 typedef NCollection_DataMap <Handle(SelectMgr_SelectableObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > SelectMgr_DataMapOfObjectOwners;
577 SelectMgr_DataMapOfObjectOwners aMap;
579 Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
581 // to avoid problems when there is a loop searching for selected objects...
582 #if !defined OCC189 && !defined USE_MAP
583 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
584 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++)
586 const Handle(Standard_Transient)& Tr = Obj(i);
588 const AIS_NListTransient& Obj = Sel->Objects();
589 AIS_NListTransient::Iterator anIter( Obj );
590 for(; anIter.More(); anIter.Next())
592 const Handle(Standard_Transient)& Tr = anIter.Value();
595 const Handle(SelectMgr_EntityOwner)& Ownr =
596 *((const Handle(SelectMgr_EntityOwner)*) &Tr);
597 Handle(AIS_InteractiveObject) IO;
598 if(Ownr->HasSelectable()){
599 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
600 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
601 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
602 IO = *((Handle(AIS_InteractiveObject)*)&SO);
603 updMain = Standard_True;
606 updMain = Standard_True;
609 updMain = Standard_True;
610 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
611 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
612 if ( Ownr->IsAutoHilight() )
613 Ownr->HilightWithColor(PM,myCTX->SelectionColor(),HM);
614 else if ( aMap.IsBound (SO) )
615 aMap(SO)->Append ( Ownr );
617 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq = new SelectMgr_SequenceOfOwner;
618 aSeq->Append ( Ownr );
619 aMap.Bind ( SO, aSeq );
624 for ( SelectMgr_DataMapOfObjectOwners::Iterator aMapIter(aMap);
625 aMapIter.More(); aMapIter.Next() )
627 aMapIter.Key()->HilightSelected (myMainPM, *aMapIter.Value());
632 myCTX->CurrentViewer()->Update();
636 //==================================================
639 //==================================================
640 void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer)
642 myMainPM->ClearImmediateDraw();
644 Standard_Boolean updMain(Standard_False);
646 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
648 if( Sel.IsNull() ) return;
650 Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
651 NCollection_Map<Handle(SelectMgr_SelectableObject)> anObjMap;
653 #if !defined OCC189 && !defined USE_MAP
654 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
655 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
656 const Handle(Standard_Transient)& Tr = Obj(i);
658 const AIS_NListTransient& Obj = Sel->Objects();
659 AIS_NListTransient::Iterator anIter( Obj );
660 for(; anIter.More(); anIter.Next()){
661 const Handle(Standard_Transient)& Tr = anIter.Value();
664 const Handle(SelectMgr_EntityOwner)& Ownr =
665 *((const Handle(SelectMgr_EntityOwner)*) &Tr);
666 Standard_Integer HM(0);
667 if(Ownr->HasSelectable()){
669 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
670 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
675 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
676 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
678 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
679 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
682 updMain = Standard_True;
685 updMain = Standard_True;
687 Ownr->Unhilight(PM,HM);
691 for (NCollection_Map<Handle(SelectMgr_SelectableObject)>::Iterator anIter1 ( anObjMap );
692 anIter1.More(); anIter1.Next() )
694 if ( !anIter1.Key()->IsAutoHilight() )
695 anIter1.Key()->ClearSelected();
700 myCTX->CurrentViewer()->Update();
702 if(updMain) myCTX->CurrentViewer()->Update();
708 //=======================================================================
709 //function : IsSelected
711 //=======================================================================
712 Standard_Boolean AIS_LocalContext::IsSelected(const Handle(AIS_InteractiveObject)& anIObj) const
714 return (!FindSelectedOwnerFromIO(anIObj).IsNull());
717 //=======================================================================
718 //function : IsSelected
720 //=======================================================================
722 Standard_Boolean AIS_LocalContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
724 return !theOwner.IsNull() && theOwner->IsSelected();
727 //==================================================
730 //==================================================
731 void AIS_LocalContext::
734 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
735 AIS_Selection::CurrentSelection()->Init();
738 //==================================================
741 //==================================================
742 Standard_Boolean AIS_LocalContext::
745 return AIS_Selection::CurrentSelection()->More();
748 //==================================================
751 //==================================================
752 void AIS_LocalContext::
755 AIS_Selection::CurrentSelection()->Next();
758 //==================================================
761 //==================================================
762 Standard_Boolean AIS_LocalContext::
765 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
766 if( Tr.IsNull() ) return Standard_False;
767 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
768 Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
769 if(BRO.IsNull()) return Standard_False;
770 Standard_Boolean hasshape = BRO->HasShape();
771 Standard_Boolean comes = BRO->ComesFromDecomposition();
772 return (hasshape&&comes);
775 //==================================================
778 //==================================================
779 TopoDS_Shape AIS_LocalContext::SelectedShape() const
781 Handle(Standard_Transient) aTr = AIS_Selection::CurrentSelection()->Value();
782 Handle(SelectMgr_EntityOwner) anEO = *((Handle(SelectMgr_EntityOwner)*)&aTr);
783 Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(anEO);
786 return TopoDS_Shape();
788 return aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
791 //==================================================
794 //==================================================
795 Handle(AIS_InteractiveObject) AIS_LocalContext::
796 SelectedInteractive() const
798 Handle(AIS_InteractiveObject) IO;
799 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
801 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
802 Handle(SelectMgr_SelectableObject) SO;
803 if(EO->HasSelectable()){
804 SO = EO->Selectable();
805 IO = *((Handle(AIS_InteractiveObject)*)&SO);
810 //==================================================
813 //==================================================
814 Handle(SelectMgr_EntityOwner) AIS_LocalContext::
815 SelectedOwner() const
817 Handle(SelectMgr_EntityOwner) EO;
818 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
820 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
824 //==================================================
827 //==================================================
828 Standard_Boolean AIS_LocalContext::
829 HasApplicative() const
831 Handle(AIS_InteractiveObject) IO = SelectedInteractive();
832 if( IO.IsNull() ) return Standard_False;
833 return IO->HasOwner();
836 //==================================================
839 //==================================================
840 const Handle(Standard_Transient)& AIS_LocalContext::
841 SelectedApplicative() const
843 return SelectedInteractive()->GetOwner();
848 //=======================================================================
849 //function : UpdateSelection
850 //purpose : should disappear...
851 //=======================================================================
852 void AIS_LocalContext::UpdateSelected(const Standard_Boolean updateviewer)
854 UnhilightPicked(Standard_False);
855 HilightPicked(updateviewer);
858 //================================================================
859 // Function : UpdateSelected
860 // Purpose : Part of advanced selection mechanism.
861 // Highlightes or clears selection presentation for the given IO
862 //================================================================
863 void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj,
864 const Standard_Boolean updateviewer)
866 if (anobj.IsNull() || anobj->IsAutoHilight())
869 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
870 Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
872 SelectMgr_SequenceOfOwner aSeq;
873 for ( Sel->Init(); Sel->More(); Sel->Next() ){
874 Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(Sel->Value());
876 if ( !aOwner.IsNull() && aOwner->HasSelectable() && aOwner->Selectable() == anobj )
877 aSeq.Append( aOwner );
881 anobj->HilightSelected( myMainPM, aSeq );
883 anobj->ClearSelected();
886 myCTX->CurrentViewer()->Update();
890 //==================================================
891 // Function: ClearSelected
893 //==================================================
894 void AIS_LocalContext::ClearSelected (const Standard_Boolean updateviewer)
896 UnhilightPicked(updateviewer);
897 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
899 Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
900 #if !defined OCC189 && !defined USE_MAP
901 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
902 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
903 const Handle(Standard_Transient)& Tr = Obj(i);
905 const AIS_NListTransient& Obj = Sel->Objects();
906 AIS_NListTransient::Iterator anIter( Obj );
907 for(; anIter.More(); anIter.Next()){
908 const Handle(Standard_Transient)& Tr = anIter.Value();
912 (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False);
915 AIS_Selection::Select();
919 //==================================================
920 // Function: ClearOutdatedSelection
922 //==================================================
923 void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObject)& theIO,
924 const Standard_Boolean toClearDeactivated)
926 // 1. Collect selectable entities
927 SelectMgr_IndexedMapOfOwner aValidOwners;
929 const TColStd_ListOfInteger& aModes = SelectionModes (theIO);
931 TColStd_ListIteratorOfListOfInteger aModeIter (aModes);
932 for (; aModeIter.More(); aModeIter.Next())
934 int aMode = aModeIter.Value();
935 if (!theIO->HasSelection(aMode))
940 if (toClearDeactivated && !mySM->IsActivated (theIO, myMainVS, aMode))
945 Handle(SelectMgr_Selection) aSelection = theIO->Selection(aMode);
946 for (aSelection->Init(); aSelection->More(); aSelection->Next())
948 Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive();
949 if (anEntity.IsNull())
954 Handle(SelectMgr_EntityOwner) anOwner =
955 Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
957 if (anOwner.IsNull())
962 aValidOwners.Add(anOwner);
966 // 2. Refresh context's detection and selection and keep only active owners
967 // Keep last detected object for lastindex initialization.
968 Handle(SelectMgr_EntityOwner) aLastPicked = myMainVS->OnePicked();
970 // Remove entity owners from detected sequences
971 for (Standard_Integer anIdx = 1; anIdx <= myDetectedSeq.Length(); ++anIdx)
973 Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (anIdx));
974 if (anOwner.IsNull() || anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
979 myDetectedSeq.Remove (anIdx--);
981 if (anIdx < myCurDetected)
986 myCurDetected = Max (myCurDetected, 1);
988 Standard_Boolean isAISRemainsDetected = Standard_False;
990 // 3. Remove entity owners from AIS_Selection
991 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
992 Handle(AIS_Selection) aSelection = AIS_Selection::Selection (mySelName.ToCString());
993 AIS_NListTransient::Iterator anIter (aSelection->Objects());
994 AIS_NListTransient aRemoveEntites;
995 for (; anIter.More(); anIter.Next())
997 Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anIter.Value());
998 if (anOwner.IsNull() || anOwner->Selectable() != theIO)
1003 if (aValidOwners.Contains (anOwner))
1005 isAISRemainsDetected = Standard_True;
1008 aRemoveEntites.Append (anOwner);
1009 anOwner->SetSelected (Standard_False);
1010 for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
1012 Unhilight (anOwner, aViewer->ActiveView());
1016 AIS_NListTransient::Iterator anIterRemove (aRemoveEntites);
1017 for (; anIterRemove.More(); anIterRemove.Next())
1019 aSelection->Select (anIterRemove.Value());
1022 // 4. Remove entity owners from myMapOfOwner
1023 SelectMgr_IndexedMapOfOwner anOwnersToKeep;
1024 for (Standard_Integer anIdx = 1; anIdx <= myMapOfOwner.Extent(); anIdx++)
1026 Handle(SelectMgr_EntityOwner) anOwner = myMapOfOwner (anIdx);
1027 if (anOwner.IsNull())
1032 if (anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
1034 anOwnersToKeep.Add (anOwner);
1038 for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
1040 Unhilight (anOwner, aViewer->ActiveView());
1044 myMapOfOwner.Clear();
1045 myMapOfOwner.Assign (anOwnersToKeep);
1046 mylastindex = myMapOfOwner.FindIndex (aLastPicked);
1048 if (!isAISRemainsDetected)
1050 // Remove the interactive object from detected sequences
1051 for (Standard_Integer anIdx = 1; anIdx <= myAISDetectedSeq.Length(); ++anIdx)
1053 Handle(AIS_InteractiveObject) aDetectedIO = myAISDetectedSeq.Value (anIdx);
1054 if (aDetectedIO.IsNull() || aDetectedIO != theIO)
1059 myAISDetectedSeq.Remove (anIdx--);
1061 if (anIdx < myAISCurDetected)
1066 myAISCurDetected = Max (myAISCurDetected, 1);
1070 //=======================================================================
1071 //function : SetSelected
1073 //=======================================================================
1074 void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,
1075 const Standard_Boolean updateviewer)
1077 if(!IsValidForSelection(anIObj)) return;
1078 UnhilightPicked(Standard_False);
1080 //1st case, owner already <anIObj> as owner
1081 // and not separated is found...
1083 Handle(AIS_Selection) sel = AIS_Selection::Selection(mySelName.ToCString());
1084 //Standard_Boolean found(Standard_False);
1085 Handle(Standard_Transient) Tr;
1086 Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromIO(anIObj);
1088 //check if in selection number 0 there is an owner that can be triturated...
1089 if(anIObj->HasSelection(0)){
1090 const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
1093 Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
1094 EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
1098 EO = new SelectMgr_EntityOwner(anIObj);
1101 ClearSelected(Standard_False);
1103 AIS_Selection::Select(EO);
1104 EO->SetSelected (Standard_True);
1106 HilightPicked(updateviewer);
1109 //=======================================================================
1110 //function : AddOrRemoveSelected
1112 //=======================================================================
1114 void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& anIObj,
1115 const Standard_Boolean updateviewer)
1117 if(!IsValidForSelection(anIObj)) return;
1118 UnhilightPicked(Standard_False);
1119 // first check if it is selected...
1120 Handle(SelectMgr_EntityOwner) EO;
1122 EO = FindSelectedOwnerFromIO(anIObj);
1126 if(anIObj->HasSelection(0))
1128 const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
1132 Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
1133 EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
1138 EO = new SelectMgr_EntityOwner(anIObj);
1142 // cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<<mySelName<<endl;
1143 const Handle(AIS_Selection)& S = AIS_Selection::Selection(mySelName.ToCString());
1147 AIS_SelectStatus aStatus = S->Select(EO);
1148 EO->SetSelected (aStatus == AIS_SS_Added);
1151 HilightPicked(updateviewer);
1154 //=======================================================================
1155 //function : AddOrRemoveSelected
1156 //purpose : To check...
1157 //=======================================================================
1158 void AIS_LocalContext::AddOrRemoveSelected(const TopoDS_Shape& Sh,
1159 const Standard_Boolean updateviewer)
1161 UnhilightPicked (Standard_False);
1162 Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromShape(Sh);
1165 AIS_Selection::Selection(mySelName.ToCString())->Select(EO);
1166 EO->SetSelected (Standard_True);
1168 HilightPicked (updateviewer);
1171 void AIS_LocalContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1172 const Standard_Boolean toUpdateViewer)
1176 UnhilightPicked (Standard_False);
1179 Standard_Boolean toSelect = theOwner->IsSelected() ? Standard_False : Standard_True;
1181 AIS_Selection::Selection (mySelName.ToCString())->Select (theOwner);
1182 theOwner->SetSelected (toSelect);
1186 HilightPicked (toUpdateViewer);
1190 //==================================================
1191 // Function: manageDetected
1193 //==================================================
1194 void AIS_LocalContext::manageDetected (const Handle(SelectMgr_EntityOwner)& thePickOwner,
1195 const Handle(V3d_View)& theView,
1196 const Standard_Boolean theToRedrawImmediate)
1198 if (thePickOwner.IsNull())
1200 if (theToRedrawImmediate)
1202 theView->RedrawImmediate();
1207 if (!myFilters->IsOk (thePickOwner))
1209 if (mylastindex != 0)
1211 mylastgood = mylastindex;
1213 if (theToRedrawImmediate)
1215 theView->RedrawImmediate();
1220 //=======================================================================================================
1221 // 2 cases : a- object is in the map of picks:
1222 // 1. this is the same index as the last detected: -> Do nothing
1224 // - if lastindex = 0 (no object was detected at the last step)
1225 // the object presentation is highlighted and lastindex = index(objet)
1227 // the presentation of the object corresponding to lastindex is "unhighlighted"
1228 // it is removed if the object is not visualized but only active
1229 // then the presentation of the detected object is highlighted and lastindex = index(objet)
1230 // b- the object is not in the map of picked objects
1231 // - if lastindex != 0 (object detected at the last step) it is unhighlighted ...
1232 // if the object was decomposed, presentation is created for the detected shape and the couple
1233 // (Proprietaire,Prs)is added in the map.
1234 // otherwise the couple(proprietaire, NullPrs) is placed in the map and the interactive object
1235 // itself is highlighted.
1237 //=======================================================================================================
1239 const Standard_Integer aNewIndex = myMapOfOwner.Contains (thePickOwner)
1240 ? myMapOfOwner.FindIndex (thePickOwner)
1241 : myMapOfOwner.Add (thePickOwner);
1243 // For the advanced mesh selection mode the owner indices comparison
1244 // is not effective because in that case only one owner manage the
1245 // selection in current selection mode. It is necessary to check the current detected
1246 // entity and hilight it only if the detected entity is not the same as
1247 // previous detected (IsForcedHilight call)
1248 if (aNewIndex != mylastindex
1249 || thePickOwner->IsForcedHilight())
1251 if (mylastindex != 0
1252 && mylastindex <= myMapOfOwner.Extent())
1254 const Handle(SelectMgr_EntityOwner)& aLastOwner = myMapOfOwner (mylastindex);
1255 Unhilight (aLastOwner, theView);
1260 if (!thePickOwner->IsSelected() || myCTX->ToHilightSelected())
1262 Hilight (thePickOwner, theView);
1264 if (theToRedrawImmediate)
1266 theView->RedrawImmediate();
1270 mylastindex = aNewIndex;
1275 mylastgood = mylastindex;
1279 //=======================================================================
1280 //function : HasDetectedShape
1282 //=======================================================================
1284 Standard_Boolean AIS_LocalContext::HasDetectedShape() const
1286 if(mylastindex==0) return Standard_False;
1287 return IsShape(mylastindex);
1290 //=======================================================================
1291 //function : DetectedShape
1293 //=======================================================================
1296 AIS_LocalContext::DetectedShape() const
1298 static TopoDS_Shape bidsh;
1299 if(mylastindex != 0)
1301 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner(mylastindex));
1302 if(BROwnr.IsNull()) return bidsh;
1303 return BROwnr->Shape();
1308 //=======================================================================
1309 //function : DetectedInteractive
1311 //=======================================================================
1313 Handle(AIS_InteractiveObject)
1314 AIS_LocalContext::DetectedInteractive() const
1316 Handle(AIS_InteractiveObject) Iobj;
1317 if(IsValidIndex(mylastindex)){
1318 Handle(SelectMgr_SelectableObject) SO = myMapOfOwner.FindKey(mylastindex)->Selectable();
1319 Iobj = *((Handle(AIS_InteractiveObject)*) &SO);
1323 //=======================================================================
1324 //function : DetectedInteractive
1326 //=======================================================================
1327 Handle(SelectMgr_EntityOwner) AIS_LocalContext::DetectedOwner() const
1329 Handle(SelectMgr_EntityOwner) bid;
1330 if(!IsValidIndex(mylastindex)) return bid;
1331 return myMapOfOwner.FindKey(mylastindex);
1335 //=======================================================================
1336 //function : ComesFromDecomposition
1338 //=======================================================================
1340 Standard_Boolean AIS_LocalContext::ComesFromDecomposition(const Standard_Integer PickedIndex) const
1342 const Handle(SelectMgr_EntityOwner)& OWN = myMapOfOwner.FindKey(PickedIndex);
1343 Handle(SelectMgr_SelectableObject) aSel = OWN->Selectable();
1344 if (myActiveObjects.IsBound (aSel)) { // debug of jmi
1345 const Handle(AIS_LocalStatus)& Stat = myActiveObjects(aSel);
1346 return Stat->Decomposed();
1348 return Standard_False;
1352 //=======================================================================
1353 //function : DisplayAreas
1355 //=======================================================================
1357 void AIS_LocalContext::DisplayAreas(const Handle(V3d_View)& aviou)
1359 myMainVS->DisplayAreas(aviou);
1362 //=======================================================================
1363 //function : ClearAreas
1365 //=======================================================================
1367 void AIS_LocalContext::ClearAreas(const Handle(V3d_View)& aviou)
1369 myMainVS->ClearAreas(aviou);
1372 //=======================================================================
1373 //function : DisplaySensitive
1375 //=======================================================================
1377 void AIS_LocalContext::DisplaySensitive(const Handle(V3d_View)& aviou)
1379 myMainVS->DisplaySensitive(aviou);
1382 //=======================================================================
1383 //function : ClearSensitive
1385 //=======================================================================
1387 void AIS_LocalContext::ClearSensitive(const Handle(V3d_View)& aviou)
1389 myMainVS->ClearSensitive(aviou);
1393 //=======================================================================
1394 //function : IsShape
1396 //=======================================================================
1397 Standard_Boolean AIS_LocalContext::IsShape(const Standard_Integer Index) const
1400 if(Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner.FindKey(Index)).IsNull())
1401 return Standard_False;
1403 ComesFromDecomposition(Index);
1406 Standard_Boolean AIS_LocalContext::IsValidForSelection(const Handle(AIS_InteractiveObject)& anIObj) const
1410 // Shape was not transfered from AIS_Shape to EntityOwner
1411 Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(anIObj);
1412 if( !shape.IsNull() )
1413 return myFilters->IsOk(new StdSelect_BRepOwner(shape->Shape(),shape));
1415 return myFilters->IsOk(new SelectMgr_EntityOwner(anIObj));
1419 //=======================================================================
1420 //function : HilightNextDetected
1422 //=======================================================================
1423 Standard_Integer AIS_LocalContext::HilightNextDetected (const Handle(V3d_View)& theView,
1424 const Standard_Boolean theToRedrawImmediate)
1426 // go to the next owner
1427 if (myDetectedSeq.IsEmpty())
1432 const Standard_Integer aLen = myDetectedSeq.Length();
1433 if (++myCurDetected > aLen)
1437 Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected));
1438 if (anOwner.IsNull())
1442 manageDetected (anOwner, theView, theToRedrawImmediate);
1443 return myCurDetected;
1446 //=======================================================================
1447 //function : HilightPreviousDetected
1449 //=======================================================================
1450 Standard_Integer AIS_LocalContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1451 const Standard_Boolean theToRedrawImmediate)
1453 if (myDetectedSeq.IsEmpty())
1458 if (--myCurDetected < 1)
1462 Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected));
1463 if (anOwner.IsNull())
1468 manageDetected (anOwner, theView, theToRedrawImmediate);
1469 return myCurDetected;
1472 //=======================================================================
1473 //function : UnhilightLastDetected
1475 //=======================================================================
1476 Standard_Boolean AIS_LocalContext::UnhilightLastDetected (const Handle(V3d_View)& theView)
1478 if (!IsValidIndex (mylastindex))
1480 return Standard_False;
1483 myMainPM->BeginImmediateDraw();
1484 const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (mylastindex);
1485 const Standard_Integer aHilightMode = anOwner->HasSelectable()
1486 ? GetHiMod (Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()))
1489 myMapOfOwner (mylastindex)->Unhilight (myMainPM, aHilightMode);
1490 myMainPM->EndImmediateDraw (theView);
1492 return Standard_True;
1495 //=======================================================================
1496 //function : FindSelectedOwnerFromIO
1497 //purpose : it is checked if one of the selected owners really presents IObj
1498 //=======================================================================
1499 Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO
1500 (const Handle(AIS_InteractiveObject)& anIObj) const
1502 Handle(SelectMgr_EntityOwner) EO,bid;
1503 if (anIObj.IsNull()) return EO;
1505 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
1508 cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "
1509 <<mySelName<<" Nulle "<<endl;
1513 Standard_Boolean found(Standard_False);
1514 #if !defined OCC189 && !defined USE_MAP
1515 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
1516 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
1517 const Handle(Standard_Transient)& Tr = Obj(i);
1519 const AIS_NListTransient& Obj = Sel->Objects();
1520 AIS_NListTransient::Iterator anIter( Obj );
1521 for(; anIter.More(); anIter.Next()){
1522 const Handle(Standard_Transient)& Tr = anIter.Value();
1525 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
1526 if(EO->HasSelectable()){
1527 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
1528 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
1529 if (anIObj == EO->Selectable()){
1530 found =Standard_True;
1537 if(found) return EO;
1541 //=======================================================================
1542 //function : FindSelectedOwnerFromShape
1543 //purpose : it is checked if one of the selected owners really presents IObj
1544 //=======================================================================
1545 Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const TopoDS_Shape& sh) const
1548 Handle(SelectMgr_EntityOwner) EO, bid;
1550 Handle(SelectMgr_EntityOwner) EO;
1552 if (sh.IsNull()) return EO;
1554 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
1557 cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<<mySelName<<" Nulle "<<endl;
1562 Standard_Boolean found(Standard_False);
1566 SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive aSensitiveIt (myMainVS->Primitives());
1567 for (; aSensitiveIt.More(); aSensitiveIt.Next()) {
1568 EO = Handle(SelectMgr_EntityOwner)::DownCast (aSensitiveIt.Value()->OwnerId());
1569 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
1570 if (!BROwnr.IsNull() && BROwnr->HasShape() && BROwnr->Shape() == sh) {
1571 found = Standard_True;
1577 #if !defined OCC189 && !defined USE_MAP
1578 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
1579 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
1580 const Handle(Standard_Transient)& Tr = Obj(i);
1582 const AIS_NListTransient& Obj = Sel->Objects();
1583 AIS_NListTransient::Iterator anIter( Obj );
1584 for(; anIter.More(); anIter.Next()){
1585 const Handle(Standard_Transient)& Tr = anIter.Value();
1589 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
1591 if ( EO->Shape() == sh)
1592 found =Standard_True;
1598 if(found) return EO;
1603 //=======================================================================
1604 //function : AIS_LocalContext::InitDetected
1606 //=======================================================================
1607 void AIS_LocalContext::InitDetected()
1609 myAISCurDetected = myAISDetectedSeq.Length()? 1 : 0;
1612 //=======================================================================
1613 //function : AIS_LocalContext::MoreDetected
1615 //=======================================================================
1616 Standard_Boolean AIS_LocalContext::MoreDetected() const
1618 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length());
1621 //=======================================================================
1622 //function : AIS_LocalContext::NextDetected
1624 //=======================================================================
1625 void AIS_LocalContext::NextDetected()
1630 //=======================================================================
1631 //function : DetectedCurrentShape
1633 //=======================================================================
1634 const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const
1636 static TopoDS_Shape aDummyShape;
1638 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1640 if (aCurrentShape.IsNull())
1645 return aCurrentShape->Shape();
1647 //=======================================================================
1648 //function : DetectedCurrentObject
1650 //=======================================================================
1651 Handle(AIS_InteractiveObject) AIS_LocalContext::DetectedCurrentObject() const
1653 return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;