1 // Created on: 1997-01-29
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
19 #include <AIS_GlobalStatus.hxx>
20 #include <AIS_InteractiveContext.hxx>
21 #include <AIS_InteractiveObject.hxx>
22 #include <AIS_LocalContext.hxx>
23 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
24 #include <AIS_MapOfInteractive.hxx>
25 #include <AIS_Selection.hxx>
26 #include <AIS_Shape.hxx>
27 #include <AIS_StatusOfDetection.hxx>
28 #include <AIS_StatusOfPick.hxx>
29 #include <Aspect_Grid.hxx>
30 #include <Prs3d_BasicAspect.hxx>
31 #include <Prs3d_LineAspect.hxx>
32 #include <Prs3d_Presentation.hxx>
33 #include <Quantity_Color.hxx>
34 #include <SelectBasics_SensitiveEntity.hxx>
35 #include <SelectMgr_EntityOwner.hxx>
36 #include <SelectMgr_Filter.hxx>
37 #include <SelectMgr_OrFilter.hxx>
38 #include <SelectMgr_Selection.hxx>
39 #include <SelectMgr_SelectionManager.hxx>
40 #include <Standard_Transient.hxx>
41 #include <StdSelect_BRepOwner.hxx>
42 #include <StdSelect_ViewerSelector3d.hxx>
43 #include <TCollection_AsciiString.hxx>
44 #include <TCollection_ExtendedString.hxx>
45 #include <TColStd_ListIteratorOfListOfInteger.hxx>
46 #include <TopLoc_Location.hxx>
47 #include <TopoDS_Shape.hxx>
48 #include <V3d_AmbientLight.hxx>
49 #include <V3d_DirectionalLight.hxx>
50 #include <V3d_Light.hxx>
51 #include <V3d_PositionalLight.hxx>
52 #include <V3d_SpotLight.hxx>
53 #include <V3d_View.hxx>
54 #include <V3d_Viewer.hxx>
56 typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
58 //=======================================================================
59 //function : highlightWithColor
61 //=======================================================================
62 void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
63 const Quantity_NameOfColor theColor,
64 const Handle(V3d_Viewer)& theViewer)
66 const Handle(AIS_InteractiveObject) anObj =
67 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
70 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
72 myMainPM->BeginImmediateDraw();
73 theOwner->HilightWithColor (myMainPM, theColor, aHiMode);
74 myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
77 //=======================================================================
78 //function : highlightSelected
80 //=======================================================================
81 void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
82 const Quantity_NameOfColor theSelColor)
84 const Handle(AIS_InteractiveObject) anObj =
85 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
88 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
90 if (!theOwner->IsAutoHilight())
92 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
93 const Handle(AIS_Selection)& aCurSel = AIS_Selection::CurrentSelection();
94 SelectMgr_SequenceOfOwner aSeq;
95 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
97 const Handle(SelectMgr_EntityOwner) aSelOwnr =
98 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
99 if (aSelOwnr->Selectable() != anObj)
101 aSeq.Append (aSelOwnr);
103 anObj->HilightSelected (myMainPM, aSeq);
107 theOwner->HilightWithColor (myMainPM, theSelColor, aHiMode);
111 //=======================================================================
112 //function : unhighlightSelected
114 //=======================================================================
115 void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
117 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
118 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
119 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
120 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
122 const Handle(SelectMgr_EntityOwner) anOwner =
123 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
124 if (anOwner.IsNull() || !anOwner->HasSelectable())
127 const Handle(AIS_InteractiveObject) anInteractive =
128 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
129 if (anOwner->IsAutoHilight())
131 const Standard_Integer aHiMode = anInteractive->HasHilightMode() ? anInteractive->HilightMode() : 0;
132 anOwner->Unhilight (myMainPM, aHiMode);
133 if (theIsToHilightSubIntensity)
135 if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn())
137 anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode);
143 if (!anObjToClear.Contains (anInteractive))
144 anObjToClear.Add (anInteractive);
147 if (anOwner == anInteractive->GlobalSelOwner())
149 myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
152 for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
154 const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
155 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
156 myMainPM->Unhighlight (anObj, aHiMode);
157 anObj->ClearSelected();
161 //=======================================================================
164 //=======================================================================
165 AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
166 const Standard_Integer theYPix,
167 const Handle(V3d_View)& theView,
168 const Standard_Boolean theToRedrawOnUpdate)
170 if (HasOpenedContext())
172 myWasLastMain = Standard_True;
173 return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
176 myAISCurDetected = 0;
177 myAISDetectedSeq.Clear();
179 if (theView->Viewer() != myMainVwr)
181 return AIS_SOD_Error;
185 myLastPicked = myLastinMain;
186 myWasLastMain = Standard_True;
187 AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
188 Standard_Boolean toUpdateViewer = Standard_False;
190 myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
191 myMainSel->Pick (theXPix, theYPix, theView);
193 // filling of myAISDetectedSeq sequence storing information about detected AIS objects
194 // (the objects must be AIS_Shapes)
195 const Standard_Integer aDetectedNb = myMainSel->NbPicked();
196 Standard_Integer aNewDetected = 0;
197 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
199 Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
201 || !myFilters->IsOk (anOwner))
206 if (aNewDetected < 1)
208 aNewDetected = aDetIter;
210 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
213 myAISDetectedSeq.Append (anObj);
217 if (aNewDetected >= 1)
219 // does nothing if previously detected object is equal to the current one
220 Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
221 if (aNewPickedOwner == myLastPicked)
223 return myLastPicked->IsSelected()
225 : AIS_SOD_OnlyOneDetected;
228 // Previously detected object is unhilighted if it is not selected or hilighted
229 // with selection color if it is selected. Such highlighting with selection color
230 // is needed only if myToHilightSelected flag is true. In this case previously detected
231 // object has been already highlighted with myHilightColor during previous MoveTo()
232 // method call. As result it is necessary to rehighligt it with mySelectionColor.
233 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
235 myMainPM->ClearImmediateDraw();
236 const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
237 const Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
238 if (!myLastPicked->IsSelected())
240 myLastPicked->Unhilight (myMainPM, aHiMod);
241 toUpdateViewer = Standard_True;
243 else if (myToHilightSelected)
245 highlightWithColor (aNewPickedOwner, mySelectionColor, theView->Viewer());
246 toUpdateViewer = Standard_True;
250 // initialize myLastPicked field with currently detected object
251 myLastPicked = aNewPickedOwner;
252 myLastinMain = myLastPicked;
254 // highlight detected object if it is not selected or myToHilightSelected flag is true
255 if (myLastPicked->HasSelectable())
257 if (!myLastPicked->IsSelected() || myToHilightSelected)
259 highlightWithColor (myLastPicked, myHilightColor, theView->Viewer());
260 toUpdateViewer = Standard_True;
263 aStatus = myLastPicked->IsSelected()
265 : AIS_SOD_OnlyOneDetected;
270 // previously detected object is unhilighted if it is not selected or hilighted
271 // with selection color if it is selected
272 aStatus = AIS_SOD_Nothing;
273 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
275 myMainPM->ClearImmediateDraw();
276 const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
277 Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
278 if (!myLastPicked->IsSelected())
280 if (myLastPicked->IsAutoHilight())
282 myLastPicked->Unhilight (myMainPM, aHiMod);
284 toUpdateViewer = Standard_True;
286 else if (myToHilightSelected)
288 highlightSelected (myLastPicked, mySelectionColor);
289 toUpdateViewer = Standard_True;
293 myLastinMain.Nullify();
294 myLastPicked.Nullify();
298 && theToRedrawOnUpdate)
300 theView->Viewer()->Update();
303 mylastmoveview = theView;
307 //=======================================================================
310 //=======================================================================
311 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
312 const Standard_Integer theYPMin,
313 const Standard_Integer theXPMax,
314 const Standard_Integer theYPMax,
315 const Handle(V3d_View)& theView,
316 const Standard_Boolean toUpdateViewer)
318 // all objects detected by the selector are taken, previous current objects are emptied,
319 // new objects are put...
321 if (HasOpenedContext())
323 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
325 theView, toUpdateViewer);
328 ClearSelected (Standard_False);
330 Handle(StdSelect_ViewerSelector3d) aSelector;
332 if (theView->Viewer() == myMainVwr)
334 aSelector = myMainSel;
335 myWasLastMain = Standard_True;
338 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
339 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
341 for (aSelector->Init(); aSelector->More(); aSelector->Next())
343 const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked();
344 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
347 AIS_Selection::Select (aCurOwner);
348 aCurOwner->State (1);
351 HilightSelected (toUpdateViewer);
353 Standard_Integer aSelNum = NbSelected();
355 return (aSelNum == 0) ? AIS_SOP_NothingSelected
356 : (aSelNum == 1) ? AIS_SOP_OneSelected
357 : AIS_SOP_SeveralSelected;
361 //=======================================================================
363 //purpose : Selection by polyline
364 //=======================================================================
365 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
366 const Handle(V3d_View)& theView,
367 const Standard_Boolean toUpdateViewer)
369 // all objects detected by the selector are taken, previous current objects are emptied,
370 // new objects are put...
372 if (HasOpenedContext())
374 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
377 ClearSelected (Standard_False);
379 Handle(StdSelect_ViewerSelector3d) aSelector;
381 if (theView->Viewer() == myMainVwr)
383 aSelector = myMainSel;
384 myWasLastMain = Standard_True;
387 aSelector->Pick (thePolyline, theView);
388 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
390 for (aSelector->Init(); aSelector->More(); aSelector->Next())
392 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
393 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
396 AIS_Selection::Select (anOwner);
400 HilightSelected (toUpdateViewer);
402 Standard_Integer aSelNum = NbSelected();
404 return (aSelNum == 0) ? AIS_SOP_NothingSelected
405 : (aSelNum == 1) ? AIS_SOP_OneSelected
406 : AIS_SOP_SeveralSelected;
410 //=======================================================================
413 //=======================================================================
414 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
416 if (HasOpenedContext())
420 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
424 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
425 return AIS_SOP_OneSelected;
429 myMainPM->ClearImmediateDraw();
430 if (myWasLastMain && !myLastinMain.IsNull())
432 if(!myLastinMain->IsSelected())
434 SetSelected (myLastinMain, Standard_False);
437 UpdateCurrentViewer();
443 unhighlightSelected (Standard_True);
445 AIS_Selection::Select();
446 if (toUpdateViewer && myWasLastMain)
448 UpdateCurrentViewer();
452 Standard_Integer aSelNum = NbSelected();
454 return (aSelNum == 0) ? AIS_SOP_NothingSelected
455 : (aSelNum == 1) ? AIS_SOP_OneSelected
456 : AIS_SOP_SeveralSelected;
459 //=======================================================================
460 //function : ShiftSelect
462 //=======================================================================
463 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
465 if (HasOpenedContext())
469 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
473 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
475 Standard_Integer aSelNum = NbSelected();
476 return (aSelNum == 0) ? AIS_SOP_NothingSelected
477 : (aSelNum == 1) ? AIS_SOP_OneSelected
478 : AIS_SOP_SeveralSelected;
482 myMainPM->ClearImmediateDraw();
483 if (myWasLastMain && !myLastinMain.IsNull())
485 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
488 Standard_Integer aSelNum = NbSelected();
490 return (aSelNum == 0) ? AIS_SOP_NothingSelected
491 : (aSelNum == 1) ? AIS_SOP_OneSelected
492 : AIS_SOP_SeveralSelected;
495 //=======================================================================
496 //function : ShiftSelect
498 //=======================================================================
499 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
500 const Standard_Integer theYPMin,
501 const Standard_Integer theXPMax,
502 const Standard_Integer theYPMax,
503 const Handle(V3d_View)& theView,
504 const Standard_Boolean toUpdateViewer)
506 if (HasOpenedContext())
508 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
509 theView, toUpdateViewer);
512 UnhilightSelected (Standard_False);
514 Handle(StdSelect_ViewerSelector3d) aSelector;
515 if (theView->Viewer() == myMainVwr)
517 aSelector = myMainSel;
518 myWasLastMain = Standard_True;
522 return AIS_SOP_NothingSelected;
525 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
526 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
527 for (aSelector->Init(); aSelector->More(); aSelector->Next())
529 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
530 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
533 AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
534 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
535 anOwner->State (aState);
538 HilightSelected (toUpdateViewer);
540 Standard_Integer aSelNum = NbSelected();
542 return (aSelNum == 0) ? AIS_SOP_NothingSelected
543 : (aSelNum == 1) ? AIS_SOP_OneSelected
544 : AIS_SOP_SeveralSelected;
548 //=======================================================================
549 //function : ShiftSelect
551 //=======================================================================
552 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
553 const Handle(V3d_View)& theView,
554 const Standard_Boolean toUpdateViewer)
556 if (HasOpenedContext())
558 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
561 UnhilightSelected (Standard_False);
563 Handle(StdSelect_ViewerSelector3d) aSelector;
565 if (theView->Viewer() == myMainVwr)
567 aSelector= myMainSel;
568 myWasLastMain = Standard_True;
572 return AIS_SOP_NothingSelected;
575 aSelector->Pick (thePolyline, theView);
577 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
578 for (aSelector->Init(); aSelector->More(); aSelector->Next())
580 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked();
581 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
584 AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
585 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
586 anOwner->State (aState);
589 HilightSelected (toUpdateViewer);
591 Standard_Integer aSelNum = NbSelected();
593 return (aSelNum == 0) ? AIS_SOP_NothingSelected
594 : (aSelNum == 1) ? AIS_SOP_OneSelected
595 : AIS_SOP_SeveralSelected;
598 //=======================================================================
599 //function : SetCurrentObject
600 //purpose : OBSOLETE, please use SetSelected() instead
601 //TODO : Remove in process of local context deletion
602 //=======================================================================
603 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
604 const Standard_Boolean theToUpdateViewer)
606 if (HasOpenedContext())
609 SetSelected (theObject, theToUpdateViewer);
612 //=======================================================================
613 //function : AddOrRemoveCurrentObject
614 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
615 //TODO : Remove in process of local context deletion
616 //=======================================================================
617 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
618 const Standard_Boolean theIsToUpdateViewer)
620 if (HasOpenedContext())
623 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
625 //=======================================================================
626 //function : UpdateCurrent
627 //purpose : OBSOLETE, please use UpdateSelected() instead
628 //TODO : Remove in process of local context deletion
629 //=======================================================================
630 void AIS_InteractiveContext::UpdateCurrent()
635 //=======================================================================
636 //function : IsCurrent
637 //purpose : OBSOLETE, please use IsSelected() instead
638 //TODO : Remove in process of local context deletion
639 //=======================================================================
640 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
642 return IsSelected (theObject);
645 //=======================================================================
646 //function : InitCurrent
647 //purpose : OBSOLETE, please use InitSelected() instead
648 //TODO : Remove in process of local context deletion
649 //=======================================================================
650 void AIS_InteractiveContext::InitCurrent()
652 if (HasOpenedContext())
658 //=======================================================================
659 //function : MoreCurrent
660 //purpose : OBSOLETE, please use MoreSelected() instead
661 //TODO : Remove in process of local context deletion
662 //=======================================================================
663 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
665 return !HasOpenedContext() && MoreSelected();
668 //=======================================================================
669 //function : NextCurrent
670 //purpose : OBSOLETE, please use NextSelected() instead
671 //TODO : Remove in process of local context deletion
672 //=======================================================================
673 void AIS_InteractiveContext::NextCurrent()
675 if (HasOpenedContext())
681 //=======================================================================
683 //purpose : OBSOLETE, please use SelectedInteractive() instead
684 //TODO : Remove in process of local context deletion
685 //=======================================================================
686 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
688 return HasOpenedContext() ? NULL : SelectedInteractive();
691 //=======================================================================
692 //function : NbCurrents
693 //purpose : OBSOLETE, please use NbSelected() instead
694 //TODO : Remove in process of local context deletion
695 //=======================================================================
696 Standard_Integer AIS_InteractiveContext::NbCurrents()
698 return HasOpenedContext() ? -1 : NbSelected();
701 //=======================================================================
702 //function : HilightCurrents
703 //purpose : OBSOLETE, please use HilightSelected() instead
704 //TODO : Remove in process of local context deletion
705 //=======================================================================
706 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
708 if (HasOpenedContext())
711 HilightSelected (theToUpdateViewer);
714 //=======================================================================
715 //function : UnhilightCurrents
716 //purpose : OBSOLETE, please use UnhilightSelected() instead
717 //TODO : Remove in process of local context deletion
718 //=======================================================================
719 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
721 if (HasOpenedContext())
724 UnhilightSelected (theToUpdateViewer);
727 //=======================================================================
728 //function : ClearCurrents
729 //purpose : OBSOLETE, please use ClearCurrents() instead
730 //TODO : Remove in process of local context deletion
731 //=======================================================================
732 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
734 if (HasOpenedContext())
737 ClearSelected (theToUpdateViewer);
741 //=======================================================================
742 //function : HilightSelected
744 //=======================================================================
745 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
747 if (HasOpenedContext())
749 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
752 // In case of selection without using local context
753 myMainPM->ClearImmediateDraw();
754 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
755 Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
756 AIS_MapOfObjSelectedOwners anObjOwnerMap;
757 for (aSel->Init(); aSel->More(); aSel->Next())
759 const Handle(SelectMgr_EntityOwner) anOwner =
760 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
761 if (!anOwner.IsNull() && anOwner->HasSelectable())
763 const Handle(AIS_InteractiveObject) anObj =
764 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
765 if (anOwner == anObj->GlobalSelOwner())
767 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj);
768 aState->SetHilightStatus (Standard_True);
769 aState->SetHilightColor (mySelectionColor);
772 if (!anOwner->IsAutoHilight())
774 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
775 if (anObjOwnerMap.Find (anObj, aSeq))
777 aSeq->Append (anOwner);
781 aSeq = new SelectMgr_SequenceOfOwner();
782 aSeq->Append (anOwner);
783 anObjOwnerMap.Bind (anObj, aSeq);
788 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
789 anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
794 if (!anObjOwnerMap.IsEmpty())
796 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
798 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
800 anObjOwnerMap.Clear();
803 if (theToUpdateViewer)
804 UpdateCurrentViewer();
807 //=======================================================================
808 //function : UnhilightSelected
810 //=======================================================================
811 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
813 if (HasOpenedContext())
815 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
818 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
819 Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
820 for (aSel->Init(); aSel->More(); aSel->Next())
822 const Handle(SelectMgr_EntityOwner) anOwner =
823 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
824 if (!anOwner.IsNull() && anOwner->HasSelectable())
826 const Handle(AIS_InteractiveObject) anObj =
827 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
828 if (anOwner == anObj->GlobalSelOwner())
830 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
833 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0;
834 anOwner->Unhilight (myMainPM, aHiMode);
838 if (theToUpdateViewer)
839 UpdateCurrentViewer();
843 //=======================================================================
844 //function : ClearSelected
846 //=======================================================================
847 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
849 if (HasOpenedContext())
850 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
852 if (NbSelected() == 0)
855 unhighlightSelected();
857 AIS_Selection::Select();
858 myMainPM->ClearImmediateDraw();
860 if (theToUpdateViewer)
861 UpdateCurrentViewer();
864 //=======================================================================
865 //function : UpdateSelected
867 //=======================================================================
868 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
870 if (HasOpenedContext())
872 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
875 HilightSelected (theToUpdateViewer);
878 //=======================================================================
879 //function : SetSelected
880 //purpose : Sets the whole object as selected and highlights it with selection color
881 //=======================================================================
882 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
883 const Standard_Boolean theToUpdateViewer)
885 if(HasOpenedContext())
887 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
890 if (theObject.IsNull())
892 if(!myObjects.IsBound (theObject))
893 Display (theObject, Standard_False);
894 if (theObject->HasSelection (0))
897 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
899 Quantity_NameOfColor aHiCol;
900 Standard_Boolean hasHiCol = Standard_False;
901 if (IsHilighted (theObject, hasHiCol, aHiCol))
903 if (hasHiCol && aHiCol!= mySelectionColor)
905 HilightWithColor (theObject, mySelectionColor, theToUpdateViewer);
911 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
912 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
913 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
915 const Handle(SelectMgr_EntityOwner) anOwner =
916 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
917 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
920 Handle(AIS_InteractiveObject) aSelectable =
921 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
922 Unhilight (aSelectable, Standard_False);
924 if (anOwner == aSelectable->GlobalSelOwner())
926 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
930 // added to avoid untimely viewer update...
931 const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
935 Handle(SelectMgr_EntityOwner) anOwner =
936 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
937 AIS_Selection::ClearAndSelect (anOwner);
939 if (anOwner == theObject->GlobalSelOwner())
941 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject);
942 aState->SetHilightStatus (Standard_True);
943 aState->SetHilightColor (mySelectionColor);
945 Quantity_NameOfColor aHiCol;
946 Standard_Boolean hasHiCol = Standard_False;
947 if (IsHilighted (theObject, hasHiCol, aHiCol))
949 if (hasHiCol && aHiCol!= mySelectionColor)
951 HilightWithColor (theObject, mySelectionColor, Standard_False);
956 HilightWithColor (theObject, mySelectionColor, Standard_False);
959 if (theToUpdateViewer)
960 UpdateCurrentViewer();
963 //=======================================================================
964 //function : SetSelected
965 //purpose : Sets the whole object as selected and highlights it with selection color
966 //=======================================================================
967 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
968 const Standard_Boolean theToUpdateViewer)
970 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
973 const Handle(AIS_InteractiveObject) anObject =
974 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
976 if (NbSelected() == 1 && theOwner->IsSelected())
978 Quantity_NameOfColor aCustomColor;
979 Standard_Boolean isCustomColorSet;
980 if (IsHilighted (theOwner, isCustomColorSet, aCustomColor))
982 if (isCustomColorSet && aCustomColor != mySelectionColor)
984 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
985 theOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
991 if (!myObjects.IsBound (anObject))
992 Display (anObject, Standard_False);
994 unhighlightSelected();
996 AIS_Selection::ClearAndSelect (theOwner);
998 Quantity_NameOfColor aCustomColor;
999 Standard_Boolean isCustomColorSet;
1000 if (!IsHilighted (theOwner, isCustomColorSet, aCustomColor) || (isCustomColorSet && aCustomColor!= mySelectionColor))
1002 highlightSelected (theOwner, mySelectionColor);
1005 if (theOwner == anObject->GlobalSelOwner())
1007 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1008 aState->SetHilightStatus (Standard_True);
1009 aState->SetHilightColor (mySelectionColor);
1012 if (theToUpdateViewer)
1013 UpdateCurrentViewer();
1016 //=======================================================================
1017 //function : AddOrRemoveSelected
1018 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1019 // Since this method makes sence only for neutral point selection of a whole object,
1020 // if 0 selection of the object is empty this method simply does nothing.
1021 //=======================================================================
1022 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1023 const Standard_Boolean theToUpdateViewer)
1025 if (theObject.IsNull())
1028 if (HasOpenedContext())
1029 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1031 const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
1032 if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
1035 if (!theObject->HasInteractiveContext())
1036 theObject->SetContext (this);
1038 const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1040 if (anOwner.IsNull() || !anOwner->HasSelectable())
1043 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1045 //=======================================================================
1046 //function : AddOrRemoveSelected
1048 //=======================================================================
1050 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1051 const Standard_Boolean updateviewer)
1053 if(!HasOpenedContext()) {
1055 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1060 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1061 if(updateviewer) UpdateCurrentViewer();
1065 //=======================================================================
1066 //function : AddOrRemoveSelected
1067 //purpose : Allows to highlight or unhighlight the owner given depending on
1068 // its selection status
1069 //=======================================================================
1070 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1071 const Standard_Boolean theToUpdateViewer)
1073 if (HasOpenedContext())
1074 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1076 if (theOwner.IsNull() || !theOwner->HasSelectable())
1079 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
1080 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1082 AIS_SelectStatus aSelStat = AIS_Selection::Select (theOwner);
1084 Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0;
1085 theOwner->State (aState);
1086 const Handle(AIS_InteractiveObject) anObj =
1087 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1088 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1089 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1090 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
1093 highlightSelected (theOwner, mySelectionColor);
1096 aStatus->SetHilightStatus (Standard_True);
1097 aStatus->SetHilightColor (mySelectionColor);
1102 if (theOwner->IsAutoHilight())
1103 theOwner->Unhilight (myMainPM, aHiMode);
1105 anObj->ClearSelected();
1106 aStatus->SetHilightStatus (Standard_False);
1107 aStatus->SetHilightColor (Quantity_NOC_WHITE);
1110 if (theToUpdateViewer)
1111 UpdateCurrentViewer();
1115 //=======================================================================
1116 //function : IsSelected
1118 //=======================================================================
1119 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1121 if(HasOpenedContext())
1122 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1124 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1125 return Standard_False;
1127 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1128 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1129 Standard_Boolean isGlobalModeActivated = Standard_False;
1130 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1132 if (aModeIter.Value() == aGlobalSelMode)
1134 isGlobalModeActivated = Standard_True;
1138 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
1139 return Standard_False;
1141 return theObj->GlobalSelOwner()->State() == 1;
1144 //=======================================================================
1145 //function : IsSelected
1146 //purpose : Returns true is the owner given is selected
1147 //=======================================================================
1148 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1150 if (HasOpenedContext())
1151 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1153 if (theOwner.IsNull())
1154 return Standard_False;
1156 return theOwner->IsSelected();
1159 //=======================================================================
1160 //function : InitSelected
1162 //=======================================================================
1163 void AIS_InteractiveContext::InitSelected()
1165 if (HasOpenedContext())
1167 myLocalContexts (myCurLocalIndex)->InitSelected();
1171 AIS_Selection::Selection (myCurrentName.ToCString())->Init();
1174 //=======================================================================
1175 //function : MoreSelected
1177 //=======================================================================
1178 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1180 if (HasOpenedContext())
1181 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1183 return AIS_Selection::Selection (myCurrentName.ToCString())->More();
1186 //=======================================================================
1187 //function : NextSelected
1189 //=======================================================================
1190 void AIS_InteractiveContext::NextSelected()
1192 if(HasOpenedContext())
1194 return myLocalContexts (myCurLocalIndex)->NextSelected();
1198 AIS_Selection::Selection (myCurrentName.ToCString())->Next();
1201 //=======================================================================
1202 //function : HasSelectedShape
1204 //=======================================================================
1205 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1207 if(HasOpenedContext())
1209 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1212 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
1213 return !aShape.IsNull();
1216 //=======================================================================
1217 //function : SelectedShape
1219 //=======================================================================
1220 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1222 if (HasOpenedContext())
1224 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1227 if (AIS_Selection::Selection (myCurrentName.ToCString())->Extent() == 0)
1228 return TopoDS_Shape();
1230 const Handle(StdSelect_BRepOwner) anOwner =
1231 Handle(StdSelect_BRepOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
1232 if (!anOwner->HasSelectable())
1233 return TopoDS_Shape();
1235 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1238 //=======================================================================
1239 //function : SelectedInteractive
1241 //=======================================================================
1242 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1244 if (HasOpenedContext())
1246 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1249 const Handle(SelectMgr_EntityOwner) anOwner =
1250 Handle(SelectMgr_EntityOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
1251 if (anOwner.IsNull() || !anOwner->HasSelectable())
1254 return Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
1256 //=======================================================================
1257 //function : SelectedOwner
1259 //=======================================================================
1260 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1262 if(HasOpenedContext())
1264 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1267 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1269 return aCurSel->Extent() > 0 ?
1270 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()) : NULL;
1273 //=======================================================================
1274 //function : EntityOwners
1276 //=======================================================================
1277 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1278 const Handle(AIS_InteractiveObject)& theIObj,
1279 const Standard_Integer theMode) const
1281 if ( theIObj.IsNull() )
1284 TColStd_ListOfInteger aModes;
1285 if ( theMode == -1 )
1286 ActivatedModes( theIObj, aModes );
1288 aModes.Append( theMode );
1290 if (theOwners.IsNull())
1291 theOwners = new SelectMgr_IndexedMapOfOwner();
1293 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1294 for (; anItr.More(); anItr.Next() )
1296 int aMode = anItr.Value();
1297 if ( !theIObj->HasSelection( aMode ) )
1300 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1302 for ( aSel->Init(); aSel->More(); aSel->Next() )
1304 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1305 if ( aEntity.IsNull() )
1308 Handle(SelectMgr_EntityOwner) aOwner =
1309 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1310 if ( !aOwner.IsNull() )
1311 theOwners->Add( aOwner );
1316 //=======================================================================
1317 //function : NbSelected
1319 //=======================================================================
1320 Standard_Integer AIS_InteractiveContext::NbSelected()
1322 Standard_Integer aNbSelected = 0;
1323 for (InitSelected(); MoreSelected(); NextSelected())
1331 //=======================================================================
1332 //function : HasApplicative
1334 //=======================================================================
1335 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1337 return SelectedInteractive()->HasOwner();
1340 //=======================================================================
1341 //function : Applicative
1343 //=======================================================================
1344 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1346 return SelectedInteractive()->GetOwner();
1349 //==================================================
1350 // Function: HasDetected
1352 //==================================================
1353 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1355 if(HasOpenedContext())
1356 return myLocalContexts(myCurLocalIndex)->HasDetected();
1358 return !myLastPicked.IsNull();
1361 //=======================================================================
1362 //function : HasDetectedShape
1364 //=======================================================================
1366 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1368 if(HasOpenedContext())
1369 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1370 return Standard_False;
1373 //=======================================================================
1374 //function : DetectedShape
1376 //=======================================================================
1379 AIS_InteractiveContext::DetectedShape() const
1381 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1384 //=======================================================================
1385 //function : DetectedInteractive
1387 //=======================================================================
1388 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1390 if (HasOpenedContext())
1391 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1393 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1397 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1399 if(!HasOpenedContext())
1400 return Standard_False; // temporaire
1402 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1407 //=======================================================================
1408 //function : DetectedOwner
1410 //=======================================================================
1411 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1413 if (HasOpenedContext())
1414 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1416 return myLastPicked;
1419 //=======================================================================
1420 //function : HilightNextDetected
1422 //=======================================================================
1423 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1424 const Standard_Boolean theToRedrawImmediate)
1426 return HasOpenedContext()
1427 ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
1432 //=======================================================================
1433 //function : HilightNextDetected
1435 //=======================================================================
1436 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1437 const Standard_Boolean theToRedrawImmediate)
1439 return HasOpenedContext()
1440 ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
1445 //=======================================================================
1446 //function : InitDetected
1448 //=======================================================================
1449 void AIS_InteractiveContext::InitDetected()
1451 if (HasOpenedContext())
1453 myLocalContexts(myCurLocalIndex)->InitDetected();
1457 if(myAISDetectedSeq.Length() != 0)
1459 myAISCurDetected = 1;
1463 //=======================================================================
1464 //function : MoreDetected
1466 //=======================================================================
1467 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1469 if (HasOpenedContext())
1471 return myLocalContexts(myCurLocalIndex)->MoreDetected();
1474 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
1475 Standard_True : Standard_False;
1478 //=======================================================================
1479 //function : NextDetected
1481 //=======================================================================
1482 void AIS_InteractiveContext::NextDetected()
1484 if(HasOpenedContext())
1486 myLocalContexts(myCurLocalIndex)->NextDetected();
1493 //=======================================================================
1494 //function : DetectedCurrentShape
1496 //=======================================================================
1497 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1499 if (HasOpenedContext())
1501 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1504 static TopoDS_Shape aDummyShape;
1506 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1508 if (aCurrentShape.IsNull())
1513 return aCurrentShape->Shape();
1516 //=======================================================================
1517 //function : DetectedCurrentObject
1519 //=======================================================================
1520 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1522 if (HasOpenedContext())
1524 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1527 return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
1530 //=======================================================================
1531 //function : FirstSelectedObject
1533 //=======================================================================
1534 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1536 Handle(AIS_InteractiveObject) anObject;
1538 if (HasOpenedContext())
1544 return SelectedInteractive();
1549 //=======================================================================
1550 //function : RedrawImmediate
1551 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1552 //=======================================================================
1553 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1555 myMainPM->RedrawImmediate (theViewer);