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>
55 #include <Visual3d_View.hxx>
57 typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
59 //=======================================================================
60 //function : highlightWithColor
62 //=======================================================================
63 void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
64 const Quantity_NameOfColor theColor,
65 const Handle(V3d_Viewer)& theViewer)
67 const Handle(AIS_InteractiveObject) anObj =
68 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
71 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
73 myMainPM->BeginImmediateDraw();
74 theOwner->HilightWithColor (myMainPM, theColor, aHiMode);
75 myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
78 //=======================================================================
79 //function : highlightSelected
81 //=======================================================================
82 void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
83 const Quantity_NameOfColor theSelColor)
85 const Handle(AIS_InteractiveObject) anObj =
86 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
89 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
91 if (!theOwner->IsAutoHilight())
93 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
94 const Handle(AIS_Selection)& aCurSel = AIS_Selection::CurrentSelection();
95 SelectMgr_SequenceOfOwner aSeq;
96 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
98 const Handle(SelectMgr_EntityOwner) aSelOwnr =
99 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
100 if (aSelOwnr->Selectable() != anObj)
102 aSeq.Append (aSelOwnr);
104 anObj->HilightSelected (myMainPM, aSeq);
108 theOwner->HilightWithColor (myMainPM, theSelColor, aHiMode);
112 //=======================================================================
115 //=======================================================================
116 AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
117 const Standard_Integer theYPix,
118 const Handle(V3d_View)& theView,
119 const Standard_Boolean theToRedrawOnUpdate)
121 if (HasOpenedContext())
123 myWasLastMain = Standard_True;
124 return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
127 myAISCurDetected = 0;
128 myAISDetectedSeq.Clear();
130 if (theView->Viewer() != myMainVwr)
132 return AIS_SOD_Error;
136 myLastPicked = myLastinMain;
137 myWasLastMain = Standard_True;
138 AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
139 Standard_Boolean toUpdateViewer = Standard_False;
141 myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
142 myMainSel->Pick (theXPix, theYPix, theView);
144 // filling of myAISDetectedSeq sequence storing information about detected AIS objects
145 // (the objects must be AIS_Shapes)
146 const Standard_Integer aDetectedNb = myMainSel->NbPicked();
147 Standard_Integer aNewDetected = 0;
148 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
150 Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
152 || !myFilters->IsOk (anOwner))
157 if (aNewDetected < 1)
159 aNewDetected = aDetIter;
161 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
164 myAISDetectedSeq.Append (anObj);
168 if (aNewDetected >= 1)
170 // does nothing if previously detected object is equal to the current one
171 Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
172 if (aNewPickedOwner == myLastPicked)
174 return myLastPicked->IsSelected()
176 : AIS_SOD_OnlyOneDetected;
179 // Previously detected object is unhilighted if it is not selected or hilighted
180 // with selection color if it is selected. Such highlighting with selection color
181 // is needed only if myToHilightSelected flag is true. In this case previously detected
182 // object has been already highlighted with myHilightColor during previous MoveTo()
183 // method call. As result it is necessary to rehighligt it with mySelectionColor.
184 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
186 myMainPM->ClearImmediateDraw();
187 const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
188 const Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
189 if (!myLastPicked->IsSelected())
191 myLastPicked->Unhilight (myMainPM, aHiMod);
192 toUpdateViewer = Standard_True;
194 else if (myToHilightSelected)
196 highlightWithColor (aNewPickedOwner, mySelectionColor, theView->Viewer());
197 toUpdateViewer = Standard_True;
201 // initialize myLastPicked field with currently detected object
202 myLastPicked = aNewPickedOwner;
203 myLastinMain = myLastPicked;
205 // highlight detected object if it is not selected or myToHilightSelected flag is true
206 if (myLastPicked->HasSelectable())
208 if (!myLastPicked->IsSelected() || myToHilightSelected)
210 highlightWithColor (myLastPicked, myHilightColor, theView->Viewer());
211 toUpdateViewer = Standard_True;
214 aStatus = myLastPicked->IsSelected()
216 : AIS_SOD_OnlyOneDetected;
221 // previously detected object is unhilighted if it is not selected or hilighted
222 // with selection color if it is selected
223 aStatus = AIS_SOD_Nothing;
224 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
226 myMainPM->ClearImmediateDraw();
227 const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
228 Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
229 if (!myLastPicked->IsSelected())
231 if (myLastPicked->IsAutoHilight())
233 myLastPicked->Unhilight (myMainPM, aHiMod);
235 toUpdateViewer = Standard_True;
237 else if (myToHilightSelected)
239 highlightSelected (myLastPicked, mySelectionColor);
240 toUpdateViewer = Standard_True;
244 myLastinMain.Nullify();
245 myLastPicked.Nullify();
250 if (theToRedrawOnUpdate)
252 theView->Viewer()->Update();
256 theView->Viewer()->Invalidate();
260 mylastmoveview = theView;
264 //=======================================================================
267 //=======================================================================
268 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
269 const Standard_Integer theYPMin,
270 const Standard_Integer theXPMax,
271 const Standard_Integer theYPMax,
272 const Handle(V3d_View)& theView,
273 const Standard_Boolean toUpdateViewer)
275 // all objects detected by the selector are taken, previous current objects are emptied,
276 // new objects are put...
278 if (HasOpenedContext())
280 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
282 theView, toUpdateViewer);
285 ClearSelected (Standard_False);
287 Handle(StdSelect_ViewerSelector3d) aSelector;
289 if (theView->Viewer() == myMainVwr)
291 aSelector = myMainSel;
292 myWasLastMain = Standard_True;
295 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
296 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
298 for (aSelector->Init(); aSelector->More(); aSelector->Next())
300 const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked();
301 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
304 AIS_Selection::Select (aCurOwner);
305 aCurOwner->State (1);
308 HilightSelected (toUpdateViewer);
310 Standard_Integer aSelNum = NbSelected();
312 return (aSelNum == 0) ? AIS_SOP_NothingSelected
313 : (aSelNum == 1) ? AIS_SOP_OneSelected
314 : AIS_SOP_SeveralSelected;
318 //=======================================================================
320 //purpose : Selection by polyline
321 //=======================================================================
322 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
323 const Handle(V3d_View)& theView,
324 const Standard_Boolean toUpdateViewer)
326 // all objects detected by the selector are taken, previous current objects are emptied,
327 // new objects are put...
329 if (HasOpenedContext())
331 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
334 ClearSelected (Standard_False);
336 Handle(StdSelect_ViewerSelector3d) aSelector;
338 if (theView->Viewer() == myMainVwr)
340 aSelector = myMainSel;
341 myWasLastMain = Standard_True;
344 aSelector->Pick (thePolyline, theView);
345 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
347 for (aSelector->Init(); aSelector->More(); aSelector->Next())
349 const Handle(SelectMgr_EntityOwner) anOwner =
350 Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
351 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
354 AIS_Selection::Select (anOwner);
358 HilightSelected (toUpdateViewer);
360 Standard_Integer aSelNum = NbSelected();
362 return (aSelNum == 0) ? AIS_SOP_NothingSelected
363 : (aSelNum == 1) ? AIS_SOP_OneSelected
364 : AIS_SOP_SeveralSelected;
368 //=======================================================================
371 //=======================================================================
372 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
374 if (HasOpenedContext())
378 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
382 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
383 return AIS_SOP_OneSelected;
387 myMainPM->ClearImmediateDraw();
388 if (myWasLastMain && !myLastinMain.IsNull())
390 if(!myLastinMain->IsSelected())
392 SetSelected (myLastinMain, Standard_False);
395 UpdateCurrentViewer();
401 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
402 Handle(AIS_Selection) aSelection = AIS_Selection::CurrentSelection();
403 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
404 for (aSelection->Init(); aSelection->More(); aSelection->Next())
406 const Handle(SelectMgr_EntityOwner) anOwner
407 = Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Value());
409 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
412 const Handle(AIS_InteractiveObject) anObject =
413 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
415 if (anOwner == anObject->GlobalSelOwner())
417 myObjects.ChangeFind (anObject)->SetHilightStatus (Standard_False);
419 if (!anOwner->IsAutoHilight())
421 if (!anObjToClear.Contains (anObject))
422 anObjToClear.Add (anObject);
426 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
427 anOwner->Unhilight (myMainPM, aHiMode);
428 if (myObjects.IsBound (anObject) && myObjects(anObject)->IsSubIntensityOn())
430 anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode);
434 while (!anObjToClear.IsEmpty())
436 anObjToClear.FindKey (anObjToClear.Size())->ClearSelected();
437 anObjToClear.RemoveLast();
440 AIS_Selection::Select();
441 if (toUpdateViewer && myWasLastMain)
443 UpdateCurrentViewer();
447 Standard_Integer aSelNum = NbSelected();
449 return (aSelNum == 0) ? AIS_SOP_NothingSelected
450 : (aSelNum == 1) ? AIS_SOP_OneSelected
451 : AIS_SOP_SeveralSelected;
454 //=======================================================================
455 //function : ShiftSelect
457 //=======================================================================
458 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
460 if (HasOpenedContext())
464 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
468 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
470 Standard_Integer aSelNum = NbSelected();
471 return (aSelNum == 0) ? AIS_SOP_NothingSelected
472 : (aSelNum == 1) ? AIS_SOP_OneSelected
473 : AIS_SOP_SeveralSelected;
477 myMainPM->ClearImmediateDraw();
478 if (myWasLastMain && !myLastinMain.IsNull())
480 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
483 Standard_Integer aSelNum = NbSelected();
485 return (aSelNum == 0) ? AIS_SOP_NothingSelected
486 : (aSelNum == 1) ? AIS_SOP_OneSelected
487 : AIS_SOP_SeveralSelected;
490 //=======================================================================
491 //function : ShiftSelect
493 //=======================================================================
494 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
495 const Standard_Integer theYPMin,
496 const Standard_Integer theXPMax,
497 const Standard_Integer theYPMax,
498 const Handle(V3d_View)& theView,
499 const Standard_Boolean toUpdateViewer)
501 if (HasOpenedContext())
503 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
504 theView, toUpdateViewer);
507 UnhilightSelected (Standard_False);
509 Handle(StdSelect_ViewerSelector3d) aSelector;
510 if (theView->Viewer() == myMainVwr)
512 aSelector = myMainSel;
513 myWasLastMain = Standard_True;
517 return AIS_SOP_NothingSelected;
520 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
521 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
522 for (aSelector->Init(); aSelector->More(); aSelector->Next())
524 const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
525 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
528 AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
529 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
530 anOwner->State (aState);
533 HilightSelected (toUpdateViewer);
535 Standard_Integer aSelNum = NbSelected();
537 return (aSelNum == 0) ? AIS_SOP_NothingSelected
538 : (aSelNum == 1) ? AIS_SOP_OneSelected
539 : AIS_SOP_SeveralSelected;
543 //=======================================================================
544 //function : ShiftSelect
546 //=======================================================================
547 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
548 const Handle(V3d_View)& theView,
549 const Standard_Boolean toUpdateViewer)
551 if (HasOpenedContext())
553 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
556 UnhilightSelected (Standard_False);
558 Handle(StdSelect_ViewerSelector3d) aSelector;
560 if (theView->Viewer() == myMainVwr)
562 aSelector= myMainSel;
563 myWasLastMain = Standard_True;
567 return AIS_SOP_NothingSelected;
570 aSelector->Pick (thePolyline, theView);
572 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
573 for (aSelector->Init(); aSelector->More(); aSelector->Next())
575 const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelector->Picked());
576 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
579 AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner);
580 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
581 anOwner->State (aState);
584 HilightSelected (toUpdateViewer);
586 Standard_Integer aSelNum = NbSelected();
588 return (aSelNum == 0) ? AIS_SOP_NothingSelected
589 : (aSelNum == 1) ? AIS_SOP_OneSelected
590 : AIS_SOP_SeveralSelected;
593 //=======================================================================
594 //function : SetCurrentObject
595 //purpose : OBSOLETE, please use SetSelected() instead
596 //TODO : Remove in process of local context deletion
597 //=======================================================================
598 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
599 const Standard_Boolean theToUpdateViewer)
601 if (HasOpenedContext())
604 SetSelected (theObject, theToUpdateViewer);
607 //=======================================================================
608 //function : AddOrRemoveCurrentObject
609 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
610 //TODO : Remove in process of local context deletion
611 //=======================================================================
612 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
613 const Standard_Boolean theIsToUpdateViewer)
615 if (HasOpenedContext())
618 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
620 //=======================================================================
621 //function : UpdateCurrent
622 //purpose : OBSOLETE, please use UpdateSelected() instead
623 //TODO : Remove in process of local context deletion
624 //=======================================================================
625 void AIS_InteractiveContext::UpdateCurrent()
630 //=======================================================================
631 //function : IsCurrent
632 //purpose : OBSOLETE, please use IsSelected() instead
633 //TODO : Remove in process of local context deletion
634 //=======================================================================
635 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
637 return IsSelected (theObject);
640 //=======================================================================
641 //function : InitCurrent
642 //purpose : OBSOLETE, please use InitSelected() instead
643 //TODO : Remove in process of local context deletion
644 //=======================================================================
645 void AIS_InteractiveContext::InitCurrent()
647 if (HasOpenedContext())
653 //=======================================================================
654 //function : MoreCurrent
655 //purpose : OBSOLETE, please use MoreSelected() instead
656 //TODO : Remove in process of local context deletion
657 //=======================================================================
658 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
660 return !HasOpenedContext() && MoreSelected();
663 //=======================================================================
664 //function : NextCurrent
665 //purpose : OBSOLETE, please use NextSelected() instead
666 //TODO : Remove in process of local context deletion
667 //=======================================================================
668 void AIS_InteractiveContext::NextCurrent()
670 if (HasOpenedContext())
676 //=======================================================================
678 //purpose : OBSOLETE, please use SelectedInteractive() instead
679 //TODO : Remove in process of local context deletion
680 //=======================================================================
681 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
683 return HasOpenedContext() ? NULL : SelectedInteractive();
686 //=======================================================================
687 //function : NbCurrents
688 //purpose : OBSOLETE, please use NbSelected() instead
689 //TODO : Remove in process of local context deletion
690 //=======================================================================
691 Standard_Integer AIS_InteractiveContext::NbCurrents()
693 return HasOpenedContext() ? -1 : NbSelected();
696 //=======================================================================
697 //function : HilightCurrents
698 //purpose : OBSOLETE, please use HilightSelected() instead
699 //TODO : Remove in process of local context deletion
700 //=======================================================================
701 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
703 if (HasOpenedContext())
706 HilightSelected (theToUpdateViewer);
709 //=======================================================================
710 //function : UnhilightCurrents
711 //purpose : OBSOLETE, please use UnhilightSelected() instead
712 //TODO : Remove in process of local context deletion
713 //=======================================================================
714 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
716 if (HasOpenedContext())
719 UnhilightSelected (theToUpdateViewer);
722 //=======================================================================
723 //function : ClearCurrents
724 //purpose : OBSOLETE, please use ClearCurrents() instead
725 //TODO : Remove in process of local context deletion
726 //=======================================================================
727 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
729 if (HasOpenedContext())
732 ClearSelected (theToUpdateViewer);
736 //=======================================================================
737 //function : HilightSelected
739 //=======================================================================
740 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
742 if (HasOpenedContext())
744 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
747 // In case of selection without using local context
748 myMainPM->ClearImmediateDraw();
749 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
750 Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
751 AIS_MapOfObjSelectedOwners anObjOwnerMap;
752 for (aSel->Init(); aSel->More(); aSel->Next())
754 const Handle(SelectMgr_EntityOwner) anOwner =
755 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
756 if (!anOwner.IsNull() && anOwner->HasSelectable())
758 const Handle(AIS_InteractiveObject) anObj =
759 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
760 if (anOwner == anObj->GlobalSelOwner())
762 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj);
763 aState->SetHilightStatus (Standard_True);
764 aState->SetHilightColor (mySelectionColor);
767 if (!anOwner->IsAutoHilight())
769 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
770 if (anObjOwnerMap.Find (anObj, aSeq))
772 aSeq->Append (anOwner);
776 aSeq = new SelectMgr_SequenceOfOwner();
777 aSeq->Append (anOwner);
778 anObjOwnerMap.Bind (anObj, aSeq);
783 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
784 anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
789 if (!anObjOwnerMap.IsEmpty())
791 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
793 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
795 anObjOwnerMap.Clear();
798 if (theToUpdateViewer)
799 UpdateCurrentViewer();
802 //=======================================================================
803 //function : UnhilightSelected
805 //=======================================================================
806 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
808 if (HasOpenedContext())
810 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
813 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
814 Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString());
815 for (aSel->Init(); aSel->More(); aSel->Next())
817 const Handle(SelectMgr_EntityOwner) anOwner =
818 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
819 if (!anOwner.IsNull() && anOwner->HasSelectable())
821 const Handle(AIS_InteractiveObject) anObj =
822 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
823 if (anOwner == anObj->GlobalSelOwner())
825 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
828 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0;
829 anOwner->Unhilight (myMainPM, aHiMode);
833 if (theToUpdateViewer)
834 UpdateCurrentViewer();
838 //=======================================================================
839 //function : ClearSelected
841 //=======================================================================
842 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
844 if (HasOpenedContext())
845 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
847 if (NbSelected() == 0)
850 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
851 Handle(AIS_Selection) aSel = AIS_Selection::CurrentSelection();
852 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
853 for (aSel->Init(); aSel->More(); aSel->Next())
855 const Handle(SelectMgr_EntityOwner) anOwner =
856 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value());
857 if (!anOwner.IsNull() && anOwner->HasSelectable())
859 const Handle(AIS_InteractiveObject) anObj =
860 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
861 if (anOwner == anObj->GlobalSelOwner())
863 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
866 if (!anOwner->IsAutoHilight())
868 if (!anObjToClear.Contains (anObj))
869 anObjToClear.Add (anObj);
873 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
874 anOwner->Unhilight (myMainPM, aHiMode);
879 while (!anObjToClear.IsEmpty())
881 anObjToClear.FindKey (anObjToClear.Size())->ClearSelected();
882 anObjToClear.RemoveLast();
885 AIS_Selection::Select();
886 myMainPM->ClearImmediateDraw();
888 if (theToUpdateViewer)
889 UpdateCurrentViewer();
892 //=======================================================================
893 //function : UpdateSelected
895 //=======================================================================
896 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
898 if (HasOpenedContext())
900 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
903 HilightSelected (theToUpdateViewer);
906 //=======================================================================
907 //function : SetSelected
908 //purpose : Sets the whole object as selected and highlights it with selection color
909 //=======================================================================
910 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
911 const Standard_Boolean theToUpdateViewer)
913 if(HasOpenedContext())
915 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
918 if (theObject.IsNull())
920 if(!myObjects.IsBound (theObject))
921 Display (theObject, Standard_False);
922 if (theObject->HasSelection (0))
925 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
927 Quantity_NameOfColor aHiCol;
928 Standard_Boolean hasHiCol = Standard_False;
929 if (IsHilighted (theObject, hasHiCol, aHiCol))
931 if (hasHiCol && aHiCol!= mySelectionColor)
933 HilightWithColor (theObject, mySelectionColor, theToUpdateViewer);
939 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
940 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
941 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
943 const Handle(SelectMgr_EntityOwner) anOwner =
944 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
945 if (anOwner.IsNull() || !anOwner->HasSelectable())
948 Handle(AIS_InteractiveObject) aSelectable =
949 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
950 Unhilight (aSelectable, Standard_False);
952 if (anOwner == aSelectable->GlobalSelOwner())
954 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
958 // added to avoid untimely viewer update...
959 const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
963 Handle(SelectMgr_EntityOwner) anOwner =
964 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
965 AIS_Selection::ClearAndSelect (anOwner);
967 if (anOwner == theObject->GlobalSelOwner())
969 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject);
970 aState->SetHilightStatus (Standard_True);
971 aState->SetHilightColor (mySelectionColor);
973 Quantity_NameOfColor aHiCol;
974 Standard_Boolean hasHiCol = Standard_False;
975 if (IsHilighted (theObject, hasHiCol, aHiCol))
977 if (hasHiCol && aHiCol!= mySelectionColor)
979 HilightWithColor (theObject, mySelectionColor, Standard_False);
984 HilightWithColor (theObject, mySelectionColor, Standard_False);
987 if (theToUpdateViewer)
988 UpdateCurrentViewer();
991 //=======================================================================
992 //function : SetSelected
993 //purpose : Sets the whole object as selected and highlights it with selection color
994 //=======================================================================
995 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
996 const Standard_Boolean theToUpdateViewer)
998 if (theOwner.IsNull() || !theOwner->HasSelectable())
1001 const Handle(AIS_InteractiveObject) anObject =
1002 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1004 if (NbSelected() == 1 && theOwner->IsSelected())
1006 Quantity_NameOfColor aCustomColor;
1007 Standard_Boolean isCustomColorSet;
1008 if (IsHilighted (theOwner, isCustomColorSet, aCustomColor))
1010 if (isCustomColorSet && aCustomColor != mySelectionColor)
1012 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
1013 theOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
1019 if (!myObjects.IsBound (anObject))
1020 Display (anObject, Standard_False);
1022 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
1023 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1024 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
1025 for (aCurSel->Init(); aCurSel->More(); aCurSel->Next())
1027 const Handle(SelectMgr_EntityOwner) anOwner =
1028 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value());
1029 if (!anOwner->HasSelectable())
1031 const Handle(AIS_InteractiveObject) anInteractive =
1032 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
1033 if (anOwner->IsAutoHilight())
1035 const Standard_Integer aHiMode = anInteractive->HasHilightMode() ? anInteractive->HilightMode() : 0;
1036 anOwner->Unhilight (myMainPM, aHiMode);
1040 if (!anObjToClear.Contains (anInteractive))
1041 anObjToClear.Add (anInteractive);
1044 if (theOwner == anObject->GlobalSelOwner())
1046 myObjects.ChangeFind (anObject)->SetHilightStatus (Standard_False);
1049 while (!anObjToClear.IsEmpty())
1051 anObjToClear.FindKey (anObjToClear.Size())->ClearSelected();
1052 anObjToClear.RemoveLast();
1055 AIS_Selection::ClearAndSelect (theOwner);
1056 theOwner->State (1);
1057 Quantity_NameOfColor aCustomColor;
1058 Standard_Boolean isCustomColorSet;
1059 if (!IsHilighted (theOwner, isCustomColorSet, aCustomColor) || (isCustomColorSet && aCustomColor!= mySelectionColor))
1061 highlightSelected (theOwner, mySelectionColor);
1064 if (theOwner == anObject->GlobalSelOwner())
1066 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1067 aState->SetHilightStatus (Standard_True);
1068 aState->SetHilightColor (mySelectionColor);
1071 if (theToUpdateViewer)
1072 UpdateCurrentViewer();
1075 //=======================================================================
1076 //function : AddOrRemoveSelected
1077 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1078 // Since this method makes sence only for neutral point selection of a whole object,
1079 // if 0 selection of the object is empty this method simply does nothing.
1080 //=======================================================================
1081 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1082 const Standard_Boolean theToUpdateViewer)
1084 if (!theObject->HasInteractiveContext())
1085 theObject->SetContext (this);
1087 if (HasOpenedContext())
1088 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1090 if (theObject.IsNull() || !myObjects.IsBound (theObject) || !theObject->HasSelection (0))
1093 const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0);
1095 if (aSel->IsEmpty())
1099 const Handle(SelectMgr_EntityOwner) anOwner =
1100 Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
1102 if (anOwner.IsNull() || !anOwner->HasSelectable())
1105 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1107 //=======================================================================
1108 //function : AddOrRemoveSelected
1110 //=======================================================================
1112 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1113 const Standard_Boolean updateviewer)
1115 if(!HasOpenedContext()) {
1117 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1122 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1123 if(updateviewer) UpdateCurrentViewer();
1127 //=======================================================================
1128 //function : AddOrRemoveSelected
1129 //purpose : Allows to highlight or unhighlight the owner given depending on
1130 // its selection status
1131 //=======================================================================
1132 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1133 const Standard_Boolean theToUpdateViewer)
1135 if (HasOpenedContext())
1136 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1138 if (theOwner.IsNull() || !theOwner->HasSelectable())
1141 AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
1142 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1144 AIS_SelectStatus aSelStat = AIS_Selection::Select (theOwner);
1146 Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0;
1147 theOwner->State (aState);
1148 const Handle(AIS_InteractiveObject) anObj =
1149 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1150 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1151 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1152 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
1155 highlightSelected (theOwner, mySelectionColor);
1158 aStatus->SetHilightStatus (Standard_True);
1159 aStatus->SetHilightColor (mySelectionColor);
1164 if (theOwner->IsAutoHilight())
1165 theOwner->Unhilight (myMainPM, aHiMode);
1167 anObj->ClearSelected();
1168 aStatus->SetHilightStatus (Standard_False);
1169 aStatus->SetHilightColor (Quantity_NOC_WHITE);
1172 if (theToUpdateViewer)
1173 UpdateCurrentViewer();
1177 //=======================================================================
1178 //function : IsSelected
1180 //=======================================================================
1181 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1183 if(HasOpenedContext())
1184 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1186 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1187 return Standard_False;
1189 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1190 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1191 Standard_Boolean isGlobalModeActivated = Standard_False;
1192 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1194 if (aModeIter.Value() == aGlobalSelMode)
1196 isGlobalModeActivated = Standard_True;
1200 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated)
1201 return Standard_False;
1203 return myObjects (theObj)->IsHilighted();
1206 //=======================================================================
1207 //function : IsSelected
1208 //purpose : Returns true is the owner given is selected
1209 //=======================================================================
1210 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1212 if (HasOpenedContext())
1213 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1215 if (theOwner.IsNull())
1216 return Standard_False;
1218 return theOwner->IsSelected();
1221 //=======================================================================
1222 //function : InitSelected
1224 //=======================================================================
1225 void AIS_InteractiveContext::InitSelected()
1227 if (HasOpenedContext())
1229 myLocalContexts (myCurLocalIndex)->InitSelected();
1233 AIS_Selection::Selection (myCurrentName.ToCString())->Init();
1236 //=======================================================================
1237 //function : MoreSelected
1239 //=======================================================================
1240 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1242 if (HasOpenedContext())
1243 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1245 return AIS_Selection::Selection (myCurrentName.ToCString())->More();
1248 //=======================================================================
1249 //function : NextSelected
1251 //=======================================================================
1252 void AIS_InteractiveContext::NextSelected()
1254 if(HasOpenedContext())
1256 return myLocalContexts (myCurLocalIndex)->NextSelected();
1260 AIS_Selection::Selection (myCurrentName.ToCString())->Next();
1263 //=======================================================================
1264 //function : HasSelectedShape
1266 //=======================================================================
1267 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1269 if(HasOpenedContext())
1271 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1274 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
1275 return !aShape.IsNull();
1278 //=======================================================================
1279 //function : SelectedShape
1281 //=======================================================================
1282 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1284 if (HasOpenedContext())
1286 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1289 if (AIS_Selection::Selection (myCurrentName.ToCString())->Extent() == 0)
1290 return TopoDS_Shape();
1292 const Handle(StdSelect_BRepOwner) anOwner =
1293 Handle(StdSelect_BRepOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
1294 if (!anOwner->HasSelectable())
1295 return TopoDS_Shape();
1297 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1300 //=======================================================================
1301 //function : SelectedInteractive
1303 //=======================================================================
1304 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1306 if (HasOpenedContext())
1308 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1311 const Handle(SelectMgr_EntityOwner) anOwner =
1312 Handle(SelectMgr_EntityOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value());
1313 if (anOwner.IsNull() || !anOwner->HasSelectable())
1316 return Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
1318 //=======================================================================
1319 //function : SelectedOwner
1321 //=======================================================================
1322 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1324 if(HasOpenedContext())
1326 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1329 Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString());
1331 return aCurSel->Extent() > 0 ?
1332 Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()) : NULL;
1335 //=======================================================================
1336 //function : EntityOwners
1338 //=======================================================================
1339 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1340 const Handle(AIS_InteractiveObject)& theIObj,
1341 const Standard_Integer theMode) const
1343 if ( theIObj.IsNull() )
1346 TColStd_ListOfInteger aModes;
1347 if ( theMode == -1 )
1348 ActivatedModes( theIObj, aModes );
1350 aModes.Append( theMode );
1352 if (theOwners.IsNull())
1353 theOwners = new SelectMgr_IndexedMapOfOwner();
1355 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1356 for (; anItr.More(); anItr.Next() )
1358 int aMode = anItr.Value();
1359 if ( !theIObj->HasSelection( aMode ) )
1362 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1364 for ( aSel->Init(); aSel->More(); aSel->Next() )
1366 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1367 if ( aEntity.IsNull() )
1370 Handle(SelectMgr_EntityOwner) aOwner =
1371 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1372 if ( !aOwner.IsNull() )
1373 theOwners->Add( aOwner );
1378 //=======================================================================
1379 //function : NbSelected
1381 //=======================================================================
1382 Standard_Integer AIS_InteractiveContext::NbSelected()
1384 Standard_Integer aNbSelected = 0;
1385 for (InitSelected(); MoreSelected(); NextSelected())
1393 //=======================================================================
1394 //function : HasApplicative
1396 //=======================================================================
1397 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1399 return SelectedInteractive()->HasOwner();
1402 //=======================================================================
1403 //function : Applicative
1405 //=======================================================================
1406 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1408 return SelectedInteractive()->GetOwner();
1411 //==================================================
1412 // Function: HasDetected
1414 //==================================================
1415 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1417 if(HasOpenedContext())
1418 return myLocalContexts(myCurLocalIndex)->HasDetected();
1420 return !myLastPicked.IsNull();
1423 //=======================================================================
1424 //function : HasDetectedShape
1426 //=======================================================================
1428 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1430 if(HasOpenedContext())
1431 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1432 return Standard_False;
1435 //=======================================================================
1436 //function : DetectedShape
1438 //=======================================================================
1441 AIS_InteractiveContext::DetectedShape() const
1443 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1446 //=======================================================================
1447 //function : DetectedInteractive
1449 //=======================================================================
1450 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1452 if (HasOpenedContext())
1453 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1455 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1459 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1461 if(!HasOpenedContext())
1462 return Standard_False; // temporaire
1464 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1469 //=======================================================================
1470 //function : DetectedOwner
1472 //=======================================================================
1473 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1475 if (HasOpenedContext())
1476 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1478 return myLastPicked;
1481 //=======================================================================
1482 //function : HilightNextDetected
1484 //=======================================================================
1485 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1486 const Standard_Boolean theToRedrawImmediate)
1488 return HasOpenedContext()
1489 ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
1494 //=======================================================================
1495 //function : HilightNextDetected
1497 //=======================================================================
1498 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1499 const Standard_Boolean theToRedrawImmediate)
1501 return HasOpenedContext()
1502 ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
1507 //=======================================================================
1508 //function : InitDetected
1510 //=======================================================================
1511 void AIS_InteractiveContext::InitDetected()
1513 if (HasOpenedContext())
1515 myLocalContexts(myCurLocalIndex)->InitDetected();
1519 if(myAISDetectedSeq.Length() != 0)
1521 myAISCurDetected = 1;
1525 //=======================================================================
1526 //function : MoreDetected
1528 //=======================================================================
1529 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1531 if (HasOpenedContext())
1533 return myLocalContexts(myCurLocalIndex)->MoreDetected();
1536 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
1537 Standard_True : Standard_False;
1540 //=======================================================================
1541 //function : NextDetected
1543 //=======================================================================
1544 void AIS_InteractiveContext::NextDetected()
1546 if(HasOpenedContext())
1548 myLocalContexts(myCurLocalIndex)->NextDetected();
1555 //=======================================================================
1556 //function : DetectedCurrentShape
1558 //=======================================================================
1559 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1561 if (HasOpenedContext())
1563 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1566 static TopoDS_Shape aDummyShape;
1568 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1570 if (aCurrentShape.IsNull())
1575 return aCurrentShape->Shape();
1578 //=======================================================================
1579 //function : DetectedCurrentObject
1581 //=======================================================================
1582 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1584 if (HasOpenedContext())
1586 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1589 return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
1592 //=======================================================================
1593 //function : FirstSelectedObject
1595 //=======================================================================
1596 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1598 Handle(AIS_InteractiveObject) anObject;
1600 if (HasOpenedContext())
1606 return SelectedInteractive();
1611 //=======================================================================
1612 //function : RedrawImmediate
1613 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1614 //=======================================================================
1615 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1617 myMainPM->RedrawImmediate (theViewer);