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 <V3d_AmbientLight.hxx>
48 #include <V3d_DirectionalLight.hxx>
49 #include <V3d_Light.hxx>
50 #include <V3d_PositionalLight.hxx>
51 #include <V3d_SpotLight.hxx>
52 #include <V3d_View.hxx>
53 #include <V3d_Viewer.hxx>
55 typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
59 TopoDS_Shape AIS_myDummyShape;
62 //=======================================================================
63 //function : highlightWithColor
65 //=======================================================================
66 void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
67 const Handle(V3d_Viewer)& theViewer)
69 const Handle(AIS_InteractiveObject) anObj =
70 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
73 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
75 myMainPM->BeginImmediateDraw();
76 theOwner->HilightWithColor (myMainPM, getHiStyle (anObj), aHiMode);
77 myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
80 //=======================================================================
81 //function : highlightSelected
83 //=======================================================================
84 void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
86 const Handle(AIS_InteractiveObject) anObj =
87 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
90 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
92 if (!theOwner->IsAutoHilight())
94 SelectMgr_SequenceOfOwner aSeq;
95 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
97 if (aSelIter.Value()->IsSameSelectable (anObj))
99 aSeq.Append (aSelIter.Value());
102 anObj->HilightSelected (myMainPM, aSeq);
106 theOwner->HilightWithColor (myMainPM, getSelStyle (anObj), aHiMode);
110 //=======================================================================
111 //function : highlightGlobal
113 //=======================================================================
114 void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
115 const Handle(Graphic3d_HighlightStyle)& theStyle,
116 const Standard_Integer theMode) const
120 const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
122 if (aGlobOwner.IsNull())
124 myMainPM->Color (theObj, theStyle, theMode);
128 if (!aGlobOwner->IsAutoHilight())
130 SelectMgr_SequenceOfOwner aSeq;
131 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
133 if (aSelIter.Value()->IsSameSelectable (theObj))
135 aSeq.Append (aSelIter.Value());
138 theObj->HilightSelected (myMainPM, aSeq);
142 aGlobOwner->HilightWithColor (myMainPM, theStyle, theMode);
146 //=======================================================================
147 //function : unhighlightSelected
149 //=======================================================================
150 void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
152 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
153 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
155 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
156 const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
157 if (anOwner->IsAutoHilight())
159 const Standard_Integer aHiMode = anInteractive->HasHilightMode() ? anInteractive->HilightMode() : 0;
160 anOwner->Unhilight (myMainPM, aHiMode);
161 if (theIsToHilightSubIntensity)
163 if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn())
165 highlightWithSubintensity (anOwner, aHiMode);
171 if (!anObjToClear.Contains (anInteractive))
172 anObjToClear.Add (anInteractive);
175 if (anOwner == anInteractive->GlobalSelOwner())
177 myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
180 for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
182 const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
183 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
184 myMainPM->Unhighlight (anObj, aHiMode);
185 anObj->ClearSelected();
189 //=======================================================================
190 //function : unhighlightGlobal
192 //=======================================================================
193 void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
194 const Standard_Integer theMode) const
198 const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
200 if (aGlobOwner.IsNull())
202 myMainPM->Unhighlight (theObj, theMode);
206 if (aGlobOwner->IsAutoHilight())
208 aGlobOwner->Unhilight (myMainPM, theMode);
212 myMainPM->Unhighlight (theObj, theMode);
213 theObj->ClearSelected();
217 //=======================================================================
218 //function : turnOnSubintensity
220 //=======================================================================
221 void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject,
222 const Standard_Integer theDispMode,
223 const Standard_Boolean theIsDisplayedOnly) const
225 // the only differ with selection highlight is color, so
226 // sync transparency values
227 mySubintStyle->SetTransparency (mySelStyle->Transparency());
229 if (theObject.IsNull())
231 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next())
233 const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value();
234 if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
237 aStatus->SubIntensityOn();
239 if (theDispMode == -1)
241 myMainPM->Color (anObjsIter.Key(), mySubintStyle, aStatus->DisplayMode());
244 myMainPM->Color (anObjsIter.Key(), mySubintStyle, theDispMode);
249 Handle(AIS_GlobalStatus) aStatus;
250 if (!myObjects.Find (theObject, aStatus))
253 if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
256 aStatus->SubIntensityOn();
258 if (theDispMode == -1)
260 myMainPM->Color (theObject, mySubintStyle, aStatus->DisplayMode());
263 myMainPM->Color (theObject, mySubintStyle, theDispMode);
267 //=======================================================================
268 //function : highlightWithSubintensity
270 //=======================================================================
271 void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
272 const Standard_Integer theMode) const
274 // the only differ with selection highlight is color, so
275 // sync transparency values
276 mySubintStyle->SetTransparency (mySelStyle->Transparency());
278 myMainPM->Color (theObject, mySubintStyle, theMode);
281 //=======================================================================
282 //function : highlightWithSubintensity
284 //=======================================================================
285 void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
286 const Standard_Integer theMode) const
288 // the only differ with selection highlight is color, so
289 // sync transparency values
290 mySubintStyle->SetTransparency (mySelStyle->Transparency());
292 theOwner->HilightWithColor (myMainPM, mySubintStyle, theMode);
295 //=======================================================================
298 //=======================================================================
299 AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
300 const Standard_Integer theYPix,
301 const Handle(V3d_View)& theView,
302 const Standard_Boolean theToRedrawOnUpdate)
304 if (HasOpenedContext())
306 myWasLastMain = Standard_True;
307 return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
310 myAISCurDetected = 0;
311 myAISDetectedSeq.Clear();
313 if (theView->Viewer() != myMainVwr)
315 return AIS_SOD_Error;
319 myLastPicked = myLastinMain;
320 myWasLastMain = Standard_True;
321 AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
322 Standard_Boolean toUpdateViewer = Standard_False;
324 myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
325 myMainSel->Pick (theXPix, theYPix, theView);
327 // filling of myAISDetectedSeq sequence storing information about detected AIS objects
328 // (the objects must be AIS_Shapes)
329 const Standard_Integer aDetectedNb = myMainSel->NbPicked();
330 Standard_Integer aNewDetected = 0;
331 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
333 Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
335 || !myFilters->IsOk (anOwner))
340 if (aNewDetected < 1)
342 aNewDetected = aDetIter;
344 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
347 myAISDetectedSeq.Append (anObj);
351 if (aNewDetected >= 1)
353 // Does nothing if previously detected object is equal to the current one.
354 // However in advanced selection modes the owners comparison
355 // is not effective because in that case only one owner manage the
356 // selection in current selection mode. It is necessary to check the current detected
357 // entity and hilight it only if the detected entity is not the same as
358 // previous detected (IsForcedHilight call)
359 Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
360 if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
362 return myLastPicked->IsSelected()
364 : AIS_SOD_OnlyOneDetected;
367 // Previously detected object is unhilighted if it is not selected or hilighted
368 // with selection color if it is selected. Such highlighting with selection color
369 // is needed only if myToHilightSelected flag is true. In this case previously detected
370 // object has been already highlighted with myHilightColor during previous MoveTo()
371 // method call. As result it is necessary to rehighligt it with mySelectionColor.
372 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
374 myMainPM->ClearImmediateDraw();
375 const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
376 const Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
377 if (!myLastPicked->IsSelected())
379 myLastPicked->Unhilight (myMainPM, aHiMod);
380 toUpdateViewer = Standard_True;
382 else if (myToHilightSelected)
384 highlightSelected (aNewPickedOwner);
385 toUpdateViewer = Standard_True;
389 // initialize myLastPicked field with currently detected object
390 myLastPicked = aNewPickedOwner;
391 myLastinMain = myLastPicked;
393 // highlight detected object if it is not selected or myToHilightSelected flag is true
394 if (myLastPicked->HasSelectable())
396 if (!myLastPicked->IsSelected() || myToHilightSelected)
398 highlightWithColor (myLastPicked, theView->Viewer());
399 toUpdateViewer = Standard_True;
402 aStatus = myLastPicked->IsSelected()
404 : AIS_SOD_OnlyOneDetected;
409 // previously detected object is unhilighted if it is not selected or hilighted
410 // with selection color if it is selected
411 aStatus = AIS_SOD_Nothing;
412 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
414 myMainPM->ClearImmediateDraw();
415 const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
416 Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0;
417 if (!myLastPicked->IsSelected())
419 if (myLastPicked->IsAutoHilight())
421 myLastPicked->Unhilight (myMainPM, aHiMod);
423 toUpdateViewer = Standard_True;
425 else if (myToHilightSelected)
427 highlightSelected (myLastPicked);
428 toUpdateViewer = Standard_True;
432 myLastinMain.Nullify();
433 myLastPicked.Nullify();
437 && theToRedrawOnUpdate)
439 theView->Viewer()->Update();
442 mylastmoveview = theView;
446 //=======================================================================
447 //function : AddSelect
449 //=======================================================================
450 AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
452 if (HasOpenedContext())
454 return myLocalContexts(myCurLocalIndex)->AddSelect (theObject);
456 mySelection->AddSelect (theObject);
458 Standard_Integer aSelNum = NbSelected();
459 return (aSelNum == 0) ? AIS_SOP_NothingSelected
460 : (aSelNum == 1) ? AIS_SOP_OneSelected
461 : AIS_SOP_SeveralSelected;
464 //=======================================================================
467 //=======================================================================
468 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
469 const Standard_Integer theYPMin,
470 const Standard_Integer theXPMax,
471 const Standard_Integer theYPMax,
472 const Handle(V3d_View)& theView,
473 const Standard_Boolean toUpdateViewer)
475 // all objects detected by the selector are taken, previous current objects are emptied,
476 // new objects are put...
478 if (HasOpenedContext())
480 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
482 theView, toUpdateViewer);
485 ClearSelected (Standard_False);
487 Handle(StdSelect_ViewerSelector3d) aSelector;
489 if (theView->Viewer() == myMainVwr)
491 aSelector = myMainSel;
492 myWasLastMain = Standard_True;
495 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
496 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
498 const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter);
499 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
502 mySelection->Select (aCurOwner);
503 aCurOwner->State (1);
506 HilightSelected (toUpdateViewer);
508 Standard_Integer aSelNum = NbSelected();
510 return (aSelNum == 0) ? AIS_SOP_NothingSelected
511 : (aSelNum == 1) ? AIS_SOP_OneSelected
512 : AIS_SOP_SeveralSelected;
516 //=======================================================================
518 //purpose : Selection by polyline
519 //=======================================================================
520 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
521 const Handle(V3d_View)& theView,
522 const Standard_Boolean toUpdateViewer)
524 // all objects detected by the selector are taken, previous current objects are emptied,
525 // new objects are put...
527 if (HasOpenedContext())
529 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
532 ClearSelected (Standard_False);
534 Handle(StdSelect_ViewerSelector3d) aSelector;
536 if (theView->Viewer() == myMainVwr)
538 aSelector = myMainSel;
539 myWasLastMain = Standard_True;
542 aSelector->Pick (thePolyline, theView);
543 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
545 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
546 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
549 mySelection->Select (anOwner);
553 HilightSelected (toUpdateViewer);
555 Standard_Integer aSelNum = NbSelected();
557 return (aSelNum == 0) ? AIS_SOP_NothingSelected
558 : (aSelNum == 1) ? AIS_SOP_OneSelected
559 : AIS_SOP_SeveralSelected;
563 //=======================================================================
566 //=======================================================================
567 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
569 if (HasOpenedContext())
573 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
577 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
578 return AIS_SOP_OneSelected;
582 myMainPM->ClearImmediateDraw();
583 if (myWasLastMain && !myLastinMain.IsNull())
585 if(!myLastinMain->IsSelected())
587 SetSelected (myLastinMain, Standard_False);
590 UpdateCurrentViewer();
596 unhighlightSelected (Standard_True);
598 mySelection->Clear();
599 if (toUpdateViewer && myWasLastMain)
601 UpdateCurrentViewer();
605 Standard_Integer aSelNum = NbSelected();
607 return (aSelNum == 0) ? AIS_SOP_NothingSelected
608 : (aSelNum == 1) ? AIS_SOP_OneSelected
609 : AIS_SOP_SeveralSelected;
612 //=======================================================================
613 //function : ShiftSelect
615 //=======================================================================
616 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
618 if (HasOpenedContext())
622 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
626 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
628 Standard_Integer aSelNum = NbSelected();
629 return (aSelNum == 0) ? AIS_SOP_NothingSelected
630 : (aSelNum == 1) ? AIS_SOP_OneSelected
631 : AIS_SOP_SeveralSelected;
635 myMainPM->ClearImmediateDraw();
636 if (myWasLastMain && !myLastinMain.IsNull())
638 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
641 Standard_Integer aSelNum = NbSelected();
643 return (aSelNum == 0) ? AIS_SOP_NothingSelected
644 : (aSelNum == 1) ? AIS_SOP_OneSelected
645 : AIS_SOP_SeveralSelected;
648 //=======================================================================
649 //function : ShiftSelect
651 //=======================================================================
652 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
653 const Standard_Integer theYPMin,
654 const Standard_Integer theXPMax,
655 const Standard_Integer theYPMax,
656 const Handle(V3d_View)& theView,
657 const Standard_Boolean toUpdateViewer)
659 if (HasOpenedContext())
661 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
662 theView, toUpdateViewer);
665 UnhilightSelected (Standard_False);
667 Handle(StdSelect_ViewerSelector3d) aSelector;
668 if (theView->Viewer() == myMainVwr)
670 aSelector = myMainSel;
671 myWasLastMain = Standard_True;
675 return AIS_SOP_NothingSelected;
678 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
679 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
681 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
682 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
685 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
686 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
687 anOwner->State (aState);
690 HilightSelected (toUpdateViewer);
692 Standard_Integer aSelNum = NbSelected();
694 return (aSelNum == 0) ? AIS_SOP_NothingSelected
695 : (aSelNum == 1) ? AIS_SOP_OneSelected
696 : AIS_SOP_SeveralSelected;
700 //=======================================================================
701 //function : ShiftSelect
703 //=======================================================================
704 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
705 const Handle(V3d_View)& theView,
706 const Standard_Boolean toUpdateViewer)
708 if (HasOpenedContext())
710 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
713 UnhilightSelected (Standard_False);
715 Handle(StdSelect_ViewerSelector3d) aSelector;
717 if (theView->Viewer() == myMainVwr)
719 aSelector= myMainSel;
720 myWasLastMain = Standard_True;
724 return AIS_SOP_NothingSelected;
727 aSelector->Pick (thePolyline, theView);
728 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
730 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
731 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
734 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
735 Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0;
736 anOwner->State (aState);
739 HilightSelected (toUpdateViewer);
741 Standard_Integer aSelNum = NbSelected();
743 return (aSelNum == 0) ? AIS_SOP_NothingSelected
744 : (aSelNum == 1) ? AIS_SOP_OneSelected
745 : AIS_SOP_SeveralSelected;
748 //=======================================================================
749 //function : SetCurrentObject
750 //purpose : OBSOLETE, please use SetSelected() instead
751 //TODO : Remove in process of local context deletion
752 //=======================================================================
753 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
754 const Standard_Boolean theToUpdateViewer)
756 if (HasOpenedContext())
759 SetSelected (theObject, theToUpdateViewer);
762 //=======================================================================
763 //function : AddOrRemoveCurrentObject
764 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
765 //TODO : Remove in process of local context deletion
766 //=======================================================================
767 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
768 const Standard_Boolean theIsToUpdateViewer)
770 if (HasOpenedContext())
773 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
775 //=======================================================================
776 //function : UpdateCurrent
777 //purpose : OBSOLETE, please use UpdateSelected() instead
778 //TODO : Remove in process of local context deletion
779 //=======================================================================
780 void AIS_InteractiveContext::UpdateCurrent()
785 //=======================================================================
786 //function : IsCurrent
787 //purpose : OBSOLETE, please use IsSelected() instead
788 //TODO : Remove in process of local context deletion
789 //=======================================================================
790 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
792 return IsSelected (theObject);
795 //=======================================================================
796 //function : InitCurrent
797 //purpose : OBSOLETE, please use InitSelected() instead
798 //TODO : Remove in process of local context deletion
799 //=======================================================================
800 void AIS_InteractiveContext::InitCurrent()
802 if (HasOpenedContext())
808 //=======================================================================
809 //function : MoreCurrent
810 //purpose : OBSOLETE, please use MoreSelected() instead
811 //TODO : Remove in process of local context deletion
812 //=======================================================================
813 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
815 return !HasOpenedContext() && MoreSelected();
818 //=======================================================================
819 //function : NextCurrent
820 //purpose : OBSOLETE, please use NextSelected() instead
821 //TODO : Remove in process of local context deletion
822 //=======================================================================
823 void AIS_InteractiveContext::NextCurrent()
825 if (HasOpenedContext())
831 //=======================================================================
833 //purpose : OBSOLETE, please use SelectedInteractive() instead
834 //TODO : Remove in process of local context deletion
835 //=======================================================================
836 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
838 return HasOpenedContext() ? NULL : SelectedInteractive();
841 //=======================================================================
842 //function : NbCurrents
843 //purpose : OBSOLETE, please use NbSelected() instead
844 //TODO : Remove in process of local context deletion
845 //=======================================================================
846 Standard_Integer AIS_InteractiveContext::NbCurrents()
848 return HasOpenedContext() ? -1 : NbSelected();
851 //=======================================================================
852 //function : HilightCurrents
853 //purpose : OBSOLETE, please use HilightSelected() instead
854 //TODO : Remove in process of local context deletion
855 //=======================================================================
856 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
858 if (HasOpenedContext())
861 HilightSelected (theToUpdateViewer);
864 //=======================================================================
865 //function : UnhilightCurrents
866 //purpose : OBSOLETE, please use UnhilightSelected() instead
867 //TODO : Remove in process of local context deletion
868 //=======================================================================
869 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
871 if (HasOpenedContext())
874 UnhilightSelected (theToUpdateViewer);
877 //=======================================================================
878 //function : ClearCurrents
879 //purpose : OBSOLETE, please use ClearCurrents() instead
880 //TODO : Remove in process of local context deletion
881 //=======================================================================
882 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
884 if (HasOpenedContext())
887 ClearSelected (theToUpdateViewer);
891 //=======================================================================
892 //function : HilightSelected
894 //=======================================================================
895 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
897 if (HasOpenedContext())
899 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
902 // In case of selection without using local context
903 myMainPM->ClearImmediateDraw();
904 AIS_MapOfObjSelectedOwners anObjOwnerMap;
905 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
907 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
908 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
909 const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = getSelStyle (anObj);
910 if (anOwner == anObj->GlobalSelOwner())
912 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj);
913 aState->SetHilightStatus (Standard_True);
914 aState->SetHilightStyle (anObjSelStyle);
917 if (!anOwner->IsAutoHilight())
919 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
920 if (anObjOwnerMap.Find (anObj, aSeq))
922 aSeq->Append (anOwner);
926 aSeq = new SelectMgr_SequenceOfOwner();
927 aSeq->Append (anOwner);
928 anObjOwnerMap.Bind (anObj, aSeq);
933 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
934 anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
938 if (!anObjOwnerMap.IsEmpty())
940 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
942 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
944 anObjOwnerMap.Clear();
947 if (theToUpdateViewer)
948 UpdateCurrentViewer();
951 //=======================================================================
952 //function : UnhilightSelected
954 //=======================================================================
955 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
957 if (HasOpenedContext())
959 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
962 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
964 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
965 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
966 if (anOwner == anObj->GlobalSelOwner())
968 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
972 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0;
973 anOwner->Unhilight (myMainPM, aHiMode);
976 if (theToUpdateViewer)
977 UpdateCurrentViewer();
981 //=======================================================================
982 //function : ClearSelected
984 //=======================================================================
985 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
987 if (HasOpenedContext())
988 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
990 if (NbSelected() == 0)
993 unhighlightSelected();
995 mySelection->Clear();
996 myMainPM->ClearImmediateDraw();
998 if (theToUpdateViewer)
999 UpdateCurrentViewer();
1002 //=======================================================================
1003 //function : UpdateSelected
1005 //=======================================================================
1006 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
1008 if (HasOpenedContext())
1010 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
1013 HilightSelected (theToUpdateViewer);
1016 //=======================================================================
1017 //function : SetSelected
1018 //purpose : Sets the whole object as selected and highlights it with selection color
1019 //=======================================================================
1020 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
1021 const Standard_Boolean theToUpdateViewer)
1023 if(HasOpenedContext())
1025 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
1028 if (theObject.IsNull())
1030 if(!myObjects.IsBound (theObject))
1031 Display (theObject, Standard_False);
1032 if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
1035 const Handle(Graphic3d_HighlightStyle)& anObjSelStyle =
1036 getSelStyle (theObject);
1038 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
1040 Handle(Graphic3d_HighlightStyle) aCustomStyle;
1041 if (HighlightStyle (theObject, aCustomStyle))
1043 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1045 HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
1051 for (mySelection->Init(); mySelection->More(); mySelection->Next())
1053 const Handle(SelectMgr_EntityOwner) anOwner = mySelection->Value();
1054 if (!myFilters->IsOk (anOwner))
1059 Handle(AIS_InteractiveObject) aSelectable =
1060 Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
1061 Unhilight (aSelectable, Standard_False);
1063 if (anOwner == aSelectable->GlobalSelOwner())
1065 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
1069 // added to avoid untimely viewer update...
1070 Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1071 if (anOwner.IsNull())
1073 mySelection->ClearAndSelect (anOwner);
1075 Handle(Graphic3d_HighlightStyle) aCustomStyle;
1076 if (HighlightStyle (theObject, aCustomStyle))
1078 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1080 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1085 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1089 if (theToUpdateViewer)
1090 UpdateCurrentViewer();
1093 //=======================================================================
1094 //function : SetSelected
1095 //purpose : Sets the whole object as selected and highlights it with selection color
1096 //=======================================================================
1097 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1098 const Standard_Boolean theToUpdateViewer)
1100 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
1103 const Handle(AIS_InteractiveObject) anObject =
1104 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1105 const Handle(Graphic3d_HighlightStyle)& anObjSelStyle =
1106 getSelStyle (anObject);
1108 if (NbSelected() == 1 && theOwner->IsSelected())
1110 Handle(Graphic3d_HighlightStyle) aCustomStyle;
1111 if (HighlightStyle (theOwner, aCustomStyle))
1113 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1115 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
1116 theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
1122 if (!myObjects.IsBound (anObject))
1123 Display (anObject, Standard_False);
1125 unhighlightSelected();
1127 mySelection->ClearAndSelect (theOwner);
1128 Handle(Graphic3d_HighlightStyle) aCustomStyle;
1129 if (!HighlightStyle (theOwner, aCustomStyle) ||
1130 (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
1132 highlightSelected (theOwner);
1135 theOwner->State (1);
1136 if (theOwner == anObject->GlobalSelOwner())
1138 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1139 aState->SetHilightStatus (Standard_True);
1140 aState->SetHilightStyle (anObjSelStyle);
1143 if (theToUpdateViewer)
1144 UpdateCurrentViewer();
1147 //=======================================================================
1148 //function : AddOrRemoveSelected
1149 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1150 // Since this method makes sence only for neutral point selection of a whole object,
1151 // if 0 selection of the object is empty this method simply does nothing.
1152 //=======================================================================
1153 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1154 const Standard_Boolean theToUpdateViewer)
1156 if (theObject.IsNull())
1159 if (HasOpenedContext())
1160 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1162 const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
1163 if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
1166 setContextToObject (theObject);
1167 const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1169 if (anOwner.IsNull() || !anOwner->HasSelectable())
1172 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1174 //=======================================================================
1175 //function : AddOrRemoveSelected
1177 //=======================================================================
1179 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1180 const Standard_Boolean updateviewer)
1182 if(!HasOpenedContext()) {
1184 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1189 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1190 if(updateviewer) UpdateCurrentViewer();
1194 //=======================================================================
1195 //function : AddOrRemoveSelected
1196 //purpose : Allows to highlight or unhighlight the owner given depending on
1197 // its selection status
1198 //=======================================================================
1199 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1200 const Standard_Boolean theToUpdateViewer)
1202 if (HasOpenedContext())
1203 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1205 if (theOwner.IsNull() || !theOwner->HasSelectable())
1208 AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
1210 Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0;
1211 theOwner->State (aState);
1212 const Handle(AIS_InteractiveObject) anObj =
1213 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1214 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1215 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1216 const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
1219 highlightSelected (theOwner);
1222 aStatus->SetHilightStatus (Standard_True);
1223 aStatus->SetHilightStyle (getSelStyle (anObj));
1228 if (theOwner->IsAutoHilight())
1229 theOwner->Unhilight (myMainPM, aHiMode);
1231 anObj->ClearSelected();
1232 aStatus->SetHilightStatus (Standard_False);
1233 aStatus->SetHilightStyle (new Graphic3d_HighlightStyle());
1236 if (theToUpdateViewer)
1237 UpdateCurrentViewer();
1241 //=======================================================================
1242 //function : IsSelected
1244 //=======================================================================
1245 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1247 if(HasOpenedContext())
1248 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1250 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1251 return Standard_False;
1253 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1254 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1255 Standard_Boolean isGlobalModeActivated = Standard_False;
1256 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1258 if (aModeIter.Value() == aGlobalSelMode)
1260 isGlobalModeActivated = Standard_True;
1264 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
1265 return Standard_False;
1267 return theObj->GlobalSelOwner()->State() == 1;
1270 //=======================================================================
1271 //function : IsSelected
1272 //purpose : Returns true is the owner given is selected
1273 //=======================================================================
1274 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1276 if (HasOpenedContext())
1277 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1279 if (theOwner.IsNull())
1280 return Standard_False;
1282 return theOwner->IsSelected();
1285 //=======================================================================
1286 //function : InitSelected
1288 //=======================================================================
1289 void AIS_InteractiveContext::InitSelected()
1291 if (HasOpenedContext())
1293 myLocalContexts (myCurLocalIndex)->InitSelected();
1297 mySelection->Init();
1300 //=======================================================================
1301 //function : MoreSelected
1303 //=======================================================================
1304 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1306 if (HasOpenedContext())
1307 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1309 return mySelection->More();
1312 //=======================================================================
1313 //function : NextSelected
1315 //=======================================================================
1316 void AIS_InteractiveContext::NextSelected()
1318 if(HasOpenedContext())
1320 return myLocalContexts (myCurLocalIndex)->NextSelected();
1323 mySelection->Next();
1326 //=======================================================================
1327 //function : HasSelectedShape
1329 //=======================================================================
1330 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1332 if(HasOpenedContext())
1334 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1336 if (!mySelection->More())
1337 return Standard_False;
1339 const Handle(StdSelect_BRepOwner) anOwner =
1340 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1342 return !anOwner.IsNull() && anOwner->HasShape();
1345 //=======================================================================
1346 //function : SelectedShape
1348 //=======================================================================
1349 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1351 if (HasOpenedContext())
1353 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1356 if (!mySelection->More())
1357 return TopoDS_Shape();
1359 const Handle(StdSelect_BRepOwner) anOwner =
1360 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1361 if (anOwner.IsNull() || !anOwner->HasSelectable())
1362 return TopoDS_Shape();
1364 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1367 //=======================================================================
1368 //function : SelectedInteractive
1370 //=======================================================================
1371 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1373 if (HasOpenedContext())
1375 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1378 return !mySelection->More()
1379 ? Handle(AIS_InteractiveObject)()
1380 : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
1382 //=======================================================================
1383 //function : SelectedOwner
1385 //=======================================================================
1386 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1388 if(HasOpenedContext())
1390 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1393 return !mySelection->More()
1394 ? Handle(SelectMgr_EntityOwner)()
1395 : mySelection->Value();
1398 //=======================================================================
1399 //function : EntityOwners
1401 //=======================================================================
1402 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1403 const Handle(AIS_InteractiveObject)& theIObj,
1404 const Standard_Integer theMode) const
1406 if ( theIObj.IsNull() )
1409 TColStd_ListOfInteger aModes;
1410 if ( theMode == -1 )
1411 ActivatedModes( theIObj, aModes );
1413 aModes.Append( theMode );
1415 if (theOwners.IsNull())
1416 theOwners = new SelectMgr_IndexedMapOfOwner();
1418 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1419 for (; anItr.More(); anItr.Next() )
1421 int aMode = anItr.Value();
1422 if ( !theIObj->HasSelection( aMode ) )
1425 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1427 for ( aSel->Init(); aSel->More(); aSel->Next() )
1429 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1430 if ( aEntity.IsNull() )
1433 Handle(SelectMgr_EntityOwner) aOwner =
1434 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1435 if ( !aOwner.IsNull() )
1436 theOwners->Add( aOwner );
1441 //=======================================================================
1442 //function : NbSelected
1444 //=======================================================================
1445 Standard_Integer AIS_InteractiveContext::NbSelected()
1447 Standard_Integer aNbSelected = 0;
1448 for (InitSelected(); MoreSelected(); NextSelected())
1456 //=======================================================================
1457 //function : HasApplicative
1459 //=======================================================================
1460 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1462 return SelectedInteractive()->HasOwner();
1465 //=======================================================================
1466 //function : Applicative
1468 //=======================================================================
1469 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1471 return SelectedInteractive()->GetOwner();
1474 //==================================================
1475 // Function: HasDetected
1477 //==================================================
1478 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1480 if(HasOpenedContext())
1481 return myLocalContexts(myCurLocalIndex)->HasDetected();
1483 return !myLastPicked.IsNull();
1486 //=======================================================================
1487 //function : HasDetectedShape
1489 //=======================================================================
1491 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1493 if(HasOpenedContext())
1494 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1495 return Standard_False;
1498 //=======================================================================
1499 //function : DetectedShape
1501 //=======================================================================
1504 AIS_InteractiveContext::DetectedShape() const
1506 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1509 //=======================================================================
1510 //function : DetectedInteractive
1512 //=======================================================================
1513 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1515 if (HasOpenedContext())
1516 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1518 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1522 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1524 if(!HasOpenedContext())
1525 return Standard_False; // temporaire
1527 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1532 //=======================================================================
1533 //function : DetectedOwner
1535 //=======================================================================
1536 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1538 if (HasOpenedContext())
1539 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1541 return myLastPicked;
1544 //=======================================================================
1545 //function : HilightNextDetected
1547 //=======================================================================
1548 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1549 const Standard_Boolean theToRedrawImmediate)
1551 return HasOpenedContext()
1552 ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
1557 //=======================================================================
1558 //function : HilightNextDetected
1560 //=======================================================================
1561 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1562 const Standard_Boolean theToRedrawImmediate)
1564 return HasOpenedContext()
1565 ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
1570 //=======================================================================
1571 //function : InitDetected
1573 //=======================================================================
1574 void AIS_InteractiveContext::InitDetected()
1576 if (HasOpenedContext())
1578 myLocalContexts(myCurLocalIndex)->InitDetected();
1582 if(myAISDetectedSeq.Length() != 0)
1584 myAISCurDetected = 1;
1588 //=======================================================================
1589 //function : MoreDetected
1591 //=======================================================================
1592 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1594 if (HasOpenedContext())
1596 return myLocalContexts(myCurLocalIndex)->MoreDetected();
1599 return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
1600 Standard_True : Standard_False;
1603 //=======================================================================
1604 //function : NextDetected
1606 //=======================================================================
1607 void AIS_InteractiveContext::NextDetected()
1609 if(HasOpenedContext())
1611 myLocalContexts(myCurLocalIndex)->NextDetected();
1618 //=======================================================================
1619 //function : DetectedCurrentShape
1621 //=======================================================================
1622 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1624 if (HasOpenedContext())
1626 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1629 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1631 if (aCurrentShape.IsNull())
1633 return AIS_myDummyShape;
1636 return aCurrentShape->Shape();
1639 //=======================================================================
1640 //function : DetectedCurrentObject
1642 //=======================================================================
1643 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1645 if (HasOpenedContext())
1647 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1650 return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
1653 //=======================================================================
1654 //function : FirstSelectedObject
1656 //=======================================================================
1657 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1659 Handle(AIS_InteractiveObject) anObject;
1661 if (HasOpenedContext())
1667 return SelectedInteractive();
1672 //=======================================================================
1673 //function : RedrawImmediate
1674 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1675 //=======================================================================
1676 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1678 myMainPM->RedrawImmediate (theViewer);