0023654: Problem with displaying vertices in OCC view after closing all OCC views...
[occt.git] / src / AIS / AIS_InteractiveContext_1.cxx
CommitLineData
b311480e 1// Created on: 1997-01-29
2// Created by: Robert COUBLANC
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
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.
10//
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.
13//
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.
20
7fd59977 21
22#define UKI60826 //GG_161199 Use the requested selection color instead of default
23
24#define IMP280200 //GG Don't returns a NULL shape in SelectedShape()
25// method when the current selected is a shape !
26
27#define BUC60814 //GG_300101 Idem UKI60826
28
29#define IMP150501 //GG_150501 CADPAK_V2 Add Drag() method
30
31#define IMP160701 //ZSV Add InitDetected(),MoreDetected(),NextDetected(),
32// DetectedCurrentShape(),DetectedCurrentObject()
33// methods
34
35#define IMP191001 //GG Avoid to raise when switching with the
36// SetAutomaticHilight() method.
37// Thanks to IFO of SAMTECH company for this improvment.
38
39#define OCC138 //VTN Avoding infinit loop in AddOrRemoveCurrentObject method.
40
41#define OCC9657
42
43#include <AIS_InteractiveContext.jxx>
44#include <SelectMgr_EntityOwner.hxx>
45#include <AIS_Selection.hxx>
46#include <AIS_StatusOfDetection.hxx>
47#include <AIS_StatusOfPick.hxx>
48
49#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
50#include <AIS_LocalContext.hxx>
51#include <AIS_GlobalStatus.hxx>
52#include <AIS_Shape.hxx>
53
54#include <V3d_Light.hxx>
55#include <V3d_PositionalLight.hxx>
56#include <V3d_SpotLight.hxx>
57#include <V3d_DirectionalLight.hxx>
58#include <V3d_AmbientLight.hxx>
59
60#include <TColStd_ListIteratorOfListOfInteger.hxx>
61#include <SelectMgr_Selection.hxx>
62#include <SelectBasics_SensitiveEntity.hxx>
63
64#ifdef IMP150501
65#include <Visual3d_TransientManager.hxx>
66#include <Prs3d_Presentation.hxx>
67#endif
68
69#ifdef OCC9657
70#include <AIS_MapOfInteractive.hxx>
71#include <AIS_MapIteratorOfMapOfInteractive.hxx>
72#endif
73
74//unused
75/*#ifdef DEB
76static void InfoOnLight(const Handle(V3d_View) aView)
77{
78 Standard_Real V1=0.,V2=0.,V3=0.;
79 Standard_Integer IndexOfLit(0);
80
81 static Standard_Boolean FirstTime (Standard_True);
82 if(FirstTime)
83 {
84 FirstTime = Standard_False;
85 for (aView->InitActiveLights();aView->MoreActiveLights();aView->NextActiveLights()){
86 IndexOfLit++;
87 cout<<"lumiere no "<<IndexOfLit<<"\n************\n\t";
88 Handle(V3d_Light) Li = aView->ActiveLight();
89 Quantity_NameOfColor Col;
90 Li->Color(Col);
91 cout<<"Color :"<<Standard_Integer(Col)<<"\n\t"<<endl;
92 cout<<"type :";
93 switch(Li->Type()){
94 case V3d_AMBIENT:
95 {
96 cout<<" AMBIENT\n\t";
97//POP K4L
98// Handle(V3d_AmbientLight)::DownCast(Li)->DisplayPosition(V1,V2,V3);
99 cout<<"Position : X1 = "<<V1<<" X2 = "<<V2<<" X3 = "<<V3<<endl;
100 break;
101 }
102 case V3d_DIRECTIONAL:
103 {
104 cout<<" DIRECTIONAL\n\t";
105 Handle(V3d_DirectionalLight)::DownCast(Li)->DisplayPosition(V1,V2,V3);
106 cout<<"Position : X1 = "<<V1<<" X2 = "<<V2<<" X3 = "<<V3<<endl;
107 Handle(V3d_DirectionalLight)::DownCast(Li)->Direction(V1,V2,V3);
108 cout<<"Direction : V1 = "<<V1<<" V2 = "<<V2<<" V3 = "<<V3<<endl;
109
110 break;
111 }
112 case V3d_POSITIONAL:
113 {
114 cout<<" POSITIONAL\n\t";
115 Handle(V3d_PositionalLight)::DownCast(Li)->Position(V1,V2,V3);
116 cout<<"Position : X1 = "<<V1<<" X2 = "<<V2<<" X3 = "<<V3<<endl;
117 Handle(V3d_PositionalLight)::DownCast(Li)->Target(V1,V2,V3);
118 cout<<"Target : x1 = "<<V1<<" x2 = "<<V2<<" x3 = "<<V3<<endl;
119 break;
120 }
121 case V3d_SPOT:
122 {
123 cout<<" SPOT\n\t";
124 cout<<" DIRECTIONAL\n\t";
125 Handle(V3d_SpotLight)::DownCast(Li)->Position(V1,V2,V3);
126 cout<<"Position : X1 = "<<V1<<" X2 = "<<V2<<" X3 = "<<V3<<endl;
127 Handle(V3d_SpotLight)::DownCast(Li)->Direction(V1,V2,V3);
128 cout<<"Direction : V1 = "<<V1<<" V2 = "<<V2<<" V3 = "<<V3<<endl;
129 Handle(V3d_PositionalLight)::DownCast(Li)->Target(V1,V2,V3);
130 cout<<"Target : x1 = "<<V1<<" x2 = "<<V2<<" x3 = "<<V3<<endl;
131 cout<<"\tAngle :"<<Handle(V3d_SpotLight)::DownCast(Li)->Angle()<<endl;
132 break;
133 }
134 }
135 }
136 }
137}
138#endif
139*/
140//=======================================================================
141//function : MoveTo
142//purpose :
143//=======================================================================
144
145AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix,
146 const Standard_Integer YPix,
147 const Handle(V3d_View)& aView)
148{
eb4320f2 149 if(HasOpenedContext()){
7fd59977 150 myWasLastMain = Standard_True;
151 return myLocalContexts(myCurLocalIndex)->MoveTo(XPix,YPix,aView);
152 }
153
154#ifdef IMP160701
155 //Nullify class members storing information about detected AIS objects.
156 myAISCurDetected = 0;
157 myAISDetectedSeq.Clear();
158#endif
159
160 // OCC11904 - local variables made non-static - it looks and works better like this
161 Handle (PrsMgr_PresentationManager3d) pmgr ;
162 Handle (StdSelect_ViewerSelector3d) selector;
163 Standard_Boolean ismain = Standard_True,UpdVwr = Standard_False;
164
165 // Preliminaires
166 if(aView->Viewer()== myMainVwr) {
167 pmgr = myMainPM;
168 selector=myMainSel;
169 myLastPicked = myLastinMain;
170 myWasLastMain = Standard_True;
171 }
7fd59977 172 else
173 return AIS_SOD_Error;
174
175 AIS_StatusOfDetection TheStat(AIS_SOD_Nothing);
176
177
178 // allonzy
179 selector->Pick(XPix, YPix, aView);
180
181#ifdef IMP160701
182 //filling of myAISDetectedSeq sequence storing information about detected AIS objects
183 // (the objects must be AIS_Shapes).
184 Handle(SelectMgr_EntityOwner) anEntityOwner;
185 const Standard_Integer NbDetected = selector->NbPicked();
186 for(Standard_Integer i_detect = 1;i_detect<=NbDetected;i_detect++)
187 {
188 anEntityOwner = selector->Picked(i_detect);
189 if(!anEntityOwner.IsNull())
190 if(myFilters->IsOk(anEntityOwner))
191 {
192 Handle(AIS_InteractiveObject) anObj =
193 Handle(AIS_InteractiveObject)::DownCast(anEntityOwner->Selectable());
194 if(!Handle(AIS_Shape)::DownCast(anObj).IsNull())
195 myAISDetectedSeq.Append(anObj);
196 }
197 }
198#endif
199
200 selector->Init();
201 if ( selector->More() )
202 {
eafb234b 203 if ( HasOpenedContext() )
204 {
7fd59977 205 if ( !myFilters->IsOk( selector->OnePicked() ) )
eafb234b 206 return AIS_SOD_AllBad;
7fd59977 207 else
208 if ( !myLocalContexts( myCurLocalIndex )->Filter()->IsOk( selector->OnePicked() ) )
209 return AIS_SOD_AllBad;
eafb234b 210 }
81bba717 211
7fd59977 212 // Does nothing if previously detected object is equal to the current one
213 if ( selector->OnePicked()->Selectable() == myLastPicked )
214 return AIS_SOD_OnlyOneDetected;
81bba717 215
7fd59977 216 // Previously detected object is unhilighted if it is not selected or hilighted
217 // with selection color if it is selected. Such highlighting with selection color
218 // is needed only if myToHilightSelected flag is true. In this case previously detected
219 // object has been already highlighted with myHilightColor during previous MoveTo()
220 // method call. As result it is necessary to rehighligt it with mySelectionColor.
221 if ( !myLastPicked.IsNull() )
222 {
223 Standard_Integer HiMod =
224 myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
225 if ( myLastPicked->State() != 1 )
226 {
227 pmgr->Unhighlight( myLastPicked, HiMod );
228 UpdVwr = Standard_True;
229 }
230 else if ( myToHilightSelected )
231 {
232 pmgr->Color( myLastPicked, mySelectionColor, HiMod );
233 UpdVwr = Standard_True;
234 }
235 }
236
237 // Initialize myLastPicked field with currently detected object
238 Handle(SelectMgr_SelectableObject) SO = selector->OnePicked()->Selectable();
239 myLastPicked = *((Handle(AIS_InteractiveObject)*)&SO);
240
241 if ( ismain )
242 myLastinMain = myLastPicked;
7fd59977 243#ifdef IMP191001
244 // Highlight detected object if it is not selected or myToHilightSelected flag is true
245 if ( !myLastPicked.IsNull() &&
246 ( myLastPicked->State()!= 1 || myToHilightSelected ) )
247#else
248 if ( myLastPicked->State()!= 1 )
249#endif
250 {
251 Standard_Integer HiMod =
252 myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
253 pmgr->Color( myLastPicked, myHilightColor, HiMod );
254 UpdVwr = Standard_True;
255 }
256
257 if ( myLastPicked->State()==1 )
258 TheStat = AIS_SOD_Selected;
259 }
260 else
261 {
262 // Previously detected object is unhilighted if it is not selected or hilighted
263 // with selection color if it is selected.
264 TheStat = AIS_SOD_Nothing;
265 if ( !myLastPicked.IsNull() )
266 {
267 Standard_Integer HiMod =
268 myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
269 if ( myLastPicked->State() != 1 )
270 {
271 pmgr->Unhighlight( myLastPicked, HiMod );
272 UpdVwr = Standard_True;
273 }
274 else if ( myToHilightSelected )
275 {
276 pmgr->Color( myLastPicked, mySelectionColor, HiMod );
277 UpdVwr = Standard_True;
278 }
279 }
280
281 if ( ismain )
282 myLastinMain.Nullify();
7fd59977 283 }
284
285 if(UpdVwr) aView->Viewer()->Update();
286 myLastPicked.Nullify();
287
288 mylastmoveview = aView;
289 return TheStat;
290}
291
292//=======================================================================
293//function : Select
294//purpose :
295//=======================================================================
296
297AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Integer XPMin,
298 const Standard_Integer YPMin,
299 const Standard_Integer XPMax,
300 const Standard_Integer YPMax,
301 const Handle(V3d_View)& aView,
302 const Standard_Boolean updateviewer)
303{
81bba717 304 // all objects detected by the selector are taken, previous current objects are emptied,
305 // new objects are put...
7fd59977 306
307 if(HasOpenedContext())
308 return myLocalContexts(myCurLocalIndex)->Select(XPMin,YPMin,XPMax,YPMax,aView,updateviewer);
309
310 ClearCurrents(Standard_False);
311 // OCC11904 - local variables made non-static - it looks and works better like this
312 Handle(StdSelect_ViewerSelector3d) selector;
313
314 if(aView->Viewer()== myMainVwr) {
315 selector= myMainSel;
316 myWasLastMain = Standard_True;}
eb4320f2 317
7fd59977 318 selector->Pick(XPMin,YPMin,XPMax,YPMax,aView);
319 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
320
321#ifdef OCC9657
322 AIS_MapOfInteractive theSelectedObj;
323 for( selector->Init(); selector->More(); selector->Next() )
324 {
325 Handle( AIS_InteractiveObject ) anObj =
326 Handle( AIS_InteractiveObject )::DownCast( selector->Picked()->Selectable() );
327 if( !anObj.IsNull() )
328 theSelectedObj.Add( anObj );
329 }
330 AIS_MapIteratorOfMapOfInteractive anIt( theSelectedObj );
331 for( ; anIt.More(); anIt.Next() )
332 {
333 AIS_Selection::Select( anIt.Key() );
334 anIt.Key()->State(1);
335 }
336#else
337 for(selector->Init();selector->More();selector->Next()){
338 const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable();
339 if(!SO.IsNull()){
340#ifdef OCC138
341 AIS_Selection::Select(SO);
342 (*((Handle(AIS_InteractiveObject)*)&SO))->State(1);
343#else
344 (*((Handle(AIS_InteractiveObject)*)&SO))->State(1);
345 AIS_Selection::Select(SO);
346#endif //OCC138
347 }
348 }
349
350#endif //OCC9657
351 HilightCurrents(updateviewer);
352
353 Standard_Integer NS = NbCurrents();
354 if(NS==0) return AIS_SOP_NothingSelected;
355 if(NS==1) return AIS_SOP_OneSelected;
356 return AIS_SOP_SeveralSelected;
357
358}
359
360//=======================================================================
361//function : Select
362//purpose : Selection by polyline
363//=======================================================================
364
365AIS_StatusOfPick AIS_InteractiveContext::Select(const TColgp_Array1OfPnt2d& aPolyline,
366 const Handle(V3d_View)& aView,
367 const Standard_Boolean updateviewer)
368{
81bba717 369 // all objects detected by the selector are taken, previous current objects are emptied,
370 // new objects are put...
7fd59977 371
372 if(HasOpenedContext())
373 return myLocalContexts(myCurLocalIndex)->Select(aPolyline,aView,updateviewer);
374
375 ClearCurrents(Standard_False);
376 // OCC11904 - local variables made non-static - it looks and works better like this
377 Handle(StdSelect_ViewerSelector3d) selector;
378
379 if(aView->Viewer()== myMainVwr) {
380 selector= myMainSel;
381 myWasLastMain = Standard_True;}
eb4320f2 382
7fd59977 383 selector->Pick(aPolyline,aView);
384 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
385
386
387#ifdef OCC9657
388 AIS_MapOfInteractive theSelectedObj;
389 for( selector->Init(); selector->More(); selector->Next() )
390 {
391 Handle( AIS_InteractiveObject ) anObj =
392 Handle( AIS_InteractiveObject )::DownCast( selector->Picked()->Selectable() );
393 if( !anObj.IsNull() )
394 theSelectedObj.Add( anObj );
395 }
396 AIS_MapIteratorOfMapOfInteractive anIt( theSelectedObj );
397 for( ; anIt.More(); anIt.Next() )
398 {
399 AIS_Selection::Select( anIt.Key() );
400 anIt.Key()->State(1);
401 }
402#else
403 for(selector->Init();selector->More();selector->Next()){
404 const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable();
405 if(!SO.IsNull()){
406#ifdef OCC138
407 AIS_Selection::Select(SO);
408 (*((Handle(AIS_InteractiveObject)*)&SO))->State(1);
409#else
410 (*((Handle(AIS_InteractiveObject)*)&SO))->State(1);
411 AIS_Selection::Select(SO);
412#endif //OCC138
413 }
414 }
415#endif //OCC9657
416 HilightCurrents(updateviewer);
417
418 Standard_Integer NS = NbCurrents();
419 if(NS==0) return AIS_SOP_NothingSelected;
420 if(NS==1) return AIS_SOP_OneSelected;
421 return AIS_SOP_SeveralSelected;
422
423}
424
425//=======================================================================
426//function : Select
427//purpose :
428//=======================================================================
429
430AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Boolean updateviewer)
431{
432 if(HasOpenedContext()){
433 if(myWasLastMain)
434 return myLocalContexts(myCurLocalIndex)->Select(updateviewer);
435 else
81bba717 436 // picking was done in the collector, special processing is required...
7fd59977 437 {
438 myLocalContexts(myCurLocalIndex)->SetSelected(myLastPicked,updateviewer);
439 return AIS_SOP_OneSelected;
440 }
441 }
442// AIS_StatusOfPick PS(AIS_SOP_NothingSelected);
443 if(myWasLastMain && !myLastinMain.IsNull()){
444 if(myLastinMain->State()!=1){
445 SetCurrentObject(myLastinMain,Standard_False);
446 if(updateviewer)
447 UpdateCurrentViewer();}
448 }
7fd59977 449 else{
450 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
451 Handle(AIS_Selection) S = AIS_Selection::CurrentSelection();
452 Handle(Standard_Transient) Tr;
453 Handle(AIS_InteractiveObject) IO;
454
455 for(S->Init();S->More();S->Next()){
456 Tr = S->Value();
457 IO = (*((Handle(AIS_InteractiveObject)*)&Tr));
458 IO->State(0);
459 Unhilight(IO,Standard_False);
460 if(myObjects.IsBound(IO)){ // anti-plantage-rob
461 if(myObjects(IO)->IsSubIntensityOn())
462 HilightWithColor(IO,mySubIntensity,Standard_False);
463 }
464 }
465
466 AIS_Selection::Select();
467 if(updateviewer){
468 if(myWasLastMain)
eb4320f2 469 UpdateCurrentViewer();
7fd59977 470 }
471 }
472 Standard_Integer NS = NbCurrents();
473 if(NS==0) return AIS_SOP_NothingSelected;
474 if(NS==1) return AIS_SOP_OneSelected;
475 return AIS_SOP_SeveralSelected;
476}
477
478//=======================================================================
479//function : ShiftSelect
480//purpose :
481//=======================================================================
482
483AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const Standard_Boolean updateviewer)
484{
485 if(HasOpenedContext()){
486 if(myWasLastMain)
487 return myLocalContexts(myCurLocalIndex)->ShiftSelect(updateviewer);
488 else{
489 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(myLastPicked,updateviewer);
490 Standard_Integer NS =NbSelected();
491 if(NS==0) return AIS_SOP_NothingSelected;
492 if(NS==1) return AIS_SOP_OneSelected;
493 return AIS_SOP_SeveralSelected;
494 }
495 }
496 if(myWasLastMain && !myLastinMain.IsNull())
497 AddOrRemoveCurrentObject(myLastinMain,updateviewer);
eb4320f2 498
7fd59977 499 Standard_Integer NS = NbCurrents();
500 if(NS==0) return AIS_SOP_NothingSelected;
501 if(NS==1) return AIS_SOP_OneSelected;
502 return AIS_SOP_SeveralSelected;
503}
504
505
506//=======================================================================
507//function : ShiftSelect
508//purpose :
509//=======================================================================
510
511AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const Standard_Integer XPMin,
512 const Standard_Integer YPMin,
513 const Standard_Integer XPMax,
514 const Standard_Integer YPMax,
515 const Handle(V3d_View)& aView,
516 const Standard_Boolean updateviewer)
517{
518
519 if(HasOpenedContext())
520 return myLocalContexts(myCurLocalIndex)->ShiftSelect(XPMin,YPMin,XPMax,YPMax,aView,updateviewer);
521
522 UnhilightCurrents(Standard_False);
523 // OCC11904 - local variables made non-static - it looks and works better like this
524 Handle(StdSelect_ViewerSelector3d) selector;
525
526 if(aView->Viewer()== myMainVwr) {
527 selector= myMainSel;
528 myWasLastMain = Standard_True;}
7fd59977 529 else
530 return AIS_SOP_NothingSelected;
531
532 selector->Pick(XPMin,YPMin,XPMax,YPMax,aView);
533 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
534 for(selector->Init();selector->More();selector->Next()){
535 const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable();
536 if(!SO.IsNull()){
537 AIS_SelectStatus SelStat = AIS_Selection::Select(SO);
538 Standard_Integer mod = (SelStat==AIS_SS_Added)?1:0;
539 (*((Handle(AIS_InteractiveObject)*)&SO))->State(mod);
540 }
541 }
542
543 HilightCurrents(updateviewer);
544
545 Standard_Integer NS =NbCurrents();
546 if(NS==0) return AIS_SOP_NothingSelected;
547 if(NS==1) return AIS_SOP_OneSelected;
548 return AIS_SOP_SeveralSelected;
549
550}
551
552//=======================================================================
553//function : ShiftSelect
554//purpose :
555//=======================================================================
556
557AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect( const TColgp_Array1OfPnt2d& aPolyline,
558 const Handle(V3d_View)& aView,
559 const Standard_Boolean updateviewer )
560{
561 if( HasOpenedContext() )
562 return myLocalContexts( myCurLocalIndex )->ShiftSelect( aPolyline, aView, updateviewer );
563
564 UnhilightCurrents( Standard_False );
565 // OCC11904 - local variables made non-static - it looks and works better like this
566 Handle(StdSelect_ViewerSelector3d) selector;
567
568 if( aView->Viewer() == myMainVwr ) {
569 selector= myMainSel;
570 myWasLastMain = Standard_True;
571 }
7fd59977 572 else
573 return AIS_SOP_NothingSelected;
574
575 selector->Pick( aPolyline, aView );
576
577 AIS_Selection::SetCurrentSelection( myCurrentName.ToCString() );
578 for( selector->Init(); selector->More(); selector->Next() ) {
579 const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable();
580 if( !SO.IsNull() ) {
581 AIS_SelectStatus SelStat = AIS_Selection::Select( SO );
582 Standard_Integer mod = ( SelStat == AIS_SS_Added ) ? 1 : 0;
583 (*((Handle(AIS_InteractiveObject)*)&SO))->State( mod );
584 }
585 }
586
587 HilightCurrents( updateviewer );
588 Standard_Integer NS = NbCurrents();
589 if( NS == 0 ) return AIS_SOP_NothingSelected;
590 if( NS == 1 ) return AIS_SOP_OneSelected;
591 return AIS_SOP_SeveralSelected;
592}
593
594//=======================================================================
595//function : SetCurrentObject
596//purpose :
597//=======================================================================
598
599void AIS_InteractiveContext::SetCurrentObject(const Handle(AIS_InteractiveObject)& anIObj,
600 const Standard_Boolean updateviewer)
601{
81bba717 602 // single case processing...
7fd59977 603 if(NbCurrents()==1 && anIObj->State()==1){
604 Quantity_NameOfColor HiCol;
605 Standard_Boolean HasHiCol;
606 if(IsHilighted(anIObj,HasHiCol,HiCol)){
607 if(HasHiCol && HiCol!= mySelectionColor) {
608#ifdef UKI60826
609 HilightWithColor(anIObj,mySelectionColor,updateviewer);
610#else
611 Hilight(anIObj,updateviewer);
612#endif
613 }
614 }
615 return;
616 }
617
618
619 //
620 if(!HasOpenedContext()) {
621 if(anIObj.IsNull()) return;
622 if(!myObjects.IsBound(anIObj))
623 Display(anIObj,Standard_False);
624
625 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
626 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
627 Handle(Standard_Transient) TR;
628 Handle(AIS_InteractiveObject) IO;
629 sel->Init();
630 while (sel->More()) {
631 TR = sel->Value();
632 IO = *((Handle(AIS_InteractiveObject)*)&TR);
633 Unhilight(IO,Standard_False);
634 IO->State(0);
635 sel->Next();
636 }
637
81bba717 638 // added to avoid untimely viewer update...
7fd59977 639 AIS_Selection::ClearAndSelect(anIObj);
640 anIObj->State(1);
641 Quantity_NameOfColor HiCol;
642 Standard_Boolean HasHiCol;
643 if(IsHilighted(anIObj,HasHiCol,HiCol)){
644 if(HasHiCol && HiCol!= mySelectionColor) {
645#ifdef UKI60826
646 HilightWithColor(anIObj,mySelectionColor,Standard_False);
647#else
648 Hilight(anIObj,Standard_False);
649#endif
650 }
651 }
652 else{
653#ifdef UKI60826
654 HilightWithColor(anIObj,mySelectionColor,Standard_False);
655#else
656 Hilight(anIObj,Standard_False);
657#endif
658 }
659 if (updateviewer)
660 UpdateCurrentViewer();
661 }
662 else{
663#ifdef DEB
664 cout<<"Nothing Done : Opened Local Context"<<endl;
665#endif
666 }
667}
668
669//=======================================================================
670//function : AddOrRemoveCurrentObject
671//purpose :
672//=======================================================================
673
674void AIS_InteractiveContext::
675AddOrRemoveCurrentObject(const Handle(AIS_InteractiveObject)& anIObj,
676 const Standard_Boolean updateviewer)
677{
678 if(anIObj.IsNull()) return;
679//OCC5682 to remove an object from neutral point even if Local Context is opened (Remove method)
680 if(!HasOpenedContext() /*OCC5682*/|| myObjects.IsBound(anIObj)) {
681
682 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
683 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
684
685 AIS_SelectStatus SelStat = AIS_Selection::Select(anIObj);
686
687 Standard_Integer mod = (SelStat==AIS_SS_Added) ? 1 : 0;
688 anIObj->State(mod);
689 if(mod==1)
690#ifdef BUC60814
691 HilightWithColor(anIObj,mySelectionColor,Standard_False);
692#else
693 Hilight(anIObj,Standard_False);
694#endif
695 else
696 Unhilight(anIObj,Standard_False);
697
698
699 if(updateviewer)
700 UpdateCurrentViewer();
701 }
702 else{
703#ifdef DEB
704 cout<<"Nothing Done : Opened Local Context"<<endl;
705#endif
706 }
707}
708//=======================================================================
709//function : UpdateCurrent
710//purpose :
711//=======================================================================
712
713void AIS_InteractiveContext::UpdateCurrent()
714{
715 HilightCurrents();
716}
717
718//=======================================================================
719//function : IsCurrent
720//purpose :
721//=======================================================================
722
723Standard_Boolean AIS_InteractiveContext::IsCurrent(const Handle(AIS_InteractiveObject)& anIObj) const
724{
725
726 if (anIObj.IsNull()) return Standard_False;
727 return (anIObj->State()==1);
728
729 // Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
730 // sel->Init();
731 // while (sel->More()) {
732 // if (anIObj == sel->Value()) return Standard_True;
733 // sel->Next();
734 // }
735 // return Standard_False;
736
737}
738
739//=======================================================================
740//function : InitCurrent
741//purpose :
742//=======================================================================
743
744void AIS_InteractiveContext::InitCurrent()
745{
746 AIS_Selection::Selection(myCurrentName.ToCString())->Init();
747}
748
749//=======================================================================
750//function : MoreCurrent
751//purpose :
752//=======================================================================
753
754Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
755{
756 return AIS_Selection::Selection(myCurrentName.ToCString())->More();
757
758}
759
760//=======================================================================
761//function : NextCurrent
762//purpose :
763//=======================================================================
764
765void AIS_InteractiveContext::NextCurrent()
766{
767 AIS_Selection::Selection(myCurrentName.ToCString())->Next();
768}
769
770//=======================================================================
771//function : Current
772//purpose :
773//=======================================================================
774
775Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
776{
777 Handle(Standard_Transient) TR = AIS_Selection::Selection(myCurrentName.ToCString())->Value();
778 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR);
779 return IO;
780}
781
782//=======================================================================
783//function : FirstCurrentObject
784//purpose :
785//=======================================================================
786Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstCurrentObject()
787{
788 Handle(AIS_InteractiveObject) IO ;
789 InitCurrent();
790 if(MoreCurrent()){
791 return Current();
792 }
793 return IO;
794}
795
796//=======================================================================
797//function : NbCurrents
798//purpose :
799//=======================================================================
800Standard_Integer AIS_InteractiveContext::NbCurrents()
801{
802 Standard_Integer i(0);
803 for(InitCurrent();MoreCurrent();NextCurrent())
804 {i++;}
805 return i;
806}
807
808//=======================================================================
809//function : HilightCurrents
810//purpose :
811//=======================================================================
812void AIS_InteractiveContext::HilightCurrents(const Standard_Boolean updateviewer)
813{
814 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
815 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
816 Handle(Standard_Transient) TR;
817 Handle(AIS_InteractiveObject) IO;
818 sel->Init();
819 while (sel->More()) {
820 TR = sel->Value();
821 IO = *((Handle(AIS_InteractiveObject)*)&TR);
822#ifdef BUC60814
823 HilightWithColor(IO,mySelectionColor,Standard_False);
824#else
825 Hilight(IO,Standard_False);
826#endif
827 sel->Next();
828 }
829 if(updateviewer)
830 UpdateCurrentViewer();
831}
832
833//=======================================================================
834//function : UnhilightCurrents
835//purpose :
836//=======================================================================
837
838void AIS_InteractiveContext::UnhilightCurrents(const Standard_Boolean updateviewer)
839{
840 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
841 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
842 Handle(Standard_Transient) TR;
843 Handle(AIS_InteractiveObject) IO;
844 sel->Init();
845 while (sel->More()) {
846 TR = sel->Value();
847 IO = *((Handle(AIS_InteractiveObject)*)&TR);
848 Unhilight(IO,Standard_False);
849 sel->Next();
850 }
851 if(updateviewer)
852 UpdateCurrentViewer();
853}
854
855//=======================================================================
856//function : ClearCurrents
857//purpose :
858//=======================================================================
859
860void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean updateviewer)
861{
862 if(NbCurrents()==0) return;
863 AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
864 Handle(AIS_Selection) S = AIS_Selection::CurrentSelection();
865 Handle(Standard_Transient) Tr;
866 Handle(AIS_InteractiveObject) IO;
867 for(S->Init();S->More();S->Next()){
868 Tr = S->Value();
869 IO = (*((Handle(AIS_InteractiveObject)*)&Tr));
870 IO->State(0);
871 Unhilight(IO,Standard_False);
872 }
873 AIS_Selection::Select();
874 if(updateviewer)
875 UpdateCurrentViewer();
876}
877
878
879//=======================================================================
880//function : HilightSelected
881//purpose :
882//=======================================================================
883
884void AIS_InteractiveContext::HilightSelected(const Standard_Boolean updateviewer)
885{
886 if(!HasOpenedContext()){
887 AIS_Selection::SetCurrentSelection(mySelectionName.ToCString());
888 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
889 Handle(Standard_Transient) TR;
890 Handle(AIS_InteractiveObject) IO;
891 sel->Init();
892 while (sel->More()) {
893 TR = sel->Value();
894 IO = *((Handle(AIS_InteractiveObject)*)&TR);
895#ifdef BUC60814
896 HilightWithColor(IO,mySelectionColor,Standard_False);
897#else
898 Hilight(IO,Standard_False);
899#endif
900 sel->Next();
901 }
902 }
903 else
904 {
905 myLocalContexts(myCurLocalIndex)->HilightPicked(updateviewer);
906 }
907 if(updateviewer)
908 UpdateCurrentViewer();
909}
910
911//=======================================================================
912//function : UnhilightSelected
913//purpose :
914//=======================================================================
915
916void AIS_InteractiveContext::UnhilightSelected(const Standard_Boolean updateviewer)
917{
918 if(!HasOpenedContext()){
919 AIS_Selection::SetCurrentSelection(mySelectionName.ToCString());
920 Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
921 Handle(Standard_Transient) TR;
922 Handle(AIS_InteractiveObject) IO;
923 sel->Init();
924 while (sel->More()) {
925 TR = sel->Value();
926 IO = *((Handle(AIS_InteractiveObject)*)&TR);
927 Unhilight(IO,Standard_False);
928 sel->Next();
929 }
930 if(updateviewer)
931 UpdateCurrentViewer();
932 }
933 else
934 {
935 myLocalContexts(myCurLocalIndex)->UnhilightPicked(updateviewer);
936 }
937}
938
939
940//=======================================================================
941//function : ClearSelected
942//purpose :
943//=======================================================================
944
945void AIS_InteractiveContext::ClearSelected(const Standard_Boolean updateviewer)
946{
947 if(!HasOpenedContext())
948 ClearCurrents(updateviewer);
949 else
950 myLocalContexts(myCurLocalIndex)->ClearSelected(updateviewer);
951
952}
953
954
955//=======================================================================
956//function : SetSelectedCurrent
957//purpose :
958//=======================================================================
959
960void AIS_InteractiveContext::SetSelectedCurrent()
961{
962
963
964#ifdef DEB
965 cout<<"Not Yet Implemented"<<endl;
966#endif
967}
968
969//=======================================================================
970//function : UpdateSelection
971//purpose :
972//=======================================================================
973
974void AIS_InteractiveContext::UpdateSelected(const Standard_Boolean updateviewer)
975{
976 if(!HasOpenedContext()) {
977 HilightSelected();
978#ifndef BUG
979 return;
980#endif
981 }
982 myLocalContexts(myCurLocalIndex)->UpdateSelected(updateviewer);
983}
984
985//=======================================================================
986//function : SetCurrentObject
987//purpose :
988//=======================================================================
989void AIS_InteractiveContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,const Standard_Boolean updateviewer)
990{
991 if(!HasOpenedContext())
992 SetCurrentObject(anIObj,updateviewer);
993 else
994 myLocalContexts(myCurLocalIndex)->SetSelected(anIObj,updateviewer);
995}
996
997//=======================================================================
998//function : AddOrRemoveSelected
999//purpose :
1000//=======================================================================
1001
1002void AIS_InteractiveContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& anIObj,
1003 const Standard_Boolean updateviewer)
1004{
1005 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
1006 if(!HasOpenedContext())
1007 AddOrRemoveCurrentObject(anIObj,updateviewer);
1008 else
1009 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(anIObj,updateviewer);
1010
1011}
1012//=======================================================================
1013//function : AddOrRemoveSelected
1014//purpose :
1015//=======================================================================
1016
1017void AIS_InteractiveContext::AddOrRemoveSelected(const TopoDS_Shape& aShap,
1018 const Standard_Boolean updateviewer)
1019{
1020 if(!HasOpenedContext()) {
1021#ifdef DEB
1022 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1023#endif
1024 return;
1025 }
1026
1027 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1028 if(updateviewer) UpdateCurrentViewer();
1029
1030}
1031//=======================================================================
1032//function : AddOrRemoveSelected
1033//purpose :
1034//=======================================================================
1035
1036void AIS_InteractiveContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& Own,
1037 const Standard_Boolean updateviewer)
1038{
1039 if(!HasOpenedContext()) {
1040#ifdef DEB
1041 cout<<" Attempt to remove a selected ownr with no opened local context"<<endl;
1042#endif
1043 return;
1044 }
1045
1046 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(Own,Standard_False);
1047 if(updateviewer) UpdateCurrentViewer();
1048
1049}
1050
1051
1052
1053//=======================================================================
1054//function : IsSelected
1055//purpose :
1056//=======================================================================
1057
1058Standard_Boolean AIS_InteractiveContext::
1059IsSelected(const Handle(AIS_InteractiveObject)& anIObj) const
1060{
1061 if (anIObj.IsNull()) return Standard_False;
1062
1063 if(!HasOpenedContext())
1064 return (anIObj->State()==1);
1065 else
1066 return myLocalContexts(myCurLocalIndex)->IsSelected(anIObj);
1067}
1068
1069
1070//=======================================================================
1071//function : InitSelected
1072//purpose :
1073//=======================================================================
1074
1075void AIS_InteractiveContext::InitSelected()
1076{
1077 if(!HasOpenedContext())
1078 AIS_Selection::Selection(myCurrentName.ToCString())->Init();
1079 else
1080 myLocalContexts(myCurLocalIndex)->InitSelected();
1081}
1082
1083//=======================================================================
1084//function : MoreSelected
1085//purpose :
1086//=======================================================================
1087
1088Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1089{
1090 if(!HasOpenedContext())
1091 return AIS_Selection::Selection(myCurrentName.ToCString())->More();
1092 return myLocalContexts(myCurLocalIndex)->MoreSelected();
1093}
1094
1095//=======================================================================
1096//function : NextSelected
1097//purpose :
1098//=======================================================================
1099
1100void AIS_InteractiveContext::NextSelected()
1101{
1102 if(!HasOpenedContext())
1103 AIS_Selection::Selection(myCurrentName.ToCString())->Next();
1104 else
1105 myLocalContexts(myCurLocalIndex)->NextSelected();
1106}
1107
1108//=======================================================================
1109//function : HasSelectedShape
1110//purpose :
1111//=======================================================================
1112
1113Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1114{
1115 if(!HasOpenedContext()) {
1116#ifdef IMP280200
1117 Handle(AIS_Shape) shape =
1118 Handle(AIS_Shape)::DownCast(SelectedInteractive());
1119 if( !shape.IsNull() ) return Standard_True;
1120#endif
1121 return Standard_False;
1122 }
1123 return myLocalContexts(myCurLocalIndex)->HasShape();
1124
1125
1126}
1127
1128//=======================================================================
1129//function : SelectedShape
1130//purpose :
1131//=======================================================================
1132
1133TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1134{
1135
1136 if(!HasOpenedContext()){
1137 TopoDS_Shape sh;
1138#ifdef IMP280200
1139 Handle(AIS_Shape) shape =
1140 Handle(AIS_Shape)::DownCast(SelectedInteractive());
1141 if( !shape.IsNull() ) sh = shape->Shape();
1142#endif
1143 return sh;
1144 } else
1145 return myLocalContexts(myCurLocalIndex)->SelectedShape();
1146}
1147
1148//=======================================================================
1149//function : Interactive
1150//purpose :
1151//=======================================================================
1152
1153Handle(AIS_InteractiveObject) AIS_InteractiveContext::Interactive() const
1154{
1155 return SelectedInteractive();
1156}
1157
1158Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1159{
1160 if(!HasOpenedContext()){
1161 Handle(Standard_Transient) TR =AIS_Selection::Selection(myCurrentName.ToCString())->Value();
1162 Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR);
1163 return IO;}
1164
1165 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1166
1167}
1168//=======================================================================
1169//function : Interactive
1170//purpose :
1171//=======================================================================
1172
1173Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1174{
1175 if(!HasOpenedContext()){
1176 Handle(SelectMgr_EntityOwner) Ownr;
1177 return Ownr;
1178 }
1179 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1180
1181}
1182
1183//=======================================================================
1184//function : EntityOwners
1185//purpose :
1186//=======================================================================
1187void AIS_InteractiveContext::EntityOwners(SelectMgr_IndexedMapOfOwner& theOwners,
1188 const Handle(AIS_InteractiveObject)& theIObj,
1189 const Standard_Integer theMode) const
1190{
1191 if ( theIObj.IsNull() )
1192 return;
1193
1194 TColStd_ListOfInteger aModes;
1195 if ( theMode == -1 )
1196 ActivatedModes( theIObj, aModes );
1197 else
1198 aModes.Append( theMode );
1199
1200 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1201 for (; anItr.More(); anItr.Next() )
1202 {
1203 int aMode = anItr.Value();
1204 if ( !theIObj->HasSelection( aMode ) )
1205 continue;
1206
1207 Handle(SelectMgr_Selection) aSel = theIObj->Selection( aMode );
1208
1209 for ( aSel->Init(); aSel->More(); aSel->Next() )
1210 {
1211 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive();
1212 if ( aEntity.IsNull() )
1213 continue;
1214
1215 Handle(SelectMgr_EntityOwner) aOwner =
1216 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1217 if ( !aOwner.IsNull() )
1218 theOwners.Add( aOwner );
1219 }
1220 }
1221}
1222
1223Standard_Integer AIS_InteractiveContext::NbSelected()
1224{
1225 Standard_Integer i(0);
1226 for(InitSelected();MoreSelected();NextSelected())
1227 {i++;}
1228 return i;
1229}
1230
1231//=======================================================================
1232//function : HasApplicative
1233//purpose :
1234//=======================================================================
1235
1236 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1237{
1238 return Interactive()->HasOwner();
1239}
1240
1241//=======================================================================
1242//function : Applicative
1243//purpose :
1244//=======================================================================
1245
1246Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1247{
1248 return Interactive()->GetOwner();
1249}
1250
1251
1252
1253//==================================================
1254// Function:
1255// Purpose :
1256//==================================================
1257Standard_Boolean AIS_InteractiveContext::HasDetected() const
1258{
1259 if(HasOpenedContext())
1260 return myLocalContexts(myCurLocalIndex)->HasDetected();
1261 else
1262 return !myLastPicked.IsNull();
1263}
1264
1265//=======================================================================
1266//function : HasDetectedShape
1267//purpose :
1268//=======================================================================
1269
1270Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1271{
1272 if(HasOpenedContext())
1273 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1274 return Standard_False;
1275}
1276
1277//=======================================================================
1278//function : DetectedShape
1279//purpose :
1280//=======================================================================
1281
1282const TopoDS_Shape&
1283AIS_InteractiveContext::DetectedShape() const
1284{
1285 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1286}
1287
1288//=======================================================================
1289//function : DetectedInteractive
1290//purpose :
1291//=======================================================================
1292
1293Handle(AIS_InteractiveObject)
1294AIS_InteractiveContext::DetectedInteractive() const
1295{
1296 if(HasOpenedContext())
1297 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1298 return myLastPicked;
1299}
1300
1301
1302Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1303{
1304 if(!HasOpenedContext())
1305 return Standard_False; // temporaire
1306 else
1307 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1308
1309}
1310
1311
1312//=======================================================================
1313//function : DetectedOwner
1314//purpose :
1315//=======================================================================
1316Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1317{
1318 if(HasOpenedContext())
1319 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1320 Handle(SelectMgr_EntityOwner) Ownr;
1321 return Ownr;
1322}
1323
1324
1325//=======================================================================
1326//function : HilightNextDetected
1327//purpose :
1328//=======================================================================
1329Standard_Integer AIS_InteractiveContext::HilightNextDetected(const Handle(V3d_View)& V)
1330{
1331 if(!HasOpenedContext())
1332 return 0;
1333 return myLocalContexts(myCurLocalIndex)->HilightNextDetected(V);
1334
1335}
1336
1337//=======================================================================
1338//function : HilightNextDetected
1339//purpose :
1340//=======================================================================
1341Standard_Integer AIS_InteractiveContext::HilightPreviousDetected(const Handle(V3d_View)& V)
1342{
1343 if(!HasOpenedContext())
1344 return 0;
1345 return myLocalContexts(myCurLocalIndex)->HilightPreviousDetected(V);
1346
1347}
1348
1349#ifdef IMP150501
1350void AIS_InteractiveContext::Drag(
1351 const Handle(V3d_View)& aView,
1352 const Handle(AIS_InteractiveObject)& anObject,
1353 const Handle(Geom_Transformation)& aTrsf,
1354 const Standard_Boolean postConcatenate,
1355 const Standard_Boolean update,
1356 const Standard_Boolean zBuffer) {
1357
1358 if( anObject.IsNull() || aView.IsNull() ) return;
1359
1360 if( update ) {
1361 anObject->SetTransformation(aTrsf,postConcatenate,Standard_True);
1362 aView->Update();
1363 } else if( Visual3d_TransientManager::BeginDraw(aView->View(),
1364 zBuffer,Standard_False) ) {
1365 Handle(Prs3d_Presentation) P = anObject->Presentation();
1366 if( !P.IsNull() ) {
1367 if( postConcatenate ) P->Multiply(aTrsf);
1368 else P->Transform(aTrsf);
1369 Visual3d_TransientManager::DrawStructure(P);
1370 }
1371 Visual3d_TransientManager::EndDraw(Standard_True);
1372 }
1373}
1374#endif
1375
1376#ifdef IMP160701
1377//=======================================================================
1378//function : InitDetected
1379//purpose :
1380//=======================================================================
1381void AIS_InteractiveContext::InitDetected()
1382{
1383 if(HasOpenedContext())
1384 {
1385 myLocalContexts(myCurLocalIndex)->InitDetected();
1386 return;
1387 }
1388
1389 if(myAISDetectedSeq.Length() != 0)
1390 myAISCurDetected = 1;
1391
1392}
1393
1394//=======================================================================
1395//function : MoreDetected
1396//purpose :
1397//=======================================================================
1398Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1399{
1400 if(HasOpenedContext())
1401 return myLocalContexts(myCurLocalIndex)->MoreDetected();
1402
1403 return (myAISCurDetected>0 &&myAISCurDetected <= myAISDetectedSeq.Length()) ?
1404 Standard_True : Standard_False;
1405}
1406
1407//=======================================================================
1408//function : NextDetected
1409//purpose :
1410//=======================================================================
1411void AIS_InteractiveContext::NextDetected()
1412{
1413 if(HasOpenedContext())
1414 {
1415 myLocalContexts(myCurLocalIndex)->NextDetected();
1416 return;
1417 }
1418
1419 myAISCurDetected++;
1420}
1421
1422//=======================================================================
1423//function : DetectedCurrentShape
1424//purpose :
1425//=======================================================================
1426
1427const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1428{
1429 if(HasOpenedContext())
1430 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1431
1432 static TopoDS_Shape bidsh;
1433 if(myAISCurDetected > 0 &&
1434 myAISCurDetected <= myAISDetectedSeq.Length())
1435 return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape();
1436 return bidsh;
1437}
1438
1439//=======================================================================
1440//function : DetectedCurrentObject
1441//purpose :
1442//=======================================================================
1443
1444Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const {
1445 if(HasOpenedContext())
1446 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1447
1448 Handle(AIS_InteractiveObject) aBad;
1449
1450 if(myAISCurDetected > 0 &&
1451 myAISCurDetected <= myAISDetectedSeq.Length())
1452 return myAISDetectedSeq(myAISCurDetected);
1453 else
1454 return aBad;
1455}
1456#endif