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