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 =
393 Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
394 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
397 AIS_Selection::Select (anOwner);
401 HilightSelected (toUpdateViewer);
403 Standard_Integer aSelNum = NbSelected();
405 return (aSelNum == 0) ? AIS_SOP_NothingSelected
406 : (aSelNum == 1) ? AIS_SOP_OneSelected
407 : AIS_SOP_SeveralSelected;
411 //=======================================================================
414 //=======================================================================
415 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
417 if (HasOpenedContext())
421 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
425 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
426 return AIS_SOP_OneSelected;
430 myMainPM->ClearImmediateDraw();
431 if (myWasLastMain && !myLastinMain.IsNull())
433 if(!myLastinMain->IsSelected())
435 SetSelected (myLastinMain, Standard_False);
438 UpdateCurrentViewer();
444 unhighlightSelected (Standard_True);
446 AIS_Selection::Select();
447 if (toUpdateViewer && myWasLastMain)
449 UpdateCurrentViewer();
453 Standard_Integer aSelNum = NbSelected();
455 return (aSelNum == 0) ? AIS_SOP_NothingSelected
456 : (aSelNum == 1) ? AIS_SOP_OneSelected
457 : AIS_SOP_SeveralSelected;
460 //=======================================================================
461 //function : ShiftSelect
463 //=======================================================================
464 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
466 if (HasOpenedContext())
470 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
474 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
476 Standard_Integer aSelNum = NbSelected();
477 return (aSelNum == 0) ? AIS_SOP_NothingSelected
478 : (aSelNum == 1) ? AIS_SOP_OneSelected
479 : AIS_SOP_SeveralSelected;
483 myMainPM->ClearImmediateDraw();
484 if (myWasLastMain && !myLastinMain.IsNull())
486 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
489 Standard_Integer aSelNum = NbSelected();
491 return (aSelNum == 0) ? AIS_SOP_NothingSelected
492 : (aSelNum == 1) ? AIS_SOP_OneSelected
493 : AIS_SOP_SeveralSelected;
496 //=======================================================================
497 //function : ShiftSelect
499 //=======================================================================
500 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
501 const Standard_Integer theYPMin,
502 const Standard_Integer theXPMax,
503 const Standard_Integer theYPMax,
504 const Handle(V3d_View)& theView,
505 const Standard_Boolean toUpdateViewer)
507 if (HasOpenedContext())
509 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
510 theView, toUpdateViewer);
513 UnhilightSelected (Standard_False);
515 Handle(StdSelect_ViewerSelector3d) aSelector;
516 if (theView->Viewer() == myMainVwr)
518 aSelector = myMainSel;
519 myWasLastMain = Standard_True;
523 return AIS_SOP_NothingSelected;
526 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
527 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
528 for (aSelector->Init(); aSelector->More(); aSelector->Next())
530 const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
531 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
534 AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
535 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
536 anOwner->State (aState);
539 HilightSelected (toUpdateViewer);
541 Standard_Integer aSelNum = NbSelected();
543 return (aSelNum == 0) ? AIS_SOP_NothingSelected
544 : (aSelNum == 1) ? AIS_SOP_OneSelected
545 : AIS_SOP_SeveralSelected;
549 //=======================================================================
550 //function : ShiftSelect
552 //=======================================================================
553 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
554 const Handle(V3d_View)& theView,
555 const Standard_Boolean toUpdateViewer)
557 if (HasOpenedContext())
559 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
562 UnhilightSelected (Standard_False);
564 Handle(StdSelect_ViewerSelector3d) aSelector;
566 if (theView->Viewer() == myMainVwr)
568 aSelector= myMainSel;
569 myWasLastMain = Standard_True;
573 return AIS_SOP_NothingSelected;
576 aSelector->Pick (thePolyline, theView);
578 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
579 for (aSelector->Init(); aSelector->More(); aSelector->Next())
581 const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
582 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
585 AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
586 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
587 anOwner->State (aState);
590 HilightSelected (toUpdateViewer);
592 Standard_Integer aSelNum = NbSelected();
594 return (aSelNum == 0) ? AIS_SOP_NothingSelected
595 : (aSelNum == 1) ? AIS_SOP_OneSelected
596 : AIS_SOP_SeveralSelected;
599 //=======================================================================
600 //function : SetCurrentObject
601 //purpose : OBSOLETE, please use SetSelected() instead
602 //TODO : Remove in process of local context deletion
603 //=======================================================================
604 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
605 const Standard_Boolean theToUpdateViewer)
607 if (HasOpenedContext())
610 SetSelected (theObject, theToUpdateViewer);
613 //=======================================================================
614 //function : AddOrRemoveCurrentObject
615 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
616 //TODO : Remove in process of local context deletion
617 //=======================================================================
618 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
619 const Standard_Boolean theIsToUpdateViewer)
621 if (HasOpenedContext())
624 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
626 //=======================================================================
627 //function : UpdateCurrent
628 //purpose : OBSOLETE, please use UpdateSelected() instead
629 //TODO : Remove in process of local context deletion
630 //=======================================================================
631 void AIS_InteractiveContext::UpdateCurrent()
636 //=======================================================================
637 //function : IsCurrent
638 //purpose : OBSOLETE, please use IsSelected() instead
639 //TODO : Remove in process of local context deletion
640 //=======================================================================
641 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
643 return IsSelected (theObject);
646 //=======================================================================
647 //function : InitCurrent
648 //purpose : OBSOLETE, please use InitSelected() instead
649 //TODO : Remove in process of local context deletion
650 //=======================================================================
651 void AIS_InteractiveContext::InitCurrent()
653 if (HasOpenedContext())
659 //=======================================================================
660 //function : MoreCurrent
661 //purpose : OBSOLETE, please use MoreSelected() instead
662 //TODO : Remove in process of local context deletion
663 //=======================================================================
664 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
666 return !HasOpenedContext() && MoreSelected();
669 //=======================================================================
670 //function : NextCurrent
671 //purpose : OBSOLETE, please use NextSelected() instead
672 //TODO : Remove in process of local context deletion
673 //=======================================================================
674 void AIS_InteractiveContext::NextCurrent()
676 if (HasOpenedContext())
682 //=======================================================================
684 //purpose : OBSOLETE, please use SelectedInteractive() instead
685 //TODO : Remove in process of local context deletion
686 //=======================================================================
687 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
689 return HasOpenedContext() ? NULL : SelectedInteractive();
692 //=======================================================================
693 //function : NbCurrents
694 //purpose : OBSOLETE, please use NbSelected() instead
695 //TODO : Remove in process of local context deletion
696 //=======================================================================
697 Standard_Integer AIS_InteractiveContext::NbCurrents()
699 return HasOpenedContext() ? -1 : NbSelected();
702 //=======================================================================
703 //function : HilightCurrents
704 //purpose : OBSOLETE, please use HilightSelected() instead
705 //TODO : Remove in process of local context deletion
706 //=======================================================================
707 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
709 if (HasOpenedContext())
712 HilightSelected (theToUpdateViewer);
715 //=======================================================================
716 //function : UnhilightCurrents
717 //purpose : OBSOLETE, please use UnhilightSelected() instead
718 //TODO : Remove in process of local context deletion
719 //=======================================================================
720 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
722 if (HasOpenedContext())
725 UnhilightSelected (theToUpdateViewer);
728 //=======================================================================
729 //function : ClearCurrents
730 //purpose : OBSOLETE, please use ClearCurrents() instead
731 //TODO : Remove in process of local context deletion
732 //=======================================================================
733 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
735 if (HasOpenedContext())
738 ClearSelected (theToUpdateViewer);
742 //=======================================================================
743 //function : HilightSelected
745 //=======================================================================
746 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
748 if (HasOpenedContext())
750 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
753 // In case of selection without using local context
754 myMainPM->ClearImmediateDraw();
755 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
756 Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
757 AIS_MapOfObjSelectedOwners anObjOwnerMap;
758 for (aSel->Init(); aSel->More(); aSel->Next())
760 const Handle(SelectMgr_EntityOwner) anOwner =
761 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
762 if (!anOwner.IsNull() && anOwner->HasSelectable())
764 const Handle(AIS_InteractiveObject) anObj =
765 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
766 if (anOwner == anObj->GlobalSelOwner())
768 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj);
769 aState->SetHilightStatus (Standard_True);
770 aState->SetHilightColor (mySelectionColor);
773 if (!anOwner->IsAutoHilight())
775 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
776 if (anObjOwnerMap.Find (anObj, aSeq))
778 aSeq->Append (anOwner);
782 aSeq = new SelectMgr_SequenceOfOwner();
783 aSeq->Append (anOwner);
784 anObjOwnerMap.Bind (anObj, aSeq);
789 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
790 anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
795 if (!anObjOwnerMap.IsEmpty())
797 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
799 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
801 anObjOwnerMap.Clear();
804 if (theToUpdateViewer)
805 UpdateCurrentViewer();
808 //=======================================================================
809 //function : UnhilightSelected
811 //=======================================================================
812 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
814 if (HasOpenedContext())
816 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
819 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
820 Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
821 for (aSel->Init(); aSel->More(); aSel->Next())
823 const Handle(SelectMgr_EntityOwner) anOwner =
824 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
825 if (!anOwner.IsNull() && anOwner->HasSelectable())
827 const Handle(AIS_InteractiveObject) anObj =
828 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
829 if (anOwner == anObj->GlobalSelOwner())
831 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
834 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0;
835 anOwner->Unhilight (myMainPM, aHiMode);
839 if (theToUpdateViewer)
840 UpdateCurrentViewer();
844 //=======================================================================
845 //function : ClearSelected
847 //=======================================================================
848 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
850 if (HasOpenedContext())
851 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
853 if (NbSelected() == 0)
856 unhighlightSelected();
858 AIS_Selection::Select();
859 myMainPM->ClearImmediateDraw();
861 if (theToUpdateViewer)
862 UpdateCurrentViewer();
865 //=======================================================================
866 //function : UpdateSelected
868 //=======================================================================
869 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
871 if (HasOpenedContext())
873 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
876 HilightSelected (theToUpdateViewer);
879 //=======================================================================
880 //function : SetSelected
881 //purpose : Sets the whole object as selected and highlights it with selection color
882 //=======================================================================
883 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
884 const Standard_Boolean theToUpdateViewer)
886 if(HasOpenedContext())
888 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
891 if (theObject.IsNull())
893 if(!myObjects.IsBound (theObject))
894 Display (theObject, Standard_False);
895 if (theObject->HasSelection (0))
898 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
900 Quantity_NameOfColor aHiCol;
901 Standard_Boolean hasHiCol = Standard_False;
902 if (IsHilighted (theObject, hasHiCol, aHiCol))
904 if (hasHiCol && aHiCol!= mySelectionColor)
906 HilightWithColor (theObject, mySelectionColor, theToUpdateViewer);
912 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
913 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
914 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
916 const Handle(SelectMgr_EntityOwner) anOwner =
917 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
918 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
921 Handle(AIS_InteractiveObject) aSelectable =
922 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
923 Unhilight (aSelectable, Standard_False);
925 if (anOwner == aSelectable->GlobalSelOwner())
927 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
931 // added to avoid untimely viewer update...
932 const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
936 Handle(SelectMgr_EntityOwner) anOwner =
937 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
938 AIS_Selection::ClearAndSelect (anOwner);
940 if (anOwner == theObject->GlobalSelOwner())
942 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject);
943 aState->SetHilightStatus (Standard_True);
944 aState->SetHilightColor (mySelectionColor);
946 Quantity_NameOfColor aHiCol;
947 Standard_Boolean hasHiCol = Standard_False;
948 if (IsHilighted (theObject, hasHiCol, aHiCol))
950 if (hasHiCol && aHiCol!= mySelectionColor)
952 HilightWithColor (theObject, mySelectionColor, Standard_False);
957 HilightWithColor (theObject, mySelectionColor, Standard_False);
960 if (theToUpdateViewer)
961 UpdateCurrentViewer();
964 //=======================================================================
965 //function : SetSelected
966 //purpose : Sets the whole object as selected and highlights it with selection color
967 //=======================================================================
968 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
969 const Standard_Boolean theToUpdateViewer)
971 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
974 const Handle(AIS_InteractiveObject) anObject =
975 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
977 if (NbSelected() == 1 && theOwner->IsSelected())
979 Quantity_NameOfColor aCustomColor;
980 Standard_Boolean isCustomColorSet;
981 if (IsHilighted (theOwner, isCustomColorSet, aCustomColor))
983 if (isCustomColorSet && aCustomColor != mySelectionColor)
985 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
986 theOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
992 if (!myObjects.IsBound (anObject))
993 Display (anObject, Standard_False);
995 unhighlightSelected();
997 AIS_Selection::ClearAndSelect (theOwner);
999 Quantity_NameOfColor aCustomColor;
1000 Standard_Boolean isCustomColorSet;
1001 if (!IsHilighted (theOwner, isCustomColorSet, aCustomColor) || (isCustomColorSet && aCustomColor!= mySelectionColor))
1003 highlightSelected (theOwner, mySelectionColor);
1006 if (theOwner == anObject->GlobalSelOwner())
1008 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1009 aState->SetHilightStatus (Standard_True);
1010 aState->SetHilightColor (mySelectionColor);
1013 if (theToUpdateViewer)
1014 UpdateCurrentViewer();
1017 //=======================================================================
1018 //function : AddOrRemoveSelected
1019 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1020 // Since this method makes sence only for neutral point selection of a whole object,
1021 // if 0 selection of the object is empty this method simply does nothing.
1022 //=======================================================================
1023 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1024 const Standard_Boolean theToUpdateViewer)
1026 if (theObject.IsNull())
1029 if (HasOpenedContext())
1030 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1032 const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
1033 if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
1036 if (!theObject->HasInteractiveContext())
1037 theObject->SetContext (this);
1039 const Handle(SelectMgr_Selection)& aSel = theObject->Selection (aGlobalSelMode);
1041 if (aSel->IsEmpty())
1045 const Handle(SelectMgr_EntityOwner) anOwner =
1046 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
1048 if (anOwner.IsNull() || !anOwner->HasSelectable())
1051 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1053 //=======================================================================
1054 //function : AddOrRemoveSelected
1056 //=======================================================================
1058 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1059 const Standard_Boolean updateviewer)
1061 if(!HasOpenedContext()) {
1063 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1068 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1069 if(updateviewer) UpdateCurrentViewer();
1073 //=======================================================================
1074 //function : AddOrRemoveSelected
1075 //purpose : Allows to highlight or unhighlight the owner given depending on
1076 // its selection status
1077 //=======================================================================
1078 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1079 const Standard_Boolean theToUpdateViewer)
1081 if (HasOpenedContext())
1082 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1084 if (theOwner.IsNull() || !theOwner->HasSelectable())
1087 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
1088 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1090 AIS_SelectStatus aSelStat = AIS_Selection::Select (theOwner);
1092 Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0;
1093 theOwner->State (aState);
1094 const Handle(AIS_InteractiveObject) anObj =
1095 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1096 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1097 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1098 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
1101 highlightSelected (theOwner, mySelectionColor);
1104 aStatus->SetHilightStatus (Standard_True);
1105 aStatus->SetHilightColor (mySelectionColor);
1110 if (theOwner->IsAutoHilight())
1111 theOwner->Unhilight (myMainPM, aHiMode);
1113 anObj->ClearSelected();
1114 aStatus->SetHilightStatus (Standard_False);
1115 aStatus->SetHilightColor (Quantity_NOC_WHITE);
1118 if (theToUpdateViewer)
1119 UpdateCurrentViewer();
1123 //=======================================================================
1124 //function : IsSelected
1126 //=======================================================================
1127 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1129 if(HasOpenedContext())
1130 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1132 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1133 return Standard_False;
1135 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1136 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1137 Standard_Boolean isGlobalModeActivated = Standard_False;
1138 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1140 if (aModeIter.Value() == aGlobalSelMode)
1142 isGlobalModeActivated = Standard_True;
1146 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
1147 return Standard_False;
1149 return theObj->GlobalSelOwner()->State() == 1;
1152 //=======================================================================
1153 //function : IsSelected
1154 //purpose : Returns true is the owner given is selected
1155 //=======================================================================
1156 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1158 if (HasOpenedContext())
1159 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1161 if (theOwner.IsNull())
1162 return Standard_False;
1164 return theOwner->IsSelected();
1167 //=======================================================================
1168 //function : InitSelected
1170 //=======================================================================
1171 void AIS_InteractiveContext::InitSelected()
1173 if (HasOpenedContext())
1175 myLocalContexts (myCurLocalIndex)->InitSelected();
1179 AIS_Selection::Selection (myCurrentName.ToCString())->Init();
1182 //=======================================================================
1183 //function : MoreSelected
1185 //=======================================================================
1186 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1188 if (HasOpenedContext())
1189 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1191 return AIS_Selection::Selection (myCurrentName.ToCString())->More();
1194 //=======================================================================
1195 //function : NextSelected
1197 //=======================================================================
1198 void AIS_InteractiveContext::NextSelected()
1200 if(HasOpenedContext())
1202 return myLocalContexts (myCurLocalIndex)->NextSelected();
1206 AIS_Selection::Selection (myCurrentName.ToCString())->Next();
1209 //=======================================================================
1210 //function : HasSelectedShape
1212 //=======================================================================
1213 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1215 if(HasOpenedContext())
1217 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1220 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
1221 return !aShape.IsNull();
1224 //=======================================================================
1225 //function : SelectedShape
1227 //=======================================================================
1228 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1230 if (HasOpenedContext())
1232 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1235 if (AIS_Selection::Selection (myCurrentName.ToCString())->Extent() == 0)
1236 return TopoDS_Shape();
1238 const Handle(StdSelect_BRepOwner) anOwner =
1239 Handle(StdSelect_BRepOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
1240 if (!anOwner->HasSelectable())
1241 return TopoDS_Shape();
1243 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1246 //=======================================================================
1247 //function : SelectedInteractive
1249 //=======================================================================
1250 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1252 if (HasOpenedContext())
1254 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1257 const Handle(SelectMgr_EntityOwner) anOwner =
1258 Handle(SelectMgr_EntityOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
1259 if (anOwner.IsNull() || !anOwner->HasSelectable())
1262 return Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
1264 //=======================================================================
1265 //function : SelectedOwner
1267 //=======================================================================
1268 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1270 if(HasOpenedContext())
1272 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1275 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1277 return aCurSel->Extent() > 0 ?
1278 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()) : NULL;
1281 //=======================================================================
1282 //function : EntityOwners
1284 //=======================================================================
1285 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1286 const Handle(AIS_InteractiveObject)& theIObj,
1287 const Standard_Integer theMode) const
1289 if ( theIObj.IsNull() )
1292 TColStd_ListOfInteger aModes;
1293 if ( theMode == -1 )
1294 ActivatedModes( theIObj, aModes );
1296 aModes.Append( theMode );
1298 if (theOwners.IsNull())
1299 theOwners = new SelectMgr_IndexedMapOfOwner();
1301 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1302 for (; anItr.More(); anItr.Next() )
1304 int aMode = anItr.Value();
1305 if ( !theIObj->HasSelection( aMode ) )
1308 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1310 for ( aSel->Init(); aSel->More(); aSel->Next() )
1312 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1313 if ( aEntity.IsNull() )
1316 Handle(SelectMgr_EntityOwner) aOwner =
1317 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1318 if ( !aOwner.IsNull() )
1319 theOwners->Add( aOwner );
1324 //=======================================================================
1325 //function : NbSelected
1327 //=======================================================================
1328 Standard_Integer AIS_InteractiveContext::NbSelected()
1330 Standard_Integer aNbSelected = 0;
1331 for (InitSelected(); MoreSelected(); NextSelected())
1339 //=======================================================================
1340 //function : HasApplicative
1342 //=======================================================================
1343 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1345 return SelectedInteractive()->HasOwner();
1348 //=======================================================================
1349 //function : Applicative
1351 //=======================================================================
1352 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1354 return SelectedInteractive()->GetOwner();
1357 //==================================================
1358 // Function: HasDetected
1360 //==================================================
1361 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1363 if(HasOpenedContext())
1364 return myLocalContexts(myCurLocalIndex)->HasDetected();
1366 return !myLastPicked.IsNull();
1369 //=======================================================================
1370 //function : HasDetectedShape
1372 //=======================================================================
1374 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1376 if(HasOpenedContext())
1377 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1378 return Standard_False;
1381 //=======================================================================
1382 //function : DetectedShape
1384 //=======================================================================
1387 AIS_InteractiveContext::DetectedShape() const
1389 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1392 //=======================================================================
1393 //function : DetectedInteractive
1395 //=======================================================================
1396 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1398 if (HasOpenedContext())
1399 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1401 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1405 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1407 if(!HasOpenedContext())
1408 return Standard_False; // temporaire
1410 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1415 //=======================================================================
1416 //function : DetectedOwner
1418 //=======================================================================
1419 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1421 if (HasOpenedContext())
1422 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1424 return myLastPicked;
1427 //=======================================================================
1428 //function : HilightNextDetected
1430 //=======================================================================
1431 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1432 const Standard_Boolean theToRedrawImmediate)
1434 return HasOpenedContext()
1435 ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
1440 //=======================================================================
1441 //function : HilightNextDetected
1443 //=======================================================================
1444 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1445 const Standard_Boolean theToRedrawImmediate)
1447 return HasOpenedContext()
1448 ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
1453 //=======================================================================
1454 //function : InitDetected
1456 //=======================================================================
1457 void AIS_InteractiveContext::InitDetected()
1459 if (HasOpenedContext())
1461 myLocalContexts(myCurLocalIndex)->InitDetected();
1465 if(myAISDetectedSeq.Length() != 0)
1467 myAISCurDetected = 1;
1471 //=======================================================================
1472 //function : MoreDetected
1474 //=======================================================================
1475 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1477 if (HasOpenedContext())
1479 return myLocalContexts(myCurLocalIndex)->MoreDetected();
1482 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
1483 Standard_True : Standard_False;
1486 //=======================================================================
1487 //function : NextDetected
1489 //=======================================================================
1490 void AIS_InteractiveContext::NextDetected()
1492 if(HasOpenedContext())
1494 myLocalContexts(myCurLocalIndex)->NextDetected();
1501 //=======================================================================
1502 //function : DetectedCurrentShape
1504 //=======================================================================
1505 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1507 if (HasOpenedContext())
1509 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1512 static TopoDS_Shape aDummyShape;
1514 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1516 if (aCurrentShape.IsNull())
1521 return aCurrentShape->Shape();
1524 //=======================================================================
1525 //function : DetectedCurrentObject
1527 //=======================================================================
1528 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1530 if (HasOpenedContext())
1532 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1535 return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
1538 //=======================================================================
1539 //function : FirstSelectedObject
1541 //=======================================================================
1542 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1544 Handle(AIS_InteractiveObject) anObject;
1546 if (HasOpenedContext())
1552 return SelectedInteractive();
1557 //=======================================================================
1558 //function : RedrawImmediate
1559 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1560 //=======================================================================
1561 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1563 myMainPM->RedrawImmediate (theViewer);