1 // Created on: 1996-10-30
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // Modified by rob Thu Apr 02 1998
22 // - use of optimisation in SelectMgr_ViewerSelector
23 // -> Best management in detected entities...
25 #define BUC60569 //GG_051199 Enable to select the local context
26 // in any case and especially in multi selection mode.
27 // Note that right now when an hilighted owner is selected
28 // this owner is unhilighted,this permits to see the selection!
29 // Principle : an owner can have 3 state :
30 // 1 : The owner is selected and no more highlightable
31 // 0 : The owner is NOT selected
32 // -1: The owner is selected but stay highlightable (NEW)
34 // IMP230600 //GG Add protection on selection methodes
35 // when nothing is selected
37 #define BUC60726 //GG_040900 When nothing is detected,
38 // Clear the last temporary stuff in any case
40 #define BUC60765 //GG_121000 Avoid to raise when the same selection
41 // is attached to several local context.
43 #define BUC60771 //GG_261000 Avoid to crash after closing a view
44 // containing a selected entity and creating a new one.
46 #define BUC60774 //GG_261000 Returns right select status on
47 // bounding-box selection type.
49 #define BUC60818 //GG_300101 Enable detection even if
50 // SetAutomaticHilight(FALSE) has been used.
52 #define IMP300101 //GG Enable to use polygon highlighting
54 #define BUC60863 //GG_270301 Clear hilight soon after selecting or
55 // unselecting something in Local Context mode.
57 #define BUC60876 //GG_050401 Clear selection always even
58 // if the current highlight mode is not 0.
60 #define BUC60953 //SAV_060701 For Select optimization. Selection by rectangle case.
61 // for single selection no optimization done.
63 #define IMP120701 //SZV made a shape valid for selection
66 #define IMP160701 //SZV Add InitDetected(),MoreDetected(),NextDetected(),
67 // DetectedCurrentShape(),DetectedCurrentObject()
70 #define OCC138 //VTN Avoding infinit loop in AddOrRemoveSelected method.
72 #define OCC189 //SAV: 18/03/02 AIS_Selection::Objects() returns ListOfTransient
75 #define USE_MAP //san : 18/04/03 USE_MAP - additional datamap is used to speed up access
76 //to certain owners in AIS_Selection::myresult list
78 #define IMP120402 // GG : Add protection in manual detection methods
79 // after deselecting any item using ShiftSelect action.
80 // Thanks to Ivan FONTAINE of SAMTECH company
82 #define IMP051001 //GG manage Z detection
84 #define OCC9026 //AEL Performance optimization of the FindSelectedOwnerFromShape() method.
86 #include <AIS_LocalContext.jxx>
87 #include <StdSelect_BRepOwner.hxx>
88 #include <TColStd_MapOfTransient.hxx>
89 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
90 #include <Prs3d_Presentation.hxx>
91 #include <Prs3d_Drawer.hxx>
92 #include <Prs3d_ShadingAspect.hxx>
93 #include <AIS_LocalStatus.hxx>
94 #include <StdPrs_WFShape.hxx>
95 #include <Visual3d_TransientManager.hxx>
96 #include <Graphic3d_ArrayOfTriangles.hxx>
97 #include <Graphic3d_Group.hxx>
98 #include <Select3D_SensitiveTriangulation.hxx>
99 #include <SelectBasics_SensitiveEntity.hxx>
100 #include <TCollection_AsciiString.hxx>
102 #include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
104 #include <SelectMgr_Selection.hxx>
105 #include <OSD_Environment.hxx>
106 #include <SelectMgr_DataMapOfObjectOwners.hxx>
108 #include <Geom_Transformation.hxx>
109 #include <AIS_Selection.hxx>
111 #include <AIS_Shape.hxx>
115 static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
117 return IO->HasHilightMode() ? IO->HilightMode():0;
120 //==================================================
123 //==================================================
124 AIS_StatusOfDetection AIS_LocalContext::MoveTo(const Standard_Integer Xpix,
125 const Standard_Integer Ypix,
126 const Handle(V3d_View)& aview)
128 // check that ViewerSelector gives
129 if(aview->Viewer()== myCTX->CurrentViewer()) {
131 //Nullify class members storing information about detected AIS objects.
132 myAISCurDetected = 0;
133 myAISDetectedSeq.Clear();
136 myDetectedSeq.Clear();
137 myMainVS->Pick(Xpix,Ypix,aview);
138 Standard_Boolean had_nothing = myMainVS->NbPicked()==0;
139 Standard_Integer NbDetected = myMainVS->NbPicked();
140 Handle(SelectMgr_EntityOwner) EO;
142 for(Standard_Integer i_detect = 1;i_detect<=NbDetected;i_detect++){
143 EO = myMainVS->Picked(i_detect);
145 if(myFilters->IsOk(EO)) {
146 myDetectedSeq.Append(i_detect); // normallly they are already arranged in correct order...
148 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
149 if(!Handle(AIS_Shape)::DownCast(anObj).IsNull())
150 myAISDetectedSeq.Append(anObj);
156 //result of courses..
157 if(had_nothing || myDetectedSeq.IsEmpty()){
158 if(mylastindex !=0 && mylastindex <= myMapOfOwner.Extent()){
161 Unhilight(myMapOfOwner(mylastindex),aview);
163 if(!IsSelected(myMapOfOwner(mylastindex)))
164 Unhilight(myMapOfOwner(mylastindex),aview);
168 return (had_nothing ? AIS_SOD_Nothing : AIS_SOD_AllBad);
171 // all owners detected by the selector are passed to the
172 // filters and correct ones are preserved...
174 EO = myMainVS->Picked(myDetectedSeq(myCurDetected));
176 static Standard_Boolean Normal_State(Standard_True);
177 static Standard_Boolean firsttime(Standard_True);
179 OSD_Environment toto("HITRI");
180 if(!toto.Value().IsEmpty())
181 Normal_State = Standard_False;
182 firsttime = Standard_False;
186 ManageDetected(EO,aview);
188 HilightTriangle(1,aview);
190 if(myDetectedSeq.Length() == 1){
192 return AIS_SOD_OnlyOneDetected;
194 return AIS_SOD_OnlyOneGood;
197 return AIS_SOD_SeveralGood;
201 return AIS_SOD_Error;
204 //==================================================
207 //==================================================
208 AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Boolean updateviewer)
211 UnhilightPicked(Standard_False);
213 Standard_Integer DI = DetectedIndex();
214 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
215 Standard_Integer NbSel = AIS_Selection::Extent();
218 ClearSelected(updateviewer);
219 return NbSel== 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
222 const Handle(SelectMgr_EntityOwner)& EO = myMapOfOwner(DI);
225 ClearSelected(Standard_False);
226 Standard_Integer state = EO->State();
229 if( state == 0 ) AIS_Selection::Select(EO);
233 AIS_Selection::ClearAndSelect(EO);
238 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
239 for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
240 Unhilight(EO, aViewer->ActiveView());
242 // san - advanced selection highlighting mechanism
243 if (!EO->IsAutoHilight() && EO->HasSelectable()){
244 Handle(AIS_InteractiveObject) anIO =
245 Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
246 UpdateSelected(anIO, Standard_False);
250 myCTX->CurrentViewer()->Update();
252 HilightPicked(updateviewer);
255 return ( AIS_Selection::Extent() == 1)? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected ;
257 //==================================================
260 //==================================================
261 AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Integer XPMin,
262 const Standard_Integer YPMin,
263 const Standard_Integer XPMax,
264 const Standard_Integer YPMax,
265 const Handle(V3d_View)& aView,
266 const Standard_Boolean updateviewer)
268 if(aView->Viewer()== myCTX->CurrentViewer()){
269 myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView);
270 if (myAutoHilight) UnhilightPicked(Standard_False);
272 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
273 Standard_Integer LastExt = AIS_Selection::Extent();
276 if(!myMainVS->More()) {
277 ClearSelected(updateviewer);
279 return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed;
282 ClearSelected(Standard_False);
284 for(myMainVS->Init();myMainVS->More();myMainVS->Next()){
285 const Handle(SelectMgr_EntityOwner)& OWNR = myMainVS->Picked();
286 if(myFilters->IsOk(OWNR)){
287 // it can be helpfil to classify this owner immediately...
289 Standard_Integer state = OWNR->State();
292 if( state == 0 ) AIS_Selection::Select(OWNR);
296 if( state == 0 ) AIS_Selection::Select(OWNR);
300 if(!IsSelected(OWNR)){
302 AIS_Selection::Select(OWNR);
308 HilightPicked(updateviewer);
311 Standard_Integer NS = AIS_Selection::Extent();
312 if( NS == 1 ) return AIS_SOP_OneSelected;
313 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
315 return AIS_SOP_Error;
320 //==================================================
323 //==================================================
324 AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Boolean updateviewer)
326 Standard_Integer I = DetectedIndex();
330 UnhilightPicked(Standard_False);
333 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
335 Standard_Integer NbSel = AIS_Selection::Extent();
337 const Handle(SelectMgr_EntityOwner)& EO = myMapOfOwner(I);
339 Standard_Integer mod = EO->State()==0 ? -1 : 0;
341 Standard_Integer mod = EO->State()==0 ? 1 : 0;
345 AIS_Selection::Select(EO);
350 AIS_Selection::Select(EO);
355 const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
356 for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
357 Unhilight(EO, aViewer->ActiveView());
359 // san - advanced selection highlighting mechanism
360 if (!EO->IsAutoHilight() && EO->HasSelectable()){
361 Handle(AIS_InteractiveObject) anIO =
362 Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
363 UpdateSelected(anIO, Standard_False);
367 myCTX->CurrentViewer()->Update();
369 HilightPicked(updateviewer);
373 Standard_Integer NS = AIS_Selection::Extent();
374 if( NS == 1 ) return AIS_SOP_OneSelected;
375 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
376 return NbSel== 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
379 return AIS_SOP_Error;
381 //==================================================
382 // Function: the already selected objects are unselected
383 // Purpose : others are selected.
384 //==================================================
385 AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Integer XPMin,
386 const Standard_Integer YPMin,
387 const Standard_Integer XPMax,
388 const Standard_Integer YPMax,
389 const Handle(V3d_View)& aView,
390 const Standard_Boolean updateviewer)
392 if(aView->Viewer()== myCTX->CurrentViewer()) {
393 myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView);
395 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
396 Standard_Integer LastExt = AIS_Selection::Extent();
399 if(!myMainVS->More())
401 return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed;
403 return AIS_SOP_NothingSelected; // no effet if click on empty space
406 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
407 if (myAutoHilight) UnhilightPicked(Standard_False);
409 for(myMainVS->Init();myMainVS->More();myMainVS->Next()){
410 const Handle(SelectMgr_EntityOwner)& EO = myMainVS->Picked();
411 if(myFilters->IsOk(EO)){
413 Standard_Integer mod = EO->State()==0 ? -1 : 0;
415 Standard_Integer mod = EO->State()==0 ? 1 : 0;
419 AIS_Selection::Select(EO);
423 AIS_Selection::Select(EO);
427 if (myAutoHilight) HilightPicked(updateviewer);
431 Standard_Integer NS = AIS_Selection::Extent();
432 if( NS == 1 ) return AIS_SOP_OneSelected;
433 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
435 return AIS_SOP_Error;
438 //==================================================
440 // Purpose : Selection by polyline
441 //==================================================
442 AIS_StatusOfPick AIS_LocalContext::Select(const TColgp_Array1OfPnt2d& aPolyline,
443 const Handle(V3d_View)& aView,
444 const Standard_Boolean updateviewer)
446 if(aView->Viewer()== myCTX->CurrentViewer()){
447 myMainVS->Pick(aPolyline,aView);
448 if (myAutoHilight) UnhilightPicked(Standard_False);
450 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
451 Standard_Integer LastExt = AIS_Selection::Extent();
454 if(!myMainVS->More()) {
455 ClearSelected(updateviewer);
457 return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed;
460 ClearSelected(Standard_False);
462 for(myMainVS->Init();myMainVS->More();myMainVS->Next()){
463 const Handle(SelectMgr_EntityOwner)& OWNR = myMainVS->Picked();
464 if(myFilters->IsOk(OWNR)){
465 // it can be helpfil to classify this owner immediately...
467 Standard_Integer state = OWNR->State();
469 if( state == 0 ) AIS_Selection::AddSelect(OWNR);
473 if(!IsSelected(OWNR)){
475 AIS_Selection::AddSelect(OWNR);
482 HilightPicked(updateviewer);
485 Standard_Integer NS = AIS_Selection::Extent();
486 if( NS == 1 ) return AIS_SOP_OneSelected;
487 else if( NS > 1 ) return AIS_SOP_SeveralSelected;
489 return AIS_SOP_Error;
492 //==================================================
494 // Purpose : Selection by polyline
495 //==================================================
496 AIS_StatusOfPick AIS_LocalContext::ShiftSelect( const TColgp_Array1OfPnt2d& aPolyline,
497 const Handle(V3d_View)& aView,
498 const Standard_Boolean updateviewer )
500 if( aView->Viewer() == myCTX->CurrentViewer() ) {
501 myMainVS->Pick( aPolyline, aView );
503 AIS_Selection::SetCurrentSelection( mySelName.ToCString() );
504 Standard_Integer LastExt = AIS_Selection::Extent();
506 if( !myMainVS->More() )
507 return LastExt == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
509 AIS_Selection::SetCurrentSelection( mySelName.ToCString() );
512 UnhilightPicked( Standard_False );
513 for( myMainVS->Init(); myMainVS->More(); myMainVS->Next() ) {
514 const Handle(SelectMgr_EntityOwner)& EO = myMainVS->Picked();
515 if( myFilters->IsOk( EO ) ) {
516 Standard_Integer mod = EO->State() == 0 ? -1 : 0;
517 AIS_Selection::Select(EO);
522 HilightPicked( updateviewer );
524 Standard_Integer NS = AIS_Selection::Extent();
526 return AIS_SOP_OneSelected;
528 return AIS_SOP_SeveralSelected;
529 return AIS_SOP_Error;
532 //==================================================
535 //==================================================
536 void AIS_LocalContext::Hilight(const Handle(SelectMgr_EntityOwner)& Ownr,
537 const Handle(V3d_View)& aview)
540 if( aview.IsNull() ) return;
541 aview->TransientManagerClearDraw();
543 if(aview->TransientManagerBeginDraw())
544 Visual3d_TransientManager::EndDraw();
546 myMainPM->BeginDraw();
547 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
548 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
549 Ownr->HilightWithColor(myMainPM,myCTX->HilightColor(),HM);
551 myMainPM->EndDraw(aview,myCTX->ZDetection());
553 myMainPM->EndDraw(aview);
558 //==================================================
561 //==================================================
562 void AIS_LocalContext::Unhilight(const Handle(SelectMgr_EntityOwner)& Ownr,
563 const Handle(V3d_View)& aview)
566 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
567 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
569 if( aview.IsNull() ) return;
570 if( IsSelected(Ownr) ) {
571 if ( Ownr->IsAutoHilight() )
572 Ownr->HilightWithColor(myMainPM,myCTX->SelectionColor(),HM);
576 myMainPM->BeginDraw();
577 Ownr->Unhilight(myMainPM,HM);
578 myMainPM->EndDraw(aview);
580 aview->TransientManagerClearDraw();
582 if(aview->TransientManagerBeginDraw())
583 Visual3d_TransientManager::EndDraw();
584 myMainPM->BeginDraw();
585 Ownr->Unhilight(myMainPM,HM);
586 myMainPM->EndDraw(aview);
591 //=======================================================================
592 //function : HilightPicked
594 //=======================================================================
595 void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
597 Standard_Boolean updMain(Standard_False);
599 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
601 if( Sel.IsNull() ) return;
604 Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
605 SelectMgr_DataMapOfObjectOwners aMap;
607 // to avoid problems when there is a loop searching for selected objects...
608 #if !defined OCC189 && !defined USE_MAP
609 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
610 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++)
612 const Handle(Standard_Transient)& Tr = Obj(i);
614 const AIS_NListTransient& Obj = Sel->Objects();
615 AIS_NListTransient::Iterator anIter( Obj );
616 for(; anIter.More(); anIter.Next())
618 const Handle(Standard_Transient)& Tr = anIter.Value();
621 const Handle(SelectMgr_EntityOwner)& Ownr =
622 *((const Handle(SelectMgr_EntityOwner)*) &Tr);
623 Handle(AIS_InteractiveObject) IO;
624 if(Ownr->HasSelectable()){
625 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
626 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
627 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
628 IO = *((Handle(AIS_InteractiveObject)*)&SO);
629 updMain = Standard_True;
632 updMain = Standard_True;
635 updMain = Standard_True;
636 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
637 Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
638 if ( Ownr->IsAutoHilight() )
639 Ownr->HilightWithColor(PM,myCTX->SelectionColor(),HM);
640 else if ( aMap.IsBound (SO) )
641 aMap.ChangeFind(SO).Append ( Ownr );
643 SelectMgr_SequenceOfOwner aSeq;
644 aSeq.Append ( Ownr );
645 aMap.Bind ( SO, aSeq );
650 for ( SelectMgr_DataMapIteratorOfMapOfObjectOwners aMapIter(aMap);
651 aMapIter.More(); aMapIter.Next() )
652 aMapIter.Key()->HilightSelected ( myMainPM, aMapIter.Value() );
656 myCTX->CurrentViewer()->Update();
658 if(updMain) myCTX->CurrentViewer()->Update();
663 //==================================================
666 //==================================================
667 void AIS_LocalContext::
668 UnhilightPicked(const Standard_Boolean updateviewer)
670 Standard_Boolean updMain(Standard_False);
672 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
674 if( Sel.IsNull() ) return;
676 Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
677 SelectMgr_DataMapOfObjectOwners anObjMap;
678 SelectMgr_SequenceOfOwner anOwnSeq;
680 #if !defined OCC189 && !defined USE_MAP
681 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
682 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
683 const Handle(Standard_Transient)& Tr = Obj(i);
685 const AIS_NListTransient& Obj = Sel->Objects();
686 AIS_NListTransient::Iterator anIter( Obj );
687 for(; anIter.More(); anIter.Next()){
688 const Handle(Standard_Transient)& Tr = anIter.Value();
691 const Handle(SelectMgr_EntityOwner)& Ownr =
692 *((const Handle(SelectMgr_EntityOwner)*) &Tr);
693 Standard_Integer HM(0);
694 if(Ownr->HasSelectable()){
696 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
697 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
698 anObjMap.Bind ( IO, anOwnSeq );
702 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
703 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
705 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
706 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
709 updMain = Standard_True;
712 updMain = Standard_True;
714 Ownr->Unhilight(PM,HM);
718 for ( SelectMgr_DataMapIteratorOfMapOfObjectOwners anIter1 ( anObjMap );
719 anIter1.More(); anIter1.Next() )
720 if ( !anIter1.Key()->IsAutoHilight() )
721 anIter1.Key()->ClearSelected();
725 myCTX->CurrentViewer()->Update();
727 if(updMain) myCTX->CurrentViewer()->Update();
733 //=======================================================================
734 //function : IsSelected
736 //=======================================================================
737 Standard_Boolean AIS_LocalContext::IsSelected(const Handle(AIS_InteractiveObject)& anIObj) const
739 return (!FindSelectedOwnerFromIO(anIObj).IsNull());
742 //=======================================================================
743 //function : IsSelected
745 //=======================================================================
747 Standard_Boolean AIS_LocalContext::IsSelected(const Handle(SelectMgr_EntityOwner)& Ownr) const
749 if (Ownr.IsNull()) return Standard_False;
751 Standard_Boolean state = (Ownr->State()!=0);
753 Standard_Boolean state = (Ownr->State()==1);
758 //==================================================
761 //==================================================
762 void AIS_LocalContext::
765 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
766 AIS_Selection::CurrentSelection()->Init();
769 //==================================================
772 //==================================================
773 Standard_Boolean AIS_LocalContext::
776 return AIS_Selection::CurrentSelection()->More();
779 //==================================================
782 //==================================================
783 void AIS_LocalContext::
786 AIS_Selection::CurrentSelection()->Next();
789 //==================================================
792 //==================================================
793 Standard_Boolean AIS_LocalContext::
796 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
797 if( Tr.IsNull() ) return Standard_False;
798 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
799 Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
800 if(BRO.IsNull()) return Standard_False;
801 Standard_Boolean hasshape = BRO->HasShape();
802 Standard_Boolean comes = BRO->ComesFromDecomposition();
803 return (hasshape&&comes);
806 //==================================================
809 //==================================================
810 const TopoDS_Shape& AIS_LocalContext::
811 SelectedShape() const
813 static TopoDS_Shape aSh;
814 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
815 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
816 Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
824 //==================================================
827 //==================================================
828 Handle(AIS_InteractiveObject) AIS_LocalContext::
829 SelectedInteractive() const
831 Handle(AIS_InteractiveObject) IO;
832 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
834 Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
835 Handle(SelectMgr_SelectableObject) SO;
836 if(EO->HasSelectable()){
837 SO = EO->Selectable();
838 IO = *((Handle(AIS_InteractiveObject)*)&SO);
843 //==================================================
846 //==================================================
847 Handle(SelectMgr_EntityOwner) AIS_LocalContext::
848 SelectedOwner() const
850 Handle(SelectMgr_EntityOwner) EO;
851 Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
853 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
857 //==================================================
860 //==================================================
861 Standard_Boolean AIS_LocalContext::
862 HasApplicative() const
864 Handle(AIS_InteractiveObject) IO = SelectedInteractive();
865 if( IO.IsNull() ) return Standard_False;
866 return IO->HasOwner();
869 //==================================================
872 //==================================================
873 const Handle(Standard_Transient)& AIS_LocalContext::
874 SelectedApplicative() const
876 return SelectedInteractive()->GetOwner();
881 //=======================================================================
882 //function : UpdateSelection
883 //purpose : should disappear...
884 //=======================================================================
885 void AIS_LocalContext::UpdateSelected(const Standard_Boolean updateviewer)
887 UnhilightPicked(Standard_False);
888 HilightPicked(updateviewer);
891 //================================================================
892 // Function : UpdateSelected
893 // Purpose : Part of advanced selection mechanism.
894 // Highlightes or clears selection presentation for the given IO
895 //================================================================
896 void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj,
897 const Standard_Boolean updateviewer)
899 if (anobj.IsNull() || anobj->IsAutoHilight())
902 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
903 Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
905 SelectMgr_SequenceOfOwner aSeq;
906 for ( Sel->Init(); Sel->More(); Sel->Next() ){
907 Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(Sel->Value());
909 if ( !aOwner.IsNull() && aOwner->HasSelectable() && aOwner->Selectable() == anobj )
910 aSeq.Append( aOwner );
914 anobj->HilightSelected( myMainPM, aSeq );
916 anobj->ClearSelected();
919 myCTX->CurrentViewer()->Update();
923 //==================================================
924 // Function: ClearSelected
926 //==================================================
927 void AIS_LocalContext::ClearSelected(const Standard_Boolean updateviewer)
929 UnhilightPicked(updateviewer);
930 AIS_Selection::SetCurrentSelection(mySelName.ToCString());
932 Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
933 #if !defined OCC189 && !defined USE_MAP
934 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
935 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
936 const Handle(Standard_Transient)& Tr = Obj(i);
938 const AIS_NListTransient& Obj = Sel->Objects();
939 AIS_NListTransient::Iterator anIter( Obj );
940 for(; anIter.More(); anIter.Next()){
941 const Handle(Standard_Transient)& Tr = anIter.Value();
944 (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->State(0);
947 AIS_Selection::Select();
952 //=======================================================================
953 //function : SetSelected
955 //=======================================================================
956 void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,
957 const Standard_Boolean updateviewer)
959 if(!IsValidForSelection(anIObj)) return;
960 UnhilightPicked(Standard_False);
962 //1st case, owner already <anIObj> as owner
963 // and not separated is found...
965 Handle(AIS_Selection) sel = AIS_Selection::Selection(mySelName.ToCString());
966 //Standard_Boolean found(Standard_False);
967 Handle(Standard_Transient) Tr;
968 Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromIO(anIObj);
970 //check if in selection number 0 there is an owner that can be triturated...
971 if(anIObj->HasSelection(0)){
972 const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
975 Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
976 EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
980 EO = new SelectMgr_EntityOwner(anIObj);
983 ClearSelected(Standard_False);
985 AIS_Selection::Select(EO);
989 AIS_Selection::Select(EO);
991 HilightPicked(updateviewer);
994 //=======================================================================
995 //function : AddOrRemoveSelected
997 //=======================================================================
999 void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& anIObj,
1000 const Standard_Boolean updateviewer)
1002 if(!IsValidForSelection(anIObj)) return;
1003 UnhilightPicked(Standard_False);
1004 // first check if it is selected...
1005 Handle(SelectMgr_EntityOwner) EO;
1007 EO = FindSelectedOwnerFromIO(anIObj);
1015 if(anIObj->HasSelection(0)){
1016 const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
1019 Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
1020 EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
1024 EO = new SelectMgr_EntityOwner(anIObj);
1030 // cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<<mySelName<<endl;
1031 const Handle(AIS_Selection)& S = AIS_Selection::Selection(mySelName.ToCString());
1034 AIS_SelectStatus aStatus = S->Select(EO);
1035 if(aStatus == AIS_SS_Added)
1044 HilightPicked(updateviewer);
1047 //=======================================================================
1048 //function : AddOrRemoveSelected
1049 //purpose : To check...
1050 //=======================================================================
1051 void AIS_LocalContext::AddOrRemoveSelected(const TopoDS_Shape& Sh,
1052 const Standard_Boolean updateviewer)
1054 UnhilightPicked(Standard_False);
1055 Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromShape(Sh);
1057 // cout<<"AIS_LocalContext::AddOrRemoveSelected(sh) : Selection = "<<mySelName<<endl;
1060 AIS_Selection::Selection(mySelName.ToCString())->Select(EO);
1064 AIS_Selection::Selection(mySelName.ToCString())->Select(EO);
1067 HilightPicked(updateviewer);
1070 void AIS_LocalContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& Ownr,
1071 const Standard_Boolean updateviewer)
1073 //Not Yet Implemented
1075 UnhilightPicked(Standard_False);
1076 // cout<<"AIS_LocalContext::AddOrRemoveSelected(ownr) : Selection = "<<mySelName<<endl;
1078 Standard_Integer mod = Ownr->State()==0 ? 1 : 0;
1080 AIS_Selection::Selection(mySelName.ToCString())->Select(Ownr);
1086 AIS_Selection::Selection(mySelName.ToCString())->Select(Ownr);
1089 HilightPicked(updateviewer);
1092 //==================================================
1095 //==================================================
1096 void AIS_LocalContext::ManageDetected(const Handle(SelectMgr_EntityOwner)& aPickOwner,
1097 const Handle(V3d_View)& aview)
1100 // Warning : aPickOwner may be null !
1101 if (aPickOwner.IsNull()) return;
1103 if(!myAutoHilight) return;
1105 // const Handle(SelectMgr_SelectableObject)& SO = aPickOwner->Selectable();
1106 Standard_Boolean okStatus = myFilters->IsOk(aPickOwner);
1109 //=======================================================================================================
1110 // 2 cases : a- object is in the map of picks:
1111 // 1. this is the same index as the last detected: -> Do nothing
1113 // - if lastindex = 0 (no object was detected at the last step)
1114 // the object presentation is highlighted and lastindex = index(objet)
1116 // the presentation of the object corresponding to lastindex is "unhighlighted"
1117 // it is removed if the object is not visualized but only active
1118 // then the presentation of the detected object is highlighted and lastindex = index(objet)
1119 // b- the object is not in the map of picked objects
1120 // - if lastindex != 0 (object detected at the last step) it is unhighlighted ...
1121 // if the object was decomposed, presentation is created for the detected shape and the couple
1122 // (Proprietaire,Prs)is added in the map.
1123 // otherwise the couple(proprietaire, NullPrs) is placed in the map and the interactive object
1124 // itself is highlighted.
1126 //=======================================================================================================
1130 Standard_Boolean wasContained = myMapOfOwner.Contains(aPickOwner);
1131 Standard_Integer theNewIndex = 0;
1133 theNewIndex = myMapOfOwner.FindIndex(aPickOwner);
1135 theNewIndex = myMapOfOwner.Add(aPickOwner);
1137 // For the advanced mesh selection mode the owner indices comparison
1138 // is not effective because in that case only one owner manage the
1139 // selection in current selection mode. It is necessary to check the current detected
1140 // entity and hilight it only if the detected entity is not the same as
1141 // previous detected (IsForcedHilight call)
1142 if (theNewIndex != mylastindex || aPickOwner->IsForcedHilight()) {
1144 if (mylastindex && mylastindex <= myMapOfOwner.Extent()) {
1146 const Handle(SelectMgr_EntityOwner)& LastOwnr = myMapOfOwner(mylastindex);
1148 Unhilight(LastOwnr,aview);
1150 if(!IsSelected(LastOwnr))
1151 Unhilight(LastOwnr,aview);
1155 if (myAutoHilight) {
1156 // wasContained should not be checked because with this verification different
1157 // behaviour of application may occer depending whether mouse is moved above
1158 // owner first or second time
1159 //if (wasContained) {
1161 if (aPickOwner->State() <= 0 || myCTX->ToHilightSelected())
1163 if(!IsSelected (aPickOwner) || myCTX->ToHilightSelected())
1165 Hilight(aPickOwner,aview);
1167 else Hilight(aPickOwner,aview);*/
1170 mylastindex = theNewIndex;
1174 if (mylastindex) mylastgood = mylastindex;
1179 //=======================================================================
1180 //function : HasDetectedShape
1182 //=======================================================================
1184 Standard_Boolean AIS_LocalContext::HasDetectedShape() const
1186 if(mylastindex==0) return Standard_False;
1187 return IsShape(mylastindex);
1190 //=======================================================================
1191 //function : DetectedShape
1193 //=======================================================================
1196 AIS_LocalContext::DetectedShape() const
1198 static TopoDS_Shape bidsh;
1199 if(mylastindex != 0)
1201 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner(mylastindex));
1202 if(BROwnr.IsNull()) return bidsh;
1203 return BROwnr->Shape();
1208 //=======================================================================
1209 //function : DetectedInteractive
1211 //=======================================================================
1213 Handle(AIS_InteractiveObject)
1214 AIS_LocalContext::DetectedInteractive() const
1216 Handle(AIS_InteractiveObject) Iobj;
1217 if(IsValidIndex(mylastindex)){
1218 Handle(SelectMgr_SelectableObject) SO = myMapOfOwner.FindKey(mylastindex)->Selectable();
1219 Iobj = *((Handle(AIS_InteractiveObject)*) &SO);
1223 //=======================================================================
1224 //function : DetectedInteractive
1226 //=======================================================================
1227 Handle(SelectMgr_EntityOwner) AIS_LocalContext::DetectedOwner() const
1229 Handle(SelectMgr_EntityOwner) bid;
1230 if(!IsValidIndex(mylastindex)) return bid;
1231 return myMapOfOwner.FindKey(mylastindex);
1235 //=======================================================================
1236 //function : ComesFromDecomposition
1238 //=======================================================================
1240 Standard_Boolean AIS_LocalContext::ComesFromDecomposition(const Standard_Integer PickedIndex) const
1242 const Handle(SelectMgr_EntityOwner)& OWN = myMapOfOwner.FindKey(PickedIndex);
1243 Handle(SelectMgr_SelectableObject) aSel = OWN->Selectable();
1244 if (myActiveObjects.IsBound (aSel)) { // debug of jmi
1245 const Handle(AIS_LocalStatus)& Stat = myActiveObjects(aSel);
1246 return Stat->Decomposed();
1248 return Standard_False;
1252 //=======================================================================
1253 //function : DisplayAreas
1255 //=======================================================================
1257 void AIS_LocalContext::DisplayAreas(const Handle(V3d_View)& aviou)
1259 myMainVS->DisplayAreas(aviou);
1262 //=======================================================================
1263 //function : ClearAreas
1265 //=======================================================================
1267 void AIS_LocalContext::ClearAreas(const Handle(V3d_View)& aviou)
1269 myMainVS->ClearAreas(aviou);
1272 //=======================================================================
1273 //function : DisplaySensitive
1275 //=======================================================================
1277 void AIS_LocalContext::DisplaySensitive(const Handle(V3d_View)& aviou)
1279 myMainVS->DisplaySensitive(aviou);
1282 //=======================================================================
1283 //function : ClearSensitive
1285 //=======================================================================
1287 void AIS_LocalContext::ClearSensitive(const Handle(V3d_View)& aviou)
1289 myMainVS->ClearSensitive(aviou);
1293 //=======================================================================
1294 //function : IsShape
1296 //=======================================================================
1297 Standard_Boolean AIS_LocalContext::IsShape(const Standard_Integer Index) const
1300 if(Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner.FindKey(Index)).IsNull())
1301 return Standard_False;
1303 ComesFromDecomposition(Index);
1306 Standard_Boolean AIS_LocalContext::IsValidForSelection(const Handle(AIS_InteractiveObject)& anIObj) const
1310 // Shape was not transfered from AIS_Shape to EntityOwner
1311 Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(anIObj);
1312 if( !shape.IsNull() )
1313 return myFilters->IsOk(new StdSelect_BRepOwner(shape->Shape(),shape));
1315 return myFilters->IsOk(new SelectMgr_EntityOwner(anIObj));
1319 //=======================================================================
1320 //function : HilightNextDetected
1322 //=======================================================================
1324 Standard_Integer AIS_LocalContext::HilightNextDetected(const Handle(V3d_View)& V)
1326 // go to the next owner
1328 if(myDetectedSeq.IsEmpty()) return Standard_False;
1329 Standard_Integer L = myDetectedSeq.Length();
1334 Handle(SelectMgr_EntityOwner) EO = myMainVS->Picked(myCurDetected);
1336 if( EO.IsNull() ) return 0;
1339 static Standard_Boolean Normal_State(Standard_True);
1340 static Standard_Boolean firsttime(Standard_True);
1342 OSD_Environment toto("HITRI");
1343 if(!toto.Value().IsEmpty())
1344 Normal_State = Standard_False;
1345 firsttime = Standard_False;
1350 ManageDetected(EO,V);
1352 HilightTriangle(myCurDetected,V);
1353 return myCurDetected;
1356 //=======================================================================
1357 //function : HilightPreviousDetected
1359 //=======================================================================
1360 Standard_Integer AIS_LocalContext::HilightPreviousDetected(const Handle(V3d_View)& V)
1362 if(myDetectedSeq.IsEmpty()) return Standard_False;
1368 Handle(SelectMgr_EntityOwner) EO = myMainVS->Picked(myCurDetected);
1370 if( EO.IsNull() ) return 0;
1373 static Standard_Boolean Normal_State(Standard_True);
1374 static Standard_Boolean firsttime(Standard_True);
1376 OSD_Environment toto("HITRI");
1377 if(!toto.Value().IsEmpty())
1378 Normal_State = Standard_False;
1379 firsttime = Standard_False;
1385 ManageDetected(EO,V);
1387 HilightTriangle(myCurDetected,V);
1388 return myCurDetected;
1391 //=======================================================================
1392 //function : UnhilightLastDetected
1394 //=======================================================================
1395 Standard_Boolean AIS_LocalContext::UnhilightLastDetected(const Handle(V3d_View)& aview)
1397 if(!IsValidIndex(mylastindex)) return Standard_False;
1398 myMainPM->BeginDraw();
1399 const Handle(SelectMgr_EntityOwner)& Ownr = myMapOfOwner(mylastindex);
1400 Standard_Integer HM(0);
1401 if(Ownr->HasSelectable()){
1402 Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
1403 HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO));
1405 myMapOfOwner(mylastindex)->Unhilight(myMainPM,HM);
1406 myMainPM->EndDraw(aview);
1408 return Standard_True;
1413 //=======================================================================
1414 //function : HilightTriangle
1416 //=======================================================================
1418 void AIS_LocalContext::HilightTriangle(const Standard_Integer Rank,
1419 const Handle(V3d_View)& view)
1421 static Standard_Integer PrevRank(0);
1422 if(Rank==PrevRank) return;
1423 Handle(SelectBasics_SensitiveEntity) SE = myMainVS->Primitive(Rank);
1424 if(SE->IsKind(STANDARD_TYPE(Select3D_SensitiveTriangulation)))
1426 Handle(Select3D_SensitiveTriangulation) Tr = *((Handle(Select3D_SensitiveTriangulation)*)&SE);
1427 gp_Pnt p1,p2,p3 ; Tr->DetectedTriangle(p1,p2,p3);
1429 Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles(3);
1430 aTris->AddVertex(p1);
1431 aTris->AddVertex(p2);
1432 aTris->AddVertex(p3);
1434 static Handle(Prs3d_Presentation) TriPrs =
1435 new Prs3d_Presentation(myMainPM->StructureManager());
1438 Handle(Prs3d_ShadingAspect) asp = myCTX->DefaultDrawer()->ShadingAspect();
1439 asp->SetColor(myCTX->HilightColor());
1440 TriPrs->SetShadingAspect(asp);
1442 Prs3d_Root::CurrentGroup(TriPrs)->AddPrimitiveArray(aTris);
1445 if(view->TransientManagerBeginDraw())
1446 Visual3d_TransientManager::EndDraw();
1448 if(view->TransientManagerBeginDraw()) {
1449 Visual3d_TransientManager::DrawStructure(TriPrs);
1450 Visual3d_TransientManager::EndDraw();
1455 //=======================================================================
1456 //function : FindSelectedOwnerFromIO
1457 //purpose : it is checked if one of the selected owners really presents IObj
1458 //=======================================================================
1459 Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO
1460 (const Handle(AIS_InteractiveObject)& anIObj) const
1462 Handle(SelectMgr_EntityOwner) EO,bid;
1463 if (anIObj.IsNull()) return EO;
1465 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
1468 cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "
1469 <<mySelName<<" Nulle "<<endl;
1473 Standard_Boolean found(Standard_False);
1474 #if !defined OCC189 && !defined USE_MAP
1475 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
1476 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
1477 const Handle(Standard_Transient)& Tr = Obj(i);
1479 const AIS_NListTransient& Obj = Sel->Objects();
1480 AIS_NListTransient::Iterator anIter( Obj );
1481 for(; anIter.More(); anIter.Next()){
1482 const Handle(Standard_Transient)& Tr = anIter.Value();
1485 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
1486 if(EO->HasSelectable()){
1487 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
1488 if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
1489 if (anIObj == EO->Selectable()){
1490 found =Standard_True;
1497 if(found) return EO;
1501 //=======================================================================
1502 //function : FindSelectedOwnerFromShape
1503 //purpose : it is checked if one of the selected owners really presents IObj
1504 //=======================================================================
1505 Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const TopoDS_Shape& sh) const
1508 Handle(SelectMgr_EntityOwner) EO, bid;
1510 Handle(SelectMgr_EntityOwner) EO;
1512 if (sh.IsNull()) return EO;
1514 Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
1517 cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<<mySelName<<" Nulle "<<endl;
1522 Standard_Boolean found(Standard_False);
1526 SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive aSensitiveIt (myMainVS->Primitives());
1527 for (; aSensitiveIt.More(); aSensitiveIt.Next()) {
1528 EO = Handle(SelectMgr_EntityOwner)::DownCast (aSensitiveIt.Value()->OwnerId());
1529 Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
1530 if (!BROwnr.IsNull() && BROwnr->HasShape() && BROwnr->Shape() == sh) {
1531 found = Standard_True;
1537 #if !defined OCC189 && !defined USE_MAP
1538 const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
1539 for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
1540 const Handle(Standard_Transient)& Tr = Obj(i);
1542 const AIS_NListTransient& Obj = Sel->Objects();
1543 AIS_NListTransient::Iterator anIter( Obj );
1544 for(; anIter.More(); anIter.Next()){
1545 const Handle(Standard_Transient)& Tr = anIter.Value();
1549 EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
1551 if ( EO->Shape() == sh)
1552 found =Standard_True;
1558 if(found) return EO;
1563 //=======================================================================
1564 //function : AIS_LocalContext::InitDetected
1566 //=======================================================================
1568 void AIS_LocalContext::InitDetected()
1570 myAISCurDetected = myAISDetectedSeq.Length()? 1 : 0;
1573 //=======================================================================
1574 //function : AIS_LocalContext::MoreDetected
1576 //=======================================================================
1578 Standard_Boolean AIS_LocalContext::MoreDetected() const
1580 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length());
1584 //=======================================================================
1585 //function : AIS_LocalContext::NextDetected
1587 //=======================================================================
1589 void AIS_LocalContext::NextDetected()
1591 if (MoreDetected()) myAISCurDetected++;
1594 //=======================================================================
1595 //function : DetectedCurrentShape
1597 //=======================================================================
1599 const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const
1601 static TopoDS_Shape bidsh;
1603 return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape();
1607 //=======================================================================
1608 //function : DetectedCurrentObject
1610 //=======================================================================
1612 Handle(AIS_InteractiveObject) AIS_LocalContext::DetectedCurrentObject() const
1614 Handle(AIS_InteractiveObject) theIObj;
1616 theIObj = myAISDetectedSeq(myAISCurDetected);