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