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 //=======================================================================
328 //=======================================================================
329 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
330 const Standard_Boolean theToUpdateViewer)
332 if (theIObj.IsNull())
337 Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
338 GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
340 Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
341 theToUpdateViewer, theIObj->AcceptShapeDecomposition());
344 //=======================================================================
347 //=======================================================================
348 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
349 const Standard_Integer theDispMode,
350 const Standard_Integer theSelectionMode,
351 const Standard_Boolean theToUpdateViewer,
352 const Standard_Boolean theToAllowDecomposition,
353 const AIS_DisplayStatus theDispStatus)
355 if (theIObj.IsNull())
360 if (theDispStatus == AIS_DS_Erased)
362 Erase (theIObj, theToUpdateViewer);
363 Load (theIObj, theSelectionMode, theToAllowDecomposition);
367 if (!theIObj->HasInteractiveContext())
369 theIObj->SetContext (this);
372 if (theDispStatus == AIS_DS_Temporary
373 && !HasOpenedContext())
377 else if (HasOpenedContext())
379 if (theDispStatus == AIS_DS_None
380 || theDispStatus == AIS_DS_Temporary)
382 myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
383 if (theToUpdateViewer)
391 if (!myObjects.IsBound (theIObj))
393 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
394 myObjects.Bind (theIObj, aStatus);
395 myMainPM->Display(theIObj, theDispMode);
396 if (theSelectionMode != -1)
398 if (!mgrSelector->Contains (theIObj))
400 mgrSelector->Load (theIObj);
402 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
407 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
408 if (aStatus->GraphicStatus() == AIS_DS_Temporary)
413 // Erase presentations for all display modes different from aDispMode.
414 // Then make sure aDispMode is displayed and maybe highlighted.
415 // Finally, activate selection mode <SelMode> if not yet activated.
416 TColStd_ListOfInteger aModesToRemove;
417 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
419 const Standard_Integer anOldMode = aDispModeIter.Value();
420 if (anOldMode != theDispMode)
422 aModesToRemove.Append (anOldMode);
423 if(myMainPM->IsHighlighted (theIObj, anOldMode))
425 myMainPM->Unhighlight (theIObj, anOldMode);
427 myMainPM->Erase (theIObj, anOldMode);
431 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
433 aStatus->RemoveDisplayMode (aRemModeIter.Value());
436 if (!aStatus->IsDModeIn (theDispMode))
438 aStatus->AddDisplayMode (theDispMode);
441 myMainPM->Display (theIObj, theDispMode);
442 aStatus->SetGraphicStatus (AIS_DS_Displayed);
443 if (aStatus->IsHilighted())
445 const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
446 myMainPM->Highlight (theIObj, aHiMod);
448 if (theSelectionMode != -1)
450 if (!mgrSelector->Contains (theIObj))
452 mgrSelector->Load (theIObj);
454 if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
456 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
461 if (theToUpdateViewer)
467 //=======================================================================
470 //=======================================================================
471 void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
472 const Standard_Integer theSelMode,
473 const Standard_Boolean theToAllowDecomposition)
475 if (theIObj.IsNull())
480 if (!theIObj->HasInteractiveContext())
482 theIObj->SetContext (this);
485 if (HasOpenedContext())
487 myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
492 && !theToAllowDecomposition)
494 if (!myObjects.IsBound (theIObj))
496 Standard_Integer aDispMode, aHiMod, aSelModeDef;
497 GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
498 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, aSelModeDef);
499 myObjects.Bind (theIObj, aStatus);
502 // Register theIObj in the selection manager to prepare further activation of selection
503 if (!mgrSelector->Contains (theIObj))
505 mgrSelector->Load (theIObj);
510 //=======================================================================
513 //=======================================================================
514 void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
515 const Standard_Boolean theToUpdateViewer)
517 if (theIObj.IsNull())
522 if (!theIObj->IsAutoHilight())
524 theIObj->ClearSelected();
527 Standard_Boolean wasInCtx = Standard_False;
528 if (HasOpenedContext())
530 // First it is checked if it is possible to remove in the current local context
531 // then one tries to remove in other local contexts, if they allow it...
532 wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
533 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
535 if (aCtxIter.Value()->AcceptErase())
537 wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
544 EraseGlobal (theIObj, Standard_False);
547 if (theToUpdateViewer)
553 //=======================================================================
554 //function : EraseAll
556 //=======================================================================
557 void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
559 if (HasOpenedContext())
564 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
566 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
568 Erase (anObjIter.Key(), Standard_False);
572 if (theToUpdateViewer)
578 //=======================================================================
579 //function : DisplayAll
581 //=======================================================================
582 void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
584 if (HasOpenedContext())
589 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
591 const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
592 if (aStatus == AIS_DS_Erased)
594 Display (anObjIter.Key(), Standard_False);
598 if (theToUpdateViewer)
604 //=======================================================================
605 //function : DisplaySelected
607 //=======================================================================
608 void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
610 if (HasOpenedContext())
615 Standard_Boolean isFound = Standard_False;
616 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
617 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
619 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
620 Display (anObj, Standard_False);
621 isFound = Standard_True;
624 if (isFound && theToUpdateViewer)
630 //=======================================================================
631 //function : EraseSelected
633 //=======================================================================
634 void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
636 if (HasOpenedContext())
641 Standard_Boolean isFound = Standard_False;
642 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString());
643 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
645 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
646 Erase (anObj, Standard_False);
647 isFound = Standard_True;
650 if (isFound && theToUpdateViewer)
656 //=======================================================================
659 //=======================================================================
661 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
662 const Standard_Integer WhichContext)
664 if(anIObj.IsNull()) return Standard_False;
666 if(!HasOpenedContext()) return Standard_False;
667 if(myObjects.IsBound(anIObj)) return Standard_False;
668 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
670 // Protection : if one tries to preserve a temporary object
671 // which is not in the local active context... rob 11-06-97
673 Standard_Integer IsItInLocal = myCurLocalIndex;
674 Standard_Boolean Found(Standard_False);
676 while(IsItInLocal>0 && !Found){
677 if(!myLocalContexts.IsBound(IsItInLocal))
679 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
680 Found = Standard_True;
685 if(!Found) return Standard_False;
688 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
689 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
691 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
692 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
696 if(LS->IsTemporary()){
697 Standard_Integer DM,HM,SM;
698 GetDefModes(anIObj,DM,HM,SM);
700 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
701 if(LS->DisplayMode()!= DM ){
702 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
703 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
706 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
710 // GS->SubIntensityOn();
711 myObjects.Bind(anIObj,GS);
712 mgrSelector->Load(anIObj);
713 mgrSelector->Activate(anIObj,SM,myMainSel);
715 LS->SetTemporary(Standard_False);
717 return Standard_True;
720 //=======================================================================
721 //function : DisplayStatus
723 //=======================================================================
724 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
726 if (theIObj.IsNull())
730 else if (myObjects.IsBound (theIObj))
732 return myObjects (theIObj)->GraphicStatus();
735 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
737 if (aCtxIter.Value()->IsIn (theIObj))
739 return AIS_DS_Temporary;
745 //=======================================================================
746 //function : DisplayedModes
748 //=======================================================================
749 const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
751 return myObjects (theIObj)->DisplayedModes();
754 //=======================================================================
757 //=======================================================================
758 void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
759 const Standard_Boolean theToUpdateViewer)
761 if (theIObj.IsNull())
766 if (HasOpenedContext())
768 myLocalContexts (myCurLocalIndex)->Remove (theIObj);
769 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
771 if (aCtxIter.Value()->AcceptErase())
773 aCtxIter.Value()->Remove (theIObj);
778 ClearGlobal (theIObj, theToUpdateViewer);
781 //=======================================================================
782 //function : RemoveAll
784 //=======================================================================
785 void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
787 AIS_ListOfInteractive aList;
788 ObjectsInside (aList);
789 for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
791 Remove (aListIterator.Value(), Standard_False);
794 if (theToUpdateViewer)
800 //=======================================================================
801 //function : ClearPrs
803 //=======================================================================
804 void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
805 const Standard_Integer theMode,
806 const Standard_Boolean theToUpdateViewer)
808 if (theIObj.IsNull())
813 if (!HasOpenedContext())
815 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
819 Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
820 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
822 if (aCtxIter.Value()->AcceptErase())
824 wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
829 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
831 else if (theToUpdateViewer)
837 //=======================================================================
840 //=======================================================================
841 void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj,
842 const Standard_Boolean theToUpdateViewer)
844 if (theIObj.IsNull())
849 if (!theIObj->HasInteractiveContext())
851 theIObj->SetContext (this);
853 if (!HasOpenedContext())
855 if (!myObjects.IsBound (theIObj))
860 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
861 aStatus->SetHilightStatus (Standard_True);
862 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
864 Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
865 myMainPM->Highlight (theIObj, aHilightMode);
870 myLocalContexts (myCurLocalIndex)->Hilight (theIObj);
873 if (theToUpdateViewer)
878 //=======================================================================
881 //=======================================================================
883 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
884 const Quantity_NameOfColor aCol,
885 const Standard_Boolean updateviewer)
887 if(anIObj.IsNull()) return;
889 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
891 if (!HasOpenedContext())
893 if(!myObjects.IsBound(anIObj)) return;
895 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
896 aStatus->SetHilightStatus (Standard_True);
898 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
900 const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
901 myMainPM->Color (anIObj, aCol, aHilightMode);
902 aStatus->SetHilightColor (aCol);
907 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
909 if(updateviewer) myMainVwr->Update();
912 //=======================================================================
913 //function : Unhilight
915 //=======================================================================
917 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
919 if(anIObj.IsNull()) return;
921 if (!HasOpenedContext())
923 if(!myObjects.IsBound(anIObj)) return;
925 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
926 aStatus->SetHilightStatus (Standard_False);
927 aStatus->SetHilightColor(Quantity_NOC_WHITE);
929 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
931 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
932 myMainPM->Unhighlight (anIObj, aHilightMode);
937 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
939 if(updateviewer) myMainVwr->Update();
942 //=======================================================================
943 //function : IsHilighted
945 //=======================================================================
947 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
949 if(anIObj.IsNull()) return Standard_False;
951 if (!HasOpenedContext()){
952 if(!myObjects.IsBound(anIObj))
953 return Standard_False;
954 return myObjects(anIObj)->IsHilighted();
956 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
957 for(;ItM.More();ItM.Next()){
958 if(ItM.Value()->IsHilighted(anIObj))
959 return Standard_True;
961 return Standard_False;
964 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
965 Standard_Boolean& WithColor,
966 Quantity_NameOfColor& TheHiCol) const
968 if(!HasOpenedContext()){
969 if(myObjects.IsBound(anIObj)){
970 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
971 if(STAT->IsHilighted()){
972 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
973 WithColor=Standard_True;
974 TheHiCol = STAT->HilightColor();
977 WithColor = Standard_False;
978 return Standard_True;
981 return Standard_False;
983 Standard_Integer MaxIndex = HighestIndex();
984 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
985 if(myLocalContexts.IsBound(i)){
986 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
987 return Standard_True;
991 return Standard_False;
996 //=======================================================================
997 //function : IsDisplayed
999 //=======================================================================
1001 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1003 if(anIObj.IsNull()) return Standard_False;
1006 if(myObjects.IsBound(anIObj))
1007 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1008 return Standard_True;
1010 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1011 for(;ItM.More();ItM.Next()){
1012 if(ItM.Value()->IsDisplayed(anIObj))
1013 return Standard_True;
1015 return Standard_False;
1019 //=======================================================================
1020 //function : IsDisplayed
1022 //=======================================================================
1023 Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
1024 const Standard_Integer theMode) const
1026 if (theIObj.IsNull())
1028 return Standard_False;
1031 if (myObjects.IsBound (theIObj))
1033 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1034 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1035 && aStatus->IsDModeIn (theMode))
1037 return Standard_True;
1041 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
1043 if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
1045 return Standard_True;
1048 return Standard_False;
1051 //=======================================================================
1052 //function : DisplayPriority
1054 //=======================================================================
1055 Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
1057 if (theIObj.IsNull())
1061 else if (!myObjects.IsBound (theIObj))
1066 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1067 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1068 || aStatus->GraphicStatus() == AIS_DS_Erased)
1070 Standard_Integer aDispMode = theIObj->HasDisplayMode()
1071 ? theIObj->DisplayMode()
1072 : (theIObj->AcceptDisplayMode (myDisplayMode)
1075 return myMainPM->DisplayPriority (theIObj, aDispMode);
1080 //=======================================================================
1081 //function : SetDisplayPriority
1083 //=======================================================================
1084 void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
1085 const Standard_Integer thePriority)
1087 if (theIObj.IsNull())
1092 if (!theIObj->HasInteractiveContext())
1094 theIObj->SetContext (this);
1097 if (myObjects.IsBound (theIObj))
1099 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1100 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1101 || aStatus->GraphicStatus() == AIS_DS_Erased)
1103 Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
1104 ? theIObj->DisplayMode()
1105 : (theIObj->AcceptDisplayMode (myDisplayMode)
1108 myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
1111 else if (HasOpenedContext())
1113 myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
1117 //=======================================================================
1118 //function : Redisplay
1120 //=======================================================================
1121 void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
1122 const Standard_Boolean theToUpdateViewer,
1123 const Standard_Boolean theAllModes)
1125 RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
1126 RecomputeSelectionOnly (theIObj);
1129 //=======================================================================
1130 //function : Redisplay
1132 //=======================================================================
1133 void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
1134 const Standard_Integer /*theSign*/,
1135 const Standard_Boolean theToUpdateViewer)
1137 Standard_Boolean isRedisplayed = Standard_False;
1138 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1140 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1141 if (anObj->Type() != theKOI)
1146 Redisplay (anObj, Standard_False);
1147 isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
1151 if (theToUpdateViewer
1154 myMainVwr->Update();
1158 //=======================================================================
1159 //function : RecomputePrsOnly
1161 //=======================================================================
1162 void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
1163 const Standard_Boolean theToUpdateViewer,
1164 const Standard_Boolean theAllModes)
1166 if (theIObj.IsNull())
1171 theIObj->Update (theAllModes);
1172 if (!theToUpdateViewer)
1177 if (HasOpenedContext()
1178 || (myObjects.IsBound (theIObj)
1179 && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
1181 myMainVwr->Update();
1184 //=======================================================================
1185 //function : RecomputeSelectionOnly
1187 //=======================================================================
1188 void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
1195 mgrSelector->RecomputeSelection (theIO);
1197 if (HasOpenedContext())
1199 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1201 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
1206 if (!myObjects.IsBound (theIO) ||
1207 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1212 TColStd_ListOfInteger aModes;
1213 ActivatedModes (theIO, aModes);
1214 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1215 for (; aModesIter.More(); aModesIter.Next())
1217 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
1221 //=======================================================================
1224 //=======================================================================
1225 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1226 const Standard_Boolean theUpdateViewer)
1228 if (theIObj.IsNull())
1233 TColStd_ListOfInteger aPrsModes;
1234 theIObj->ToBeUpdated (aPrsModes);
1235 for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
1237 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1240 mgrSelector->Update(theIObj);
1242 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1244 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1247 if (theUpdateViewer)
1249 if (!myObjects.IsBound (theIObj))
1254 switch (myObjects (theIObj)->GraphicStatus())
1256 case AIS_DS_Displayed:
1257 case AIS_DS_Temporary:
1258 myMainVwr->Update();
1266 //=======================================================================
1267 //function : SetLocation
1269 //=======================================================================
1270 void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
1271 const TopLoc_Location& theLoc)
1273 if (theIObj.IsNull())
1278 if (theIObj->HasTransformation()
1279 && theLoc.IsIdentity())
1281 theIObj->ResetTransformation();
1282 mgrSelector->Update (theIObj, Standard_False);
1285 else if (theLoc.IsIdentity())
1290 // first reset the previous location to properly clean everything...
1291 if (theIObj->HasTransformation())
1293 theIObj->ResetTransformation();
1296 theIObj->SetLocalTransformation (theLoc.Transformation());
1298 if (!HasOpenedContext())
1300 mgrSelector->Update (theIObj, Standard_False);
1304 Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
1305 mgrSelector->Update (theIObj, aTempSel, Standard_False);
1309 //=======================================================================
1310 //function : ResetLocation
1312 //=======================================================================
1313 void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
1315 if (theIObj.IsNull())
1320 theIObj->ResetTransformation();
1321 mgrSelector->Update (theIObj, Standard_False);
1324 //=======================================================================
1325 //function : HasLocation
1327 //=======================================================================
1328 Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
1330 return !theIObj.IsNull()
1331 && theIObj->HasTransformation();
1334 //=======================================================================
1335 //function : Location
1337 //=======================================================================
1338 TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
1340 return theIObj->Transformation();
1343 //=======================================================================
1344 //function : SetDeviationCoefficient
1346 //=======================================================================
1347 void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
1349 myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
1352 //=======================================================================
1353 //function : SetDeviationAngle
1355 //=======================================================================
1356 void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
1358 myDefaultDrawer->SetDeviationCoefficient (theAngle);
1361 //=======================================================================
1362 //function : DeviationAngle
1363 //purpose : Gets deviationAngle
1364 //=======================================================================
1365 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1367 return myDefaultDrawer->DeviationAngle();
1370 //=======================================================================
1371 //function : DeviationCoefficient
1373 //=======================================================================
1374 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1376 return myDefaultDrawer->DeviationCoefficient();
1379 //=======================================================================
1380 //function : SetHLRDeviationCoefficient
1382 //=======================================================================
1383 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
1385 myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
1388 //=======================================================================
1389 //function : HLRDeviationCoefficient
1391 //=======================================================================
1392 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1394 return myDefaultDrawer->HLRDeviationCoefficient();
1397 //=======================================================================
1398 //function : SetHLRAngle
1400 //=======================================================================
1401 void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
1403 myDefaultDrawer->SetHLRAngle (theAngle);
1406 //=======================================================================
1407 //function : SetHLRAngleAndDeviation
1408 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1409 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1410 // of myDefaultDrawer
1411 //=======================================================================
1412 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
1414 Standard_Real anOutAngl, anOutDefl;
1415 HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
1417 myDefaultDrawer->SetHLRAngle (anOutAngl);
1418 myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
1421 //=======================================================================
1422 //function : HLRAngle
1424 //=======================================================================
1425 Standard_Real AIS_InteractiveContext::HLRAngle() const
1427 return myDefaultDrawer->HLRAngle();
1430 //=======================================================================
1431 //function : SetDisplayMode
1433 //=======================================================================
1434 void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
1435 const Standard_Boolean theToUpdateViewer)
1437 if (theMode == myDisplayMode)
1442 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1444 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1445 Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
1446 || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
1447 || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
1450 || anObj->HasDisplayMode()
1451 || !anObj->AcceptDisplayMode (theMode))
1456 Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
1457 if (aStatus->IsDModeIn (myDisplayMode))
1459 aStatus->RemoveDisplayMode (myDisplayMode);
1462 aStatus->AddDisplayMode (theMode);
1463 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1465 myMainPM->Display (anObj, theMode);
1466 if (aStatus->IsSubIntensityOn())
1468 myMainPM->Color (anObj, mySubIntensity, theMode);
1470 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1474 myDisplayMode = theMode;
1475 if (theToUpdateViewer)
1477 myMainVwr->Update();
1481 //=======================================================================
1482 //function : SetDisplayMode
1484 //=======================================================================
1485 void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1486 const Standard_Integer theMode,
1487 const Standard_Boolean theToUpdateViewer)
1489 if (!theIObj->HasInteractiveContext())
1491 theIObj->SetContext(this);
1494 if (!myObjects.IsBound (theIObj))
1496 theIObj->SetDisplayMode (theMode);
1499 else if (!theIObj->AcceptDisplayMode (theMode))
1504 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1505 if (aStatus->GraphicStatus() != AIS_DS_Displayed)
1507 theIObj->SetDisplayMode (theMode);
1511 // erase presentations for all display modes different from <aMode>
1512 TColStd_ListOfInteger aModesToRemove;
1513 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
1515 const Standard_Integer anOldMode = aDispModeIter.Value();
1516 if (anOldMode != theMode)
1518 aModesToRemove.Append (anOldMode);
1519 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1521 myMainPM->Unhighlight (theIObj, anOldMode);
1523 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1527 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
1529 aStatus->RemoveDisplayMode (aRemModeIter.Value());
1532 if (!aStatus->IsDModeIn (theMode))
1534 aStatus->AddDisplayMode (theMode);
1537 myMainPM->Display (theIObj, theMode);
1538 Standard_Integer aDispMode, aHiMode, aSelMode;
1539 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1540 if (aStatus->IsHilighted())
1542 myMainPM->Highlight (theIObj, aHiMode);
1544 if (aStatus->IsSubIntensityOn())
1546 myMainPM->Color (theIObj, mySubIntensity, theMode);
1549 if (theToUpdateViewer)
1551 myMainVwr->Update();
1553 theIObj->SetDisplayMode (theMode);
1556 //=======================================================================
1557 //function : UnsetDisplayMode
1559 //=======================================================================
1560 void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1561 const Standard_Boolean theToUpdateViewer)
1563 if (theIObj.IsNull()
1564 || !theIObj->HasDisplayMode())
1569 if (!myObjects.IsBound (theIObj))
1571 theIObj->UnsetDisplayMode();
1575 const Standard_Integer anOldMode = theIObj->DisplayMode();
1576 if (myDisplayMode == anOldMode)
1581 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
1582 aStatus->RemoveDisplayMode (anOldMode);
1583 if (!aStatus->IsDModeIn(myDisplayMode))
1585 aStatus->AddDisplayMode (myDisplayMode);
1588 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1590 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1592 myMainPM->Unhighlight (theIObj, anOldMode);
1594 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1595 myMainPM->Display (theIObj, myDisplayMode);
1597 Standard_Integer aDispMode, aHiMode, aSelMode;
1598 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1599 if (aStatus->IsHilighted())
1601 myMainPM->Highlight (theIObj, aHiMode);
1603 if (aStatus->IsSubIntensityOn())
1605 myMainPM->Color (theIObj, mySubIntensity, myDisplayMode);
1608 if (theToUpdateViewer)
1610 myMainVwr->Update();
1614 theIObj->UnsetDisplayMode();
1617 //=======================================================================
1618 //function : SetCurrentFacingModel
1620 //=======================================================================
1621 void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
1622 const Aspect_TypeOfFacingModel theModel)
1624 if (!theIObj.IsNull())
1626 theIObj->SetCurrentFacingModel (theModel);
1630 //=======================================================================
1631 //function : redisplayPrsRecModes
1633 //=======================================================================
1634 void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1635 const Standard_Boolean theToUpdateViewer)
1637 if (theIObj->RecomputeEveryPrs())
1639 theIObj->Redisplay();
1643 for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
1645 theIObj->Update (aModes.Value(), Standard_False);
1647 theIObj->SetRecomputeOk();
1650 if (theToUpdateViewer)
1652 UpdateCurrentViewer();
1656 //=======================================================================
1657 //function : redisplayPrsModes
1659 //=======================================================================
1660 void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1661 const Standard_Boolean theToUpdateViewer)
1663 if (theIObj->RecomputeEveryPrs())
1665 theIObj->Redisplay();
1669 TColStd_ListOfInteger aModes;
1670 theIObj->ToBeUpdated (aModes);
1671 for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
1673 theIObj->Update (aModeIter.Value(), Standard_False);
1675 theIObj->SetRecomputeOk();
1678 if (theToUpdateViewer)
1680 UpdateCurrentViewer();
1684 //=======================================================================
1685 //function : SetColor
1687 //=======================================================================
1688 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1689 const Quantity_NameOfColor theColor,
1690 const Standard_Boolean theToUpdateViewer)
1692 SetColor (theIObj, Quantity_Color(theColor), theToUpdateViewer);
1695 //=======================================================================
1696 //function : SetColor
1698 //=======================================================================
1699 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1700 const Quantity_Color& theColor,
1701 const Standard_Boolean theToUpdateViewer)
1703 if (theIObj.IsNull())
1708 if (!theIObj->HasInteractiveContext())
1710 theIObj->SetContext (this);
1712 theIObj->SetColor (theColor);
1713 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1716 //=======================================================================
1717 //function : SetDeviationCoefficient
1719 //=======================================================================
1720 void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1721 const Standard_Real theCoefficient,
1722 const Standard_Boolean theToUpdateViewer)
1724 if (theIObj.IsNull())
1729 if (!theIObj->HasInteractiveContext())
1731 theIObj->SetContext (this);
1734 // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
1735 if (theIObj->Type() != AIS_KOI_Object
1736 && theIObj->Type() != AIS_KOI_Shape)
1740 else if (theIObj->Signature() != 0)
1745 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1746 aShape->SetOwnDeviationCoefficient (theCoefficient);
1747 redisplayPrsModes (theIObj, theToUpdateViewer);
1750 //=======================================================================
1751 //function : SetHLRDeviationCoefficient
1753 //=======================================================================
1754 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1755 const Standard_Real theCoefficient,
1756 const Standard_Boolean theToUpdateViewer)
1758 if (theIObj.IsNull())
1763 if (!theIObj->HasInteractiveContext())
1765 theIObj->SetContext (this);
1768 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1769 if (theIObj->Type() != AIS_KOI_Object
1770 && theIObj->Type() != AIS_KOI_Shape)
1774 else if (theIObj->Signature() != 0)
1779 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1780 aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
1781 redisplayPrsModes (theIObj, theToUpdateViewer);
1784 //=======================================================================
1785 //function : SetDeviationAngle
1787 //=======================================================================
1788 void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1789 const Standard_Real theAngle,
1790 const Standard_Boolean theToUpdateViewer)
1792 if (theIObj.IsNull())
1797 if (!theIObj->HasInteractiveContext())
1799 theIObj->SetContext (this);
1802 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1803 if (theIObj->Type() != AIS_KOI_Shape)
1807 else if (theIObj->Signature() != 0)
1812 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1813 aShape->SetOwnDeviationAngle (theAngle);
1814 redisplayPrsModes (theIObj, theToUpdateViewer);
1817 //=======================================================================
1818 //function : SetAngleAndDeviation
1820 //=======================================================================
1821 void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1822 const Standard_Real theAngle,
1823 const Standard_Boolean theToUpdateViewer)
1825 if (theIObj.IsNull())
1830 if (!theIObj->HasInteractiveContext())
1832 theIObj->SetContext (this);
1835 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1836 if (theIObj->Type() != AIS_KOI_Shape)
1840 if (theIObj->Signature() != 0)
1845 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1846 aShape->SetAngleAndDeviation (theAngle);
1848 if (theIObj->RecomputeEveryPrs())
1850 theIObj->Redisplay();
1854 Update (theIObj, theToUpdateViewer);
1858 //=======================================================================
1859 //function : SetHLRAngleAndDeviation
1861 //=======================================================================
1862 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1863 const Standard_Real theAngle,
1864 const Standard_Boolean theToUpdateViewer)
1866 if (theIObj.IsNull())
1871 if (!theIObj->HasInteractiveContext())
1873 theIObj->SetContext (this);
1876 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1877 if (theIObj->Type() != AIS_KOI_Shape)
1881 if (theIObj->Signature() != 0)
1885 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1886 aShape->SetHLRAngleAndDeviation (theAngle);
1887 redisplayPrsModes (theIObj, theToUpdateViewer);
1890 //=======================================================================
1891 //function : SetHLRDeviationAngle
1893 //=======================================================================
1894 void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1895 const Standard_Real theAngle,
1896 const Standard_Boolean theToUpdateViewer)
1898 if (theIObj.IsNull())
1903 if (!theIObj->HasInteractiveContext())
1905 theIObj->SetContext (this);
1908 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1909 if (theIObj->Type() != AIS_KOI_Shape)
1913 if (theIObj->Signature() != 0)
1917 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1918 aShape->SetOwnHLRDeviationAngle (theAngle);
1919 redisplayPrsModes (theIObj, theToUpdateViewer);
1922 //=======================================================================
1923 //function : UnsetColor
1925 //=======================================================================
1926 void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
1927 const Standard_Boolean theToUpdateViewer)
1929 if (theIObj.IsNull())
1934 theIObj->UnsetColor();
1935 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1938 //=======================================================================
1939 //function : HasColor
1941 //=======================================================================
1942 Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
1944 return theIObj->HasColor();
1947 //=======================================================================
1950 //=======================================================================
1951 Quantity_NameOfColor AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj) const
1953 return theIObj->Color();
1956 //=======================================================================
1959 //=======================================================================
1960 void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
1961 Quantity_Color& theColor) const
1963 theIObj->Color (theColor);
1966 //=======================================================================
1969 //=======================================================================
1970 Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
1972 return theIObj->Width();
1975 //=======================================================================
1976 //function : SetWidth
1978 //=======================================================================
1979 void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
1980 const Standard_Real theWidth,
1981 const Standard_Boolean theToUpdateViewer)
1983 if (theIObj.IsNull())
1988 if (!theIObj->HasInteractiveContext())
1990 theIObj->SetContext (this);
1993 theIObj->SetWidth (theWidth);
1994 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1997 //=======================================================================
1998 //function : UnsetWidth
2000 //=======================================================================
2001 void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2002 const Standard_Boolean theToUpdateViewer)
2004 if (theIObj.IsNull())
2009 theIObj->UnsetWidth();
2010 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2013 //=======================================================================
2014 //function : SetMaterial
2016 //=======================================================================
2017 void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2018 const Graphic3d_NameOfMaterial theName,
2019 const Standard_Boolean theToUpdateViewer)
2021 if (theIObj.IsNull())
2026 if (!theIObj->HasInteractiveContext())
2028 theIObj->SetContext (this);
2031 theIObj->SetMaterial (theName);
2032 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2035 //=======================================================================
2036 //function : UnsetMaterial
2038 //=======================================================================
2039 void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2040 const Standard_Boolean theToUpdateViewer)
2042 if (theIObj.IsNull())
2046 theIObj->UnsetMaterial();
2047 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2050 //=======================================================================
2051 //function : SetTransparency
2053 //=======================================================================
2054 void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2055 const Standard_Real theValue,
2056 const Standard_Boolean theToUpdateViewer)
2058 if (theIObj.IsNull())
2063 if (!theIObj->HasInteractiveContext())
2065 theIObj->SetContext (this);
2068 if (!theIObj->IsTransparent()
2069 && theValue <= 0.05)
2074 if (theValue <= 0.05)
2076 UnsetTransparency (theIObj, theToUpdateViewer);
2080 theIObj->SetTransparency (theValue);
2081 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2084 //=======================================================================
2085 //function : UnsetTransparency
2087 //=======================================================================
2088 void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2089 const Standard_Boolean theToUpdateViewer)
2091 if (theIObj.IsNull())
2096 theIObj->UnsetTransparency();
2097 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2100 //=======================================================================
2101 //function : SetSelectedAspect
2103 //=======================================================================
2104 void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
2105 const Standard_Boolean theIsGlobalChange,
2106 const Standard_Boolean theToUpdateViewer)
2108 if (HasOpenedContext())
2113 Standard_Boolean isFound = Standard_False;
2114 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
2115 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
2117 isFound = Standard_True;
2118 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
2119 anObj->SetAspect (theAspect, theIsGlobalChange);
2123 && theToUpdateViewer)
2125 myMainVwr->Update();
2129 //=======================================================================
2130 //function : SetLocalAttributes
2132 //=======================================================================
2133 void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2134 const Handle(Prs3d_Drawer)& theDrawer,
2135 const Standard_Boolean theToUpdateViewer)
2137 if (theIObj.IsNull())
2142 if (!theIObj->HasInteractiveContext())
2144 theIObj->SetContext (this);
2147 theIObj->SetAttributes (theDrawer);
2148 Update (theIObj, theToUpdateViewer);
2151 //=======================================================================
2152 //function : UnsetLocalAttributes
2154 //=======================================================================
2155 void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2156 const Standard_Boolean theToUpdateViewer)
2158 if (theIObj.IsNull())
2163 if (!theIObj->HasInteractiveContext())
2165 theIObj->SetContext (this);
2167 theIObj->UnsetAttributes();
2168 Update (theIObj, theToUpdateViewer);
2171 //=======================================================================
2174 //=======================================================================
2175 void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
2176 TCollection_ExtendedString& theStatus) const
2179 if (theIObj.IsNull()
2180 || !myObjects.IsBound (theIObj))
2185 theStatus += "\t ____________________________________________";
2186 theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2187 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2188 switch (aStatus->GraphicStatus())
2190 case AIS_DS_Displayed:
2192 theStatus += "\t| -->Displayed\n";
2197 theStatus += "\t| -->Erased\n";
2204 theStatus += "\t| Active Display Modes in the MainViewer :\n";
2205 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2207 theStatus += "\t|\t Mode ";
2208 theStatus += TCollection_AsciiString (aDispModeIter.Value());
2211 if (IsCurrent (theIObj)) theStatus +="\t| Current\n";
2212 if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
2214 theStatus += "\t| Active Selection Modes in the MainViewer :\n";
2215 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2217 theStatus += "\t\t Mode ";
2218 theStatus += TCollection_AsciiString (aSelModeIter.Value());
2221 theStatus += "\t ____________________________________________";
2224 //=======================================================================
2225 //function : GetDefModes
2227 //=======================================================================
2228 void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
2229 Standard_Integer& theDispMode,
2230 Standard_Integer& theHiMode,
2231 Standard_Integer& theSelMode) const
2233 if (theIObj.IsNull())
2238 theDispMode = theIObj->HasDisplayMode()
2239 ? theIObj->DisplayMode()
2240 : (theIObj->AcceptDisplayMode (myDisplayMode)
2243 theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
2244 theSelMode = theIObj->HasSelectionMode() ? theIObj->SelectionMode() : -1;
2247 //=======================================================================
2248 //function : EraseGlobal
2250 //=======================================================================
2251 void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2252 const Standard_Boolean theToUpdateviewer)
2254 if (theIObj.IsNull()
2255 || !myObjects.IsBound (theIObj))
2260 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2262 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2263 if (aStatus->GraphicStatus() == AIS_DS_Temporary
2264 || aStatus->GraphicStatus() == AIS_DS_Erased)
2269 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2271 if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2273 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2276 myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
2279 if (IsCurrent (theIObj)
2280 && !aStatus->IsDModeIn (aDispMode))
2282 myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
2285 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2287 mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
2289 aStatus->SetGraphicStatus (AIS_DS_Erased);
2291 if (theToUpdateviewer)
2293 myMainVwr->Update();
2297 //=======================================================================
2298 //function : ClearGlobal
2300 //=======================================================================
2301 void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2302 const Standard_Boolean theToUpdateviewer)
2304 if (theIObj.IsNull()
2305 || !myObjects.IsBound (theIObj))
2310 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2311 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2313 if (aStatus->IsHilighted())
2315 if (IsCurrent (theIObj))
2317 AddOrRemoveCurrentObject (theIObj, theToUpdateviewer);
2319 else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2321 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2324 myMainPM->Erase (theIObj, aDispModeIter.Value());
2325 myMainPM->Clear (theIObj, aDispModeIter.Value());
2326 if (theIObj->HasHilightMode())
2328 Standard_Integer im = theIObj->HilightMode();
2329 myMainPM->Unhighlight (theIObj, im);
2330 myMainPM->Erase (theIObj, im);
2334 // Object removes from Detected sequence
2335 for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
2337 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2339 && anObj != theIObj)
2341 myAISDetectedSeq.Remove (aDetIter);
2345 if (myLastinMain == theIObj)
2347 myLastinMain.Nullify();
2349 if (myLastPicked == theIObj)
2351 myLastPicked.Nullify();
2354 // remove IO from the selection manager to avoid memory leaks
2355 mgrSelector->Remove (theIObj);
2357 myObjects.UnBind (theIObj);
2359 if (theToUpdateviewer
2360 && aStatus->GraphicStatus() == AIS_DS_Displayed)
2362 myMainVwr->Update();
2366 //=======================================================================
2367 //function : ClearGlobalPrs
2369 //=======================================================================
2370 void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
2371 const Standard_Integer theMode,
2372 const Standard_Boolean theToUpdateViewer)
2374 if (theIObj.IsNull()
2375 || !myObjects.IsBound (theIObj))
2380 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2381 if (aStatus->IsDModeIn (theMode))
2383 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2384 if (aDispMode == theMode
2385 && myMainPM->IsHighlighted (theIObj, theMode))
2387 myMainPM->Unhighlight (theIObj, theMode);
2390 myMainPM->Erase (theIObj, theMode);
2391 myMainPM->Clear (theIObj, theMode);
2394 if (aStatus->GraphicStatus() == AIS_DS_Displayed
2395 && theToUpdateViewer)
2397 myMainVwr->Update();
2401 //=======================================================================
2402 //function : DrawHiddenLine
2404 //=======================================================================
2405 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
2407 return myDefaultDrawer->DrawHiddenLine();
2410 //=======================================================================
2411 //function : EnableDrawHiddenLine
2413 //=======================================================================
2414 void AIS_InteractiveContext::EnableDrawHiddenLine() const
2416 myDefaultDrawer->EnableDrawHiddenLine();
2419 //=======================================================================
2420 //function : DisableDrawHiddenLine
2422 //=======================================================================
2423 void AIS_InteractiveContext::DisableDrawHiddenLine() const
2425 myDefaultDrawer->DisableDrawHiddenLine();
2428 //=======================================================================
2429 //function : HiddenLineAspect
2431 //=======================================================================
2432 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
2434 return myDefaultDrawer->HiddenLineAspect();
2437 //=======================================================================
2438 //function : SetHiddenLineAspect
2440 //=======================================================================
2441 void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
2443 myDefaultDrawer->SetHiddenLineAspect (theAspect);
2446 //=======================================================================
2447 //function : SetIsoNumber
2449 //=======================================================================
2450 void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
2451 const AIS_TypeOfIso theType)
2456 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2459 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2462 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2463 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2468 //=======================================================================
2469 //function : IsoNumber
2471 //=======================================================================
2472 Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
2476 case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
2477 case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
2478 case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
2479 ? myDefaultDrawer->UIsoAspect()->Number()
2485 //=======================================================================
2486 //function : IsoOnPlane
2488 //=======================================================================
2489 void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
2491 myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
2494 //=======================================================================
2495 //function : IsoOnPlane
2497 //=======================================================================
2498 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2500 return myDefaultDrawer->IsoOnPlane();
2503 //=======================================================================
2504 //function : SetSelectionMode
2506 //=======================================================================
2507 void AIS_InteractiveContext::SetSelectionMode (const Handle(AIS_InteractiveObject)& ,
2508 const Standard_Integer )
2513 //=======================================================================
2514 //function : UnsetSelectionMode
2516 //=======================================================================
2517 void AIS_InteractiveContext::UnsetSelectionMode (const Handle(AIS_InteractiveObject)& )
2522 //=======================================================================
2523 //function : SetSensitivityMode
2525 //=======================================================================
2526 void AIS_InteractiveContext::SetSensitivityMode (const StdSelect_SensitivityMode theMode)
2528 if (HasOpenedContext())
2530 myLocalContexts (myCurLocalIndex)->SetSensitivityMode (theMode);
2534 myMainSel->SetSensitivityMode (theMode);
2538 //=======================================================================
2539 //function : SensitivityMode
2541 //=======================================================================
2542 StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const
2544 return HasOpenedContext()
2545 ? myLocalContexts (myCurLocalIndex)->SensitivityMode()
2546 : myMainSel->SensitivityMode();
2549 //=======================================================================
2550 //function : SetSensitivity
2552 //=======================================================================
2553 void AIS_InteractiveContext::SetSensitivity (const Standard_Real thePrecision)
2555 if (HasOpenedContext())
2557 myLocalContexts(myCurLocalIndex)->SetSensitivity (thePrecision);
2561 myMainSel->SetSensitivity (thePrecision);
2565 //=======================================================================
2566 //function : Sensitivity
2568 //=======================================================================
2569 Standard_Real AIS_InteractiveContext::Sensitivity() const
2571 return HasOpenedContext()
2572 ? myLocalContexts(myCurLocalIndex)->Sensitivity()
2573 : myMainSel->Sensitivity();
2576 //=======================================================================
2577 //function : SetPixelTolerance
2579 //=======================================================================
2580 void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
2582 if (HasOpenedContext())
2584 myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
2588 myMainSel->SetPixelTolerance (thePrecision);
2592 //=======================================================================
2593 //function : PixelTolerance
2595 //=======================================================================
2596 Standard_Integer AIS_InteractiveContext::PixelTolerance() const
2598 return HasOpenedContext()
2599 ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
2600 : myMainSel->PixelTolerance();
2603 //=======================================================================
2604 //function : IsInLocal
2606 //=======================================================================
2607 Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
2608 Standard_Integer& theIndex) const
2610 if (theIObj.IsNull())
2612 return Standard_False;
2615 // if it exists at neutral point 0 index is returned
2616 if (myObjects.IsBound (theIObj))
2619 return Standard_False;
2622 for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
2624 if (myLocalContexts.IsBound (aCtxIter))
2626 if(myLocalContexts (aCtxIter)->IsIn (theIObj))
2628 theIndex = aCtxIter;
2629 return Standard_True;
2634 return Standard_False;
2637 //=======================================================================
2638 //function : InitAttributes
2640 //=======================================================================
2641 void AIS_InteractiveContext::InitAttributes()
2643 mgrSelector->Add (myMainSel);
2644 myCurrentName = AIS_Context_NewCurName();
2645 mySelectionName = AIS_Context_NewSelName();
2647 AIS_Selection::CreateSelection (mySelectionName.ToCString());
2648 AIS_Selection::CreateSelection (myCurrentName.ToCString());
2650 myDefaultDrawer->SetShadingAspectGlobal (Standard_False);
2651 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
2652 myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
2654 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2655 Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
2656 aLineAspect->SetColor (Quantity_NOC_GRAY20);
2657 aLineAspect->SetWidth (1.0);
2658 aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
2660 // tolerance to 4 pixels...
2661 SetPixelTolerance();
2663 // Customizing the drawer for trihedrons and planes...
2664 Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
2665 const Standard_Real aLength = 100.0;
2666 aTrihAspect->SetAxisLength (aLength, aLength, aLength);
2667 const Quantity_NameOfColor aColor = Quantity_NOC_LIGHTSTEELBLUE4;
2668 aTrihAspect->FirstAxisAspect() ->SetColor (aColor);
2669 aTrihAspect->SecondAxisAspect()->SetColor (aColor);
2670 aTrihAspect->ThirdAxisAspect() ->SetColor (aColor);
2672 Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
2673 const Standard_Real aPlaneLength = 200.0;
2674 aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
2675 aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
2678 //=======================================================================
2679 //function : TrihedronSize
2681 //=======================================================================
2682 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2684 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2687 //=======================================================================
2688 //function : SetTrihedronSize
2690 //=======================================================================
2691 void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
2692 const Standard_Boolean /*updateviewer*/)
2694 myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
2695 Redisplay (AIS_KOI_Datum, 3, Standard_False);
2696 Redisplay (AIS_KOI_Datum, 4, Standard_True);
2699 //=======================================================================
2700 //function : SetPlaneSize
2702 //=======================================================================
2703 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
2704 const Standard_Real theValY,
2705 const Standard_Boolean /*updateviewer*/)
2707 myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
2708 Redisplay (AIS_KOI_Datum, 7);
2711 //=======================================================================
2712 //function : SetPlaneSize
2714 //=======================================================================
2715 void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
2716 const Standard_Boolean theToUpdateViewer)
2718 SetPlaneSize (theVal, theVal, theToUpdateViewer);
2721 //=======================================================================
2722 //function : PlaneSize
2724 //=======================================================================
2725 Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
2726 Standard_Real& theY) const
2728 theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2729 theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2730 return (Abs (theX - theY) <= Precision::Confusion());
2733 //=======================================================================
2734 //function : SetAutoActivateSelection
2736 //=======================================================================
2737 void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
2739 myIsAutoActivateSelMode = theIsAuto;
2742 //=======================================================================
2743 //function : GetAutoActivateSelection
2745 //=======================================================================
2746 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2748 return myIsAutoActivateSelMode;
2751 //=======================================================================
2752 //function : SetZLayer
2754 //=======================================================================
2755 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2756 const Standard_Integer theLayerId)
2758 if (theIObj.IsNull())
2761 theIObj->SetZLayer (theLayerId);
2764 //=======================================================================
2765 //function : GetZLayer
2767 //=======================================================================
2768 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2770 return !theIObj.IsNull()
2772 : Graphic3d_ZLayerId_UNKNOWN;