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 <UnitsAPI.hxx>
48 #include <AIS_Trihedron.hxx>
49 #include <Geom_Axis2Placement.hxx>
50 #include <OSD_Environment.hxx>
52 #include <AIS_ListIteratorOfListOfInteractive.hxx>
56 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
57 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
59 static TCollection_AsciiString AIS_Context_NewSelName()
61 return TCollection_AsciiString ("AIS_SelContext_")
62 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
65 static TCollection_AsciiString AIS_Context_NewCurName()
67 return TCollection_AsciiString ("AIS_CurContext_")
68 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
72 //=======================================================================
73 //function : AIS_InteractiveContext
75 //=======================================================================
77 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
78 mgrSelector(new SelectMgr_SelectionManager()),
79 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
80 myMainVwr(MainViewer),
81 myMainSel(new StdSelect_ViewerSelector3d()),
82 myWasLastMain(Standard_False),
83 myCurrentTouched(Standard_False),
84 mySelectedTouched(Standard_False),
85 myToHilightSelected(Standard_True),
86 myFilters(new SelectMgr_OrFilter()),
87 myDefaultDrawer(new Prs3d_Drawer()),
88 myDefaultColor(Quantity_NOC_GOLDENROD),
89 myHilightColor(Quantity_NOC_CYAN1),
90 mySelectionColor(Quantity_NOC_GRAY80),
91 myPreselectionColor(Quantity_NOC_GREEN),
92 mySubIntensity(Quantity_NOC_GRAY40),
97 myIsAutoActivateSelMode( Standard_True )
102 void AIS_InteractiveContext::Delete() const
104 // clear the static current selection
105 AIS_Selection::ClearCurrentSelection();
107 // to avoid an exception
108 if (AIS_Selection::Find (mySelectionName.ToCString()))
110 AIS_Selection::Remove (mySelectionName.ToCString());
113 // to avoid an exception
114 if (AIS_Selection::Find (myCurrentName.ToCString()))
116 AIS_Selection::Remove (myCurrentName.ToCString());
119 // let's remove one reference explicitly. this operation's supposed to
120 // be performed when mgrSelector will be destroyed but anyway...
121 mgrSelector->Remove (myMainSel);
123 Handle(AIS_InteractiveContext) aNullContext;
124 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
126 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
127 anObj->SetContext (aNullContext);
129 MMgt_TShared::Delete();
132 //=======================================================================
133 //function : AIS_SelectionName
135 //=======================================================================
136 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
138 if(!HasOpenedContext())
139 return mySelectionName;
140 return myLocalContexts(myCurLocalIndex)->SelectionName();
146 //=======================================================================
147 //function : UpdateCurrentViewer
149 //=======================================================================
151 void AIS_InteractiveContext::UpdateCurrentViewer()
153 if (!myMainVwr.IsNull())
158 //=======================================================================
159 //function : DomainOfMainViewer
161 //=======================================================================
163 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
165 return myMainVwr->Domain();
169 //=======================================================================
170 //function : DisplayedObjects
172 //=======================================================================
173 void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
174 const Standard_Boolean theOnlyFromNeutral) const
176 if (!HasOpenedContext()
177 || theOnlyFromNeutral)
179 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
181 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
183 theListOfIO.Append (anObjIter.Key());
190 TColStd_MapOfTransient aDispMap;
191 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
193 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
195 aDispMap.Add (anObjIter.Key());
199 // parse all local contexts...
200 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
202 const Handle(AIS_LocalContext)& aLocCtx = aCtxIter.Value();
203 aLocCtx->DisplayedObjects (aDispMap);
206 Handle(AIS_InteractiveObject) anObj;
207 for (TColStd_MapIteratorOfMapOfTransient aDispMapIter (aDispMap); aDispMapIter.More(); aDispMapIter.Next())
209 const Handle(Standard_Transient)& aTransient = aDispMapIter.Key();
210 anObj = *((Handle(AIS_InteractiveObject)* )&aTransient);
211 theListOfIO.Append (anObj);
215 //=======================================================================
216 //function : DisplayedObjects
218 //=======================================================================
219 void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
220 const Standard_Integer theSign,
221 AIS_ListOfInteractive& theListOfIO,
222 const Standard_Boolean /*OnlyFromNeutral*/) const
224 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
227 //=======================================================================
228 //function : ErasedObjects
230 //=======================================================================
231 void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const
233 ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO);
236 //=======================================================================
237 //function : ErasedObjects
239 //=======================================================================
240 void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind,
241 const Standard_Integer theSign,
242 AIS_ListOfInteractive& theListOfIO) const
244 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO);
247 //=======================================================================
248 //function : ObjectsByDisplayStatus
250 //=======================================================================
251 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus,
252 AIS_ListOfInteractive& theListOfIO) const
254 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
256 if (anObjIter.Value()->GraphicStatus() == theStatus)
258 theListOfIO.Append (anObjIter.Key());
263 //=======================================================================
264 //function : ObjectsByDisplayStatus
266 //=======================================================================
267 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind,
268 const Standard_Integer theSign,
269 const AIS_DisplayStatus theStatus,
270 AIS_ListOfInteractive& theListOfIO) const
272 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
274 if (theStatus != AIS_DS_None
275 && anObjIter.Value()->GraphicStatus() != theStatus)
279 else if (anObjIter.Key()->Type() != theKind)
285 || anObjIter.Key()->Signature() == theSign)
287 theListOfIO.Append (anObjIter.Key());
292 //=======================================================================
293 //function : ObjectsInside
295 //=======================================================================
296 void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO,
297 const AIS_KindOfInteractive theKind,
298 const Standard_Integer theSign) const
300 if (theKind == AIS_KOI_None
303 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
305 theListOfIO.Append (anObjIter.Key());
310 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
312 if (anObjIter.Key()->Type() != theKind)
318 || anObjIter.Key()->Signature() == theSign)
320 theListOfIO.Append (anObjIter.Key());
325 //=======================================================================
326 //function : ObjectsForView
328 //=======================================================================
329 void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO,
330 const Handle(V3d_View)& theView,
331 const Standard_Boolean theIsVisibleInView,
332 const AIS_DisplayStatus theStatus) const
334 const Graphic3d_CView* aCView = reinterpret_cast<const Graphic3d_CView* >(theView->View()->CView());
335 const Standard_Integer aViewId = aCView->ViewId;
336 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
338 if (theStatus != AIS_DS_None
339 && anObjIter.Value()->GraphicStatus() != theStatus)
341 theListOfIO.Append (anObjIter.Key());
345 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (anObjIter.Key());
346 const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
347 if (isVisible == theIsVisibleInView)
349 theListOfIO.Append (anObjIter.Key());
354 //=======================================================================
357 //=======================================================================
358 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
359 const Standard_Boolean theToUpdateViewer)
361 if (theIObj.IsNull())
366 Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
367 GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
369 Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
370 theToUpdateViewer, theIObj->AcceptShapeDecomposition());
373 //=======================================================================
374 //function : SetViewAffinity
376 //=======================================================================
377 void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj,
378 const Handle(V3d_View)& theView,
379 const Standard_Boolean theIsVisible)
382 || !myObjects.IsBound (theIObj))
387 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (theIObj);
388 const Graphic3d_CView* aCView = reinterpret_cast<const Graphic3d_CView* >(theView->View()->CView());
389 anAffinity->SetVisible (aCView->ViewId, theIsVisible == Standard_True);
392 theView->View()->ChangeHiddenObjects()->Remove (theIObj);
396 theView->View()->ChangeHiddenObjects()->Add (theIObj);
400 //=======================================================================
403 //=======================================================================
404 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
405 const Standard_Integer theDispMode,
406 const Standard_Integer theSelectionMode,
407 const Standard_Boolean theToUpdateViewer,
408 const Standard_Boolean theToAllowDecomposition,
409 const AIS_DisplayStatus theDispStatus)
411 if (theIObj.IsNull())
416 if (theDispStatus == AIS_DS_Erased)
418 Erase (theIObj, theToUpdateViewer);
419 Load (theIObj, theSelectionMode, theToAllowDecomposition);
423 if (!theIObj->HasInteractiveContext())
425 theIObj->SetContext (this);
428 if (theDispStatus == AIS_DS_Temporary
429 && !HasOpenedContext())
433 else if (HasOpenedContext())
435 if (theDispStatus == AIS_DS_None
436 || theDispStatus == AIS_DS_Temporary)
438 myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
439 if (theToUpdateViewer)
447 if (!myObjects.IsBound (theIObj))
449 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
450 myObjects.Bind (theIObj, aStatus);
451 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->RegisterObject (theIObj);
452 myMainPM->Display(theIObj, theDispMode);
453 if (theSelectionMode != -1)
455 if (!mgrSelector->Contains (theIObj))
457 mgrSelector->Load (theIObj);
459 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
464 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
465 if (aStatus->GraphicStatus() == AIS_DS_Temporary)
470 // Erase presentations for all display modes different from aDispMode.
471 // Then make sure aDispMode is displayed and maybe highlighted.
472 // Finally, activate selection mode <SelMode> if not yet activated.
473 TColStd_ListOfInteger aModesToRemove;
474 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
476 const Standard_Integer anOldMode = aDispModeIter.Value();
477 if (anOldMode != theDispMode)
479 aModesToRemove.Append (anOldMode);
480 if(myMainPM->IsHighlighted (theIObj, anOldMode))
482 myMainPM->Unhighlight (theIObj, anOldMode);
484 myMainPM->Erase (theIObj, anOldMode);
488 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
490 aStatus->RemoveDisplayMode (aRemModeIter.Value());
493 if (!aStatus->IsDModeIn (theDispMode))
495 aStatus->AddDisplayMode (theDispMode);
498 myMainPM->Display (theIObj, theDispMode);
499 aStatus->SetGraphicStatus (AIS_DS_Displayed);
500 if (aStatus->IsHilighted())
502 const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
503 myMainPM->Highlight (theIObj, aHiMod);
505 if (theSelectionMode != -1)
507 if (!mgrSelector->Contains (theIObj))
509 mgrSelector->Load (theIObj);
511 if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
513 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
518 if (theToUpdateViewer)
524 //=======================================================================
527 //=======================================================================
528 void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
529 const Standard_Integer theSelMode,
530 const Standard_Boolean theToAllowDecomposition)
532 if (theIObj.IsNull())
537 if (!theIObj->HasInteractiveContext())
539 theIObj->SetContext (this);
542 if (HasOpenedContext())
544 myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
549 && !theToAllowDecomposition)
551 if (!myObjects.IsBound (theIObj))
553 Standard_Integer aDispMode, aHiMod, aSelModeDef;
554 GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
555 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, aSelModeDef);
556 myObjects.Bind (theIObj, aStatus);
559 // Register theIObj in the selection manager to prepare further activation of selection
560 if (!mgrSelector->Contains (theIObj))
562 mgrSelector->Load (theIObj);
567 //=======================================================================
570 //=======================================================================
571 void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
572 const Standard_Boolean theToUpdateViewer)
574 if (theIObj.IsNull())
579 if (!theIObj->IsAutoHilight())
581 theIObj->ClearSelected();
584 Standard_Boolean wasInCtx = Standard_False;
585 if (HasOpenedContext())
587 // First it is checked if it is possible to remove in the current local context
588 // then one tries to remove in other local contexts, if they allow it...
589 wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
590 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
592 if (aCtxIter.Value()->AcceptErase())
594 wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
601 EraseGlobal (theIObj, Standard_False);
604 if (theToUpdateViewer)
610 //=======================================================================
611 //function : EraseAll
613 //=======================================================================
614 void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
616 if (HasOpenedContext())
621 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
623 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
625 Erase (anObjIter.Key(), Standard_False);
629 if (theToUpdateViewer)
635 //=======================================================================
636 //function : DisplayAll
638 //=======================================================================
639 void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
641 if (HasOpenedContext())
646 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
648 const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
649 if (aStatus == AIS_DS_Erased)
651 Display (anObjIter.Key(), Standard_False);
655 if (theToUpdateViewer)
661 //=======================================================================
662 //function : DisplaySelected
664 //=======================================================================
665 void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
667 if (HasOpenedContext())
672 Standard_Boolean isFound = Standard_False;
673 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
674 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
676 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
677 Display (anObj, Standard_False);
678 isFound = Standard_True;
681 if (isFound && theToUpdateViewer)
687 //=======================================================================
688 //function : EraseSelected
690 //=======================================================================
691 void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
693 if (HasOpenedContext())
698 Standard_Boolean isFound = Standard_False;
699 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString());
700 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
702 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
703 Erase (anObj, Standard_False);
704 isFound = Standard_True;
707 if (isFound && theToUpdateViewer)
713 //=======================================================================
716 //=======================================================================
718 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
719 const Standard_Integer WhichContext)
721 if(anIObj.IsNull()) return Standard_False;
723 if(!HasOpenedContext()) return Standard_False;
724 if(myObjects.IsBound(anIObj)) return Standard_False;
725 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
727 // Protection : if one tries to preserve a temporary object
728 // which is not in the local active context... rob 11-06-97
730 Standard_Integer IsItInLocal = myCurLocalIndex;
731 Standard_Boolean Found(Standard_False);
733 while(IsItInLocal>0 && !Found){
734 if(!myLocalContexts.IsBound(IsItInLocal))
736 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
737 Found = Standard_True;
742 if(!Found) return Standard_False;
745 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
746 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
748 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
749 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
753 if(LS->IsTemporary()){
754 Standard_Integer DM,HM,SM;
755 GetDefModes(anIObj,DM,HM,SM);
757 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
758 if(LS->DisplayMode()!= DM ){
759 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
760 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
763 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
767 // GS->SubIntensityOn();
768 myObjects.Bind(anIObj,GS);
769 mgrSelector->Load(anIObj);
770 mgrSelector->Activate(anIObj,SM,myMainSel);
772 LS->SetTemporary(Standard_False);
774 return Standard_True;
777 //=======================================================================
778 //function : DisplayStatus
780 //=======================================================================
781 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
783 if (theIObj.IsNull())
787 else if (myObjects.IsBound (theIObj))
789 return myObjects (theIObj)->GraphicStatus();
792 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
794 if (aCtxIter.Value()->IsIn (theIObj))
796 return AIS_DS_Temporary;
802 //=======================================================================
803 //function : DisplayedModes
805 //=======================================================================
806 const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
808 return myObjects (theIObj)->DisplayedModes();
811 //=======================================================================
814 //=======================================================================
815 void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
816 const Standard_Boolean theToUpdateViewer)
818 if (theIObj.IsNull())
823 if (HasOpenedContext())
825 myLocalContexts (myCurLocalIndex)->Remove (theIObj);
826 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
828 if (aCtxIter.Value()->AcceptErase())
830 aCtxIter.Value()->Remove (theIObj);
835 ClearGlobal (theIObj, theToUpdateViewer);
838 //=======================================================================
839 //function : RemoveAll
841 //=======================================================================
842 void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
844 AIS_ListOfInteractive aList;
845 ObjectsInside (aList);
846 for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
848 Remove (aListIterator.Value(), Standard_False);
851 if (theToUpdateViewer)
857 //=======================================================================
858 //function : ClearPrs
860 //=======================================================================
861 void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
862 const Standard_Integer theMode,
863 const Standard_Boolean theToUpdateViewer)
865 if (theIObj.IsNull())
870 if (!HasOpenedContext())
872 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
876 Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
877 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
879 if (aCtxIter.Value()->AcceptErase())
881 wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
886 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
888 else if (theToUpdateViewer)
894 //=======================================================================
897 //=======================================================================
898 void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj,
899 const Standard_Boolean theToUpdateViewer)
901 if (theIObj.IsNull())
906 if (!theIObj->HasInteractiveContext())
908 theIObj->SetContext (this);
910 if (!HasOpenedContext())
912 if (!myObjects.IsBound (theIObj))
917 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
918 aStatus->SetHilightStatus (Standard_True);
919 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
921 Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
922 myMainPM->Highlight (theIObj, aHilightMode);
927 myLocalContexts (myCurLocalIndex)->Hilight (theIObj);
930 if (theToUpdateViewer)
935 //=======================================================================
938 //=======================================================================
940 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
941 const Quantity_NameOfColor aCol,
942 const Standard_Boolean updateviewer)
944 if(anIObj.IsNull()) return;
946 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
948 if (!HasOpenedContext())
950 if(!myObjects.IsBound(anIObj)) return;
952 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
953 aStatus->SetHilightStatus (Standard_True);
955 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
957 const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
958 myMainPM->Color (anIObj, aCol, aHilightMode);
959 aStatus->SetHilightColor (aCol);
964 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
966 if(updateviewer) myMainVwr->Update();
969 //=======================================================================
970 //function : Unhilight
972 //=======================================================================
974 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
976 if(anIObj.IsNull()) return;
978 if (!HasOpenedContext())
980 if(!myObjects.IsBound(anIObj)) return;
982 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
983 aStatus->SetHilightStatus (Standard_False);
984 aStatus->SetHilightColor(Quantity_NOC_WHITE);
986 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
988 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
989 myMainPM->Unhighlight (anIObj, aHilightMode);
994 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
996 if(updateviewer) myMainVwr->Update();
999 //=======================================================================
1000 //function : IsHilighted
1002 //=======================================================================
1004 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1006 if(anIObj.IsNull()) return Standard_False;
1008 if (!HasOpenedContext()){
1009 if(!myObjects.IsBound(anIObj))
1010 return Standard_False;
1011 return myObjects(anIObj)->IsHilighted();
1013 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1014 for(;ItM.More();ItM.Next()){
1015 if(ItM.Value()->IsHilighted(anIObj))
1016 return Standard_True;
1018 return Standard_False;
1021 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1022 Standard_Boolean& WithColor,
1023 Quantity_NameOfColor& TheHiCol) const
1025 if(!HasOpenedContext()){
1026 if(myObjects.IsBound(anIObj)){
1027 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1028 if(STAT->IsHilighted()){
1029 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1030 WithColor=Standard_True;
1031 TheHiCol = STAT->HilightColor();
1034 WithColor = Standard_False;
1035 return Standard_True;
1038 return Standard_False;
1040 Standard_Integer MaxIndex = HighestIndex();
1041 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1042 if(myLocalContexts.IsBound(i)){
1043 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1044 return Standard_True;
1048 return Standard_False;
1053 //=======================================================================
1054 //function : IsDisplayed
1056 //=======================================================================
1058 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1060 if(anIObj.IsNull()) return Standard_False;
1063 if(myObjects.IsBound(anIObj))
1064 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1065 return Standard_True;
1067 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1068 for(;ItM.More();ItM.Next()){
1069 if(ItM.Value()->IsDisplayed(anIObj))
1070 return Standard_True;
1072 return Standard_False;
1076 //=======================================================================
1077 //function : IsDisplayed
1079 //=======================================================================
1080 Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
1081 const Standard_Integer theMode) const
1083 if (theIObj.IsNull())
1085 return Standard_False;
1088 if (myObjects.IsBound (theIObj))
1090 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1091 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1092 && aStatus->IsDModeIn (theMode))
1094 return Standard_True;
1098 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
1100 if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
1102 return Standard_True;
1105 return Standard_False;
1108 //=======================================================================
1109 //function : DisplayPriority
1111 //=======================================================================
1112 Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
1114 if (theIObj.IsNull())
1118 else if (!myObjects.IsBound (theIObj))
1123 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1124 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1125 || aStatus->GraphicStatus() == AIS_DS_Erased)
1127 Standard_Integer aDispMode = theIObj->HasDisplayMode()
1128 ? theIObj->DisplayMode()
1129 : (theIObj->AcceptDisplayMode (myDisplayMode)
1132 return myMainPM->DisplayPriority (theIObj, aDispMode);
1137 //=======================================================================
1138 //function : SetDisplayPriority
1140 //=======================================================================
1141 void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
1142 const Standard_Integer thePriority)
1144 if (theIObj.IsNull())
1149 if (!theIObj->HasInteractiveContext())
1151 theIObj->SetContext (this);
1154 if (myObjects.IsBound (theIObj))
1156 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1157 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1158 || aStatus->GraphicStatus() == AIS_DS_Erased)
1160 Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
1161 ? theIObj->DisplayMode()
1162 : (theIObj->AcceptDisplayMode (myDisplayMode)
1165 myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
1168 else if (HasOpenedContext())
1170 myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
1174 //=======================================================================
1175 //function : Redisplay
1177 //=======================================================================
1178 void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
1179 const Standard_Boolean theToUpdateViewer,
1180 const Standard_Boolean theAllModes)
1182 RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
1183 RecomputeSelectionOnly (theIObj);
1186 //=======================================================================
1187 //function : Redisplay
1189 //=======================================================================
1190 void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
1191 const Standard_Integer /*theSign*/,
1192 const Standard_Boolean theToUpdateViewer)
1194 Standard_Boolean isRedisplayed = Standard_False;
1195 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1197 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1198 if (anObj->Type() != theKOI)
1203 Redisplay (anObj, Standard_False);
1204 isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
1208 if (theToUpdateViewer
1211 myMainVwr->Update();
1215 //=======================================================================
1216 //function : RecomputePrsOnly
1218 //=======================================================================
1219 void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
1220 const Standard_Boolean theToUpdateViewer,
1221 const Standard_Boolean theAllModes)
1223 if (theIObj.IsNull())
1228 theIObj->Update (theAllModes);
1229 if (!theToUpdateViewer)
1234 if (HasOpenedContext()
1235 || (myObjects.IsBound (theIObj)
1236 && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
1238 myMainVwr->Update();
1241 //=======================================================================
1242 //function : RecomputeSelectionOnly
1244 //=======================================================================
1245 void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
1252 mgrSelector->RecomputeSelection (theIO);
1254 if (HasOpenedContext())
1256 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1258 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
1263 if (!myObjects.IsBound (theIO) ||
1264 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1269 TColStd_ListOfInteger aModes;
1270 ActivatedModes (theIO, aModes);
1271 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1272 for (; aModesIter.More(); aModesIter.Next())
1274 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
1278 //=======================================================================
1281 //=======================================================================
1282 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1283 const Standard_Boolean theUpdateViewer)
1285 if (theIObj.IsNull())
1290 TColStd_ListOfInteger aPrsModes;
1291 theIObj->ToBeUpdated (aPrsModes);
1292 for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
1294 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1297 mgrSelector->Update(theIObj);
1299 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1301 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1304 if (theUpdateViewer)
1306 if (!myObjects.IsBound (theIObj))
1311 switch (myObjects (theIObj)->GraphicStatus())
1313 case AIS_DS_Displayed:
1314 case AIS_DS_Temporary:
1315 myMainVwr->Update();
1323 //=======================================================================
1324 //function : SetLocation
1326 //=======================================================================
1327 void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
1328 const TopLoc_Location& theLoc)
1330 if (theIObj.IsNull())
1335 if (theIObj->HasTransformation()
1336 && theLoc.IsIdentity())
1338 theIObj->ResetTransformation();
1339 mgrSelector->Update (theIObj, Standard_False);
1342 else if (theLoc.IsIdentity())
1347 // first reset the previous location to properly clean everything...
1348 if (theIObj->HasTransformation())
1350 theIObj->ResetTransformation();
1353 theIObj->SetLocalTransformation (theLoc.Transformation());
1355 if (!HasOpenedContext())
1357 mgrSelector->Update (theIObj, Standard_False);
1361 Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
1362 mgrSelector->Update (theIObj, aTempSel, Standard_False);
1366 //=======================================================================
1367 //function : ResetLocation
1369 //=======================================================================
1370 void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
1372 if (theIObj.IsNull())
1377 theIObj->ResetTransformation();
1378 mgrSelector->Update (theIObj, Standard_False);
1381 //=======================================================================
1382 //function : HasLocation
1384 //=======================================================================
1385 Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
1387 return !theIObj.IsNull()
1388 && theIObj->HasTransformation();
1391 //=======================================================================
1392 //function : Location
1394 //=======================================================================
1395 TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
1397 return theIObj->Transformation();
1400 //=======================================================================
1401 //function : SetDeviationCoefficient
1403 //=======================================================================
1404 void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
1406 myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
1409 //=======================================================================
1410 //function : SetDeviationAngle
1412 //=======================================================================
1413 void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
1415 myDefaultDrawer->SetDeviationCoefficient (theAngle);
1418 //=======================================================================
1419 //function : DeviationAngle
1420 //purpose : Gets deviationAngle
1421 //=======================================================================
1422 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1424 return myDefaultDrawer->DeviationAngle();
1427 //=======================================================================
1428 //function : DeviationCoefficient
1430 //=======================================================================
1431 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1433 return myDefaultDrawer->DeviationCoefficient();
1436 //=======================================================================
1437 //function : SetHLRDeviationCoefficient
1439 //=======================================================================
1440 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
1442 myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
1445 //=======================================================================
1446 //function : HLRDeviationCoefficient
1448 //=======================================================================
1449 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1451 return myDefaultDrawer->HLRDeviationCoefficient();
1454 //=======================================================================
1455 //function : SetHLRAngle
1457 //=======================================================================
1458 void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
1460 myDefaultDrawer->SetHLRAngle (theAngle);
1463 //=======================================================================
1464 //function : SetHLRAngleAndDeviation
1465 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1466 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1467 // of myDefaultDrawer
1468 //=======================================================================
1469 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
1471 Standard_Real anOutAngl, anOutDefl;
1472 HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
1474 myDefaultDrawer->SetHLRAngle (anOutAngl);
1475 myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
1478 //=======================================================================
1479 //function : HLRAngle
1481 //=======================================================================
1482 Standard_Real AIS_InteractiveContext::HLRAngle() const
1484 return myDefaultDrawer->HLRAngle();
1487 //=======================================================================
1488 //function : SetDisplayMode
1490 //=======================================================================
1491 void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
1492 const Standard_Boolean theToUpdateViewer)
1494 if (theMode == myDisplayMode)
1499 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1501 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1502 Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
1503 || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
1504 || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
1507 || anObj->HasDisplayMode()
1508 || !anObj->AcceptDisplayMode (theMode))
1513 Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
1514 if (aStatus->IsDModeIn (myDisplayMode))
1516 aStatus->RemoveDisplayMode (myDisplayMode);
1519 aStatus->AddDisplayMode (theMode);
1520 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1522 myMainPM->Display (anObj, theMode);
1523 if (aStatus->IsSubIntensityOn())
1525 myMainPM->Color (anObj, mySubIntensity, theMode);
1527 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1531 myDisplayMode = theMode;
1532 if (theToUpdateViewer)
1534 myMainVwr->Update();
1538 //=======================================================================
1539 //function : SetDisplayMode
1541 //=======================================================================
1542 void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1543 const Standard_Integer theMode,
1544 const Standard_Boolean theToUpdateViewer)
1546 if (!theIObj->HasInteractiveContext())
1548 theIObj->SetContext(this);
1551 if (!myObjects.IsBound (theIObj))
1553 theIObj->SetDisplayMode (theMode);
1556 else if (!theIObj->AcceptDisplayMode (theMode))
1561 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1562 if (aStatus->GraphicStatus() != AIS_DS_Displayed)
1564 theIObj->SetDisplayMode (theMode);
1568 // erase presentations for all display modes different from <aMode>
1569 TColStd_ListOfInteger aModesToRemove;
1570 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
1572 const Standard_Integer anOldMode = aDispModeIter.Value();
1573 if (anOldMode != theMode)
1575 aModesToRemove.Append (anOldMode);
1576 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1578 myMainPM->Unhighlight (theIObj, anOldMode);
1580 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1584 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
1586 aStatus->RemoveDisplayMode (aRemModeIter.Value());
1589 if (!aStatus->IsDModeIn (theMode))
1591 aStatus->AddDisplayMode (theMode);
1594 myMainPM->Display (theIObj, theMode);
1595 Standard_Integer aDispMode, aHiMode, aSelMode;
1596 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1597 if (aStatus->IsHilighted())
1599 myMainPM->Highlight (theIObj, aHiMode);
1601 if (aStatus->IsSubIntensityOn())
1603 myMainPM->Color (theIObj, mySubIntensity, theMode);
1606 if (theToUpdateViewer)
1608 myMainVwr->Update();
1610 theIObj->SetDisplayMode (theMode);
1613 //=======================================================================
1614 //function : UnsetDisplayMode
1616 //=======================================================================
1617 void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1618 const Standard_Boolean theToUpdateViewer)
1620 if (theIObj.IsNull()
1621 || !theIObj->HasDisplayMode())
1626 if (!myObjects.IsBound (theIObj))
1628 theIObj->UnsetDisplayMode();
1632 const Standard_Integer anOldMode = theIObj->DisplayMode();
1633 if (myDisplayMode == anOldMode)
1638 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
1639 aStatus->RemoveDisplayMode (anOldMode);
1640 if (!aStatus->IsDModeIn(myDisplayMode))
1642 aStatus->AddDisplayMode (myDisplayMode);
1645 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1647 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1649 myMainPM->Unhighlight (theIObj, anOldMode);
1651 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1652 myMainPM->Display (theIObj, myDisplayMode);
1654 Standard_Integer aDispMode, aHiMode, aSelMode;
1655 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1656 if (aStatus->IsHilighted())
1658 myMainPM->Highlight (theIObj, aHiMode);
1660 if (aStatus->IsSubIntensityOn())
1662 myMainPM->Color (theIObj, mySubIntensity, myDisplayMode);
1665 if (theToUpdateViewer)
1667 myMainVwr->Update();
1671 theIObj->UnsetDisplayMode();
1674 //=======================================================================
1675 //function : SetCurrentFacingModel
1677 //=======================================================================
1678 void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
1679 const Aspect_TypeOfFacingModel theModel)
1681 if (!theIObj.IsNull())
1683 theIObj->SetCurrentFacingModel (theModel);
1687 //=======================================================================
1688 //function : redisplayPrsRecModes
1690 //=======================================================================
1691 void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1692 const Standard_Boolean theToUpdateViewer)
1694 if (theIObj->RecomputeEveryPrs())
1696 theIObj->Update (Standard_True);
1697 theIObj->UpdateSelection();
1701 for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
1703 theIObj->Update (aModes.Value(), Standard_False);
1705 theIObj->SetRecomputeOk();
1708 if (theToUpdateViewer)
1710 UpdateCurrentViewer();
1714 //=======================================================================
1715 //function : redisplayPrsModes
1717 //=======================================================================
1718 void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1719 const Standard_Boolean theToUpdateViewer)
1721 if (theIObj->RecomputeEveryPrs())
1723 theIObj->Update (Standard_True);
1724 theIObj->UpdateSelection();
1728 TColStd_ListOfInteger aModes;
1729 theIObj->ToBeUpdated (aModes);
1730 for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
1732 theIObj->Update (aModeIter.Value(), Standard_False);
1734 theIObj->SetRecomputeOk();
1737 if (theToUpdateViewer)
1739 UpdateCurrentViewer();
1743 //=======================================================================
1744 //function : SetColor
1746 //=======================================================================
1747 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1748 const Quantity_NameOfColor theColor,
1749 const Standard_Boolean theToUpdateViewer)
1751 SetColor (theIObj, Quantity_Color(theColor), theToUpdateViewer);
1754 //=======================================================================
1755 //function : SetColor
1757 //=======================================================================
1758 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1759 const Quantity_Color& theColor,
1760 const Standard_Boolean theToUpdateViewer)
1762 if (theIObj.IsNull())
1767 if (!theIObj->HasInteractiveContext())
1769 theIObj->SetContext (this);
1771 theIObj->SetColor (theColor);
1772 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1775 //=======================================================================
1776 //function : SetDeviationCoefficient
1778 //=======================================================================
1779 void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1780 const Standard_Real theCoefficient,
1781 const Standard_Boolean theToUpdateViewer)
1783 if (theIObj.IsNull())
1788 if (!theIObj->HasInteractiveContext())
1790 theIObj->SetContext (this);
1793 // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
1794 if (theIObj->Type() != AIS_KOI_Object
1795 && theIObj->Type() != AIS_KOI_Shape)
1799 else if (theIObj->Signature() != 0)
1804 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1805 aShape->SetOwnDeviationCoefficient (theCoefficient);
1806 redisplayPrsModes (theIObj, theToUpdateViewer);
1809 //=======================================================================
1810 //function : SetHLRDeviationCoefficient
1812 //=======================================================================
1813 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1814 const Standard_Real theCoefficient,
1815 const Standard_Boolean theToUpdateViewer)
1817 if (theIObj.IsNull())
1822 if (!theIObj->HasInteractiveContext())
1824 theIObj->SetContext (this);
1827 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1828 if (theIObj->Type() != AIS_KOI_Object
1829 && theIObj->Type() != AIS_KOI_Shape)
1833 else if (theIObj->Signature() != 0)
1838 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1839 aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
1840 redisplayPrsModes (theIObj, theToUpdateViewer);
1843 //=======================================================================
1844 //function : SetDeviationAngle
1846 //=======================================================================
1847 void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1848 const Standard_Real theAngle,
1849 const Standard_Boolean theToUpdateViewer)
1851 if (theIObj.IsNull())
1856 if (!theIObj->HasInteractiveContext())
1858 theIObj->SetContext (this);
1861 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1862 if (theIObj->Type() != AIS_KOI_Shape)
1866 else if (theIObj->Signature() != 0)
1871 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1872 aShape->SetOwnDeviationAngle (theAngle);
1873 redisplayPrsModes (theIObj, theToUpdateViewer);
1876 //=======================================================================
1877 //function : SetAngleAndDeviation
1879 //=======================================================================
1880 void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1881 const Standard_Real theAngle,
1882 const Standard_Boolean theToUpdateViewer)
1884 if (theIObj.IsNull())
1889 if (!theIObj->HasInteractiveContext())
1891 theIObj->SetContext (this);
1894 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1895 if (theIObj->Type() != AIS_KOI_Shape)
1899 if (theIObj->Signature() != 0)
1904 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1905 aShape->SetAngleAndDeviation (theAngle);
1907 if (theIObj->RecomputeEveryPrs())
1909 theIObj->Update (Standard_True);
1910 theIObj->UpdateSelection();
1914 Update (theIObj, theToUpdateViewer);
1918 //=======================================================================
1919 //function : SetHLRAngleAndDeviation
1921 //=======================================================================
1922 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1923 const Standard_Real theAngle,
1924 const Standard_Boolean theToUpdateViewer)
1926 if (theIObj.IsNull())
1931 if (!theIObj->HasInteractiveContext())
1933 theIObj->SetContext (this);
1936 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1937 if (theIObj->Type() != AIS_KOI_Shape)
1941 if (theIObj->Signature() != 0)
1945 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1946 aShape->SetHLRAngleAndDeviation (theAngle);
1947 redisplayPrsModes (theIObj, theToUpdateViewer);
1950 //=======================================================================
1951 //function : SetHLRDeviationAngle
1953 //=======================================================================
1954 void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1955 const Standard_Real theAngle,
1956 const Standard_Boolean theToUpdateViewer)
1958 if (theIObj.IsNull())
1963 if (!theIObj->HasInteractiveContext())
1965 theIObj->SetContext (this);
1968 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1969 if (theIObj->Type() != AIS_KOI_Shape)
1973 if (theIObj->Signature() != 0)
1977 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1978 aShape->SetOwnHLRDeviationAngle (theAngle);
1979 redisplayPrsModes (theIObj, theToUpdateViewer);
1982 //=======================================================================
1983 //function : UnsetColor
1985 //=======================================================================
1986 void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
1987 const Standard_Boolean theToUpdateViewer)
1989 if (theIObj.IsNull())
1994 theIObj->UnsetColor();
1995 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1998 //=======================================================================
1999 //function : HasColor
2001 //=======================================================================
2002 Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
2004 return theIObj->HasColor();
2007 //=======================================================================
2010 //=======================================================================
2011 Quantity_NameOfColor AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj) const
2013 return theIObj->Color();
2016 //=======================================================================
2019 //=======================================================================
2020 void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
2021 Quantity_Color& theColor) const
2023 theIObj->Color (theColor);
2026 //=======================================================================
2029 //=======================================================================
2030 Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
2032 return theIObj->Width();
2035 //=======================================================================
2036 //function : SetWidth
2038 //=======================================================================
2039 void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2040 const Standard_Real theWidth,
2041 const Standard_Boolean theToUpdateViewer)
2043 if (theIObj.IsNull())
2048 if (!theIObj->HasInteractiveContext())
2050 theIObj->SetContext (this);
2053 theIObj->SetWidth (theWidth);
2054 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2057 //=======================================================================
2058 //function : UnsetWidth
2060 //=======================================================================
2061 void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2062 const Standard_Boolean theToUpdateViewer)
2064 if (theIObj.IsNull())
2069 theIObj->UnsetWidth();
2070 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2073 //=======================================================================
2074 //function : SetMaterial
2076 //=======================================================================
2077 void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2078 const Graphic3d_NameOfMaterial theName,
2079 const Standard_Boolean theToUpdateViewer)
2081 if (theIObj.IsNull())
2086 if (!theIObj->HasInteractiveContext())
2088 theIObj->SetContext (this);
2091 theIObj->SetMaterial (theName);
2092 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2095 //=======================================================================
2096 //function : UnsetMaterial
2098 //=======================================================================
2099 void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2100 const Standard_Boolean theToUpdateViewer)
2102 if (theIObj.IsNull())
2106 theIObj->UnsetMaterial();
2107 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2110 //=======================================================================
2111 //function : SetTransparency
2113 //=======================================================================
2114 void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2115 const Standard_Real theValue,
2116 const Standard_Boolean theToUpdateViewer)
2118 if (theIObj.IsNull())
2123 if (!theIObj->HasInteractiveContext())
2125 theIObj->SetContext (this);
2128 if (!theIObj->IsTransparent()
2129 && theValue <= 0.05)
2134 if (theValue <= 0.05)
2136 UnsetTransparency (theIObj, theToUpdateViewer);
2140 theIObj->SetTransparency (theValue);
2141 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2144 //=======================================================================
2145 //function : UnsetTransparency
2147 //=======================================================================
2148 void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2149 const Standard_Boolean theToUpdateViewer)
2151 if (theIObj.IsNull())
2156 theIObj->UnsetTransparency();
2157 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2160 //=======================================================================
2161 //function : SetSelectedAspect
2163 //=======================================================================
2164 void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
2165 const Standard_Boolean theIsGlobalChange,
2166 const Standard_Boolean theToUpdateViewer)
2168 if (HasOpenedContext())
2173 Standard_Boolean isFound = Standard_False;
2174 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
2175 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
2177 isFound = Standard_True;
2178 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
2179 anObj->SetAspect (theAspect, theIsGlobalChange);
2183 && theToUpdateViewer)
2185 myMainVwr->Update();
2189 //=======================================================================
2190 //function : SetLocalAttributes
2192 //=======================================================================
2193 void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2194 const Handle(Prs3d_Drawer)& theDrawer,
2195 const Standard_Boolean theToUpdateViewer)
2197 if (theIObj.IsNull())
2202 if (!theIObj->HasInteractiveContext())
2204 theIObj->SetContext (this);
2207 theIObj->SetAttributes (theDrawer);
2208 Update (theIObj, theToUpdateViewer);
2211 //=======================================================================
2212 //function : UnsetLocalAttributes
2214 //=======================================================================
2215 void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2216 const Standard_Boolean theToUpdateViewer)
2218 if (theIObj.IsNull())
2223 if (!theIObj->HasInteractiveContext())
2225 theIObj->SetContext (this);
2227 theIObj->UnsetAttributes();
2228 Update (theIObj, theToUpdateViewer);
2231 //=======================================================================
2234 //=======================================================================
2235 void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
2236 TCollection_ExtendedString& theStatus) const
2239 if (theIObj.IsNull()
2240 || !myObjects.IsBound (theIObj))
2245 theStatus += "\t ____________________________________________";
2246 theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2247 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2248 switch (aStatus->GraphicStatus())
2250 case AIS_DS_Displayed:
2252 theStatus += "\t| -->Displayed\n";
2257 theStatus += "\t| -->Erased\n";
2264 theStatus += "\t| Active Display Modes in the MainViewer :\n";
2265 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2267 theStatus += "\t|\t Mode ";
2268 theStatus += TCollection_AsciiString (aDispModeIter.Value());
2271 if (IsCurrent (theIObj)) theStatus +="\t| Current\n";
2272 if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
2274 theStatus += "\t| Active Selection Modes in the MainViewer :\n";
2275 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2277 theStatus += "\t\t Mode ";
2278 theStatus += TCollection_AsciiString (aSelModeIter.Value());
2281 theStatus += "\t ____________________________________________";
2284 //=======================================================================
2285 //function : GetDefModes
2287 //=======================================================================
2288 void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
2289 Standard_Integer& theDispMode,
2290 Standard_Integer& theHiMode,
2291 Standard_Integer& theSelMode) const
2293 if (theIObj.IsNull())
2298 theDispMode = theIObj->HasDisplayMode()
2299 ? theIObj->DisplayMode()
2300 : (theIObj->AcceptDisplayMode (myDisplayMode)
2303 theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
2304 theSelMode = theIObj->HasSelectionMode() ? theIObj->SelectionMode() : -1;
2307 //=======================================================================
2308 //function : EraseGlobal
2310 //=======================================================================
2311 void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2312 const Standard_Boolean theToUpdateviewer)
2314 if (theIObj.IsNull()
2315 || !myObjects.IsBound (theIObj))
2320 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2322 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2323 if (aStatus->GraphicStatus() == AIS_DS_Temporary
2324 || aStatus->GraphicStatus() == AIS_DS_Erased)
2329 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2331 if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2333 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2336 myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
2339 if (IsCurrent (theIObj)
2340 && !aStatus->IsDModeIn (aDispMode))
2342 myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
2345 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2347 mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
2349 aStatus->SetGraphicStatus (AIS_DS_Erased);
2351 if (theToUpdateviewer)
2353 myMainVwr->Update();
2357 //=======================================================================
2358 //function : ClearGlobal
2360 //=======================================================================
2361 void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2362 const Standard_Boolean theToUpdateviewer)
2364 if (theIObj.IsNull()
2365 || !myObjects.IsBound (theIObj))
2370 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2371 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2373 if (aStatus->IsHilighted())
2375 if (IsCurrent (theIObj))
2377 AddOrRemoveCurrentObject (theIObj, theToUpdateviewer);
2379 else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2381 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2384 myMainPM->Erase (theIObj, aDispModeIter.Value());
2385 myMainPM->Clear (theIObj, aDispModeIter.Value());
2386 if (theIObj->HasHilightMode())
2388 Standard_Integer im = theIObj->HilightMode();
2389 myMainPM->Unhighlight (theIObj, im);
2390 myMainPM->Erase (theIObj, im);
2394 // Object removes from Detected sequence
2395 for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
2397 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2399 && anObj != theIObj)
2401 myAISDetectedSeq.Remove (aDetIter);
2405 if (myLastinMain == theIObj)
2407 myLastinMain.Nullify();
2409 if (myLastPicked == theIObj)
2411 myLastPicked.Nullify();
2414 // remove IO from the selection manager to avoid memory leaks
2415 mgrSelector->Remove (theIObj);
2417 myObjects.UnBind (theIObj);
2418 myMainVwr->Viewer()->UnregisterObject (theIObj);
2419 for (myMainVwr->InitDefinedViews(); myMainVwr->MoreDefinedViews(); myMainVwr->NextDefinedViews())
2421 myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj);
2424 if (theToUpdateviewer
2425 && aStatus->GraphicStatus() == AIS_DS_Displayed)
2427 myMainVwr->Update();
2431 //=======================================================================
2432 //function : ClearGlobalPrs
2434 //=======================================================================
2435 void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
2436 const Standard_Integer theMode,
2437 const Standard_Boolean theToUpdateViewer)
2439 if (theIObj.IsNull()
2440 || !myObjects.IsBound (theIObj))
2445 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2446 if (aStatus->IsDModeIn (theMode))
2448 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2449 if (aDispMode == theMode
2450 && myMainPM->IsHighlighted (theIObj, theMode))
2452 myMainPM->Unhighlight (theIObj, theMode);
2455 myMainPM->Erase (theIObj, theMode);
2456 myMainPM->Clear (theIObj, theMode);
2459 if (aStatus->GraphicStatus() == AIS_DS_Displayed
2460 && theToUpdateViewer)
2462 myMainVwr->Update();
2466 //=======================================================================
2467 //function : DrawHiddenLine
2469 //=======================================================================
2470 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
2472 return myDefaultDrawer->DrawHiddenLine();
2475 //=======================================================================
2476 //function : EnableDrawHiddenLine
2478 //=======================================================================
2479 void AIS_InteractiveContext::EnableDrawHiddenLine() const
2481 myDefaultDrawer->EnableDrawHiddenLine();
2484 //=======================================================================
2485 //function : DisableDrawHiddenLine
2487 //=======================================================================
2488 void AIS_InteractiveContext::DisableDrawHiddenLine() const
2490 myDefaultDrawer->DisableDrawHiddenLine();
2493 //=======================================================================
2494 //function : HiddenLineAspect
2496 //=======================================================================
2497 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
2499 return myDefaultDrawer->HiddenLineAspect();
2502 //=======================================================================
2503 //function : SetHiddenLineAspect
2505 //=======================================================================
2506 void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
2508 myDefaultDrawer->SetHiddenLineAspect (theAspect);
2511 //=======================================================================
2512 //function : SetIsoNumber
2514 //=======================================================================
2515 void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
2516 const AIS_TypeOfIso theType)
2521 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2524 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2527 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2528 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2533 //=======================================================================
2534 //function : IsoNumber
2536 //=======================================================================
2537 Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
2541 case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
2542 case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
2543 case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
2544 ? myDefaultDrawer->UIsoAspect()->Number()
2550 //=======================================================================
2551 //function : IsoOnPlane
2553 //=======================================================================
2554 void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
2556 myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
2559 //=======================================================================
2560 //function : IsoOnPlane
2562 //=======================================================================
2563 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2565 return myDefaultDrawer->IsoOnPlane();
2568 //=======================================================================
2569 //function : SetSelectionMode
2571 //=======================================================================
2572 void AIS_InteractiveContext::SetSelectionMode (const Handle(AIS_InteractiveObject)& ,
2573 const Standard_Integer )
2578 //=======================================================================
2579 //function : UnsetSelectionMode
2581 //=======================================================================
2582 void AIS_InteractiveContext::UnsetSelectionMode (const Handle(AIS_InteractiveObject)& )
2587 //=======================================================================
2588 //function : SetSensitivityMode
2590 //=======================================================================
2591 void AIS_InteractiveContext::SetSensitivityMode (const StdSelect_SensitivityMode theMode)
2593 if (HasOpenedContext())
2595 myLocalContexts (myCurLocalIndex)->SetSensitivityMode (theMode);
2599 myMainSel->SetSensitivityMode (theMode);
2603 //=======================================================================
2604 //function : SensitivityMode
2606 //=======================================================================
2607 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const
2609 return HasOpenedContext()
2610 ? myLocalContexts (myCurLocalIndex)->SensitivityMode()
2611 : myMainSel->SensitivityMode();
2614 //=======================================================================
2615 //function : SetSensitivity
2617 //=======================================================================
2618 void AIS_InteractiveContext::SetSensitivity (const Standard_Real thePrecision)
2620 if (HasOpenedContext())
2622 myLocalContexts(myCurLocalIndex)->SetSensitivity (thePrecision);
2626 myMainSel->SetSensitivity (thePrecision);
2630 //=======================================================================
2631 //function : Sensitivity
2633 //=======================================================================
2634 Standard_Real AIS_InteractiveContext::Sensitivity() const
2636 return HasOpenedContext()
2637 ? myLocalContexts(myCurLocalIndex)->Sensitivity()
2638 : myMainSel->Sensitivity();
2641 //=======================================================================
2642 //function : SetPixelTolerance
2644 //=======================================================================
2645 void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
2647 if (HasOpenedContext())
2649 myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
2653 myMainSel->SetPixelTolerance (thePrecision);
2657 //=======================================================================
2658 //function : PixelTolerance
2660 //=======================================================================
2661 Standard_Integer AIS_InteractiveContext::PixelTolerance() const
2663 return HasOpenedContext()
2664 ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
2665 : myMainSel->PixelTolerance();
2668 //=======================================================================
2669 //function : IsInLocal
2671 //=======================================================================
2672 Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
2673 Standard_Integer& theIndex) const
2675 if (theIObj.IsNull())
2677 return Standard_False;
2680 // if it exists at neutral point 0 index is returned
2681 if (myObjects.IsBound (theIObj))
2684 return Standard_False;
2687 for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
2689 if (myLocalContexts.IsBound (aCtxIter))
2691 if(myLocalContexts (aCtxIter)->IsIn (theIObj))
2693 theIndex = aCtxIter;
2694 return Standard_True;
2699 return Standard_False;
2702 //=======================================================================
2703 //function : InitAttributes
2705 //=======================================================================
2706 void AIS_InteractiveContext::InitAttributes()
2708 mgrSelector->Add (myMainSel);
2709 myCurrentName = AIS_Context_NewCurName();
2710 mySelectionName = AIS_Context_NewSelName();
2712 AIS_Selection::CreateSelection (mySelectionName.ToCString());
2713 AIS_Selection::CreateSelection (myCurrentName.ToCString());
2715 myDefaultDrawer->SetShadingAspectGlobal (Standard_False);
2716 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
2717 myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
2719 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2720 Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
2721 aLineAspect->SetColor (Quantity_NOC_GRAY20);
2722 aLineAspect->SetWidth (1.0);
2723 aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
2725 // tolerance to 4 pixels...
2726 SetPixelTolerance();
2728 // Customizing the drawer for trihedrons and planes...
2729 Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
2730 const Standard_Real aLength = 100.0;
2731 aTrihAspect->SetAxisLength (aLength, aLength, aLength);
2732 const Quantity_NameOfColor aColor = Quantity_NOC_LIGHTSTEELBLUE4;
2733 aTrihAspect->FirstAxisAspect() ->SetColor (aColor);
2734 aTrihAspect->SecondAxisAspect()->SetColor (aColor);
2735 aTrihAspect->ThirdAxisAspect() ->SetColor (aColor);
2737 Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
2738 const Standard_Real aPlaneLength = 200.0;
2739 aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
2740 aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
2743 //=======================================================================
2744 //function : TrihedronSize
2746 //=======================================================================
2747 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2749 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2752 //=======================================================================
2753 //function : SetTrihedronSize
2755 //=======================================================================
2756 void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
2757 const Standard_Boolean /*updateviewer*/)
2759 myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
2760 Redisplay (AIS_KOI_Datum, 3, Standard_False);
2761 Redisplay (AIS_KOI_Datum, 4, Standard_True);
2764 //=======================================================================
2765 //function : SetPlaneSize
2767 //=======================================================================
2768 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
2769 const Standard_Real theValY,
2770 const Standard_Boolean /*updateviewer*/)
2772 myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
2773 Redisplay (AIS_KOI_Datum, 7);
2776 //=======================================================================
2777 //function : SetPlaneSize
2779 //=======================================================================
2780 void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
2781 const Standard_Boolean theToUpdateViewer)
2783 SetPlaneSize (theVal, theVal, theToUpdateViewer);
2786 //=======================================================================
2787 //function : PlaneSize
2789 //=======================================================================
2790 Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
2791 Standard_Real& theY) const
2793 theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2794 theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2795 return (Abs (theX - theY) <= Precision::Confusion());
2798 //=======================================================================
2799 //function : SetAutoActivateSelection
2801 //=======================================================================
2802 void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
2804 myIsAutoActivateSelMode = theIsAuto;
2807 //=======================================================================
2808 //function : GetAutoActivateSelection
2810 //=======================================================================
2811 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2813 return myIsAutoActivateSelMode;
2816 //=======================================================================
2817 //function : SetZLayer
2819 //=======================================================================
2820 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2821 const Standard_Integer theLayerId)
2823 if (theIObj.IsNull())
2826 theIObj->SetZLayer (theLayerId);
2829 //=======================================================================
2830 //function : GetZLayer
2832 //=======================================================================
2833 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2835 return !theIObj.IsNull()
2837 : Graphic3d_ZLayerId_UNKNOWN;