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