1 // Copyright: Matra-Datavision 1996
2 // File: AIS_LocalContext_1.cxx
3 // Created: Wed Oct 30 11:09:05 1996
4 // Author: Robert COUBLANC
6 // Modified by rob Thu Apr 02 1998
7 // - use of optimisation in SelectMgr_ViewerSelector
8 // -> Best management in detected entities...
10 #define BUC60569 //GG_051199 Enable to select the local context
11 // in any case and especially in multi selection mode.
12 // Note that right now when an hilighted owner is selected
13 // this owner is unhilighted,this permits to see the selection!
14 // Principle : an owner can have 3 state :
15 // 1 : The owner is selected and no more highlightable
16 // 0 : The owner is NOT selected
17 // -1: The owner is selected but stay highlightable (NEW)
19 // IMP230600 //GG Add protection on selection methodes
20 // when nothing is selected
22 #define BUC60726 //GG_040900 When nothing is detected,
23 // Clear the last temporary stuff in any case
25 #define BUC60765 //GG_121000 Avoid to raise when the same selection
26 // is attached to several local context.
28 #define BUC60771 //GG_261000 Avoid to crash after closing a view
29 // containing a selected entity and creating a new one.
31 #define BUC60774 //GG_261000 Returns right select status on
32 // bounding-box selection type.
34 #define BUC60818 //GG_300101 Enable detection even if
35 // SetAutomaticHilight(FALSE) has been used.
37 #define IMP300101 //GG Enable to use polygon highlighting
39 #define BUC60863 //GG_270301 Clear hilight soon after selecting or
40 // unselecting something in Local Context mode.
42 #define BUC60876 //GG_050401 Clear selection always even
43 // if the current highlight mode is not 0.
45 #define BUC60953 //SAV_060701 For Select optimization. Selection by rectangle case.
46 // for single selection no optimization done.
48 #define IMP120701 //SZV made a shape valid for selection
51 #define IMP160701 //SZV Add InitDetected(),MoreDetected(),NextDetected(),
52 // DetectedCurrentShape(),DetectedCurrentObject()
55 #define OCC138 //VTN Avoding infinit loop in AddOrRemoveSelected method.
57 #define OCC189 //SAV: 18/03/02 AIS_Selection::Objects() returns ListOfTransient
60 #define USE_MAP //san : 18/04/03 USE_MAP - additional datamap is used to speed up access
61 //to certain owners in AIS_Selection::myresult list
63 #define IMP120402 // GG : Add protection in manual detection methods
64 // after deselecting any item using ShiftSelect action.
65 // Thanks to Ivan FONTAINE of SAMTECH company
67 #define IMP051001 //GG manage Z detection
69 #define OCC9026 //AEL Performance optimization of the FindSelectedOwnerFromShape() method.
71 #include <AIS_LocalContext.jxx>
72 #include <StdSelect_BRepOwner.hxx>
73 #include <TColStd_MapOfTransient.hxx>
74 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
75 #include <Prs3d_Presentation.hxx>
76 #include <Prs3d_Drawer.hxx>
77 #include <Prs3d_ShadingAspect.hxx>
78 #include <AIS_LocalStatus.hxx>
79 #include <StdPrs_WFShape.hxx>
80 #include <Visual3d_TransientManager.hxx>
81 #include <Graphic3d_Array1OfVertex.hxx>
82 #include <Graphic3d_Group.hxx>
83 #include <Select3D_SensitiveTriangulation.hxx>
84 #include <SelectBasics_SensitiveEntity.hxx>
85 #include <TCollection_AsciiString.hxx>
87 #include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
89 #include <SelectMgr_Selection.hxx>
90 #include <OSD_Environment.hxx>
91 #include <SelectMgr_DataMapOfObjectOwners.hxx>
93 #include <Geom_Transformation.hxx>
94 #include <AIS_Selection.hxx>
96 #include <AIS_Shape.hxx>
100 static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
102 return IO->HasHilightMode() ? IO->HilightMode():0;
105 //==================================================
108 //==================================================
109 AIS_StatusOfDetection AIS_LocalContext::MoveTo(const Standard_Integer Xpix,
110 const Standard_Integer Ypix,
111 const Handle(V3d_View)& aview)
113 // check that ViewerSelector gives
114 if(aview->Viewer()== myCTX->CurrentViewer()) {
116 //Nullify class members storing information about detected AIS objects.
117 myAISCurDetected = 0;
118 myAISDetectedSeq.Clear();
121 myDetectedSeq.Clear();
122 myMainVS->Pick(Xpix,Ypix,aview);
123 Standard_Boolean had_nothing = myMainVS->NbPicked()==0;
124 Standard_Integer NbDetected = myMainVS->NbPicked();
125 Handle(SelectMgr_EntityOwner) EO;
127 for(Standard_Integer i_detect = 1;i_detect<=NbDetected;i_detect++){
128 EO = myMainVS->Picked(i_detect);
130 if(myFilters->IsOk(EO)) {
131 myDetectedSeq.Append(i_detect); // normallly they are already arranged in correct order...
133 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
134 if(!Handle(AIS_Shape)::DownCast(anObj).IsNull())
135 myAISDetectedSeq.Append(anObj);
141 //result of courses..
142 if(had_nothing || myDetectedSeq.IsEmpty()){
143 if(mylastindex !=0 && mylastindex <= myMapOfOwner.Extent()){
146 Unhilight(myMapOfOwner(mylastindex),aview);
148 if(!IsSelected(myMapOfOwner(mylastindex)))
149 Unhilight(myMapOfOwner(mylastindex),aview);
153 return (had_nothing ? AIS_SOD_Nothing : AIS_SOD_AllBad);
156 // all owners detected by the selector are passed to the
157 // filters and correct ones are preserved...
159 EO = myMainVS->Picked(myDetectedSeq(myCurDetected));
161 static Standard_Boolean Normal_State(Standard_True);
162 static Standard_Boolean firsttime(Standard_True);
164 OSD_Environment toto("HITRI");
165 if(!toto.Value().IsEmpty())
166 Normal_State = Standard_False;
167 firsttime = Standard_False;
171 ManageDetected(EO,aview);
173 HilightTriangle(1,aview);
175 if(myDetectedSeq.Length() == 1){
177 return AIS_SOD_OnlyOneDetected;
179 return AIS_SOD_OnlyOneGood;
182 return AIS_SOD_SeveralGood;
186 return AIS_SOD_Error;
189 //==================================================
192 //==================================================
193 AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Boolean updateviewer)
196 UnhilightPicked(Standard_False);
198 Standard_Integer DI = DetectedIndex();
199 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
200 Standard_Integer NbSel = AIS_Selection::Extent();
203 ClearSelected(updateviewer);
204 return NbSel== 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
207 const Handle(SelectMgr_EntityOwner)& EO = myMapOfOwner(DI);
210 ClearSelected(Standard_False);
211 Standard_Integer state = EO->State();
214 if( state == 0 ) AIS_Selection::Select(EO);
218 AIS_Selection::ClearAndSelect(EO);
223 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
224 for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
225 Unhilight(EO, aViewer->ActiveView());
227 // san - advanced selection highlighting mechanism
228 if (!EO->IsAutoHilight() && EO->HasSelectable()){
229 Handle(AIS_InteractiveObject) anIO =
230 Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
231 UpdateSelected(anIO, Standard_False);
235 myCTX->CurrentViewer()->Update();
237 HilightPicked(updateviewer);
240 return ( AIS_Selection::Extent() == 1)? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected ;
242 //==================================================
245 //==================================================
246 AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Integer XPMin,
247 const Standard_Integer YPMin,
248 const Standard_Integer XPMax,
249 const Standard_Integer YPMax,
250 const Handle(V3d_View)& aView,
251 const Standard_Boolean updateviewer)
253 if(aView->Viewer()== myCTX->CurrentViewer()){
254 myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView);
255 if (myAutoHilight) UnhilightPicked(Standard_False);
257 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
258 Standard_Integer LastExt = AIS_Selection::Extent();
261 if(!myMainVS->More()) {
262 ClearSelected(updateviewer);
264 return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed;
267 ClearSelected(Standard_False);
269 for(myMainVS->Init();myMainVS->More();myMainVS->Next()){
270 const Handle(SelectMgr_EntityOwner)& OWNR = myMainVS->Picked();
271 if(myFilters->IsOk(OWNR)){
272 // it can be helpfil to classify this owner immediately...
274 Standard_Integer state = OWNR->State();
277 if( state == 0 ) AIS_Selection::Select(OWNR);
281 if( state == 0 ) AIS_Selection::Select(OWNR);
285 if(!IsSelected(OWNR)){
287 AIS_Selection::Select(OWNR);
293 HilightPicked(updateviewer);
296 Standard_Integer NS = AIS_Selection::Extent();
297 if( NS == 1 ) return AIS_SOP_OneSelected;
298 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
300 return AIS_SOP_Error;
305 //==================================================
308 //==================================================
309 AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Boolean updateviewer)
311 Standard_Integer I = DetectedIndex();
315 UnhilightPicked(Standard_False);
318 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
320 Standard_Integer NbSel = AIS_Selection::Extent();
322 const Handle(SelectMgr_EntityOwner)& EO = myMapOfOwner(I);
324 Standard_Integer mod = EO->State()==0 ? -1 : 0;
326 Standard_Integer mod = EO->State()==0 ? 1 : 0;
330 AIS_Selection::Select(EO);
335 AIS_Selection::Select(EO);
340 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
341 for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
342 Unhilight(EO, aViewer->ActiveView());
344 // san - advanced selection highlighting mechanism
345 if (!EO->IsAutoHilight() && EO->HasSelectable()){
346 Handle(AIS_InteractiveObject) anIO =
347 Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
348 UpdateSelected(anIO, Standard_False);
352 myCTX->CurrentViewer()->Update();
354 HilightPicked(updateviewer);
358 Standard_Integer NS = AIS_Selection::Extent();
359 if( NS == 1 ) return AIS_SOP_OneSelected;
360 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
361 return NbSel== 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
364 return AIS_SOP_Error;
366 //==================================================
367 // Function: the already selected objects are unselected
368 // Purpose : others are selected.
369 //==================================================
370 AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Integer XPMin,
371 const Standard_Integer YPMin,
372 const Standard_Integer XPMax,
373 const Standard_Integer YPMax,
374 const Handle(V3d_View)& aView,
375 const Standard_Boolean updateviewer)
377 if(aView->Viewer()== myCTX->CurrentViewer()) {
378 myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView);
380 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
381 Standard_Integer LastExt = AIS_Selection::Extent();
384 if(!myMainVS->More())
386 return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed;
388 return AIS_SOP_NothingSelected; // no effet if click on empty space
391 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
392 if (myAutoHilight) UnhilightPicked(Standard_False);
394 for(myMainVS->Init();myMainVS->More();myMainVS->Next()){
395 const Handle(SelectMgr_EntityOwner)& EO = myMainVS->Picked();
396 if(myFilters->IsOk(EO)){
398 Standard_Integer mod = EO->State()==0 ? -1 : 0;
400 Standard_Integer mod = EO->State()==0 ? 1 : 0;
404 AIS_Selection::Select(EO);
408 AIS_Selection::Select(EO);
412 if (myAutoHilight) HilightPicked(updateviewer);
416 Standard_Integer NS = AIS_Selection::Extent();
417 if( NS == 1 ) return AIS_SOP_OneSelected;
418 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
420 return AIS_SOP_Error;
423 //==================================================
425 // Purpose : Selection by polyline
426 //==================================================
427 AIS_StatusOfPick AIS_LocalContext::Select(const TColgp_Array1OfPnt2d& aPolyline,
428 const Handle(V3d_View)& aView,
429 const Standard_Boolean updateviewer)
431 if(aView->Viewer()== myCTX->CurrentViewer()){
432 myMainVS->Pick(aPolyline,aView);
433 if (myAutoHilight) UnhilightPicked(Standard_False);
435 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
436 Standard_Integer LastExt = AIS_Selection::Extent();
439 if(!myMainVS->More()) {
440 ClearSelected(updateviewer);
442 return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed;
445 ClearSelected(Standard_False);
447 for(myMainVS->Init();myMainVS->More();myMainVS->Next()){
448 const Handle(SelectMgr_EntityOwner)& OWNR = myMainVS->Picked();
449 if(myFilters->IsOk(OWNR)){
450 // it can be helpfil to classify this owner immediately...
452 Standard_Integer state = OWNR->State();
454 if( state == 0 ) AIS_Selection::AddSelect(OWNR);
458 if(!IsSelected(OWNR)){
460 AIS_Selection::AddSelect(OWNR);
467 HilightPicked(updateviewer);
470 Standard_Integer NS = AIS_Selection::Extent();
471 if( NS == 1 ) return AIS_SOP_OneSelected;
472 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
474 return AIS_SOP_Error;
477 //==================================================
479 // Purpose : Selection by polyline
480 //==================================================
481 AIS_StatusOfPick AIS_LocalContext::ShiftSelect( const TColgp_Array1OfPnt2d& aPolyline,
482 const Handle(V3d_View)& aView,
483 const Standard_Boolean updateviewer )
485 if( aView->Viewer() == myCTX->CurrentViewer() ) {
486 myMainVS->Pick( aPolyline, aView );
488 AIS_Selection::SetCurrentSelection( mySelName.ToCString() );
489 Standard_Integer LastExt = AIS_Selection::Extent();
491 if( !myMainVS->More() )
492 return LastExt == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
494 AIS_Selection::SetCurrentSelection( mySelName.ToCString() );
497 UnhilightPicked( Standard_False );
498 for( myMainVS->Init(); myMainVS->More(); myMainVS->Next() ) {
499 const Handle(SelectMgr_EntityOwner)& EO = myMainVS->Picked();
500 if( myFilters->IsOk( EO ) ) {
501 Standard_Integer mod = EO->State() == 0 ? -1 : 0;
502 AIS_Selection::Select(EO);
507 HilightPicked( updateviewer );
509 Standard_Integer NS = AIS_Selection::Extent();
511 return AIS_SOP_OneSelected;
513 return AIS_SOP_SeveralSelected;
514 return AIS_SOP_Error;
517 //==================================================
520 //==================================================
521 void AIS_LocalContext::Hilight(const Handle(SelectMgr_EntityOwner)& Ownr,
522 const Handle(V3d_View)& aview)
525 if( aview.IsNull() ) return;
526 aview->TransientManagerClearDraw();
528 if(aview->TransientManagerBeginDraw())
529 Visual3d_TransientManager::EndDraw();
531 myMainPM->BeginDraw();
532 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
533 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
534 Ownr->HilightWithColor(myMainPM,myCTX->HilightColor(),HM);
536 myMainPM->EndDraw(aview,myCTX->ZDetection());
538 myMainPM->EndDraw(aview);
543 //==================================================
546 //==================================================
547 void AIS_LocalContext::Unhilight(const Handle(SelectMgr_EntityOwner)& Ownr,
548 const Handle(V3d_View)& aview)
551 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
552 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
554 if( aview.IsNull() ) return;
555 if( IsSelected(Ownr) ) {
556 if ( Ownr->IsAutoHilight() )
557 Ownr->HilightWithColor(myMainPM,myCTX->SelectionColor(),HM);
561 myMainPM->BeginDraw();
562 Ownr->Unhilight(myMainPM,HM);
563 myMainPM->EndDraw(aview);
565 aview->TransientManagerClearDraw();
567 if(aview->TransientManagerBeginDraw())
568 Visual3d_TransientManager::EndDraw();
569 myMainPM->BeginDraw();
570 Ownr->Unhilight(myMainPM,HM);
571 myMainPM->EndDraw(aview);
576 //=======================================================================
577 //function : HilightPicked
579 //=======================================================================
580 void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
582 Standard_Boolean updMain(Standard_False),updColl(Standard_False);
584 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
586 if( Sel.IsNull() ) return;
589 Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
590 SelectMgr_DataMapOfObjectOwners aMap;
592 // to avoid problems when there is a loop searching for selected objects...
593 #if !defined OCC189 && !defined USE_MAP
594 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
595 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++)
597 const Handle(Standard_Transient)& Tr = Obj(i);
599 const AIS_NListTransient& Obj = Sel->Objects();
600 AIS_NListTransient::Iterator anIter( Obj );
601 for(; anIter.More(); anIter.Next())
603 const Handle(Standard_Transient)& Tr = anIter.Value();
606 const Handle(SelectMgr_EntityOwner)& Ownr =
607 *((const Handle(SelectMgr_EntityOwner)*) &Tr);
608 Handle(AIS_InteractiveObject) IO;
609 if(Ownr->HasSelectable()){
610 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
611 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
612 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
613 IO = *((Handle(AIS_InteractiveObject)*)&SO);
614 if(myCTX->IsInCollector(IO)){
615 PM = myCTX->CollectorPrsMgr();
616 updColl = Standard_True;}
618 updMain = Standard_True;
621 updMain = Standard_True;
624 updMain = Standard_True;
625 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
626 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
627 if ( Ownr->IsAutoHilight() )
628 Ownr->HilightWithColor(PM,myCTX->SelectionColor(),HM);
629 else if ( aMap.IsBound (SO) )
630 aMap.ChangeFind(SO).Append ( Ownr );
632 SelectMgr_SequenceOfOwner aSeq;
633 aSeq.Append ( Ownr );
634 aMap.Bind ( SO, aSeq );
639 for ( SelectMgr_DataMapIteratorOfMapOfObjectOwners aMapIter(aMap);
640 aMapIter.More(); aMapIter.Next() )
641 aMapIter.Key()->HilightSelected ( myMainPM, aMapIter.Value() );
645 myCTX->CurrentViewer()->Update();
647 if(updMain) myCTX->CurrentViewer()->Update();
649 if(updColl) myCTX->Collector()->Update();
653 //==================================================
656 //==================================================
657 void AIS_LocalContext::
658 UnhilightPicked(const Standard_Boolean updateviewer)
660 Standard_Boolean updMain(Standard_False),updColl(Standard_False);
662 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
664 if( Sel.IsNull() ) return;
666 Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
667 SelectMgr_DataMapOfObjectOwners anObjMap;
668 SelectMgr_SequenceOfOwner anOwnSeq;
670 #if !defined OCC189 && !defined USE_MAP
671 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
672 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
673 const Handle(Standard_Transient)& Tr = Obj(i);
675 const AIS_NListTransient& Obj = Sel->Objects();
676 AIS_NListTransient::Iterator anIter( Obj );
677 for(; anIter.More(); anIter.Next()){
678 const Handle(Standard_Transient)& Tr = anIter.Value();
681 const Handle(SelectMgr_EntityOwner)& Ownr =
682 *((const Handle(SelectMgr_EntityOwner)*) &Tr);
683 Standard_Integer HM(0);
684 if(Ownr->HasSelectable()){
686 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
687 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
688 anObjMap.Bind ( IO, anOwnSeq );
692 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
693 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
695 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
696 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
699 if(myCTX->IsInCollector(IO)){
700 PM = myCTX->CollectorPrsMgr();
701 updColl = Standard_True;}
703 updMain = Standard_True;
706 updMain = Standard_True;
708 Ownr->Unhilight(PM,HM);
712 for ( SelectMgr_DataMapIteratorOfMapOfObjectOwners anIter1 ( anObjMap );
713 anIter1.More(); anIter1.Next() )
714 if ( !anIter1.Key()->IsAutoHilight() )
715 anIter1.Key()->ClearSelected();
719 myCTX->CurrentViewer()->Update();
721 if(updMain) myCTX->CurrentViewer()->Update();
723 if(updColl) myCTX->Collector()->Update();
728 //=======================================================================
729 //function : IsSelected
731 //=======================================================================
732 Standard_Boolean AIS_LocalContext::IsSelected(const Handle(AIS_InteractiveObject)& anIObj) const
734 return (!FindSelectedOwnerFromIO(anIObj).IsNull());
737 //=======================================================================
738 //function : IsSelected
740 //=======================================================================
742 Standard_Boolean AIS_LocalContext::IsSelected(const Handle(SelectMgr_EntityOwner)& Ownr) const
744 if (Ownr.IsNull()) return Standard_False;
746 Standard_Boolean state = (Ownr->State()!=0);
748 Standard_Boolean state = (Ownr->State()==1);
753 //==================================================
756 //==================================================
757 void AIS_LocalContext::
760 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
761 AIS_Selection::CurrentSelection()->Init();
764 //==================================================
767 //==================================================
768 Standard_Boolean AIS_LocalContext::
771 return AIS_Selection::CurrentSelection()->More();
774 //==================================================
777 //==================================================
778 void AIS_LocalContext::
781 AIS_Selection::CurrentSelection()->Next();
784 //==================================================
787 //==================================================
788 Standard_Boolean AIS_LocalContext::
791 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
792 if( Tr.IsNull() ) return Standard_False;
793 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
794 Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
795 if(BRO.IsNull()) return Standard_False;
796 Standard_Boolean hasshape = BRO->HasShape();
797 Standard_Boolean comes = BRO->ComesFromDecomposition();
798 return (hasshape&&comes);
801 //==================================================
804 //==================================================
805 const TopoDS_Shape& AIS_LocalContext::
806 SelectedShape() const
808 static TopoDS_Shape aSh;
809 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
810 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
811 Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
819 //==================================================
822 //==================================================
823 Handle(AIS_InteractiveObject) AIS_LocalContext::
824 SelectedInteractive() const
826 Handle(AIS_InteractiveObject) IO;
827 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
829 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
830 Handle(SelectMgr_SelectableObject) SO;
831 if(EO->HasSelectable()){
832 SO = EO->Selectable();
833 IO = *((Handle(AIS_InteractiveObject)*)&SO);
838 //==================================================
841 //==================================================
842 Handle(SelectMgr_EntityOwner) AIS_LocalContext::
843 SelectedOwner() const
845 Handle(SelectMgr_EntityOwner) EO;
846 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
848 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
852 //==================================================
855 //==================================================
856 Standard_Boolean AIS_LocalContext::
857 HasApplicative() const
859 Handle(AIS_InteractiveObject) IO = SelectedInteractive();
860 if( IO.IsNull() ) return Standard_False;
861 return IO->HasOwner();
864 //==================================================
867 //==================================================
868 const Handle(Standard_Transient)& AIS_LocalContext::
869 SelectedApplicative() const
871 return SelectedInteractive()->GetOwner();
876 //=======================================================================
877 //function : UpdateSelection
878 //purpose : should disappear...
879 //=======================================================================
880 void AIS_LocalContext::UpdateSelected(const Standard_Boolean updateviewer)
882 UnhilightPicked(Standard_False);
883 HilightPicked(updateviewer);
886 //================================================================
887 // Function : UpdateSelected
888 // Purpose : Part of advanced selection mechanism.
889 // Highlightes or clears selection presentation for the given IO
890 //================================================================
891 void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj,
892 const Standard_Boolean updateviewer)
894 if (anobj.IsNull() || anobj->IsAutoHilight())
897 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
898 Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
900 SelectMgr_SequenceOfOwner aSeq;
901 for ( Sel->Init(); Sel->More(); Sel->Next() ){
902 Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(Sel->Value());
904 if ( !aOwner.IsNull() && aOwner->HasSelectable() && aOwner->Selectable() == anobj )
905 aSeq.Append( aOwner );
909 anobj->HilightSelected( myMainPM, aSeq );
911 anobj->ClearSelected();
914 myCTX->CurrentViewer()->Update();
918 //==================================================
919 // Function: ClearSelected
921 //==================================================
922 void AIS_LocalContext::ClearSelected(const Standard_Boolean updateviewer)
924 UnhilightPicked(updateviewer);
925 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
927 Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
928 #if !defined OCC189 && !defined USE_MAP
929 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
930 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
931 const Handle(Standard_Transient)& Tr = Obj(i);
933 const AIS_NListTransient& Obj = Sel->Objects();
934 AIS_NListTransient::Iterator anIter( Obj );
935 for(; anIter.More(); anIter.Next()){
936 const Handle(Standard_Transient)& Tr = anIter.Value();
939 (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->State(0);
942 AIS_Selection::Select();
947 //=======================================================================
948 //function : SetSelected
950 //=======================================================================
951 void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,
952 const Standard_Boolean updateviewer)
954 if(!IsValidForSelection(anIObj)) return;
955 UnhilightPicked(Standard_False);
957 //1st case, owner already <anIObj> as owner
958 // and not separated is found...
960 Handle(AIS_Selection) sel = AIS_Selection::Selection(mySelName.ToCString());
961 //Standard_Boolean found(Standard_False);
962 Handle(Standard_Transient) Tr;
963 Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromIO(anIObj);
965 //check if in selection number 0 there is an owner that can be triturated...
966 if(anIObj->HasSelection(0)){
967 const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
970 Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
971 EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
975 EO = new SelectMgr_EntityOwner(anIObj);
978 ClearSelected(Standard_False);
980 AIS_Selection::Select(EO);
984 AIS_Selection::Select(EO);
986 HilightPicked(updateviewer);
989 //=======================================================================
990 //function : AddOrRemoveSelected
992 //=======================================================================
994 void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& anIObj,
995 const Standard_Boolean updateviewer)
997 if(!IsValidForSelection(anIObj)) return;
998 UnhilightPicked(Standard_False);
999 // first check if it is selected...
1000 Handle(SelectMgr_EntityOwner) EO;
1002 EO = FindSelectedOwnerFromIO(anIObj);
1010 if(anIObj->HasSelection(0)){
1011 const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
1014 Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
1015 EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
1019 EO = new SelectMgr_EntityOwner(anIObj);
1025 // cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<<mySelName<<endl;
1026 const Handle(AIS_Selection)& S = AIS_Selection::Selection(mySelName.ToCString());
1029 AIS_SelectStatus aStatus = S->Select(EO);
1030 if(aStatus == AIS_SS_Added)
1039 HilightPicked(updateviewer);
1042 //=======================================================================
1043 //function : AddOrRemoveSelected
1044 //purpose : To check...
1045 //=======================================================================
1046 void AIS_LocalContext::AddOrRemoveSelected(const TopoDS_Shape& Sh,
1047 const Standard_Boolean updateviewer)
1049 UnhilightPicked(Standard_False);
1050 Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromShape(Sh);
1052 // cout<<"AIS_LocalContext::AddOrRemoveSelected(sh) : Selection = "<<mySelName<<endl;
1055 AIS_Selection::Selection(mySelName.ToCString())->Select(EO);
1059 AIS_Selection::Selection(mySelName.ToCString())->Select(EO);
1062 HilightPicked(updateviewer);
1065 void AIS_LocalContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& Ownr,
1066 const Standard_Boolean updateviewer)
1068 //Not Yet Implemented
1070 UnhilightPicked(Standard_False);
1071 // cout<<"AIS_LocalContext::AddOrRemoveSelected(ownr) : Selection = "<<mySelName<<endl;
1073 Standard_Integer mod = Ownr->State()==0 ? 1 : 0;
1075 AIS_Selection::Selection(mySelName.ToCString())->Select(Ownr);
1081 AIS_Selection::Selection(mySelName.ToCString())->Select(Ownr);
1084 HilightPicked(updateviewer);
1087 //==================================================
1090 //==================================================
1091 void AIS_LocalContext::ManageDetected(const Handle(SelectMgr_EntityOwner)& aPickOwner,
1092 const Handle(V3d_View)& aview)
1095 // Warning : aPickOwner may be null !
1096 if (aPickOwner.IsNull()) return;
1098 if(!myAutoHilight) return;
1100 // const Handle(SelectMgr_SelectableObject)& SO = aPickOwner->Selectable();
1101 Standard_Boolean okStatus = myFilters->IsOk(aPickOwner);
1104 //=======================================================================================================
1105 // 2 cases : a- object is in the map of picks:
1106 // 1. this is the same index as the last detected: -> Do nothing
1108 // - if lastindex = 0 (no object was detected at the last step)
1109 // the object presentation is highlighted and lastindex = index(objet)
1111 // the presentation of the object corresponding to lastindex is "unhighlighted"
1112 // it is removed if the object is not visualized but only active
1113 // then the presentation of the detected object is highlighted and lastindex = index(objet)
1114 // b- the object is not in the map of picked objects
1115 // - if lastindex != 0 (object detected at the last step) it is unhighlighted ...
1116 // if the object was decomposed, presentation is created for the detected shape and the couple
1117 // (Proprietaire,Prs)is added in the map.
1118 // otherwise the couple(proprietaire, NullPrs) is placed in the map and the interactive object
1119 // itself is highlighted.
1121 //=======================================================================================================
1125 Standard_Boolean wasContained = myMapOfOwner.Contains(aPickOwner);
1126 Standard_Integer theNewIndex = 0;
1128 theNewIndex = myMapOfOwner.FindIndex(aPickOwner);
1130 theNewIndex = myMapOfOwner.Add(aPickOwner);
1132 // For the advanced mesh selection mode the owner indices comparison
1133 // is not effective because in that case only one owner manage the
1134 // selection in current selection mode. It is necessary to check the current detected
1135 // entity and hilight it only if the detected entity is not the same as
1136 // previous detected (IsForcedHilight call)
1137 if (theNewIndex != mylastindex || aPickOwner->IsForcedHilight()) {
1139 if (mylastindex && mylastindex <= myMapOfOwner.Extent()) {
1141 const Handle(SelectMgr_EntityOwner)& LastOwnr = myMapOfOwner(mylastindex);
1143 Unhilight(LastOwnr,aview);
1145 if(!IsSelected(LastOwnr))
1146 Unhilight(LastOwnr,aview);
1150 if (myAutoHilight) {
1151 // wasContained should not be checked because with this verification different
1152 // behaviour of application may occer depending whether mouse is moved above
1153 // owner first or second time
1154 //if (wasContained) {
1156 if (aPickOwner->State() <= 0 || myCTX->ToHilightSelected())
1158 if(!IsSelected (aPickOwner) || myCTX->ToHilightSelected())
1160 Hilight(aPickOwner,aview);
1162 else Hilight(aPickOwner,aview);*/
1165 mylastindex = theNewIndex;
1169 if (mylastindex) mylastgood = mylastindex;
1174 //=======================================================================
1175 //function : HasDetectedShape
1177 //=======================================================================
1179 Standard_Boolean AIS_LocalContext::HasDetectedShape() const
1181 if(mylastindex==0) return Standard_False;
1182 return IsShape(mylastindex);
1185 //=======================================================================
1186 //function : DetectedShape
1188 //=======================================================================
1191 AIS_LocalContext::DetectedShape() const
1193 static TopoDS_Shape bidsh;
1194 if(mylastindex != 0)
1196 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner(mylastindex));
1197 if(BROwnr.IsNull()) return bidsh;
1198 return BROwnr->Shape();
1203 //=======================================================================
1204 //function : DetectedInteractive
1206 //=======================================================================
1208 Handle(AIS_InteractiveObject)
1209 AIS_LocalContext::DetectedInteractive() const
1211 Handle(AIS_InteractiveObject) Iobj;
1212 if(IsValidIndex(mylastindex)){
1213 Handle(SelectMgr_SelectableObject) SO = myMapOfOwner.FindKey(mylastindex)->Selectable();
1214 Iobj = *((Handle(AIS_InteractiveObject)*) &SO);
1218 //=======================================================================
1219 //function : DetectedInteractive
1221 //=======================================================================
1222 Handle(SelectMgr_EntityOwner) AIS_LocalContext::DetectedOwner() const
1224 Handle(SelectMgr_EntityOwner) bid;
1225 if(!IsValidIndex(mylastindex)) return bid;
1226 return myMapOfOwner.FindKey(mylastindex);
1230 //=======================================================================
1231 //function : ComesFromDecomposition
1233 //=======================================================================
1235 Standard_Boolean AIS_LocalContext::ComesFromDecomposition(const Standard_Integer PickedIndex) const
1237 const Handle(SelectMgr_EntityOwner)& OWN = myMapOfOwner.FindKey(PickedIndex);
1238 Handle(SelectMgr_SelectableObject) aSel = OWN->Selectable();
1239 if (myActiveObjects.IsBound (aSel)) { // debug of jmi
1240 const Handle(AIS_LocalStatus)& Stat = myActiveObjects(aSel);
1241 return Stat->Decomposed();
1243 return Standard_False;
1247 //=======================================================================
1248 //function : DisplayAreas
1250 //=======================================================================
1252 void AIS_LocalContext::DisplayAreas(const Handle(V3d_View)& aviou)
1254 myMainVS->DisplayAreas(aviou);
1257 //=======================================================================
1258 //function : ClearAreas
1260 //=======================================================================
1262 void AIS_LocalContext::ClearAreas(const Handle(V3d_View)& aviou)
1264 myMainVS->ClearAreas(aviou);
1267 //=======================================================================
1268 //function : DisplaySensitive
1270 //=======================================================================
1272 void AIS_LocalContext::DisplaySensitive(const Handle(V3d_View)& aviou)
1274 myMainVS->DisplaySensitive(aviou);
1277 //=======================================================================
1278 //function : ClearSensitive
1280 //=======================================================================
1282 void AIS_LocalContext::ClearSensitive(const Handle(V3d_View)& aviou)
1284 myMainVS->ClearSensitive(aviou);
1288 //=======================================================================
1289 //function : IsShape
1291 //=======================================================================
1292 Standard_Boolean AIS_LocalContext::IsShape(const Standard_Integer Index) const
1295 if(Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner.FindKey(Index)).IsNull())
1296 return Standard_False;
1298 ComesFromDecomposition(Index);
1301 Standard_Boolean AIS_LocalContext::IsValidForSelection(const Handle(AIS_InteractiveObject)& anIObj) const
1305 // Shape was not transfered from AIS_Shape to EntityOwner
1306 Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(anIObj);
1307 if( !shape.IsNull() )
1308 return myFilters->IsOk(new StdSelect_BRepOwner(shape->Shape(),shape));
1310 return myFilters->IsOk(new SelectMgr_EntityOwner(anIObj));
1314 //=======================================================================
1315 //function : HilightNextDetected
1317 //=======================================================================
1319 Standard_Integer AIS_LocalContext::HilightNextDetected(const Handle(V3d_View)& V)
1321 // go to the next owner
1323 if(myDetectedSeq.IsEmpty()) return Standard_False;
1324 Standard_Integer L = myDetectedSeq.Length();
1329 Handle(SelectMgr_EntityOwner) EO = myMainVS->Picked(myCurDetected);
1331 if( EO.IsNull() ) return 0;
1334 static Standard_Boolean Normal_State(Standard_True);
1335 static Standard_Boolean firsttime(Standard_True);
1337 OSD_Environment toto("HITRI");
1338 if(!toto.Value().IsEmpty())
1339 Normal_State = Standard_False;
1340 firsttime = Standard_False;
1345 ManageDetected(EO,V);
1347 HilightTriangle(myCurDetected,V);
1348 return myCurDetected;
1351 //=======================================================================
1352 //function : HilightPreviousDetected
1354 //=======================================================================
1355 Standard_Integer AIS_LocalContext::HilightPreviousDetected(const Handle(V3d_View)& V)
1357 if(myDetectedSeq.IsEmpty()) return Standard_False;
1363 Handle(SelectMgr_EntityOwner) EO = myMainVS->Picked(myCurDetected);
1365 if( EO.IsNull() ) return 0;
1368 static Standard_Boolean Normal_State(Standard_True);
1369 static Standard_Boolean firsttime(Standard_True);
1371 OSD_Environment toto("HITRI");
1372 if(!toto.Value().IsEmpty())
1373 Normal_State = Standard_False;
1374 firsttime = Standard_False;
1380 ManageDetected(EO,V);
1382 HilightTriangle(myCurDetected,V);
1383 return myCurDetected;
1386 //=======================================================================
1387 //function : UnhilightLastDetected
1389 //=======================================================================
1390 Standard_Boolean AIS_LocalContext::UnhilightLastDetected(const Handle(V3d_View)& aview)
1392 if(!IsValidIndex(mylastindex)) return Standard_False;
1393 myMainPM->BeginDraw();
1394 const Handle(SelectMgr_EntityOwner)& Ownr = myMapOfOwner(mylastindex);
1395 Standard_Integer HM(0);
1396 if(Ownr->HasSelectable()){
1397 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
1398 HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
1400 myMapOfOwner(mylastindex)->Unhilight(myMainPM,HM);
1401 myMainPM->EndDraw(aview);
1403 return Standard_True;
1408 //=======================================================================
1409 //function : HilightTriangle
1411 //=======================================================================
1413 void AIS_LocalContext::HilightTriangle(const Standard_Integer Rank,
1414 const Handle(V3d_View)& view)
1416 static Standard_Integer PrevRank(0);
1417 if(Rank==PrevRank) return;
1419 Handle(SelectBasics_SensitiveEntity) SE = myMainVS->Primitive(Rank);
1420 if(SE->IsKind(STANDARD_TYPE(Select3D_SensitiveTriangulation))){
1421 Handle(Select3D_SensitiveTriangulation) Tr = *((Handle(Select3D_SensitiveTriangulation)*)&SE);
1422 gp_Pnt p1,p2,p3 ; Tr->DetectedTriangle(p1,p2,p3);
1423 static Graphic3d_Array1OfVertex Vtt(1,3);
1425 Vtt.SetValue(1,Graphic3d_Vertex(p1.X(),p1.Y(),p1.Z()));
1426 Vtt.SetValue(2,Graphic3d_Vertex(p2.X(),p2.Y(),p2.Z()));
1427 Vtt.SetValue(3,Graphic3d_Vertex(p3.X(),p3.Y(),p3.Z()));
1428 static Handle(Prs3d_Presentation) TriPrs =
1429 new Prs3d_Presentation(myMainPM->StructureManager());
1432 Handle(Prs3d_ShadingAspect) asp = myCTX->DefaultDrawer()->ShadingAspect();
1433 asp->SetColor(myCTX->HilightColor());
1434 TriPrs->SetShadingAspect(asp);
1436 Prs3d_Root::CurrentGroup(TriPrs)->Polygon(Vtt);
1439 if(view->TransientManagerBeginDraw())
1440 Visual3d_TransientManager::EndDraw();
1442 if(view->TransientManagerBeginDraw()) {
1444 Visual3d_TransientManager::DrawStructure(TriPrs);
1445 Visual3d_TransientManager::EndDraw();
1452 //=======================================================================
1453 //function : FindSelectedOwnerFromIO
1454 //purpose : it is checked if one of the selected owners really presents IObj
1455 //=======================================================================
1456 Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO
1457 (const Handle(AIS_InteractiveObject)& anIObj) const
1459 Handle(SelectMgr_EntityOwner) EO,bid;
1460 if (anIObj.IsNull()) return EO;
1462 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
1465 cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "
1466 <<mySelName<<" Nulle "<<endl;
1470 Standard_Boolean found(Standard_False);
1471 #if !defined OCC189 && !defined USE_MAP
1472 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
1473 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
1474 const Handle(Standard_Transient)& Tr = Obj(i);
1476 const AIS_NListTransient& Obj = Sel->Objects();
1477 AIS_NListTransient::Iterator anIter( Obj );
1478 for(; anIter.More(); anIter.Next()){
1479 const Handle(Standard_Transient)& Tr = anIter.Value();
1482 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
1483 if(EO->HasSelectable()){
1484 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
1485 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
1486 if (anIObj == EO->Selectable()){
1487 found =Standard_True;
1494 if(found) return EO;
1498 //=======================================================================
1499 //function : FindSelectedOwnerFromShape
1500 //purpose : it is checked if one of the selected owners really presents IObj
1501 //=======================================================================
1502 Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const TopoDS_Shape& sh) const
1505 Handle(SelectMgr_EntityOwner) EO, bid;
1507 Handle(SelectMgr_EntityOwner) EO;
1509 if (sh.IsNull()) return EO;
1511 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
1514 cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<<mySelName<<" Nulle "<<endl;
1519 Standard_Boolean found(Standard_False);
1523 //now iterate over all shapes loaded into the context (but inside the collector)
1524 SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive aSensitiveIt (myMainVS->Primitives());
1525 for (; aSensitiveIt.More(); aSensitiveIt.Next()) {
1526 EO = Handle(SelectMgr_EntityOwner)::DownCast (aSensitiveIt.Value()->OwnerId());
1527 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
1528 if (!BROwnr.IsNull() && BROwnr->HasShape() && BROwnr->Shape() == sh) {
1529 found = Standard_True;
1535 #if !defined OCC189 && !defined USE_MAP
1536 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
1537 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
1538 const Handle(Standard_Transient)& Tr = Obj(i);
1540 const AIS_NListTransient& Obj = Sel->Objects();
1541 AIS_NListTransient::Iterator anIter( Obj );
1542 for(; anIter.More(); anIter.Next()){
1543 const Handle(Standard_Transient)& Tr = anIter.Value();
1547 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
1549 if ( EO->Shape() == sh)
1550 found =Standard_True;
1556 if(found) return EO;
1561 //=======================================================================
1562 //function : AIS_LocalContext::InitDetected
1564 //=======================================================================
1566 void AIS_LocalContext::InitDetected()
1568 myAISCurDetected = myAISDetectedSeq.Length()? 1 : 0;
1571 //=======================================================================
1572 //function : AIS_LocalContext::MoreDetected
1574 //=======================================================================
1576 Standard_Boolean AIS_LocalContext::MoreDetected() const
1578 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length());
1582 //=======================================================================
1583 //function : AIS_LocalContext::NextDetected
1585 //=======================================================================
1587 void AIS_LocalContext::NextDetected()
1589 if (MoreDetected()) myAISCurDetected++;
1592 //=======================================================================
1593 //function : DetectedCurrentShape
1595 //=======================================================================
1597 const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const
1599 static TopoDS_Shape bidsh;
1601 return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape();
1605 //=======================================================================
1606 //function : DetectedCurrentObject
1608 //=======================================================================
1610 Handle(AIS_InteractiveObject) AIS_LocalContext::DetectedCurrentObject() const
1612 Handle(AIS_InteractiveObject) theIObj;
1614 theIObj = myAISDetectedSeq(myAISCurDetected);