1 // Created on: 1997-01-17
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.
17 // Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
19 #include <AIS_InteractiveContext.ixx>
21 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
22 #include <TColStd_ListIteratorOfListOfInteger.hxx>
23 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
24 #include <AIS_LocalContext.hxx>
25 #include <AIS_LocalStatus.hxx>
26 #include <Precision.hxx>
27 #include <AIS_Selection.hxx>
28 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
29 #include <AIS_ConnectedInteractive.hxx>
30 #include <AIS_MultipleConnectedInteractive.hxx>
31 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
32 #include <AIS_GlobalStatus.hxx>
33 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
34 #include <PrsMgr_ModedPresentation.hxx>
35 #include <Visual3d_ViewManager.hxx>
36 #include <Visual3d_View.hxx>
37 #include <Prs3d_ShadingAspect.hxx>
38 #include <AIS_Shape.hxx>
39 #include <Graphic3d_AspectFillArea3d.hxx>
40 #include <HLRBRep.hxx>
41 #include <Prs3d_IsoAspect.hxx>
42 #include <Prs3d_DatumAspect.hxx>
43 #include <Prs3d_PlaneAspect.hxx>
44 #include <PrsMgr_PresentableObject.hxx>
45 #include <Standard_Atomic.hxx>
46 #include <StdSelect_ViewerSelector3d.hxx>
47 #include <UnitsAPI.hxx>
49 #include <AIS_Trihedron.hxx>
50 #include <Geom_Axis2Placement.hxx>
51 #include <OSD_Environment.hxx>
53 #include <AIS_ListIteratorOfListOfInteractive.hxx>
57 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
58 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
60 static TCollection_AsciiString AIS_Context_NewSelName()
62 return TCollection_AsciiString ("AIS_SelContext_")
63 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
66 static TCollection_AsciiString AIS_Context_NewCurName()
68 return TCollection_AsciiString ("AIS_CurContext_")
69 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
73 //=======================================================================
74 //function : AIS_InteractiveContext
76 //=======================================================================
78 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
79 mgrSelector(new SelectMgr_SelectionManager()),
80 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
81 myMainVwr(MainViewer),
82 myMainSel(new StdSelect_ViewerSelector3d()),
83 myWasLastMain(Standard_False),
84 myCurrentTouched(Standard_False),
85 mySelectedTouched(Standard_False),
86 myToHilightSelected(Standard_True),
87 myFilters(new SelectMgr_OrFilter()),
88 myDefaultDrawer(new Prs3d_Drawer()),
89 myDefaultColor(Quantity_NOC_GOLDENROD),
90 myHilightColor(Quantity_NOC_CYAN1),
91 mySelectionColor(Quantity_NOC_GRAY80),
92 myPreselectionColor(Quantity_NOC_GREEN),
93 mySubIntensity(Quantity_NOC_GRAY40),
98 myIsAutoActivateSelMode( Standard_True )
103 void AIS_InteractiveContext::Delete() const
105 // clear the static current selection
106 AIS_Selection::ClearCurrentSelection();
108 // to avoid an exception
109 if (AIS_Selection::Find (mySelectionName.ToCString()))
111 AIS_Selection::Remove (mySelectionName.ToCString());
114 // to avoid an exception
115 if (AIS_Selection::Find (myCurrentName.ToCString()))
117 AIS_Selection::Remove (myCurrentName.ToCString());
120 // let's remove one reference explicitly. this operation's supposed to
121 // be performed when mgrSelector will be destroyed but anyway...
122 mgrSelector->Remove (myMainSel);
124 Handle(AIS_InteractiveContext) aNullContext;
125 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
127 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
128 anObj->SetContext (aNullContext);
130 MMgt_TShared::Delete();
133 //=======================================================================
134 //function : AIS_SelectionName
136 //=======================================================================
137 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
139 if(!HasOpenedContext())
140 return mySelectionName;
141 return myLocalContexts(myCurLocalIndex)->SelectionName();
147 //=======================================================================
148 //function : UpdateCurrentViewer
150 //=======================================================================
152 void AIS_InteractiveContext::UpdateCurrentViewer()
154 if (!myMainVwr.IsNull())
159 //=======================================================================
160 //function : DomainOfMainViewer
162 //=======================================================================
164 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
166 return myMainVwr->Domain();
170 //=======================================================================
171 //function : DisplayedObjects
173 //=======================================================================
174 void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
175 const Standard_Boolean theOnlyFromNeutral) const
177 if (!HasOpenedContext()
178 || theOnlyFromNeutral)
180 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
182 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
184 theListOfIO.Append (anObjIter.Key());
191 TColStd_MapOfTransient aDispMap;
192 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
194 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
196 aDispMap.Add (anObjIter.Key());
200 // parse all local contexts...
201 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
203 const Handle(AIS_LocalContext)& aLocCtx = aCtxIter.Value();
204 aLocCtx->DisplayedObjects (aDispMap);
207 Handle(AIS_InteractiveObject) anObj;
208 for (TColStd_MapIteratorOfMapOfTransient aDispMapIter (aDispMap); aDispMapIter.More(); aDispMapIter.Next())
210 const Handle(Standard_Transient)& aTransient = aDispMapIter.Key();
211 anObj = *((Handle(AIS_InteractiveObject)* )&aTransient);
212 theListOfIO.Append (anObj);
216 //=======================================================================
217 //function : DisplayedObjects
219 //=======================================================================
220 void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
221 const Standard_Integer theSign,
222 AIS_ListOfInteractive& theListOfIO,
223 const Standard_Boolean /*OnlyFromNeutral*/) const
225 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
228 //=======================================================================
229 //function : ErasedObjects
231 //=======================================================================
232 void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const
234 ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO);
237 //=======================================================================
238 //function : ErasedObjects
240 //=======================================================================
241 void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind,
242 const Standard_Integer theSign,
243 AIS_ListOfInteractive& theListOfIO) const
245 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO);
248 //=======================================================================
249 //function : ObjectsByDisplayStatus
251 //=======================================================================
252 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus,
253 AIS_ListOfInteractive& theListOfIO) const
255 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
257 if (anObjIter.Value()->GraphicStatus() == theStatus)
259 theListOfIO.Append (anObjIter.Key());
264 //=======================================================================
265 //function : ObjectsByDisplayStatus
267 //=======================================================================
268 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind,
269 const Standard_Integer theSign,
270 const AIS_DisplayStatus theStatus,
271 AIS_ListOfInteractive& theListOfIO) const
273 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
275 if (theStatus != AIS_DS_None
276 && anObjIter.Value()->GraphicStatus() != theStatus)
280 else if (anObjIter.Key()->Type() != theKind)
286 || anObjIter.Key()->Signature() == theSign)
288 theListOfIO.Append (anObjIter.Key());
293 //=======================================================================
294 //function : ObjectsInside
296 //=======================================================================
297 void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO,
298 const AIS_KindOfInteractive theKind,
299 const Standard_Integer theSign) const
301 if (theKind == AIS_KOI_None
304 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
306 theListOfIO.Append (anObjIter.Key());
311 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
313 if (anObjIter.Key()->Type() != theKind)
319 || anObjIter.Key()->Signature() == theSign)
321 theListOfIO.Append (anObjIter.Key());
326 //=======================================================================
327 //function : ObjectsForView
329 //=======================================================================
330 void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO,
331 const Handle(V3d_View)& theView,
332 const Standard_Boolean theIsVisibleInView,
333 const AIS_DisplayStatus theStatus) const
335 const Graphic3d_CView* aCView = reinterpret_cast<const Graphic3d_CView* >(theView->View()->CView());
336 const Standard_Integer aViewId = aCView->ViewId;
337 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
339 if (theStatus != AIS_DS_None
340 && anObjIter.Value()->GraphicStatus() != theStatus)
342 theListOfIO.Append (anObjIter.Key());
346 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (anObjIter.Key());
347 const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
348 if (isVisible == theIsVisibleInView)
350 theListOfIO.Append (anObjIter.Key());
355 //=======================================================================
358 //=======================================================================
359 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
360 const Standard_Boolean theToUpdateViewer)
362 if (theIObj.IsNull())
367 Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
368 GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
370 Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
371 theToUpdateViewer, theIObj->AcceptShapeDecomposition());
374 //=======================================================================
375 //function : SetViewAffinity
377 //=======================================================================
378 void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj,
379 const Handle(V3d_View)& theView,
380 const Standard_Boolean theIsVisible)
383 || !myObjects.IsBound (theIObj))
388 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (theIObj);
389 const Graphic3d_CView* aCView = reinterpret_cast<const Graphic3d_CView* >(theView->View()->CView());
390 anAffinity->SetVisible (aCView->ViewId, theIsVisible == Standard_True);
393 theView->View()->ChangeHiddenObjects()->Remove (theIObj);
397 theView->View()->ChangeHiddenObjects()->Add (theIObj);
401 //=======================================================================
404 //=======================================================================
405 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
406 const Standard_Integer theDispMode,
407 const Standard_Integer theSelectionMode,
408 const Standard_Boolean theToUpdateViewer,
409 const Standard_Boolean theToAllowDecomposition,
410 const AIS_DisplayStatus theDispStatus)
412 if (theIObj.IsNull())
417 if (theDispStatus == AIS_DS_Erased)
419 Erase (theIObj, theToUpdateViewer);
420 Load (theIObj, theSelectionMode, theToAllowDecomposition);
424 if (!theIObj->HasInteractiveContext())
426 theIObj->SetContext (this);
429 if (theDispStatus == AIS_DS_Temporary
430 && !HasOpenedContext())
434 else if (HasOpenedContext())
436 if (theDispStatus == AIS_DS_None
437 || theDispStatus == AIS_DS_Temporary)
439 myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
440 if (theToUpdateViewer)
448 if (!myObjects.IsBound (theIObj))
450 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
451 myObjects.Bind (theIObj, aStatus);
452 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->RegisterObject (theIObj);
453 myMainPM->Display(theIObj, theDispMode);
454 if (theSelectionMode != -1)
456 if (!mgrSelector->Contains (theIObj))
458 mgrSelector->Load (theIObj);
460 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
465 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
466 if (aStatus->GraphicStatus() == AIS_DS_Temporary)
471 // Erase presentations for all display modes different from aDispMode.
472 // Then make sure aDispMode is displayed and maybe highlighted.
473 // Finally, activate selection mode <SelMode> if not yet activated.
474 TColStd_ListOfInteger aModesToRemove;
475 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
477 const Standard_Integer anOldMode = aDispModeIter.Value();
478 if (anOldMode != theDispMode)
480 aModesToRemove.Append (anOldMode);
481 if(myMainPM->IsHighlighted (theIObj, anOldMode))
483 myMainPM->Unhighlight (theIObj, anOldMode);
485 myMainPM->Erase (theIObj, anOldMode);
489 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
491 aStatus->RemoveDisplayMode (aRemModeIter.Value());
494 if (!aStatus->IsDModeIn (theDispMode))
496 aStatus->AddDisplayMode (theDispMode);
499 myMainPM->Display (theIObj, theDispMode);
500 aStatus->SetGraphicStatus (AIS_DS_Displayed);
501 if (aStatus->IsHilighted())
503 const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
504 myMainPM->Highlight (theIObj, aHiMod);
506 if (theSelectionMode != -1)
508 if (!mgrSelector->Contains (theIObj))
510 mgrSelector->Load (theIObj);
512 if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
514 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
519 if (theToUpdateViewer)
525 //=======================================================================
528 //=======================================================================
529 void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
530 const Standard_Integer theSelMode,
531 const Standard_Boolean theToAllowDecomposition)
533 if (theIObj.IsNull())
538 if (!theIObj->HasInteractiveContext())
540 theIObj->SetContext (this);
543 if (HasOpenedContext())
545 myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
550 && !theToAllowDecomposition)
552 if (!myObjects.IsBound (theIObj))
554 Standard_Integer aDispMode, aHiMod, aSelModeDef;
555 GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
556 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, aSelModeDef);
557 myObjects.Bind (theIObj, aStatus);
560 // Register theIObj in the selection manager to prepare further activation of selection
561 if (!mgrSelector->Contains (theIObj))
563 mgrSelector->Load (theIObj);
568 //=======================================================================
571 //=======================================================================
572 void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
573 const Standard_Boolean theToUpdateViewer)
575 if (theIObj.IsNull())
580 if (!theIObj->IsAutoHilight())
582 theIObj->ClearSelected();
585 Standard_Boolean wasInCtx = Standard_False;
586 if (HasOpenedContext())
588 // First it is checked if it is possible to remove in the current local context
589 // then one tries to remove in other local contexts, if they allow it...
590 wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
591 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
593 if (aCtxIter.Value()->AcceptErase())
595 wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
602 EraseGlobal (theIObj, Standard_False);
605 if (theToUpdateViewer)
611 //=======================================================================
612 //function : EraseAll
614 //=======================================================================
615 void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
617 if (HasOpenedContext())
622 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
624 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
626 Erase (anObjIter.Key(), Standard_False);
630 if (theToUpdateViewer)
636 //=======================================================================
637 //function : DisplayAll
639 //=======================================================================
640 void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
642 if (HasOpenedContext())
647 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
649 const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
650 if (aStatus == AIS_DS_Erased)
652 Display (anObjIter.Key(), Standard_False);
656 if (theToUpdateViewer)
662 //=======================================================================
663 //function : DisplaySelected
665 //=======================================================================
666 void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
668 if (HasOpenedContext())
673 Standard_Boolean isFound = Standard_False;
674 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
675 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
677 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
678 Display (anObj, Standard_False);
679 isFound = Standard_True;
682 if (isFound && theToUpdateViewer)
688 //=======================================================================
689 //function : EraseSelected
691 //=======================================================================
692 void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
694 if (HasOpenedContext())
699 Standard_Boolean isFound = Standard_False;
700 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString());
701 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
703 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
704 Erase (anObj, Standard_False);
705 isFound = Standard_True;
708 if (isFound && theToUpdateViewer)
714 //=======================================================================
717 //=======================================================================
719 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
720 const Standard_Integer WhichContext)
722 if(anIObj.IsNull()) return Standard_False;
724 if(!HasOpenedContext()) return Standard_False;
725 if(myObjects.IsBound(anIObj)) return Standard_False;
726 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
728 // Protection : if one tries to preserve a temporary object
729 // which is not in the local active context... rob 11-06-97
731 Standard_Integer IsItInLocal = myCurLocalIndex;
732 Standard_Boolean Found(Standard_False);
734 while(IsItInLocal>0 && !Found){
735 if(!myLocalContexts.IsBound(IsItInLocal))
737 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
738 Found = Standard_True;
743 if(!Found) return Standard_False;
746 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
747 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
749 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
750 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
754 if(LS->IsTemporary()){
755 Standard_Integer DM,HM,SM;
756 GetDefModes(anIObj,DM,HM,SM);
758 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
759 if(LS->DisplayMode()!= DM ){
760 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
761 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
764 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
768 // GS->SubIntensityOn();
769 myObjects.Bind(anIObj,GS);
770 mgrSelector->Load(anIObj);
771 mgrSelector->Activate(anIObj,SM,myMainSel);
773 LS->SetTemporary(Standard_False);
775 return Standard_True;
778 //=======================================================================
779 //function : DisplayStatus
781 //=======================================================================
782 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
784 if (theIObj.IsNull())
788 else if (myObjects.IsBound (theIObj))
790 return myObjects (theIObj)->GraphicStatus();
793 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
795 if (aCtxIter.Value()->IsIn (theIObj))
797 return AIS_DS_Temporary;
803 //=======================================================================
804 //function : DisplayedModes
806 //=======================================================================
807 const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
809 return myObjects (theIObj)->DisplayedModes();
812 //=======================================================================
815 //=======================================================================
816 void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
817 const Standard_Boolean theToUpdateViewer)
819 if (theIObj.IsNull())
824 if (HasOpenedContext())
826 myLocalContexts (myCurLocalIndex)->Remove (theIObj);
827 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
829 if (aCtxIter.Value()->AcceptErase())
831 aCtxIter.Value()->Remove (theIObj);
836 ClearGlobal (theIObj, theToUpdateViewer);
839 //=======================================================================
840 //function : RemoveAll
842 //=======================================================================
843 void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
845 AIS_ListOfInteractive aList;
846 ObjectsInside (aList);
847 for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
849 Remove (aListIterator.Value(), Standard_False);
852 if (theToUpdateViewer)
858 //=======================================================================
859 //function : ClearPrs
861 //=======================================================================
862 void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
863 const Standard_Integer theMode,
864 const Standard_Boolean theToUpdateViewer)
866 if (theIObj.IsNull())
871 if (!HasOpenedContext())
873 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
877 Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
878 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
880 if (aCtxIter.Value()->AcceptErase())
882 wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
887 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
889 else if (theToUpdateViewer)
895 //=======================================================================
898 //=======================================================================
899 void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj,
900 const Standard_Boolean theToUpdateViewer)
902 if (theIObj.IsNull())
907 if (!theIObj->HasInteractiveContext())
909 theIObj->SetContext (this);
911 if (!HasOpenedContext())
913 if (!myObjects.IsBound (theIObj))
918 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
919 aStatus->SetHilightStatus (Standard_True);
920 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
922 Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
923 myMainPM->Highlight (theIObj, aHilightMode);
928 myLocalContexts (myCurLocalIndex)->Hilight (theIObj);
931 if (theToUpdateViewer)
936 //=======================================================================
939 //=======================================================================
941 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
942 const Quantity_NameOfColor aCol,
943 const Standard_Boolean updateviewer)
945 if(anIObj.IsNull()) return;
947 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
949 if (!HasOpenedContext())
951 if(!myObjects.IsBound(anIObj)) return;
953 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
954 aStatus->SetHilightStatus (Standard_True);
956 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
958 const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
959 myMainPM->Color (anIObj, aCol, aHilightMode);
960 aStatus->SetHilightColor (aCol);
965 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
967 if(updateviewer) myMainVwr->Update();
970 //=======================================================================
971 //function : Unhilight
973 //=======================================================================
975 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
977 if(anIObj.IsNull()) return;
979 if (!HasOpenedContext())
981 if(!myObjects.IsBound(anIObj)) return;
983 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
984 aStatus->SetHilightStatus (Standard_False);
985 aStatus->SetHilightColor(Quantity_NOC_WHITE);
987 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
989 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
990 myMainPM->Unhighlight (anIObj, aHilightMode);
995 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
997 if(updateviewer) myMainVwr->Update();
1000 //=======================================================================
1001 //function : IsHilighted
1003 //=======================================================================
1005 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1007 if(anIObj.IsNull()) return Standard_False;
1009 if (!HasOpenedContext()){
1010 if(!myObjects.IsBound(anIObj))
1011 return Standard_False;
1012 return myObjects(anIObj)->IsHilighted();
1014 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1015 for(;ItM.More();ItM.Next()){
1016 if(ItM.Value()->IsHilighted(anIObj))
1017 return Standard_True;
1019 return Standard_False;
1022 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1023 Standard_Boolean& WithColor,
1024 Quantity_NameOfColor& TheHiCol) const
1026 if(!HasOpenedContext()){
1027 if(myObjects.IsBound(anIObj)){
1028 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1029 if(STAT->IsHilighted()){
1030 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1031 WithColor=Standard_True;
1032 TheHiCol = STAT->HilightColor();
1035 WithColor = Standard_False;
1036 return Standard_True;
1039 return Standard_False;
1041 Standard_Integer MaxIndex = HighestIndex();
1042 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1043 if(myLocalContexts.IsBound(i)){
1044 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1045 return Standard_True;
1049 return Standard_False;
1054 //=======================================================================
1055 //function : IsDisplayed
1057 //=======================================================================
1059 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1061 if(anIObj.IsNull()) return Standard_False;
1064 if(myObjects.IsBound(anIObj))
1065 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1066 return Standard_True;
1068 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1069 for(;ItM.More();ItM.Next()){
1070 if(ItM.Value()->IsDisplayed(anIObj))
1071 return Standard_True;
1073 return Standard_False;
1077 //=======================================================================
1078 //function : IsDisplayed
1080 //=======================================================================
1081 Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
1082 const Standard_Integer theMode) const
1084 if (theIObj.IsNull())
1086 return Standard_False;
1089 if (myObjects.IsBound (theIObj))
1091 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1092 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1093 && aStatus->IsDModeIn (theMode))
1095 return Standard_True;
1099 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
1101 if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
1103 return Standard_True;
1106 return Standard_False;
1109 //=======================================================================
1110 //function : DisplayPriority
1112 //=======================================================================
1113 Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
1115 if (theIObj.IsNull())
1119 else if (!myObjects.IsBound (theIObj))
1124 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1125 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1126 || aStatus->GraphicStatus() == AIS_DS_Erased)
1128 Standard_Integer aDispMode = theIObj->HasDisplayMode()
1129 ? theIObj->DisplayMode()
1130 : (theIObj->AcceptDisplayMode (myDisplayMode)
1133 return myMainPM->DisplayPriority (theIObj, aDispMode);
1138 //=======================================================================
1139 //function : SetDisplayPriority
1141 //=======================================================================
1142 void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
1143 const Standard_Integer thePriority)
1145 if (theIObj.IsNull())
1150 if (!theIObj->HasInteractiveContext())
1152 theIObj->SetContext (this);
1155 if (myObjects.IsBound (theIObj))
1157 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1158 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1159 || aStatus->GraphicStatus() == AIS_DS_Erased)
1161 Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
1162 ? theIObj->DisplayMode()
1163 : (theIObj->AcceptDisplayMode (myDisplayMode)
1166 myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
1169 else if (HasOpenedContext())
1171 myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
1175 //=======================================================================
1176 //function : Redisplay
1178 //=======================================================================
1179 void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
1180 const Standard_Boolean theToUpdateViewer,
1181 const Standard_Boolean theAllModes)
1183 RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
1184 RecomputeSelectionOnly (theIObj);
1187 //=======================================================================
1188 //function : Redisplay
1190 //=======================================================================
1191 void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
1192 const Standard_Integer /*theSign*/,
1193 const Standard_Boolean theToUpdateViewer)
1195 Standard_Boolean isRedisplayed = Standard_False;
1196 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1198 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1199 if (anObj->Type() != theKOI)
1204 Redisplay (anObj, Standard_False);
1205 isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
1209 if (theToUpdateViewer
1212 myMainVwr->Update();
1216 //=======================================================================
1217 //function : RecomputePrsOnly
1219 //=======================================================================
1220 void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
1221 const Standard_Boolean theToUpdateViewer,
1222 const Standard_Boolean theAllModes)
1224 if (theIObj.IsNull())
1229 theIObj->Update (theAllModes);
1230 if (!theToUpdateViewer)
1235 if (HasOpenedContext()
1236 || (myObjects.IsBound (theIObj)
1237 && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
1239 myMainVwr->Update();
1242 //=======================================================================
1243 //function : RecomputeSelectionOnly
1245 //=======================================================================
1246 void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
1253 mgrSelector->RecomputeSelection (theIO);
1255 if (HasOpenedContext())
1257 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1259 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
1264 if (!myObjects.IsBound (theIO) ||
1265 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1270 TColStd_ListOfInteger aModes;
1271 ActivatedModes (theIO, aModes);
1272 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1273 for (; aModesIter.More(); aModesIter.Next())
1275 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
1279 //=======================================================================
1282 //=======================================================================
1283 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1284 const Standard_Boolean theUpdateViewer)
1286 if (theIObj.IsNull())
1291 TColStd_ListOfInteger aPrsModes;
1292 theIObj->ToBeUpdated (aPrsModes);
1293 for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
1295 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1298 mgrSelector->Update(theIObj);
1300 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1302 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1305 if (theUpdateViewer)
1307 if (!myObjects.IsBound (theIObj))
1312 switch (myObjects (theIObj)->GraphicStatus())
1314 case AIS_DS_Displayed:
1315 case AIS_DS_Temporary:
1316 myMainVwr->Update();
1324 //=======================================================================
1325 //function : SetLocation
1327 //=======================================================================
1328 void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
1329 const TopLoc_Location& theLoc)
1331 if (theIObj.IsNull())
1336 if (theIObj->HasTransformation()
1337 && theLoc.IsIdentity())
1339 theIObj->ResetTransformation();
1340 mgrSelector->Update (theIObj, Standard_False);
1343 else if (theLoc.IsIdentity())
1348 // first reset the previous location to properly clean everything...
1349 if (theIObj->HasTransformation())
1351 theIObj->ResetTransformation();
1354 theIObj->SetLocalTransformation (theLoc.Transformation());
1356 if (!HasOpenedContext())
1358 mgrSelector->Update (theIObj, Standard_False);
1362 Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
1363 mgrSelector->Update (theIObj, aTempSel, Standard_False);
1367 //=======================================================================
1368 //function : ResetLocation
1370 //=======================================================================
1371 void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
1373 if (theIObj.IsNull())
1378 theIObj->ResetTransformation();
1379 mgrSelector->Update (theIObj, Standard_False);
1382 //=======================================================================
1383 //function : HasLocation
1385 //=======================================================================
1386 Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
1388 return !theIObj.IsNull()
1389 && theIObj->HasTransformation();
1392 //=======================================================================
1393 //function : Location
1395 //=======================================================================
1396 TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
1398 return theIObj->Transformation();
1401 //=======================================================================
1402 //function : SetDeviationCoefficient
1404 //=======================================================================
1405 void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
1407 myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
1410 //=======================================================================
1411 //function : SetDeviationAngle
1413 //=======================================================================
1414 void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
1416 myDefaultDrawer->SetDeviationCoefficient (theAngle);
1419 //=======================================================================
1420 //function : DeviationAngle
1421 //purpose : Gets deviationAngle
1422 //=======================================================================
1423 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1425 return myDefaultDrawer->DeviationAngle();
1428 //=======================================================================
1429 //function : DeviationCoefficient
1431 //=======================================================================
1432 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1434 return myDefaultDrawer->DeviationCoefficient();
1437 //=======================================================================
1438 //function : SetHLRDeviationCoefficient
1440 //=======================================================================
1441 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
1443 myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
1446 //=======================================================================
1447 //function : HLRDeviationCoefficient
1449 //=======================================================================
1450 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1452 return myDefaultDrawer->HLRDeviationCoefficient();
1455 //=======================================================================
1456 //function : SetHLRAngle
1458 //=======================================================================
1459 void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
1461 myDefaultDrawer->SetHLRAngle (theAngle);
1464 //=======================================================================
1465 //function : SetHLRAngleAndDeviation
1466 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1467 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1468 // of myDefaultDrawer
1469 //=======================================================================
1470 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
1472 Standard_Real anOutAngl, anOutDefl;
1473 HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
1475 myDefaultDrawer->SetHLRAngle (anOutAngl);
1476 myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
1479 //=======================================================================
1480 //function : HLRAngle
1482 //=======================================================================
1483 Standard_Real AIS_InteractiveContext::HLRAngle() const
1485 return myDefaultDrawer->HLRAngle();
1488 //=======================================================================
1489 //function : SetDisplayMode
1491 //=======================================================================
1492 void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
1493 const Standard_Boolean theToUpdateViewer)
1495 if (theMode == myDisplayMode)
1500 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1502 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1503 Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
1504 || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
1505 || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
1508 || anObj->HasDisplayMode()
1509 || !anObj->AcceptDisplayMode (theMode))
1514 Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
1515 if (aStatus->IsDModeIn (myDisplayMode))
1517 aStatus->RemoveDisplayMode (myDisplayMode);
1520 aStatus->AddDisplayMode (theMode);
1521 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1523 myMainPM->Display (anObj, theMode);
1524 if (aStatus->IsSubIntensityOn())
1526 myMainPM->Color (anObj, mySubIntensity, theMode);
1528 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1532 myDisplayMode = theMode;
1533 if (theToUpdateViewer)
1535 myMainVwr->Update();
1539 //=======================================================================
1540 //function : SetDisplayMode
1542 //=======================================================================
1543 void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1544 const Standard_Integer theMode,
1545 const Standard_Boolean theToUpdateViewer)
1547 if (!theIObj->HasInteractiveContext())
1549 theIObj->SetContext(this);
1552 if (!myObjects.IsBound (theIObj))
1554 theIObj->SetDisplayMode (theMode);
1557 else if (!theIObj->AcceptDisplayMode (theMode))
1562 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1563 if (aStatus->GraphicStatus() != AIS_DS_Displayed)
1565 theIObj->SetDisplayMode (theMode);
1569 // erase presentations for all display modes different from <aMode>
1570 TColStd_ListOfInteger aModesToRemove;
1571 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
1573 const Standard_Integer anOldMode = aDispModeIter.Value();
1574 if (anOldMode != theMode)
1576 aModesToRemove.Append (anOldMode);
1577 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1579 myMainPM->Unhighlight (theIObj, anOldMode);
1581 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1585 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
1587 aStatus->RemoveDisplayMode (aRemModeIter.Value());
1590 if (!aStatus->IsDModeIn (theMode))
1592 aStatus->AddDisplayMode (theMode);
1595 myMainPM->Display (theIObj, theMode);
1596 Standard_Integer aDispMode, aHiMode, aSelMode;
1597 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1598 if (aStatus->IsHilighted())
1600 myMainPM->Highlight (theIObj, aHiMode);
1602 if (aStatus->IsSubIntensityOn())
1604 myMainPM->Color (theIObj, mySubIntensity, theMode);
1607 if (theToUpdateViewer)
1609 myMainVwr->Update();
1611 theIObj->SetDisplayMode (theMode);
1614 //=======================================================================
1615 //function : UnsetDisplayMode
1617 //=======================================================================
1618 void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1619 const Standard_Boolean theToUpdateViewer)
1621 if (theIObj.IsNull()
1622 || !theIObj->HasDisplayMode())
1627 if (!myObjects.IsBound (theIObj))
1629 theIObj->UnsetDisplayMode();
1633 const Standard_Integer anOldMode = theIObj->DisplayMode();
1634 if (myDisplayMode == anOldMode)
1639 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
1640 aStatus->RemoveDisplayMode (anOldMode);
1641 if (!aStatus->IsDModeIn(myDisplayMode))
1643 aStatus->AddDisplayMode (myDisplayMode);
1646 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1648 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1650 myMainPM->Unhighlight (theIObj, anOldMode);
1652 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1653 myMainPM->Display (theIObj, myDisplayMode);
1655 Standard_Integer aDispMode, aHiMode, aSelMode;
1656 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1657 if (aStatus->IsHilighted())
1659 myMainPM->Highlight (theIObj, aHiMode);
1661 if (aStatus->IsSubIntensityOn())
1663 myMainPM->Color (theIObj, mySubIntensity, myDisplayMode);
1666 if (theToUpdateViewer)
1668 myMainVwr->Update();
1672 theIObj->UnsetDisplayMode();
1675 //=======================================================================
1676 //function : SetCurrentFacingModel
1678 //=======================================================================
1679 void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
1680 const Aspect_TypeOfFacingModel theModel)
1682 if (!theIObj.IsNull())
1684 theIObj->SetCurrentFacingModel (theModel);
1688 //=======================================================================
1689 //function : redisplayPrsRecModes
1691 //=======================================================================
1692 void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1693 const Standard_Boolean theToUpdateViewer)
1695 if (theIObj->RecomputeEveryPrs())
1697 theIObj->Update (Standard_True);
1698 theIObj->UpdateSelection();
1702 for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
1704 theIObj->Update (aModes.Value(), Standard_False);
1706 theIObj->UpdateSelection();
1707 theIObj->SetRecomputeOk();
1710 if (theToUpdateViewer)
1712 UpdateCurrentViewer();
1716 //=======================================================================
1717 //function : redisplayPrsModes
1719 //=======================================================================
1720 void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1721 const Standard_Boolean theToUpdateViewer)
1723 if (theIObj->RecomputeEveryPrs())
1725 theIObj->Update (Standard_True);
1726 theIObj->UpdateSelection();
1730 TColStd_ListOfInteger aModes;
1731 theIObj->ToBeUpdated (aModes);
1732 for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
1734 theIObj->Update (aModeIter.Value(), Standard_False);
1736 theIObj->SetRecomputeOk();
1739 if (theToUpdateViewer)
1741 UpdateCurrentViewer();
1745 //=======================================================================
1746 //function : SetColor
1748 //=======================================================================
1749 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1750 const Quantity_NameOfColor theColor,
1751 const Standard_Boolean theToUpdateViewer)
1753 SetColor (theIObj, Quantity_Color(theColor), theToUpdateViewer);
1756 //=======================================================================
1757 //function : SetColor
1759 //=======================================================================
1760 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1761 const Quantity_Color& theColor,
1762 const Standard_Boolean theToUpdateViewer)
1764 if (theIObj.IsNull())
1769 if (!theIObj->HasInteractiveContext())
1771 theIObj->SetContext (this);
1773 theIObj->SetColor (theColor);
1774 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1777 //=======================================================================
1778 //function : SetDeviationCoefficient
1780 //=======================================================================
1781 void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1782 const Standard_Real theCoefficient,
1783 const Standard_Boolean theToUpdateViewer)
1785 if (theIObj.IsNull())
1790 if (!theIObj->HasInteractiveContext())
1792 theIObj->SetContext (this);
1795 // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
1796 if (theIObj->Type() != AIS_KOI_Object
1797 && theIObj->Type() != AIS_KOI_Shape)
1801 else if (theIObj->Signature() != 0)
1806 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1807 aShape->SetOwnDeviationCoefficient (theCoefficient);
1808 redisplayPrsModes (theIObj, theToUpdateViewer);
1811 //=======================================================================
1812 //function : SetHLRDeviationCoefficient
1814 //=======================================================================
1815 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1816 const Standard_Real theCoefficient,
1817 const Standard_Boolean theToUpdateViewer)
1819 if (theIObj.IsNull())
1824 if (!theIObj->HasInteractiveContext())
1826 theIObj->SetContext (this);
1829 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1830 if (theIObj->Type() != AIS_KOI_Object
1831 && theIObj->Type() != AIS_KOI_Shape)
1835 else if (theIObj->Signature() != 0)
1840 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1841 aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
1842 redisplayPrsModes (theIObj, theToUpdateViewer);
1845 //=======================================================================
1846 //function : SetDeviationAngle
1848 //=======================================================================
1849 void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1850 const Standard_Real theAngle,
1851 const Standard_Boolean theToUpdateViewer)
1853 if (theIObj.IsNull())
1858 if (!theIObj->HasInteractiveContext())
1860 theIObj->SetContext (this);
1863 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1864 if (theIObj->Type() != AIS_KOI_Shape)
1868 else if (theIObj->Signature() != 0)
1873 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1874 aShape->SetOwnDeviationAngle (theAngle);
1875 redisplayPrsModes (theIObj, theToUpdateViewer);
1878 //=======================================================================
1879 //function : SetAngleAndDeviation
1881 //=======================================================================
1882 void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1883 const Standard_Real theAngle,
1884 const Standard_Boolean theToUpdateViewer)
1886 if (theIObj.IsNull())
1891 if (!theIObj->HasInteractiveContext())
1893 theIObj->SetContext (this);
1896 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1897 if (theIObj->Type() != AIS_KOI_Shape)
1901 if (theIObj->Signature() != 0)
1906 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1907 aShape->SetAngleAndDeviation (theAngle);
1909 if (theIObj->RecomputeEveryPrs())
1911 theIObj->Update (Standard_True);
1912 theIObj->UpdateSelection();
1916 Update (theIObj, theToUpdateViewer);
1920 //=======================================================================
1921 //function : SetHLRAngleAndDeviation
1923 //=======================================================================
1924 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1925 const Standard_Real theAngle,
1926 const Standard_Boolean theToUpdateViewer)
1928 if (theIObj.IsNull())
1933 if (!theIObj->HasInteractiveContext())
1935 theIObj->SetContext (this);
1938 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1939 if (theIObj->Type() != AIS_KOI_Shape)
1943 if (theIObj->Signature() != 0)
1947 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1948 aShape->SetHLRAngleAndDeviation (theAngle);
1949 redisplayPrsModes (theIObj, theToUpdateViewer);
1952 //=======================================================================
1953 //function : SetHLRDeviationAngle
1955 //=======================================================================
1956 void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1957 const Standard_Real theAngle,
1958 const Standard_Boolean theToUpdateViewer)
1960 if (theIObj.IsNull())
1965 if (!theIObj->HasInteractiveContext())
1967 theIObj->SetContext (this);
1970 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1971 if (theIObj->Type() != AIS_KOI_Shape)
1975 if (theIObj->Signature() != 0)
1979 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1980 aShape->SetOwnHLRDeviationAngle (theAngle);
1981 redisplayPrsModes (theIObj, theToUpdateViewer);
1984 //=======================================================================
1985 //function : UnsetColor
1987 //=======================================================================
1988 void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
1989 const Standard_Boolean theToUpdateViewer)
1991 if (theIObj.IsNull())
1996 theIObj->UnsetColor();
1997 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2000 //=======================================================================
2001 //function : HasColor
2003 //=======================================================================
2004 Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
2006 return theIObj->HasColor();
2009 //=======================================================================
2012 //=======================================================================
2013 Quantity_NameOfColor AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj) const
2015 return theIObj->Color();
2018 //=======================================================================
2021 //=======================================================================
2022 void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
2023 Quantity_Color& theColor) const
2025 theIObj->Color (theColor);
2028 //=======================================================================
2031 //=======================================================================
2032 Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
2034 return theIObj->Width();
2037 //=======================================================================
2038 //function : SetWidth
2040 //=======================================================================
2041 void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2042 const Standard_Real theWidth,
2043 const Standard_Boolean theToUpdateViewer)
2045 if (theIObj.IsNull())
2050 if (!theIObj->HasInteractiveContext())
2052 theIObj->SetContext (this);
2055 theIObj->SetWidth (theWidth);
2056 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2059 //=======================================================================
2060 //function : UnsetWidth
2062 //=======================================================================
2063 void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2064 const Standard_Boolean theToUpdateViewer)
2066 if (theIObj.IsNull())
2071 theIObj->UnsetWidth();
2072 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2075 //=======================================================================
2076 //function : SetMaterial
2078 //=======================================================================
2079 void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2080 const Graphic3d_NameOfMaterial theName,
2081 const Standard_Boolean theToUpdateViewer)
2083 if (theIObj.IsNull())
2088 if (!theIObj->HasInteractiveContext())
2090 theIObj->SetContext (this);
2093 theIObj->SetMaterial (theName);
2094 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2097 //=======================================================================
2098 //function : UnsetMaterial
2100 //=======================================================================
2101 void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2102 const Standard_Boolean theToUpdateViewer)
2104 if (theIObj.IsNull())
2108 theIObj->UnsetMaterial();
2109 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2112 //=======================================================================
2113 //function : SetTransparency
2115 //=======================================================================
2116 void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2117 const Standard_Real theValue,
2118 const Standard_Boolean theToUpdateViewer)
2120 if (theIObj.IsNull())
2125 if (!theIObj->HasInteractiveContext())
2127 theIObj->SetContext (this);
2130 if (!theIObj->IsTransparent()
2131 && theValue <= 0.05)
2136 if (theValue <= 0.05)
2138 UnsetTransparency (theIObj, theToUpdateViewer);
2142 theIObj->SetTransparency (theValue);
2143 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2146 //=======================================================================
2147 //function : UnsetTransparency
2149 //=======================================================================
2150 void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2151 const Standard_Boolean theToUpdateViewer)
2153 if (theIObj.IsNull())
2158 theIObj->UnsetTransparency();
2159 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2162 //=======================================================================
2163 //function : SetSelectedAspect
2165 //=======================================================================
2166 void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
2167 const Standard_Boolean theIsGlobalChange,
2168 const Standard_Boolean theToUpdateViewer)
2170 if (HasOpenedContext())
2175 Standard_Boolean isFound = Standard_False;
2176 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
2177 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
2179 isFound = Standard_True;
2180 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
2181 anObj->SetAspect (theAspect, theIsGlobalChange);
2185 && theToUpdateViewer)
2187 myMainVwr->Update();
2191 //=======================================================================
2192 //function : SetLocalAttributes
2194 //=======================================================================
2195 void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2196 const Handle(Prs3d_Drawer)& theDrawer,
2197 const Standard_Boolean theToUpdateViewer)
2199 if (theIObj.IsNull())
2204 if (!theIObj->HasInteractiveContext())
2206 theIObj->SetContext (this);
2209 theIObj->SetAttributes (theDrawer);
2210 Update (theIObj, theToUpdateViewer);
2213 //=======================================================================
2214 //function : UnsetLocalAttributes
2216 //=======================================================================
2217 void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2218 const Standard_Boolean theToUpdateViewer)
2220 if (theIObj.IsNull())
2225 if (!theIObj->HasInteractiveContext())
2227 theIObj->SetContext (this);
2229 theIObj->UnsetAttributes();
2230 Update (theIObj, theToUpdateViewer);
2233 //=======================================================================
2236 //=======================================================================
2237 void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
2238 TCollection_ExtendedString& theStatus) const
2241 if (theIObj.IsNull()
2242 || !myObjects.IsBound (theIObj))
2247 theStatus += "\t ____________________________________________";
2248 theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2249 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2250 switch (aStatus->GraphicStatus())
2252 case AIS_DS_Displayed:
2254 theStatus += "\t| -->Displayed\n";
2259 theStatus += "\t| -->Erased\n";
2266 theStatus += "\t| Active Display Modes in the MainViewer :\n";
2267 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2269 theStatus += "\t|\t Mode ";
2270 theStatus += TCollection_AsciiString (aDispModeIter.Value());
2273 if (IsCurrent (theIObj)) theStatus +="\t| Current\n";
2274 if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
2276 theStatus += "\t| Active Selection Modes in the MainViewer :\n";
2277 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2279 theStatus += "\t\t Mode ";
2280 theStatus += TCollection_AsciiString (aSelModeIter.Value());
2283 theStatus += "\t ____________________________________________";
2286 //=======================================================================
2287 //function : GetDefModes
2289 //=======================================================================
2290 void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
2291 Standard_Integer& theDispMode,
2292 Standard_Integer& theHiMode,
2293 Standard_Integer& theSelMode) const
2295 if (theIObj.IsNull())
2300 theDispMode = theIObj->HasDisplayMode()
2301 ? theIObj->DisplayMode()
2302 : (theIObj->AcceptDisplayMode (myDisplayMode)
2305 theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
2306 theSelMode = theIObj->HasSelectionMode() ? theIObj->SelectionMode() : -1;
2309 //=======================================================================
2310 //function : EraseGlobal
2312 //=======================================================================
2313 void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2314 const Standard_Boolean theToUpdateviewer)
2316 if (theIObj.IsNull()
2317 || !myObjects.IsBound (theIObj))
2322 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2324 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2325 if (aStatus->GraphicStatus() == AIS_DS_Temporary
2326 || aStatus->GraphicStatus() == AIS_DS_Erased)
2331 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2333 if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2335 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2338 myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
2341 if (IsCurrent (theIObj)
2342 && !aStatus->IsDModeIn (aDispMode))
2344 myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
2347 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2349 mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
2351 aStatus->SetGraphicStatus (AIS_DS_Erased);
2353 if (theToUpdateviewer)
2355 myMainVwr->Update();
2359 //=======================================================================
2360 //function : ClearGlobal
2362 //=======================================================================
2363 void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2364 const Standard_Boolean theToUpdateviewer)
2366 if (theIObj.IsNull()
2367 || !myObjects.IsBound (theIObj))
2369 // for cases when reference shape of connected interactives was not displayed
2370 // but its selection primitives were calculated
2371 mgrSelector->Remove (theIObj);
2375 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2376 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2378 if (aStatus->IsHilighted())
2380 if (IsCurrent (theIObj))
2382 AddOrRemoveCurrentObject (theIObj, theToUpdateviewer);
2384 else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2386 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2389 myMainPM->Erase (theIObj, aDispModeIter.Value());
2390 myMainPM->Clear (theIObj, aDispModeIter.Value());
2391 if (theIObj->HasHilightMode())
2393 Standard_Integer im = theIObj->HilightMode();
2394 myMainPM->Unhighlight (theIObj, im);
2395 myMainPM->Erase (theIObj, im);
2399 // Object removes from Detected sequence
2400 for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
2402 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2404 && anObj != theIObj)
2406 myAISDetectedSeq.Remove (aDetIter);
2410 if (myLastinMain == theIObj)
2412 myLastinMain.Nullify();
2414 if (myLastPicked == theIObj)
2416 myLastPicked.Nullify();
2419 // remove IO from the selection manager to avoid memory leaks
2420 mgrSelector->Remove (theIObj);
2422 myObjects.UnBind (theIObj);
2423 myMainVwr->Viewer()->UnregisterObject (theIObj);
2424 for (myMainVwr->InitDefinedViews(); myMainVwr->MoreDefinedViews(); myMainVwr->NextDefinedViews())
2426 myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj);
2429 if (theToUpdateviewer
2430 && aStatus->GraphicStatus() == AIS_DS_Displayed)
2432 myMainVwr->Update();
2436 //=======================================================================
2437 //function : ClearGlobalPrs
2439 //=======================================================================
2440 void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
2441 const Standard_Integer theMode,
2442 const Standard_Boolean theToUpdateViewer)
2444 if (theIObj.IsNull()
2445 || !myObjects.IsBound (theIObj))
2450 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2451 if (aStatus->IsDModeIn (theMode))
2453 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2454 if (aDispMode == theMode
2455 && myMainPM->IsHighlighted (theIObj, theMode))
2457 myMainPM->Unhighlight (theIObj, theMode);
2460 myMainPM->Erase (theIObj, theMode);
2461 myMainPM->Clear (theIObj, theMode);
2464 if (aStatus->GraphicStatus() == AIS_DS_Displayed
2465 && theToUpdateViewer)
2467 myMainVwr->Update();
2471 //=======================================================================
2472 //function : DrawHiddenLine
2474 //=======================================================================
2475 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
2477 return myDefaultDrawer->DrawHiddenLine();
2480 //=======================================================================
2481 //function : EnableDrawHiddenLine
2483 //=======================================================================
2484 void AIS_InteractiveContext::EnableDrawHiddenLine() const
2486 myDefaultDrawer->EnableDrawHiddenLine();
2489 //=======================================================================
2490 //function : DisableDrawHiddenLine
2492 //=======================================================================
2493 void AIS_InteractiveContext::DisableDrawHiddenLine() const
2495 myDefaultDrawer->DisableDrawHiddenLine();
2498 //=======================================================================
2499 //function : HiddenLineAspect
2501 //=======================================================================
2502 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
2504 return myDefaultDrawer->HiddenLineAspect();
2507 //=======================================================================
2508 //function : SetHiddenLineAspect
2510 //=======================================================================
2511 void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
2513 myDefaultDrawer->SetHiddenLineAspect (theAspect);
2516 //=======================================================================
2517 //function : SetIsoNumber
2519 //=======================================================================
2520 void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
2521 const AIS_TypeOfIso theType)
2526 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2529 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2532 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2533 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2538 //=======================================================================
2539 //function : IsoNumber
2541 //=======================================================================
2542 Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
2546 case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
2547 case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
2548 case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
2549 ? myDefaultDrawer->UIsoAspect()->Number()
2555 //=======================================================================
2556 //function : IsoOnPlane
2558 //=======================================================================
2559 void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
2561 myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
2564 //=======================================================================
2565 //function : IsoOnPlane
2567 //=======================================================================
2568 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2570 return myDefaultDrawer->IsoOnPlane();
2573 //=======================================================================
2574 //function : SetSelectionMode
2576 //=======================================================================
2577 void AIS_InteractiveContext::SetSelectionMode (const Handle(AIS_InteractiveObject)& ,
2578 const Standard_Integer )
2583 //=======================================================================
2584 //function : UnsetSelectionMode
2586 //=======================================================================
2587 void AIS_InteractiveContext::UnsetSelectionMode (const Handle(AIS_InteractiveObject)& )
2592 //=======================================================================
2593 //function : SetPixelTolerance
2594 //purpose : Disables the mechanism of adaptive tolerance calculation in
2595 // SelectMgr_ViewerSelector and sets the given tolerance for ALL
2596 // sensitive entities activated. For more information, see
2597 // SelectMgr_ViewerSelector.hxx
2598 //=======================================================================
2599 void AIS_InteractiveContext::SetPixelTolerance (const Standard_Real thePrecision)
2601 if (HasOpenedContext())
2603 myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
2607 myMainSel->SetPixelTolerance (thePrecision);
2611 //=======================================================================
2612 //function : PixelTolerance
2614 //=======================================================================
2615 Standard_Real AIS_InteractiveContext::PixelTolerance() const
2617 return HasOpenedContext()
2618 ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
2619 : myMainSel->PixelTolerance();
2622 //=======================================================================
2623 //function : IsInLocal
2625 //=======================================================================
2626 Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
2627 Standard_Integer& theIndex) const
2629 if (theIObj.IsNull())
2631 return Standard_False;
2634 // if it exists at neutral point 0 index is returned
2635 if (myObjects.IsBound (theIObj))
2638 return Standard_False;
2641 for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
2643 if (myLocalContexts.IsBound (aCtxIter))
2645 if(myLocalContexts (aCtxIter)->IsIn (theIObj))
2647 theIndex = aCtxIter;
2648 return Standard_True;
2653 return Standard_False;
2656 //=======================================================================
2657 //function : InitAttributes
2659 //=======================================================================
2660 void AIS_InteractiveContext::InitAttributes()
2662 mgrSelector->Add (myMainSel);
2663 myCurrentName = AIS_Context_NewCurName();
2664 mySelectionName = AIS_Context_NewSelName();
2666 AIS_Selection::CreateSelection (mySelectionName.ToCString());
2667 AIS_Selection::CreateSelection (myCurrentName.ToCString());
2669 myDefaultDrawer->SetShadingAspectGlobal (Standard_False);
2670 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
2671 myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
2673 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2674 Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
2675 aLineAspect->SetColor (Quantity_NOC_GRAY20);
2676 aLineAspect->SetWidth (1.0);
2677 aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
2679 // tolerance to 2 pixels...
2680 SetPixelTolerance (2.0);
2682 // Customizing the drawer for trihedrons and planes...
2683 Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
2684 const Standard_Real aLength = 100.0;
2685 aTrihAspect->SetAxisLength (aLength, aLength, aLength);
2686 const Quantity_NameOfColor aColor = Quantity_NOC_LIGHTSTEELBLUE4;
2687 aTrihAspect->FirstAxisAspect() ->SetColor (aColor);
2688 aTrihAspect->SecondAxisAspect()->SetColor (aColor);
2689 aTrihAspect->ThirdAxisAspect() ->SetColor (aColor);
2691 Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
2692 const Standard_Real aPlaneLength = 200.0;
2693 aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
2694 aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
2697 //=======================================================================
2698 //function : TrihedronSize
2700 //=======================================================================
2701 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2703 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2706 //=======================================================================
2707 //function : SetTrihedronSize
2709 //=======================================================================
2710 void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
2711 const Standard_Boolean /*updateviewer*/)
2713 myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
2714 Redisplay (AIS_KOI_Datum, 3, Standard_False);
2715 Redisplay (AIS_KOI_Datum, 4, Standard_True);
2718 //=======================================================================
2719 //function : SetPlaneSize
2721 //=======================================================================
2722 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
2723 const Standard_Real theValY,
2724 const Standard_Boolean /*updateviewer*/)
2726 myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
2727 Redisplay (AIS_KOI_Datum, 7);
2730 //=======================================================================
2731 //function : SetPlaneSize
2733 //=======================================================================
2734 void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
2735 const Standard_Boolean theToUpdateViewer)
2737 SetPlaneSize (theVal, theVal, theToUpdateViewer);
2740 //=======================================================================
2741 //function : PlaneSize
2743 //=======================================================================
2744 Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
2745 Standard_Real& theY) const
2747 theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2748 theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2749 return (Abs (theX - theY) <= Precision::Confusion());
2752 //=======================================================================
2753 //function : SetAutoActivateSelection
2755 //=======================================================================
2756 void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
2758 myIsAutoActivateSelMode = theIsAuto;
2761 //=======================================================================
2762 //function : GetAutoActivateSelection
2764 //=======================================================================
2765 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2767 return myIsAutoActivateSelMode;
2770 //=======================================================================
2771 //function : SetZLayer
2773 //=======================================================================
2774 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2775 const Standard_Integer theLayerId)
2777 if (theIObj.IsNull())
2780 theIObj->SetZLayer (theLayerId);
2783 //=======================================================================
2784 //function : GetZLayer
2786 //=======================================================================
2787 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2789 return !theIObj.IsNull()
2791 : Graphic3d_ZLayerId_UNKNOWN;
2794 //=======================================================================
2795 //function : RebuildSelectionStructs
2796 //purpose : Rebuilds 1st level of BVH selection forcibly
2797 //=======================================================================
2798 void AIS_InteractiveContext::RebuildSelectionStructs()
2800 myMainSel->RebuildObjectsTree (Standard_True);
2803 //=======================================================================
2804 //function : Disconnect
2805 //purpose : Disconnects selectable object from an assembly and updates selection structures
2806 //=======================================================================
2807 void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly,
2808 const Handle(AIS_InteractiveObject)& theObjToDisconnect)
2810 if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive"))
2812 const Handle(AIS_MultipleConnectedInteractive)& theObj =
2813 Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly);
2814 theObj->Disconnect (theObjToDisconnect);
2815 mgrSelector->Remove (theObjToDisconnect);
2817 else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect == NULL)
2819 const Handle(AIS_ConnectedInteractive)& theObj =
2820 Handle(AIS_ConnectedInteractive)::DownCast (theAssembly);
2821 theObj->Disconnect();
2822 mgrSelector->Remove (theObj);