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 = 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 (HasOpenedContext())
308 myWasLastMain = Standard_True;
309 return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
313 myCurHighlighted = 0;
314 myDetectedSeq.Clear();
316 if (theView->Viewer() != myMainVwr)
318 return AIS_SOD_Error;
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 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
336 Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
338 || !myFilters->IsOk (anOwner))
343 if (aNewDetected < 1)
345 aNewDetected = aDetIter;
348 myDetectedSeq.Append (aDetIter);
351 if (aNewDetected >= 1)
353 myCurHighlighted = myDetectedSeq.Lower();
355 // Does nothing if previously detected object is equal to the current one.
356 // However in advanced selection modes the owners comparison
357 // is not effective because in that case only one owner manage the
358 // selection in current selection mode. It is necessary to check the current detected
359 // entity and hilight it only if the detected entity is not the same as
360 // previous detected (IsForcedHilight call)
361 Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
362 if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
364 return myLastPicked->IsSelected()
366 : AIS_SOD_OnlyOneDetected;
369 // Previously detected object is unhilighted if it is not selected or hilighted
370 // with selection color if it is selected. Such highlighting with selection color
371 // is needed only if myToHilightSelected flag is true. In this case previously detected
372 // object has been already highlighted with myHilightColor during previous MoveTo()
373 // method call. As result it is necessary to rehighligt it with mySelectionColor.
374 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
376 clearDynamicHighlight();
377 toUpdateViewer = Standard_True;
380 // initialize myLastPicked field with currently detected object
381 myLastPicked = aNewPickedOwner;
382 myLastinMain = myLastPicked;
384 // highlight detected object if it is not selected or myToHilightSelected flag is true
385 if (myLastPicked->HasSelectable())
387 if (!myLastPicked->IsSelected() || myToHilightSelected)
389 highlightWithColor (myLastPicked, theView->Viewer());
390 toUpdateViewer = Standard_True;
393 aStatus = myLastPicked->IsSelected()
395 : AIS_SOD_OnlyOneDetected;
400 // previously detected object is unhilighted if it is not selected or hilighted
401 // with selection color if it is selected
402 aStatus = AIS_SOD_Nothing;
403 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
405 clearDynamicHighlight();
406 toUpdateViewer = Standard_True;
409 myLastinMain.Nullify();
410 myLastPicked.Nullify();
414 && theToRedrawOnUpdate)
416 theView->Viewer()->Update();
419 mylastmoveview = theView;
423 //=======================================================================
424 //function : AddSelect
426 //=======================================================================
427 AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
429 if (HasOpenedContext())
431 return myLocalContexts(myCurLocalIndex)->AddSelect (theObject);
433 mySelection->AddSelect (theObject);
435 Standard_Integer aSelNum = NbSelected();
436 return (aSelNum == 0) ? AIS_SOP_NothingSelected
437 : (aSelNum == 1) ? AIS_SOP_OneSelected
438 : AIS_SOP_SeveralSelected;
441 //=======================================================================
444 //=======================================================================
445 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
446 const Standard_Integer theYPMin,
447 const Standard_Integer theXPMax,
448 const Standard_Integer theYPMax,
449 const Handle(V3d_View)& theView,
450 const Standard_Boolean toUpdateViewer)
452 // all objects detected by the selector are taken, previous current objects are emptied,
453 // new objects are put...
455 if (HasOpenedContext())
457 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
459 theView, toUpdateViewer);
462 ClearSelected (Standard_False);
464 Handle(StdSelect_ViewerSelector3d) aSelector;
466 if (theView->Viewer() == myMainVwr)
468 aSelector = myMainSel;
469 myWasLastMain = Standard_True;
472 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
473 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
475 const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter);
476 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
479 mySelection->Select (aCurOwner);
480 aCurOwner->SetSelected (Standard_True);
483 HilightSelected (toUpdateViewer);
485 Standard_Integer aSelNum = NbSelected();
487 return (aSelNum == 0) ? AIS_SOP_NothingSelected
488 : (aSelNum == 1) ? AIS_SOP_OneSelected
489 : AIS_SOP_SeveralSelected;
493 //=======================================================================
495 //purpose : Selection by polyline
496 //=======================================================================
497 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
498 const Handle(V3d_View)& theView,
499 const Standard_Boolean toUpdateViewer)
501 // all objects detected by the selector are taken, previous current objects are emptied,
502 // new objects are put...
504 if (HasOpenedContext())
506 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
509 ClearSelected (Standard_False);
511 Handle(StdSelect_ViewerSelector3d) aSelector;
513 if (theView->Viewer() == myMainVwr)
515 aSelector = myMainSel;
516 myWasLastMain = Standard_True;
519 aSelector->Pick (thePolyline, theView);
520 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
522 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
523 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
526 mySelection->Select (anOwner);
527 anOwner->SetSelected (Standard_True);
530 HilightSelected (toUpdateViewer);
532 Standard_Integer aSelNum = NbSelected();
534 return (aSelNum == 0) ? AIS_SOP_NothingSelected
535 : (aSelNum == 1) ? AIS_SOP_OneSelected
536 : AIS_SOP_SeveralSelected;
540 //=======================================================================
543 //=======================================================================
544 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
546 if (HasOpenedContext())
550 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
554 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
555 return AIS_SOP_OneSelected;
559 clearDynamicHighlight();
560 if (myWasLastMain && !myLastinMain.IsNull())
562 if (!myLastinMain->IsSelected() || myLastinMain->IsForcedHilight())
564 SetSelected (myLastinMain, Standard_False);
567 UpdateCurrentViewer();
573 unhighlightSelected (Standard_True);
575 mySelection->Clear();
576 if (toUpdateViewer && myWasLastMain)
578 UpdateCurrentViewer();
582 Standard_Integer aSelNum = NbSelected();
584 return (aSelNum == 0) ? AIS_SOP_NothingSelected
585 : (aSelNum == 1) ? AIS_SOP_OneSelected
586 : AIS_SOP_SeveralSelected;
589 //=======================================================================
590 //function : ShiftSelect
592 //=======================================================================
593 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
595 if (HasOpenedContext())
599 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
603 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
605 Standard_Integer aSelNum = NbSelected();
606 return (aSelNum == 0) ? AIS_SOP_NothingSelected
607 : (aSelNum == 1) ? AIS_SOP_OneSelected
608 : AIS_SOP_SeveralSelected;
612 clearDynamicHighlight();
613 if (myWasLastMain && !myLastinMain.IsNull())
615 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
618 Standard_Integer aSelNum = NbSelected();
620 return (aSelNum == 0) ? AIS_SOP_NothingSelected
621 : (aSelNum == 1) ? AIS_SOP_OneSelected
622 : AIS_SOP_SeveralSelected;
625 //=======================================================================
626 //function : ShiftSelect
628 //=======================================================================
629 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
630 const Standard_Integer theYPMin,
631 const Standard_Integer theXPMax,
632 const Standard_Integer theYPMax,
633 const Handle(V3d_View)& theView,
634 const Standard_Boolean toUpdateViewer)
636 if (HasOpenedContext())
638 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
639 theView, toUpdateViewer);
642 UnhilightSelected (Standard_False);
644 Handle(StdSelect_ViewerSelector3d) aSelector;
645 if (theView->Viewer() == myMainVwr)
647 aSelector = myMainSel;
648 myWasLastMain = Standard_True;
652 return AIS_SOP_NothingSelected;
655 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
656 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
658 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
659 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
662 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
663 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
666 HilightSelected (toUpdateViewer);
668 Standard_Integer aSelNum = NbSelected();
670 return (aSelNum == 0) ? AIS_SOP_NothingSelected
671 : (aSelNum == 1) ? AIS_SOP_OneSelected
672 : AIS_SOP_SeveralSelected;
676 //=======================================================================
677 //function : ShiftSelect
679 //=======================================================================
680 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
681 const Handle(V3d_View)& theView,
682 const Standard_Boolean toUpdateViewer)
684 if (HasOpenedContext())
686 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
689 UnhilightSelected (Standard_False);
691 Handle(StdSelect_ViewerSelector3d) aSelector;
693 if (theView->Viewer() == myMainVwr)
695 aSelector= myMainSel;
696 myWasLastMain = Standard_True;
700 return AIS_SOP_NothingSelected;
703 aSelector->Pick (thePolyline, theView);
704 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
706 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
707 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
710 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
711 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
714 HilightSelected (toUpdateViewer);
716 Standard_Integer aSelNum = NbSelected();
718 return (aSelNum == 0) ? AIS_SOP_NothingSelected
719 : (aSelNum == 1) ? AIS_SOP_OneSelected
720 : AIS_SOP_SeveralSelected;
723 //=======================================================================
724 //function : SetCurrentObject
725 //purpose : OBSOLETE, please use SetSelected() instead
726 //TODO : Remove in process of local context deletion
727 //=======================================================================
728 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
729 const Standard_Boolean theToUpdateViewer)
731 if (HasOpenedContext())
734 SetSelected (theObject, theToUpdateViewer);
737 //=======================================================================
738 //function : AddOrRemoveCurrentObject
739 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
740 //TODO : Remove in process of local context deletion
741 //=======================================================================
742 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
743 const Standard_Boolean theIsToUpdateViewer)
745 if (HasOpenedContext())
748 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
750 //=======================================================================
751 //function : UpdateCurrent
752 //purpose : OBSOLETE, please use UpdateSelected() instead
753 //TODO : Remove in process of local context deletion
754 //=======================================================================
755 void AIS_InteractiveContext::UpdateCurrent()
757 UpdateSelected (Standard_True);
760 //=======================================================================
761 //function : IsCurrent
762 //purpose : OBSOLETE, please use IsSelected() instead
763 //TODO : Remove in process of local context deletion
764 //=======================================================================
765 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
767 return IsSelected (theObject);
770 //=======================================================================
771 //function : InitCurrent
772 //purpose : OBSOLETE, please use InitSelected() instead
773 //TODO : Remove in process of local context deletion
774 //=======================================================================
775 void AIS_InteractiveContext::InitCurrent()
777 if (HasOpenedContext())
783 //=======================================================================
784 //function : MoreCurrent
785 //purpose : OBSOLETE, please use MoreSelected() instead
786 //TODO : Remove in process of local context deletion
787 //=======================================================================
788 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
790 return !HasOpenedContext() && MoreSelected();
793 //=======================================================================
794 //function : NextCurrent
795 //purpose : OBSOLETE, please use NextSelected() instead
796 //TODO : Remove in process of local context deletion
797 //=======================================================================
798 void AIS_InteractiveContext::NextCurrent()
800 if (HasOpenedContext())
806 //=======================================================================
808 //purpose : OBSOLETE, please use SelectedInteractive() instead
809 //TODO : Remove in process of local context deletion
810 //=======================================================================
811 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
813 return HasOpenedContext() ? NULL : SelectedInteractive();
816 //=======================================================================
817 //function : NbCurrents
818 //purpose : OBSOLETE, please use NbSelected() instead
819 //TODO : Remove in process of local context deletion
820 //=======================================================================
821 Standard_Integer AIS_InteractiveContext::NbCurrents()
823 return HasOpenedContext() ? -1 : NbSelected();
826 //=======================================================================
827 //function : HilightCurrents
828 //purpose : OBSOLETE, please use HilightSelected() instead
829 //TODO : Remove in process of local context deletion
830 //=======================================================================
831 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
833 if (HasOpenedContext())
836 HilightSelected (theToUpdateViewer);
839 //=======================================================================
840 //function : UnhilightCurrents
841 //purpose : OBSOLETE, please use UnhilightSelected() instead
842 //TODO : Remove in process of local context deletion
843 //=======================================================================
844 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
846 if (HasOpenedContext())
849 UnhilightSelected (theToUpdateViewer);
852 //=======================================================================
853 //function : ClearCurrents
854 //purpose : OBSOLETE, please use ClearCurrents() instead
855 //TODO : Remove in process of local context deletion
856 //=======================================================================
857 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
859 if (HasOpenedContext())
862 ClearSelected (theToUpdateViewer);
866 //=======================================================================
867 //function : HilightSelected
869 //=======================================================================
870 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
872 if (HasOpenedContext())
874 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
877 // In case of selection without using local context
878 clearDynamicHighlight();
879 AIS_MapOfObjSelectedOwners anObjOwnerMap;
880 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
882 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
883 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
884 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
885 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
886 if (anOwner == anObj->GlobalSelOwner())
888 aState->SetHilightStatus (Standard_True);
889 aState->SetHilightStyle (anObjSelStyle);
891 anOwner->SetSelected (Standard_True);
892 if (!anOwner->IsAutoHilight())
894 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
895 if (anObjOwnerMap.Find (anObj, aSeq))
897 aSeq->Append (anOwner);
901 aSeq = new SelectMgr_SequenceOfOwner();
902 aSeq->Append (anOwner);
903 anObjOwnerMap.Bind (anObj, aSeq);
908 const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode());
909 anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
913 if (!anObjOwnerMap.IsEmpty())
915 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
917 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
919 anObjOwnerMap.Clear();
922 if (theToUpdateViewer)
923 UpdateCurrentViewer();
926 //=======================================================================
927 //function : UnhilightSelected
929 //=======================================================================
930 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
932 if (HasOpenedContext())
934 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
937 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
939 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
940 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
941 if (anOwner == anObj->GlobalSelOwner())
943 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
946 anOwner->SetSelected (Standard_False);
947 anOwner->Unhilight (myMainPM);
950 if (theToUpdateViewer)
951 UpdateCurrentViewer();
955 //=======================================================================
956 //function : ClearSelected
958 //=======================================================================
959 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
961 if (HasOpenedContext())
962 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
964 if (NbSelected() == 0)
967 unhighlightSelected();
969 mySelection->Clear();
970 clearDynamicHighlight();
972 if (theToUpdateViewer)
973 UpdateCurrentViewer();
976 //=======================================================================
977 //function : UpdateSelected
979 //=======================================================================
980 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
982 if (HasOpenedContext())
984 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
987 HilightSelected (theToUpdateViewer);
990 //=======================================================================
991 //function : SetSelected
992 //purpose : Sets the whole object as selected and highlights it with selection color
993 //=======================================================================
994 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
995 const Standard_Boolean theToUpdateViewer)
997 if (HasOpenedContext())
999 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
1002 if (theObject.IsNull())
1007 if (!myObjects.IsBound (theObject))
1009 Display (theObject, Standard_False);
1011 if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
1015 Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1016 if (anOwner.IsNull())
1021 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
1022 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
1024 Handle(Prs3d_Drawer) aCustomStyle;
1025 if (HighlightStyle (theObject, aCustomStyle))
1027 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1029 HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
1035 for (mySelection->Init(); mySelection->More(); mySelection->Next())
1037 const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value();
1038 if (!myFilters->IsOk (aSelOwner))
1043 Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
1044 Unhilight (aSelectable, Standard_False);
1045 aSelOwner->SetSelected (Standard_False);
1046 if (aSelOwner == aSelectable->GlobalSelOwner())
1048 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
1052 // added to avoid untimely viewer update...
1053 mySelection->ClearAndSelect (anOwner);
1055 Handle(Prs3d_Drawer) aCustomStyle;
1056 if (HighlightStyle (theObject, aCustomStyle))
1058 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1060 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1065 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1067 anOwner->SetSelected (Standard_True);
1069 if (theToUpdateViewer)
1070 UpdateCurrentViewer();
1073 //=======================================================================
1074 //function : SetSelected
1075 //purpose : Sets the whole object as selected and highlights it with selection color
1076 //=======================================================================
1077 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1078 const Standard_Boolean theToUpdateViewer)
1080 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
1083 const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1084 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
1085 if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
1087 Handle(Prs3d_Drawer) aCustomStyle;
1088 if (HighlightStyle (theOwner, aCustomStyle))
1090 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1092 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
1093 theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
1099 if (!myObjects.IsBound (anObject))
1100 Display (anObject, Standard_False);
1102 unhighlightSelected();
1104 mySelection->ClearAndSelect (theOwner);
1105 Handle(Prs3d_Drawer) aCustomStyle;
1106 if (!HighlightStyle (theOwner, aCustomStyle) ||
1107 (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
1109 theOwner->SetSelected (Standard_True);
1110 highlightSelected (theOwner);
1113 theOwner->SetSelected (Standard_True);
1114 if (theOwner == anObject->GlobalSelOwner())
1116 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1117 aState->SetHilightStatus (Standard_True);
1118 aState->SetHilightStyle (anObjSelStyle);
1121 if (theToUpdateViewer)
1122 UpdateCurrentViewer();
1125 //=======================================================================
1126 //function : AddOrRemoveSelected
1127 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1128 // Since this method makes sence only for neutral point selection of a whole object,
1129 // if 0 selection of the object is empty this method simply does nothing.
1130 //=======================================================================
1131 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1132 const Standard_Boolean theToUpdateViewer)
1134 if (theObject.IsNull())
1137 if (HasOpenedContext())
1138 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1140 const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
1141 if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
1144 setContextToObject (theObject);
1145 const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1147 if (anOwner.IsNull() || !anOwner->HasSelectable())
1150 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1152 //=======================================================================
1153 //function : AddOrRemoveSelected
1155 //=======================================================================
1157 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1158 const Standard_Boolean updateviewer)
1160 if(!HasOpenedContext()) {
1162 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1167 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1168 if(updateviewer) UpdateCurrentViewer();
1172 //=======================================================================
1173 //function : AddOrRemoveSelected
1174 //purpose : Allows to highlight or unhighlight the owner given depending on
1175 // its selection status
1176 //=======================================================================
1177 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1178 const Standard_Boolean theToUpdateViewer)
1180 if (HasOpenedContext())
1181 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1183 if (theOwner.IsNull() || !theOwner->HasSelectable())
1186 if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
1189 AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
1190 theOwner->SetSelected (aSelStat == AIS_SS_Added);
1191 const Handle(AIS_InteractiveObject) anObj =
1192 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1193 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1194 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1195 if (theOwner->IsSelected())
1197 highlightSelected (theOwner);
1200 aStatus->SetHilightStatus (Standard_True);
1201 aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
1206 if (theOwner->IsAutoHilight())
1208 theOwner->Unhilight (myMainPM);
1212 anObj->ClearSelected();
1214 aStatus->SetHilightStatus (Standard_False);
1215 aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
1218 if (theToUpdateViewer)
1219 UpdateCurrentViewer();
1223 //=======================================================================
1224 //function : IsSelected
1226 //=======================================================================
1227 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1229 if(HasOpenedContext())
1230 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1232 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1233 return Standard_False;
1235 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1236 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1237 Standard_Boolean isGlobalModeActivated = Standard_False;
1238 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1240 if (aModeIter.Value() == aGlobalSelMode)
1242 isGlobalModeActivated = Standard_True;
1246 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
1247 return Standard_False;
1249 return theObj->GlobalSelOwner()->IsSelected();
1252 //=======================================================================
1253 //function : IsSelected
1254 //purpose : Returns true is the owner given is selected
1255 //=======================================================================
1256 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1258 if (HasOpenedContext())
1259 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1261 if (theOwner.IsNull())
1262 return Standard_False;
1264 return theOwner->IsSelected();
1267 //=======================================================================
1268 //function : InitSelected
1270 //=======================================================================
1271 void AIS_InteractiveContext::InitSelected()
1273 if (HasOpenedContext())
1275 myLocalContexts (myCurLocalIndex)->InitSelected();
1279 mySelection->Init();
1282 //=======================================================================
1283 //function : MoreSelected
1285 //=======================================================================
1286 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1288 if (HasOpenedContext())
1289 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1291 return mySelection->More();
1294 //=======================================================================
1295 //function : NextSelected
1297 //=======================================================================
1298 void AIS_InteractiveContext::NextSelected()
1300 if(HasOpenedContext())
1302 return myLocalContexts (myCurLocalIndex)->NextSelected();
1305 mySelection->Next();
1308 //=======================================================================
1309 //function : HasSelectedShape
1311 //=======================================================================
1312 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1314 if(HasOpenedContext())
1316 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1318 if (!mySelection->More())
1319 return Standard_False;
1321 const Handle(StdSelect_BRepOwner) anOwner =
1322 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1324 return !anOwner.IsNull() && anOwner->HasShape();
1327 //=======================================================================
1328 //function : SelectedShape
1330 //=======================================================================
1331 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1333 if (HasOpenedContext())
1335 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1338 if (!mySelection->More())
1339 return TopoDS_Shape();
1341 const Handle(StdSelect_BRepOwner) anOwner =
1342 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1343 if (anOwner.IsNull() || !anOwner->HasSelectable())
1344 return TopoDS_Shape();
1346 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1349 //=======================================================================
1350 //function : SelectedInteractive
1352 //=======================================================================
1353 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1355 if (HasOpenedContext())
1357 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1360 return !mySelection->More()
1361 ? Handle(AIS_InteractiveObject)()
1362 : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
1364 //=======================================================================
1365 //function : SelectedOwner
1367 //=======================================================================
1368 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1370 if(HasOpenedContext())
1372 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1375 return !mySelection->More()
1376 ? Handle(SelectMgr_EntityOwner)()
1377 : mySelection->Value();
1380 //=======================================================================
1381 //function : EntityOwners
1383 //=======================================================================
1384 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1385 const Handle(AIS_InteractiveObject)& theIObj,
1386 const Standard_Integer theMode) const
1388 if ( theIObj.IsNull() )
1391 TColStd_ListOfInteger aModes;
1392 if ( theMode == -1 )
1393 ActivatedModes( theIObj, aModes );
1395 aModes.Append( theMode );
1397 if (theOwners.IsNull())
1398 theOwners = new SelectMgr_IndexedMapOfOwner();
1400 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1401 for (; anItr.More(); anItr.Next() )
1403 int aMode = anItr.Value();
1404 if ( !theIObj->HasSelection( aMode ) )
1407 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1409 for ( aSel->Init(); aSel->More(); aSel->Next() )
1411 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1412 if ( aEntity.IsNull() )
1415 Handle(SelectMgr_EntityOwner) aOwner =
1416 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1417 if ( !aOwner.IsNull() )
1418 theOwners->Add( aOwner );
1423 //=======================================================================
1424 //function : NbSelected
1426 //=======================================================================
1427 Standard_Integer AIS_InteractiveContext::NbSelected()
1429 Standard_Integer aNbSelected = 0;
1430 for (InitSelected(); MoreSelected(); NextSelected())
1438 //=======================================================================
1439 //function : HasApplicative
1441 //=======================================================================
1442 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1444 return SelectedInteractive()->HasOwner();
1447 //=======================================================================
1448 //function : Applicative
1450 //=======================================================================
1451 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1453 return SelectedInteractive()->GetOwner();
1456 //==================================================
1457 // Function: HasDetected
1459 //==================================================
1460 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1462 if(HasOpenedContext())
1463 return myLocalContexts(myCurLocalIndex)->HasDetected();
1465 return !myLastPicked.IsNull();
1468 //=======================================================================
1469 //function : HasDetectedShape
1471 //=======================================================================
1473 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1475 if(HasOpenedContext())
1476 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1477 return Standard_False;
1480 //=======================================================================
1481 //function : DetectedShape
1483 //=======================================================================
1486 AIS_InteractiveContext::DetectedShape() const
1488 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1491 //=======================================================================
1492 //function : DetectedInteractive
1494 //=======================================================================
1495 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1497 if (HasOpenedContext())
1498 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1500 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1503 //=======================================================================
1504 //function : HasNextDetected
1506 //=======================================================================
1507 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1509 if (HasOpenedContext())
1511 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1514 return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
1518 //=======================================================================
1519 //function : DetectedOwner
1521 //=======================================================================
1522 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1524 if (HasOpenedContext())
1525 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1527 return myLastPicked;
1530 //=======================================================================
1531 //function : HilightNextDetected
1533 //=======================================================================
1534 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1535 const Standard_Boolean theToRedrawImmediate)
1537 if (HasOpenedContext())
1539 return myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate);
1542 myMainPM->ClearImmediateDraw();
1543 if (myDetectedSeq.IsEmpty())
1548 if (++myCurHighlighted > myDetectedSeq.Upper())
1550 myCurHighlighted = myDetectedSeq.Lower();
1552 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1553 if (anOwner.IsNull())
1558 highlightWithColor (anOwner, theView->Viewer());
1559 myLastPicked = anOwner;
1560 myLastinMain = myLastPicked;
1562 if (theToRedrawImmediate)
1564 myMainPM->RedrawImmediate (theView->Viewer());
1565 myMainVwr->RedrawImmediate();
1568 return myCurHighlighted;
1571 //=======================================================================
1572 //function : HilightPreviousDetected
1574 //=======================================================================
1575 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1576 const Standard_Boolean theToRedrawImmediate)
1578 if (HasOpenedContext())
1580 return myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate);
1583 myMainPM->ClearImmediateDraw();
1584 if (myDetectedSeq.IsEmpty())
1589 if (--myCurHighlighted < myDetectedSeq.Lower())
1591 myCurHighlighted = myDetectedSeq.Upper();
1593 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1594 if (anOwner.IsNull())
1599 highlightWithColor (anOwner, theView->Viewer());
1600 myLastPicked = anOwner;
1601 myLastinMain = myLastPicked;
1603 if (theToRedrawImmediate)
1605 myMainPM->RedrawImmediate (theView->Viewer());
1606 myMainVwr->RedrawImmediate();
1609 return myCurHighlighted;
1612 //=======================================================================
1613 //function : InitDetected
1615 //=======================================================================
1616 void AIS_InteractiveContext::InitDetected()
1618 if (HasOpenedContext())
1620 myLocalContexts (myCurLocalIndex)->InitDetected();
1624 if (!myDetectedSeq.IsEmpty())
1626 myCurDetected = myDetectedSeq.Lower();
1630 //=======================================================================
1631 //function : MoreDetected
1633 //=======================================================================
1634 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1636 if (HasOpenedContext())
1638 return myLocalContexts (myCurLocalIndex)->MoreDetected();
1641 return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper();
1644 //=======================================================================
1645 //function : NextDetected
1647 //=======================================================================
1648 void AIS_InteractiveContext::NextDetected()
1650 if (HasOpenedContext())
1652 myLocalContexts (myCurLocalIndex)->NextDetected();
1659 //=======================================================================
1660 //function : DetectedCurrentShape
1662 //=======================================================================
1663 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1665 if (HasOpenedContext())
1667 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1670 Standard_DISABLE_DEPRECATION_WARNINGS
1671 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1672 Standard_ENABLE_DEPRECATION_WARNINGS
1674 if (aCurrentShape.IsNull())
1676 return AIS_myDummyShape;
1679 return aCurrentShape->Shape();
1682 //=======================================================================
1683 //function : DetectedCurrentObject
1685 //=======================================================================
1686 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1688 if (HasOpenedContext())
1690 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1693 return MoreDetected()
1694 ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
1698 //=======================================================================
1699 //function : FirstSelectedObject
1701 //=======================================================================
1702 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1704 Handle(AIS_InteractiveObject) anObject;
1706 if (HasOpenedContext())
1712 return SelectedInteractive();
1717 //=======================================================================
1718 //function : RedrawImmediate
1719 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1720 //=======================================================================
1721 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1723 myMainPM->RedrawImmediate (theViewer);