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