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_InteractiveContext_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 = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
75 const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner);
76 const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
78 myMainPM->BeginImmediateDraw();
79 theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
80 myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
83 //=======================================================================
84 //function : highlightSelected
86 //=======================================================================
87 void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
89 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
95 if (!theOwner->IsAutoHilight())
97 SelectMgr_SequenceOfOwner aSeq;
98 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
100 if (aSelIter.Value()->IsSameSelectable (anObj))
102 aSeq.Append (aSelIter.Value());
105 anObj->HilightSelected (myMainPM, aSeq);
109 const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
110 const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
111 theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
115 //=======================================================================
116 //function : highlightGlobal
118 //=======================================================================
119 void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
120 const Handle(Prs3d_Drawer)& theStyle,
121 const Standard_Integer theDispMode) const
128 const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode);
129 const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
131 if (aGlobOwner.IsNull())
133 myMainPM->Color (theObj, theStyle, aHiMode);
137 if (!aGlobOwner->IsAutoHilight())
139 SelectMgr_SequenceOfOwner aSeq;
140 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
142 if (aSelIter.Value()->IsSameSelectable (theObj))
144 aSeq.Append (aSelIter.Value());
147 theObj->HilightSelected (myMainPM, aSeq);
151 aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode);
155 //=======================================================================
156 //function : unhighlightSelected
158 //=======================================================================
159 void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
161 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
162 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
164 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
165 const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
166 Handle(AIS_GlobalStatus) aStatus;
167 if (!myObjects.Find (anInteractive, aStatus))
172 if (anOwner->IsAutoHilight())
174 anOwner->Unhilight (myMainPM);
175 if (theIsToHilightSubIntensity)
177 if (aStatus->IsSubIntensityOn())
179 const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode());
180 highlightWithSubintensity (anOwner, aHiMode);
186 anObjToClear.Add (anInteractive);
188 anOwner->SetSelected (Standard_False);
189 if (anOwner == anInteractive->GlobalSelOwner())
191 myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
194 for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
196 const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
197 myMainPM->Unhighlight (anObj);
198 anObj->ClearSelected();
202 //=======================================================================
203 //function : unhighlightGlobal
205 //=======================================================================
206 void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const
213 const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
214 if (aGlobOwner.IsNull())
216 myMainPM->Unhighlight (theObj);
220 if (aGlobOwner->IsAutoHilight())
222 aGlobOwner->Unhilight (myMainPM);
226 myMainPM->Unhighlight (theObj);
227 theObj->ClearSelected();
231 //=======================================================================
232 //function : turnOnSubintensity
234 //=======================================================================
235 void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject,
236 const Standard_Integer theDispMode,
237 const Standard_Boolean theIsDisplayedOnly) const
239 // the only differ with selection highlight is color, so sync transparency values
240 const Handle(Prs3d_Drawer)& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
241 aSubStyle->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
243 if (theObject.IsNull())
245 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next())
247 const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value();
248 if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
251 aStatus->SubIntensityOn();
252 myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
257 Handle(AIS_GlobalStatus) aStatus;
258 if (!myObjects.Find (theObject, aStatus))
261 if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
264 aStatus->SubIntensityOn();
265 myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
269 //=======================================================================
270 //function : highlightWithSubintensity
272 //=======================================================================
273 void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
274 const Standard_Integer theMode) const
276 // the only differ with selection highlight is color, so
277 // sync transparency values
278 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
280 myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
283 //=======================================================================
284 //function : highlightWithSubintensity
286 //=======================================================================
287 void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
288 const Standard_Integer theMode) const
290 // the only differ with selection highlight is color, so
291 // sync transparency values
292 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
294 theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
297 //=======================================================================
300 //=======================================================================
301 AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
302 const Standard_Integer theYPix,
303 const Handle(V3d_View)& theView,
304 const Standard_Boolean theToRedrawOnUpdate)
306 if (theView->Viewer() != myMainVwr)
308 throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument");
311 if (HasOpenedContext())
313 myWasLastMain = Standard_True;
314 return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
318 myCurHighlighted = 0;
319 myDetectedSeq.Clear();
322 myLastPicked = myLastinMain;
323 myWasLastMain = Standard_True;
324 AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
325 Standard_Boolean toUpdateViewer = Standard_False;
327 myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
328 myMainSel->Pick (theXPix, theYPix, theView);
330 // filling of myAISDetectedSeq sequence storing information about detected AIS objects
331 // (the objects must be AIS_Shapes)
332 const Standard_Integer aDetectedNb = myMainSel->NbPicked();
333 Standard_Integer aNewDetected = 0;
334 Standard_Boolean toIgnoreDetTop = Standard_False;
335 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
337 Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
339 || !myFilters->IsOk (anOwner))
341 if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
343 toIgnoreDetTop = Standard_True;
351 aNewDetected = aDetIter;
354 myDetectedSeq.Append (aDetIter);
357 if (aNewDetected >= 1)
359 myCurHighlighted = myDetectedSeq.Lower();
361 // Does nothing if previously detected object is equal to the current one.
362 // However in advanced selection modes the owners comparison
363 // is not effective because in that case only one owner manage the
364 // selection in current selection mode. It is necessary to check the current detected
365 // entity and hilight it only if the detected entity is not the same as
366 // previous detected (IsForcedHilight call)
367 Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
368 if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
370 return myLastPicked->IsSelected()
372 : AIS_SOD_OnlyOneDetected;
375 // Previously detected object is unhilighted if it is not selected or hilighted
376 // with selection color if it is selected. Such highlighting with selection color
377 // is needed only if myToHilightSelected flag is true. In this case previously detected
378 // object has been already highlighted with myHilightColor during previous MoveTo()
379 // method call. As result it is necessary to rehighligt it with mySelectionColor.
380 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
382 clearDynamicHighlight();
383 toUpdateViewer = Standard_True;
386 // initialize myLastPicked field with currently detected object
387 myLastPicked = aNewPickedOwner;
388 myLastinMain = myLastPicked;
390 // highlight detected object if it is not selected or myToHilightSelected flag is true
391 if (myLastPicked->HasSelectable())
393 if (!myLastPicked->IsSelected() || myToHilightSelected)
395 highlightWithColor (myLastPicked, theView->Viewer());
396 toUpdateViewer = Standard_True;
399 aStatus = myLastPicked->IsSelected()
401 : AIS_SOD_OnlyOneDetected;
406 // previously detected object is unhilighted if it is not selected or hilighted
407 // with selection color if it is selected
408 aStatus = AIS_SOD_Nothing;
409 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
411 clearDynamicHighlight();
412 toUpdateViewer = Standard_True;
415 myLastinMain.Nullify();
416 myLastPicked.Nullify();
420 && theToRedrawOnUpdate)
422 theView->Viewer()->Update();
428 //=======================================================================
429 //function : AddSelect
431 //=======================================================================
432 AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
434 if (HasOpenedContext())
436 return myLocalContexts(myCurLocalIndex)->AddSelect (theObject);
438 mySelection->AddSelect (theObject);
440 Standard_Integer aSelNum = NbSelected();
441 return (aSelNum == 0) ? AIS_SOP_NothingSelected
442 : (aSelNum == 1) ? AIS_SOP_OneSelected
443 : AIS_SOP_SeveralSelected;
446 //=======================================================================
449 //=======================================================================
450 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
451 const Standard_Integer theYPMin,
452 const Standard_Integer theXPMax,
453 const Standard_Integer theYPMax,
454 const Handle(V3d_View)& theView,
455 const Standard_Boolean toUpdateViewer)
457 if (theView->Viewer() != myMainVwr)
459 throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
462 // all objects detected by the selector are taken, previous current objects are emptied,
463 // new objects are put...
465 if (HasOpenedContext())
467 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
469 theView, toUpdateViewer);
472 ClearSelected (Standard_False);
474 myWasLastMain = Standard_True;
475 myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
476 for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
478 const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter);
479 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
482 mySelection->Select (aCurOwner);
483 aCurOwner->SetSelected (Standard_True);
486 HilightSelected (toUpdateViewer);
488 Standard_Integer aSelNum = NbSelected();
490 return (aSelNum == 0) ? AIS_SOP_NothingSelected
491 : (aSelNum == 1) ? AIS_SOP_OneSelected
492 : AIS_SOP_SeveralSelected;
496 //=======================================================================
498 //purpose : Selection by polyline
499 //=======================================================================
500 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
501 const Handle(V3d_View)& theView,
502 const Standard_Boolean toUpdateViewer)
504 if (theView->Viewer() != myMainVwr)
506 throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
509 // all objects detected by the selector are taken, previous current objects are emptied,
510 // new objects are put...
512 if (HasOpenedContext())
514 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
517 ClearSelected (Standard_False);
519 myWasLastMain = Standard_True;
520 myMainSel->Pick (thePolyline, theView);
521 for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
523 const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
524 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
527 mySelection->Select (anOwner);
528 anOwner->SetSelected (Standard_True);
531 HilightSelected (toUpdateViewer);
533 Standard_Integer aSelNum = NbSelected();
535 return (aSelNum == 0) ? AIS_SOP_NothingSelected
536 : (aSelNum == 1) ? AIS_SOP_OneSelected
537 : AIS_SOP_SeveralSelected;
541 //=======================================================================
544 //=======================================================================
545 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
547 if (HasOpenedContext())
551 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
555 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
556 return AIS_SOP_OneSelected;
560 clearDynamicHighlight();
561 if (myWasLastMain && !myLastinMain.IsNull())
563 if (!myLastinMain->IsSelected()
564 || myLastinMain->IsForcedHilight()
567 SetSelected (myLastinMain, Standard_False);
570 UpdateCurrentViewer();
576 unhighlightSelected (Standard_True);
578 mySelection->Clear();
579 if (toUpdateViewer && myWasLastMain)
581 UpdateCurrentViewer();
585 Standard_Integer aSelNum = NbSelected();
587 return (aSelNum == 0) ? AIS_SOP_NothingSelected
588 : (aSelNum == 1) ? AIS_SOP_OneSelected
589 : AIS_SOP_SeveralSelected;
592 //=======================================================================
593 //function : ShiftSelect
595 //=======================================================================
596 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
598 if (HasOpenedContext())
602 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
606 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
608 Standard_Integer aSelNum = NbSelected();
609 return (aSelNum == 0) ? AIS_SOP_NothingSelected
610 : (aSelNum == 1) ? AIS_SOP_OneSelected
611 : AIS_SOP_SeveralSelected;
615 clearDynamicHighlight();
616 if (myWasLastMain && !myLastinMain.IsNull())
618 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
621 Standard_Integer aSelNum = NbSelected();
623 return (aSelNum == 0) ? AIS_SOP_NothingSelected
624 : (aSelNum == 1) ? AIS_SOP_OneSelected
625 : AIS_SOP_SeveralSelected;
628 //=======================================================================
629 //function : ShiftSelect
631 //=======================================================================
632 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
633 const Standard_Integer theYPMin,
634 const Standard_Integer theXPMax,
635 const Standard_Integer theYPMax,
636 const Handle(V3d_View)& theView,
637 const Standard_Boolean toUpdateViewer)
639 if (theView->Viewer() != myMainVwr)
641 throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
644 if (HasOpenedContext())
646 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
647 theView, toUpdateViewer);
650 UnhilightSelected (Standard_False);
652 myWasLastMain = Standard_True;
653 myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
654 for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
656 const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
657 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
660 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
661 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
664 HilightSelected (toUpdateViewer);
666 Standard_Integer aSelNum = NbSelected();
668 return (aSelNum == 0) ? AIS_SOP_NothingSelected
669 : (aSelNum == 1) ? AIS_SOP_OneSelected
670 : AIS_SOP_SeveralSelected;
674 //=======================================================================
675 //function : ShiftSelect
677 //=======================================================================
678 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
679 const Handle(V3d_View)& theView,
680 const Standard_Boolean toUpdateViewer)
682 if (theView->Viewer() != myMainVwr)
684 throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
687 if (HasOpenedContext())
689 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
692 UnhilightSelected (Standard_False);
694 myWasLastMain = Standard_True;
695 myMainSel->Pick (thePolyline, theView);
696 for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
698 const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
699 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
702 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
703 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
706 HilightSelected (toUpdateViewer);
708 Standard_Integer aSelNum = NbSelected();
710 return (aSelNum == 0) ? AIS_SOP_NothingSelected
711 : (aSelNum == 1) ? AIS_SOP_OneSelected
712 : AIS_SOP_SeveralSelected;
715 //=======================================================================
716 //function : SetCurrentObject
717 //purpose : OBSOLETE, please use SetSelected() instead
718 //TODO : Remove in process of local context deletion
719 //=======================================================================
720 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
721 const Standard_Boolean theToUpdateViewer)
723 if (HasOpenedContext())
726 SetSelected (theObject, theToUpdateViewer);
729 //=======================================================================
730 //function : AddOrRemoveCurrentObject
731 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
732 //TODO : Remove in process of local context deletion
733 //=======================================================================
734 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
735 const Standard_Boolean theIsToUpdateViewer)
737 if (HasOpenedContext())
740 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
742 //=======================================================================
743 //function : UpdateCurrent
744 //purpose : OBSOLETE, please use UpdateSelected() instead
745 //TODO : Remove in process of local context deletion
746 //=======================================================================
747 void AIS_InteractiveContext::UpdateCurrent()
749 UpdateSelected (Standard_True);
752 //=======================================================================
753 //function : IsCurrent
754 //purpose : OBSOLETE, please use IsSelected() instead
755 //TODO : Remove in process of local context deletion
756 //=======================================================================
757 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
759 return IsSelected (theObject);
762 //=======================================================================
763 //function : InitCurrent
764 //purpose : OBSOLETE, please use InitSelected() instead
765 //TODO : Remove in process of local context deletion
766 //=======================================================================
767 void AIS_InteractiveContext::InitCurrent()
769 if (HasOpenedContext())
775 //=======================================================================
776 //function : MoreCurrent
777 //purpose : OBSOLETE, please use MoreSelected() instead
778 //TODO : Remove in process of local context deletion
779 //=======================================================================
780 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
782 return !HasOpenedContext() && MoreSelected();
785 //=======================================================================
786 //function : NextCurrent
787 //purpose : OBSOLETE, please use NextSelected() instead
788 //TODO : Remove in process of local context deletion
789 //=======================================================================
790 void AIS_InteractiveContext::NextCurrent()
792 if (HasOpenedContext())
798 //=======================================================================
800 //purpose : OBSOLETE, please use SelectedInteractive() instead
801 //TODO : Remove in process of local context deletion
802 //=======================================================================
803 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
805 return HasOpenedContext() ? NULL : SelectedInteractive();
808 //=======================================================================
809 //function : NbCurrents
810 //purpose : OBSOLETE, please use NbSelected() instead
811 //TODO : Remove in process of local context deletion
812 //=======================================================================
813 Standard_Integer AIS_InteractiveContext::NbCurrents()
815 return HasOpenedContext() ? -1 : NbSelected();
818 //=======================================================================
819 //function : HilightCurrents
820 //purpose : OBSOLETE, please use HilightSelected() instead
821 //TODO : Remove in process of local context deletion
822 //=======================================================================
823 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
825 if (HasOpenedContext())
828 HilightSelected (theToUpdateViewer);
831 //=======================================================================
832 //function : UnhilightCurrents
833 //purpose : OBSOLETE, please use UnhilightSelected() instead
834 //TODO : Remove in process of local context deletion
835 //=======================================================================
836 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
838 if (HasOpenedContext())
841 UnhilightSelected (theToUpdateViewer);
844 //=======================================================================
845 //function : ClearCurrents
846 //purpose : OBSOLETE, please use ClearCurrents() instead
847 //TODO : Remove in process of local context deletion
848 //=======================================================================
849 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
851 if (HasOpenedContext())
854 ClearSelected (theToUpdateViewer);
858 //=======================================================================
859 //function : HilightSelected
861 //=======================================================================
862 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
864 if (HasOpenedContext())
866 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
869 // In case of selection without using local context
870 clearDynamicHighlight();
871 AIS_MapOfObjSelectedOwners anObjOwnerMap;
872 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
874 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
875 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
876 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
877 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
878 if (anOwner == anObj->GlobalSelOwner())
880 aState->SetHilightStatus (Standard_True);
881 aState->SetHilightStyle (anObjSelStyle);
883 anOwner->SetSelected (Standard_True);
884 if (!anOwner->IsAutoHilight())
886 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
887 if (anObjOwnerMap.Find (anObj, aSeq))
889 aSeq->Append (anOwner);
893 aSeq = new SelectMgr_SequenceOfOwner();
894 aSeq->Append (anOwner);
895 anObjOwnerMap.Bind (anObj, aSeq);
900 const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode());
901 anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
905 if (!anObjOwnerMap.IsEmpty())
907 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
909 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
911 anObjOwnerMap.Clear();
914 if (theToUpdateViewer)
915 UpdateCurrentViewer();
918 //=======================================================================
919 //function : UnhilightSelected
921 //=======================================================================
922 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
924 if (HasOpenedContext())
926 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
929 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
931 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
932 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
933 if (anOwner == anObj->GlobalSelOwner())
935 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
938 anOwner->SetSelected (Standard_False);
939 anOwner->Unhilight (myMainPM);
942 if (theToUpdateViewer)
943 UpdateCurrentViewer();
947 //=======================================================================
948 //function : ClearSelected
950 //=======================================================================
951 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
953 if (HasOpenedContext())
954 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
956 if (NbSelected() == 0)
959 unhighlightSelected();
961 mySelection->Clear();
962 clearDynamicHighlight();
964 if (theToUpdateViewer)
965 UpdateCurrentViewer();
968 //=======================================================================
969 //function : UpdateSelected
971 //=======================================================================
972 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
974 if (HasOpenedContext())
976 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
979 HilightSelected (theToUpdateViewer);
982 //=======================================================================
983 //function : SetSelected
984 //purpose : Sets the whole object as selected and highlights it with selection color
985 //=======================================================================
986 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
987 const Standard_Boolean theToUpdateViewer)
989 if (HasOpenedContext())
991 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
994 if (theObject.IsNull())
999 if (!myObjects.IsBound (theObject))
1001 Display (theObject, Standard_False);
1004 Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1005 if (anOwner.IsNull())
1010 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
1011 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
1013 Handle(Prs3d_Drawer) aCustomStyle;
1014 if (HighlightStyle (theObject, aCustomStyle))
1016 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1018 HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
1024 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
1026 const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
1027 if (!myFilters->IsOk (aSelOwner))
1032 Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
1033 Unhilight (aSelectable, Standard_False);
1034 aSelOwner->SetSelected (Standard_False);
1035 if (aSelOwner == aSelectable->GlobalSelOwner())
1037 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
1041 // added to avoid untimely viewer update...
1042 mySelection->ClearAndSelect (anOwner);
1044 Handle(Prs3d_Drawer) aCustomStyle;
1045 if (HighlightStyle (theObject, aCustomStyle))
1047 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1049 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1054 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1056 anOwner->SetSelected (Standard_True);
1058 if (theToUpdateViewer)
1059 UpdateCurrentViewer();
1062 //=======================================================================
1063 //function : SetSelected
1064 //purpose : Sets the whole object as selected and highlights it with selection color
1065 //=======================================================================
1066 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1067 const Standard_Boolean theToUpdateViewer)
1069 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
1072 const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1073 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
1074 if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
1076 Handle(Prs3d_Drawer) aCustomStyle;
1077 if (HighlightStyle (theOwner, aCustomStyle))
1079 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1081 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
1082 theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
1088 if (!myObjects.IsBound (anObject))
1089 Display (anObject, Standard_False);
1091 unhighlightSelected();
1093 mySelection->ClearAndSelect (theOwner);
1094 Handle(Prs3d_Drawer) aCustomStyle;
1095 if (!HighlightStyle (theOwner, aCustomStyle) ||
1096 (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
1098 theOwner->SetSelected (Standard_True);
1099 highlightSelected (theOwner);
1102 theOwner->SetSelected (Standard_True);
1103 if (theOwner == anObject->GlobalSelOwner())
1105 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1106 aState->SetHilightStatus (Standard_True);
1107 aState->SetHilightStyle (anObjSelStyle);
1110 if (theToUpdateViewer)
1111 UpdateCurrentViewer();
1114 //=======================================================================
1115 //function : AddOrRemoveSelected
1116 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1117 // Since this method makes sence only for neutral point selection of a whole object,
1118 // if 0 selection of the object is empty this method simply does nothing.
1119 //=======================================================================
1120 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1121 const Standard_Boolean theToUpdateViewer)
1123 if (theObject.IsNull())
1128 if (HasOpenedContext())
1130 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1133 if (!myObjects.IsBound (theObject))
1138 const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1139 if (!anOwner.IsNull()
1140 && anOwner->HasSelectable())
1142 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1145 //=======================================================================
1146 //function : AddOrRemoveSelected
1148 //=======================================================================
1150 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1151 const Standard_Boolean updateviewer)
1153 if(!HasOpenedContext()) {
1155 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1160 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1161 if(updateviewer) UpdateCurrentViewer();
1165 //=======================================================================
1166 //function : AddOrRemoveSelected
1167 //purpose : Allows to highlight or unhighlight the owner given depending on
1168 // its selection status
1169 //=======================================================================
1170 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1171 const Standard_Boolean theToUpdateViewer)
1173 if (HasOpenedContext())
1174 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1176 if (theOwner.IsNull() || !theOwner->HasSelectable())
1179 if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
1182 AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
1183 theOwner->SetSelected (aSelStat == AIS_SS_Added);
1184 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1185 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1186 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1187 if (theOwner->IsSelected())
1189 highlightSelected (theOwner);
1192 aStatus->SetHilightStatus (Standard_True);
1193 aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
1198 if (theOwner->IsAutoHilight())
1200 theOwner->Unhilight (myMainPM);
1204 anObj->ClearSelected();
1206 aStatus->SetHilightStatus (Standard_False);
1207 aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
1210 if (theToUpdateViewer)
1211 UpdateCurrentViewer();
1215 //=======================================================================
1216 //function : IsSelected
1218 //=======================================================================
1219 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1221 if(HasOpenedContext())
1222 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1224 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1225 return Standard_False;
1227 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1228 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1229 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1231 if (aModeIter.Value() == aGlobalSelMode)
1233 if (Handle(SelectMgr_EntityOwner) aGlobOwner = theObj->GlobalSelOwner())
1235 return aGlobOwner->IsSelected();
1237 return Standard_False;
1240 return Standard_False;
1243 //=======================================================================
1244 //function : IsSelected
1245 //purpose : Returns true is the owner given is selected
1246 //=======================================================================
1247 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1249 if (HasOpenedContext())
1251 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1253 return !theOwner.IsNull()
1254 && theOwner->IsSelected();
1257 //=======================================================================
1258 //function : InitSelected
1260 //=======================================================================
1261 void AIS_InteractiveContext::InitSelected()
1263 if (HasOpenedContext())
1265 myLocalContexts (myCurLocalIndex)->InitSelected();
1269 mySelection->Init();
1272 //=======================================================================
1273 //function : MoreSelected
1275 //=======================================================================
1276 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1278 if (HasOpenedContext())
1279 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1281 return mySelection->More();
1284 //=======================================================================
1285 //function : NextSelected
1287 //=======================================================================
1288 void AIS_InteractiveContext::NextSelected()
1290 if(HasOpenedContext())
1292 return myLocalContexts (myCurLocalIndex)->NextSelected();
1295 mySelection->Next();
1298 //=======================================================================
1299 //function : HasSelectedShape
1301 //=======================================================================
1302 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1304 if(HasOpenedContext())
1306 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1308 if (!mySelection->More())
1309 return Standard_False;
1311 const Handle(StdSelect_BRepOwner) anOwner =
1312 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1314 return !anOwner.IsNull() && anOwner->HasShape();
1317 //=======================================================================
1318 //function : SelectedShape
1320 //=======================================================================
1321 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1323 if (HasOpenedContext())
1325 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1328 if (!mySelection->More())
1329 return TopoDS_Shape();
1331 const Handle(StdSelect_BRepOwner) anOwner =
1332 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1333 if (anOwner.IsNull() || !anOwner->HasSelectable())
1334 return TopoDS_Shape();
1336 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1339 //=======================================================================
1340 //function : SelectedInteractive
1342 //=======================================================================
1343 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1345 if (HasOpenedContext())
1347 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1350 return !mySelection->More()
1351 ? Handle(AIS_InteractiveObject)()
1352 : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
1354 //=======================================================================
1355 //function : SelectedOwner
1357 //=======================================================================
1358 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1360 if(HasOpenedContext())
1362 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1365 return !mySelection->More()
1366 ? Handle(SelectMgr_EntityOwner)()
1367 : mySelection->Value();
1370 //=======================================================================
1371 //function : EntityOwners
1373 //=======================================================================
1374 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1375 const Handle(AIS_InteractiveObject)& theIObj,
1376 const Standard_Integer theMode) const
1378 if (theIObj.IsNull())
1383 TColStd_ListOfInteger aModes;
1386 ActivatedModes (theIObj, aModes);
1390 aModes.Append (theMode);
1393 if (theOwners.IsNull())
1395 theOwners = new SelectMgr_IndexedMapOfOwner();
1398 for (TColStd_ListIteratorOfListOfInteger anItr (aModes); anItr.More(); anItr.Next())
1400 const int aMode = anItr.Value();
1401 const Handle(SelectMgr_Selection)& aSel = theIObj->Selection (aMode);
1407 for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
1409 if (Handle(SelectBasics_SensitiveEntity) aEntity = aSelEntIter.Value()->BaseSensitive())
1411 if (Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId()))
1413 theOwners->Add (aOwner);
1420 //=======================================================================
1421 //function : NbSelected
1423 //=======================================================================
1424 Standard_Integer AIS_InteractiveContext::NbSelected()
1426 if (HasOpenedContext())
1428 return myLocalContexts (myCurLocalIndex)->Selection()->Extent();
1430 return mySelection->Extent();
1433 //=======================================================================
1434 //function : HasApplicative
1436 //=======================================================================
1437 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1439 return SelectedInteractive()->HasOwner();
1442 //=======================================================================
1443 //function : Applicative
1445 //=======================================================================
1446 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1448 return SelectedInteractive()->GetOwner();
1451 //==================================================
1452 // Function: HasDetected
1454 //==================================================
1455 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1457 if(HasOpenedContext())
1458 return myLocalContexts(myCurLocalIndex)->HasDetected();
1460 return !myLastPicked.IsNull();
1463 //=======================================================================
1464 //function : HasDetectedShape
1466 //=======================================================================
1468 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1470 if (HasOpenedContext())
1472 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1475 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
1476 return !anOwner.IsNull()
1477 && anOwner->HasShape();
1480 //=======================================================================
1481 //function : DetectedShape
1483 //=======================================================================
1484 const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const
1486 if (HasOpenedContext())
1488 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1491 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
1492 return anOwner->Shape();
1495 //=======================================================================
1496 //function : DetectedInteractive
1498 //=======================================================================
1499 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1501 if (HasOpenedContext())
1502 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1504 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1507 //=======================================================================
1508 //function : HasNextDetected
1510 //=======================================================================
1511 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1513 if (HasOpenedContext())
1515 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1518 return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
1522 //=======================================================================
1523 //function : DetectedOwner
1525 //=======================================================================
1526 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1528 if (HasOpenedContext())
1529 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1531 return myLastPicked;
1534 //=======================================================================
1535 //function : HilightNextDetected
1537 //=======================================================================
1538 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1539 const Standard_Boolean theToRedrawImmediate)
1541 if (HasOpenedContext())
1543 return myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate);
1546 myMainPM->ClearImmediateDraw();
1547 if (myDetectedSeq.IsEmpty())
1552 if (++myCurHighlighted > myDetectedSeq.Upper())
1554 myCurHighlighted = myDetectedSeq.Lower();
1556 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1557 if (anOwner.IsNull())
1562 highlightWithColor (anOwner, theView->Viewer());
1563 myLastPicked = anOwner;
1564 myLastinMain = myLastPicked;
1566 if (theToRedrawImmediate)
1568 myMainPM->RedrawImmediate (theView->Viewer());
1569 myMainVwr->RedrawImmediate();
1572 return myCurHighlighted;
1575 //=======================================================================
1576 //function : HilightPreviousDetected
1578 //=======================================================================
1579 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1580 const Standard_Boolean theToRedrawImmediate)
1582 if (HasOpenedContext())
1584 return myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate);
1587 myMainPM->ClearImmediateDraw();
1588 if (myDetectedSeq.IsEmpty())
1593 if (--myCurHighlighted < myDetectedSeq.Lower())
1595 myCurHighlighted = myDetectedSeq.Upper();
1597 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1598 if (anOwner.IsNull())
1603 highlightWithColor (anOwner, theView->Viewer());
1604 myLastPicked = anOwner;
1605 myLastinMain = myLastPicked;
1607 if (theToRedrawImmediate)
1609 myMainPM->RedrawImmediate (theView->Viewer());
1610 myMainVwr->RedrawImmediate();
1613 return myCurHighlighted;
1616 //=======================================================================
1617 //function : InitDetected
1619 //=======================================================================
1620 void AIS_InteractiveContext::InitDetected()
1622 if (HasOpenedContext())
1624 myLocalContexts (myCurLocalIndex)->InitDetected();
1628 if (!myDetectedSeq.IsEmpty())
1630 myCurDetected = myDetectedSeq.Lower();
1634 //=======================================================================
1635 //function : MoreDetected
1637 //=======================================================================
1638 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1640 if (HasOpenedContext())
1642 return myLocalContexts (myCurLocalIndex)->MoreDetected();
1645 return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper();
1648 //=======================================================================
1649 //function : NextDetected
1651 //=======================================================================
1652 void AIS_InteractiveContext::NextDetected()
1654 if (HasOpenedContext())
1656 myLocalContexts (myCurLocalIndex)->NextDetected();
1663 //=======================================================================
1664 //function : DetectedCurrentOwner
1666 //=======================================================================
1667 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedCurrentOwner() const
1669 if (HasOpenedContext())
1671 return myLocalContexts (myCurLocalIndex)->DetectedCurrentOwner();
1674 return MoreDetected()
1675 ? myMainSel->Picked (myDetectedSeq (myCurDetected))
1676 : Handle(SelectMgr_EntityOwner)();
1679 //=======================================================================
1680 //function : DetectedCurrentShape
1682 //=======================================================================
1683 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1685 if (HasOpenedContext())
1687 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1690 Standard_DISABLE_DEPRECATION_WARNINGS
1691 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1692 Standard_ENABLE_DEPRECATION_WARNINGS
1693 return !aCurrentShape.IsNull()
1694 ? aCurrentShape->Shape()
1695 : AIS_InteractiveContext_myDummyShape;
1698 //=======================================================================
1699 //function : DetectedCurrentObject
1701 //=======================================================================
1702 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1704 if (HasOpenedContext())
1706 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1709 return MoreDetected()
1710 ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
1711 : Handle(AIS_InteractiveObject)();
1714 //=======================================================================
1715 //function : FirstSelectedObject
1717 //=======================================================================
1718 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1720 Handle(AIS_InteractiveObject) anObject;
1722 if (HasOpenedContext())
1728 return SelectedInteractive();
1733 //=======================================================================
1734 //function : RedrawImmediate
1735 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1736 //=======================================================================
1737 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1739 myMainPM->RedrawImmediate (theViewer);