1 // Created on: 1997-01-17
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
19 #include <AIS_InteractiveContext.ixx>
21 //#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
22 #include <TColStd_ListIteratorOfListOfInteger.hxx>
23 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
24 #include <AIS_LocalContext.hxx>
25 #include <AIS_LocalStatus.hxx>
26 #include <Precision.hxx>
27 #include <AIS_Selection.hxx>
28 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
29 #include <AIS_ConnectedInteractive.hxx>
30 #include <AIS_MultipleConnectedInteractive.hxx>
31 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
32 #include <AIS_GlobalStatus.hxx>
33 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
34 #include <PrsMgr_ModedPresentation.hxx>
35 #include <Visual3d_ViewManager.hxx>
36 #include <Visual3d_View.hxx>
37 #include <Prs3d_ShadingAspect.hxx>
38 #include <AIS_Shape.hxx>
39 #include <Graphic3d_AspectFillArea3d.hxx>
40 #include <HLRBRep.hxx>
41 #include <Prs3d_IsoAspect.hxx>
42 #include <Prs3d_DatumAspect.hxx>
43 #include <Prs3d_PlaneAspect.hxx>
44 #include <PrsMgr_PresentableObject.hxx>
45 #include <Standard_Atomic.hxx>
46 #include <StdSelect_ViewerSelector3d.hxx>
47 #include <UnitsAPI.hxx>
49 #include <AIS_Trihedron.hxx>
50 #include <Geom_Axis2Placement.hxx>
51 #include <OSD_Environment.hxx>
53 #include <AIS_ListIteratorOfListOfInteractive.hxx>
57 static volatile Standard_Integer THE_AIS_INDEX_SEL = 0;
58 static volatile Standard_Integer THE_AIS_INDEX_CUR = 0;
60 static TCollection_AsciiString AIS_Context_NewSelName()
62 return TCollection_AsciiString ("AIS_SelContext_")
63 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL));
66 static TCollection_AsciiString AIS_Context_NewCurName()
68 return TCollection_AsciiString ("AIS_CurContext_")
69 + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
72 typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
73 typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners;
76 //=======================================================================
77 //function : AIS_InteractiveContext
79 //=======================================================================
81 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
82 mgrSelector(new SelectMgr_SelectionManager()),
83 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
84 myMainVwr(MainViewer),
85 myMainSel(new StdSelect_ViewerSelector3d()),
86 myWasLastMain(Standard_False),
87 myCurrentTouched(Standard_False),
88 mySelectedTouched(Standard_False),
89 myToHilightSelected(Standard_True),
90 myFilters(new SelectMgr_OrFilter()),
91 myDefaultDrawer(new Prs3d_Drawer()),
92 myDefaultColor(Quantity_NOC_GOLDENROD),
93 myHilightColor(Quantity_NOC_CYAN1),
94 mySelectionColor(Quantity_NOC_GRAY80),
95 myPreselectionColor(Quantity_NOC_GREEN),
96 mySubIntensity(Quantity_NOC_GRAY40),
101 myIsAutoActivateSelMode( Standard_True )
106 void AIS_InteractiveContext::Delete() const
108 // clear the static current selection
109 AIS_Selection::ClearCurrentSelection();
111 // to avoid an exception
112 if (AIS_Selection::Find (mySelectionName.ToCString()))
114 AIS_Selection::Remove (mySelectionName.ToCString());
117 // to avoid an exception
118 if (AIS_Selection::Find (myCurrentName.ToCString()))
120 AIS_Selection::Remove (myCurrentName.ToCString());
123 // let's remove one reference explicitly. this operation's supposed to
124 // be performed when mgrSelector will be destroyed but anyway...
125 mgrSelector->Remove (myMainSel);
127 Handle(AIS_InteractiveContext) aNullContext;
128 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
130 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
131 anObj->SetContext (aNullContext);
133 MMgt_TShared::Delete();
136 //=======================================================================
137 //function : AIS_SelectionName
139 //=======================================================================
140 const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const
142 if(!HasOpenedContext())
143 return mySelectionName;
144 return myLocalContexts(myCurLocalIndex)->SelectionName();
150 //=======================================================================
151 //function : UpdateCurrentViewer
153 //=======================================================================
155 void AIS_InteractiveContext::UpdateCurrentViewer()
157 if (!myMainVwr.IsNull())
162 //=======================================================================
163 //function : DomainOfMainViewer
165 //=======================================================================
167 Standard_CString AIS_InteractiveContext::DomainOfMainViewer() const
169 return myMainVwr->Domain();
173 //=======================================================================
174 //function : DisplayedObjects
176 //=======================================================================
177 void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
178 const Standard_Boolean theOnlyFromNeutral) const
180 if (!HasOpenedContext()
181 || theOnlyFromNeutral)
183 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
185 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
187 theListOfIO.Append (anObjIter.Key());
194 TColStd_MapOfTransient aDispMap;
195 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
197 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
199 aDispMap.Add (anObjIter.Key());
203 // parse all local contexts...
204 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
206 const Handle(AIS_LocalContext)& aLocCtx = aCtxIter.Value();
207 aLocCtx->DisplayedObjects (aDispMap);
210 Handle(AIS_InteractiveObject) anObj;
211 for (TColStd_MapIteratorOfMapOfTransient aDispMapIter (aDispMap); aDispMapIter.More(); aDispMapIter.Next())
213 const Handle(Standard_Transient)& aTransient = aDispMapIter.Key();
214 anObj = *((Handle(AIS_InteractiveObject)* )&aTransient);
215 theListOfIO.Append (anObj);
219 //=======================================================================
220 //function : DisplayedObjects
222 //=======================================================================
223 void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
224 const Standard_Integer theSign,
225 AIS_ListOfInteractive& theListOfIO,
226 const Standard_Boolean /*OnlyFromNeutral*/) const
228 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
231 //=======================================================================
232 //function : ErasedObjects
234 //=======================================================================
235 void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const
237 ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO);
240 //=======================================================================
241 //function : ErasedObjects
243 //=======================================================================
244 void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind,
245 const Standard_Integer theSign,
246 AIS_ListOfInteractive& theListOfIO) const
248 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO);
251 //=======================================================================
252 //function : ObjectsByDisplayStatus
254 //=======================================================================
255 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus,
256 AIS_ListOfInteractive& theListOfIO) const
258 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
260 if (anObjIter.Value()->GraphicStatus() == theStatus)
262 theListOfIO.Append (anObjIter.Key());
267 //=======================================================================
268 //function : ObjectsByDisplayStatus
270 //=======================================================================
271 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind,
272 const Standard_Integer theSign,
273 const AIS_DisplayStatus theStatus,
274 AIS_ListOfInteractive& theListOfIO) const
276 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
278 if (theStatus != AIS_DS_None
279 && anObjIter.Value()->GraphicStatus() != theStatus)
283 else if (anObjIter.Key()->Type() != theKind)
289 || anObjIter.Key()->Signature() == theSign)
291 theListOfIO.Append (anObjIter.Key());
296 //=======================================================================
297 //function : ObjectsInside
299 //=======================================================================
300 void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO,
301 const AIS_KindOfInteractive theKind,
302 const Standard_Integer theSign) const
304 if (theKind == AIS_KOI_None
307 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
309 theListOfIO.Append (anObjIter.Key());
314 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
316 if (anObjIter.Key()->Type() != theKind)
322 || anObjIter.Key()->Signature() == theSign)
324 theListOfIO.Append (anObjIter.Key());
329 //=======================================================================
330 //function : ObjectsForView
332 //=======================================================================
333 void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO,
334 const Handle(V3d_View)& theView,
335 const Standard_Boolean theIsVisibleInView,
336 const AIS_DisplayStatus theStatus) const
338 const Graphic3d_CView* aCView = reinterpret_cast<const Graphic3d_CView* >(theView->View()->CView());
339 const Standard_Integer aViewId = aCView->ViewId;
340 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
342 if (theStatus != AIS_DS_None
343 && anObjIter.Value()->GraphicStatus() != theStatus)
345 theListOfIO.Append (anObjIter.Key());
349 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (anObjIter.Key());
350 const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
351 if (isVisible == theIsVisibleInView)
353 theListOfIO.Append (anObjIter.Key());
358 //=======================================================================
361 //=======================================================================
362 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
363 const Standard_Boolean theToUpdateViewer)
365 if (theIObj.IsNull())
370 Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
371 GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
373 Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
374 theToUpdateViewer, theIObj->AcceptShapeDecomposition());
377 //=======================================================================
378 //function : SetViewAffinity
380 //=======================================================================
381 void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj,
382 const Handle(V3d_View)& theView,
383 const Standard_Boolean theIsVisible)
386 || !myObjects.IsBound (theIObj))
391 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (theIObj);
392 const Graphic3d_CView* aCView = reinterpret_cast<const Graphic3d_CView* >(theView->View()->CView());
393 anAffinity->SetVisible (aCView->ViewId, theIsVisible == Standard_True);
396 theView->View()->ChangeHiddenObjects()->Remove (theIObj);
400 theView->View()->ChangeHiddenObjects()->Add (theIObj);
404 //=======================================================================
407 //=======================================================================
408 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
409 const Standard_Integer theDispMode,
410 const Standard_Integer theSelectionMode,
411 const Standard_Boolean theToUpdateViewer,
412 const Standard_Boolean theToAllowDecomposition,
413 const AIS_DisplayStatus theDispStatus)
415 if (theIObj.IsNull())
420 if (theDispStatus == AIS_DS_Erased)
422 Erase (theIObj, theToUpdateViewer);
423 Load (theIObj, theSelectionMode, theToAllowDecomposition);
427 if (!theIObj->HasInteractiveContext())
429 theIObj->SetContext (this);
432 if (theDispStatus == AIS_DS_Temporary
433 && !HasOpenedContext())
437 else if (HasOpenedContext())
439 if (theDispStatus == AIS_DS_None
440 || theDispStatus == AIS_DS_Temporary)
442 myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
443 if (theToUpdateViewer)
451 if (!myObjects.IsBound (theIObj))
453 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
454 myObjects.Bind (theIObj, aStatus);
455 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->RegisterObject (theIObj);
456 myMainPM->Display(theIObj, theDispMode);
457 if (theSelectionMode != -1)
459 if (!mgrSelector->Contains (theIObj))
461 mgrSelector->Load (theIObj);
463 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
468 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
469 if (aStatus->GraphicStatus() == AIS_DS_Temporary)
474 // Erase presentations for all display modes different from aDispMode.
475 // Then make sure aDispMode is displayed and maybe highlighted.
476 // Finally, activate selection mode <SelMode> if not yet activated.
477 TColStd_ListOfInteger aModesToRemove;
478 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
480 const Standard_Integer anOldMode = aDispModeIter.Value();
481 if (anOldMode != theDispMode)
483 aModesToRemove.Append (anOldMode);
484 if(myMainPM->IsHighlighted (theIObj, anOldMode))
486 myMainPM->Unhighlight (theIObj, anOldMode);
488 myMainPM->Erase (theIObj, anOldMode);
492 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
494 aStatus->RemoveDisplayMode (aRemModeIter.Value());
497 if (!aStatus->IsDModeIn (theDispMode))
499 aStatus->AddDisplayMode (theDispMode);
502 myMainPM->Display (theIObj, theDispMode);
503 aStatus->SetGraphicStatus (AIS_DS_Displayed);
504 if (aStatus->IsHilighted())
506 const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
507 myMainPM->Highlight (theIObj, aHiMod);
509 if (theSelectionMode != -1)
511 if (!mgrSelector->Contains (theIObj))
513 mgrSelector->Load (theIObj);
515 if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
517 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
522 if (theToUpdateViewer)
528 //=======================================================================
531 //=======================================================================
532 void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
533 const Standard_Integer theSelMode,
534 const Standard_Boolean theToAllowDecomposition)
536 if (theIObj.IsNull())
541 if (!theIObj->HasInteractiveContext())
543 theIObj->SetContext (this);
546 if (HasOpenedContext())
548 myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
553 && !theToAllowDecomposition)
555 if (!myObjects.IsBound (theIObj))
557 Standard_Integer aDispMode, aHiMod, aSelModeDef;
558 GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
559 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, aSelModeDef);
560 myObjects.Bind (theIObj, aStatus);
563 // Register theIObj in the selection manager to prepare further activation of selection
564 if (!mgrSelector->Contains (theIObj))
566 mgrSelector->Load (theIObj);
571 //=======================================================================
574 //=======================================================================
575 void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
576 const Standard_Boolean theToUpdateViewer)
578 if (theIObj.IsNull())
583 if (!theIObj->IsAutoHilight())
585 theIObj->ClearSelected();
588 Standard_Boolean wasInCtx = Standard_False;
589 if (HasOpenedContext())
591 // First it is checked if it is possible to remove in the current local context
592 // then one tries to remove in other local contexts, if they allow it...
593 wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
594 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
596 if (aCtxIter.Value()->AcceptErase())
598 wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
605 EraseGlobal (theIObj, Standard_False);
608 if (theToUpdateViewer)
614 //=======================================================================
615 //function : EraseAll
617 //=======================================================================
618 void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
620 if (HasOpenedContext())
625 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
627 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
629 Erase (anObjIter.Key(), Standard_False);
633 if (theToUpdateViewer)
639 //=======================================================================
640 //function : DisplayAll
642 //=======================================================================
643 void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
645 if (HasOpenedContext())
650 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
652 const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
653 if (aStatus == AIS_DS_Erased)
655 Display (anObjIter.Key(), Standard_False);
659 if (theToUpdateViewer)
665 //=======================================================================
666 //function : DisplaySelected
668 //=======================================================================
669 void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
671 if (HasOpenedContext())
676 Standard_Boolean isFound = Standard_False;
677 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
678 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
680 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
681 Display (anObj, Standard_False);
682 isFound = Standard_True;
685 if (isFound && theToUpdateViewer)
691 //=======================================================================
692 //function : EraseSelected
694 //=======================================================================
695 void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
697 if (HasOpenedContext())
702 Standard_Boolean isFound = Standard_False;
703 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString());
704 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
706 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
707 Erase (anObj, Standard_False);
708 isFound = Standard_True;
711 if (isFound && theToUpdateViewer)
717 //=======================================================================
720 //=======================================================================
722 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
723 const Standard_Integer WhichContext)
725 if(anIObj.IsNull()) return Standard_False;
727 if(!HasOpenedContext()) return Standard_False;
728 if(myObjects.IsBound(anIObj)) return Standard_False;
729 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
731 // Protection : if one tries to preserve a temporary object
732 // which is not in the local active context... rob 11-06-97
734 Standard_Integer IsItInLocal = myCurLocalIndex;
735 Standard_Boolean Found(Standard_False);
737 while(IsItInLocal>0 && !Found){
738 if(!myLocalContexts.IsBound(IsItInLocal))
740 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
741 Found = Standard_True;
746 if(!Found) return Standard_False;
749 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
750 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
752 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
753 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
757 if(LS->IsTemporary()){
758 Standard_Integer DM,HM,SM;
759 GetDefModes(anIObj,DM,HM,SM);
761 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
762 if(LS->DisplayMode()!= DM ){
763 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
764 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
767 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
771 // GS->SubIntensityOn();
772 myObjects.Bind(anIObj,GS);
773 mgrSelector->Load(anIObj);
774 mgrSelector->Activate(anIObj,SM,myMainSel);
776 LS->SetTemporary(Standard_False);
778 return Standard_True;
781 //=======================================================================
782 //function : DisplayStatus
784 //=======================================================================
785 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
787 if (theIObj.IsNull())
791 else if (myObjects.IsBound (theIObj))
793 return myObjects (theIObj)->GraphicStatus();
796 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
798 if (aCtxIter.Value()->IsIn (theIObj))
800 return AIS_DS_Temporary;
806 //=======================================================================
807 //function : DisplayedModes
809 //=======================================================================
810 const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
812 return myObjects (theIObj)->DisplayedModes();
815 //=======================================================================
818 //=======================================================================
819 void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
820 const Standard_Boolean theToUpdateViewer)
822 if (theIObj.IsNull())
827 if (HasOpenedContext())
829 myLocalContexts (myCurLocalIndex)->Remove (theIObj);
830 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
832 if (aCtxIter.Value()->AcceptErase())
834 aCtxIter.Value()->Remove (theIObj);
839 ClearGlobal (theIObj, theToUpdateViewer);
842 //=======================================================================
843 //function : RemoveAll
845 //=======================================================================
846 void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
848 AIS_ListOfInteractive aList;
849 ObjectsInside (aList);
850 for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
852 Remove (aListIterator.Value(), Standard_False);
855 if (theToUpdateViewer)
861 //=======================================================================
862 //function : ClearPrs
864 //=======================================================================
865 void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
866 const Standard_Integer theMode,
867 const Standard_Boolean theToUpdateViewer)
869 if (theIObj.IsNull())
874 if (!HasOpenedContext())
876 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
880 Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
881 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
883 if (aCtxIter.Value()->AcceptErase())
885 wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
890 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
892 else if (theToUpdateViewer)
898 //=======================================================================
901 //=======================================================================
902 void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj,
903 const Standard_Boolean theToUpdateViewer)
905 if (theIObj.IsNull())
910 if (!theIObj->HasInteractiveContext())
912 theIObj->SetContext (this);
914 if (!HasOpenedContext())
916 if (!myObjects.IsBound (theIObj))
921 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
922 aStatus->SetHilightStatus (Standard_True);
923 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
925 Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
926 myMainPM->Highlight (theIObj, aHilightMode);
931 myLocalContexts (myCurLocalIndex)->Hilight (theIObj);
934 if (theToUpdateViewer)
939 //=======================================================================
942 //=======================================================================
944 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj,
945 const Quantity_NameOfColor aCol,
946 const Standard_Boolean updateviewer)
948 if(anIObj.IsNull()) return;
950 if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
952 if (!HasOpenedContext())
954 if(!myObjects.IsBound(anIObj)) return;
956 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
957 aStatus->SetHilightStatus (Standard_True);
959 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
961 const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
962 myMainPM->Color (anIObj, aCol, aHilightMode);
963 aStatus->SetHilightColor (aCol);
968 myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
970 if(updateviewer) myMainVwr->Update();
973 //=======================================================================
974 //function : Unhilight
976 //=======================================================================
978 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
980 if(anIObj.IsNull()) return;
982 if (!HasOpenedContext())
984 if(!myObjects.IsBound(anIObj)) return;
986 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
987 aStatus->SetHilightStatus (Standard_False);
988 aStatus->SetHilightColor(Quantity_NOC_WHITE);
990 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
992 Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
993 myMainPM->Unhighlight (anIObj, aHilightMode);
998 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
1000 if(updateviewer) myMainVwr->Update();
1003 //=======================================================================
1004 //function : IsHilighted
1006 //=======================================================================
1008 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const
1010 if(anIObj.IsNull()) return Standard_False;
1012 if (!HasOpenedContext()){
1013 if(!myObjects.IsBound(anIObj))
1014 return Standard_False;
1015 return myObjects(anIObj)->IsHilighted();
1017 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1018 for(;ItM.More();ItM.Next()){
1019 if(ItM.Value()->IsHilighted(anIObj))
1020 return Standard_True;
1022 return Standard_False;
1025 Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj,
1026 Standard_Boolean& WithColor,
1027 Quantity_NameOfColor& TheHiCol) const
1029 if(!HasOpenedContext()){
1030 if(myObjects.IsBound(anIObj)){
1031 const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
1032 if(STAT->IsHilighted()){
1033 if(STAT->HilightColor()!=Quantity_NOC_WHITE){
1034 WithColor=Standard_True;
1035 TheHiCol = STAT->HilightColor();
1038 WithColor = Standard_False;
1039 return Standard_True;
1042 return Standard_False;
1044 Standard_Integer MaxIndex = HighestIndex();
1045 for(Standard_Integer i=MaxIndex;i>=1 ; i--){
1046 if(myLocalContexts.IsBound(i)){
1047 if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol))
1048 return Standard_True;
1052 return Standard_False;
1057 //=======================================================================
1058 //function : IsDisplayed
1060 //=======================================================================
1062 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1064 if(anIObj.IsNull()) return Standard_False;
1067 if(myObjects.IsBound(anIObj))
1068 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1069 return Standard_True;
1071 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1072 for(;ItM.More();ItM.Next()){
1073 if(ItM.Value()->IsDisplayed(anIObj))
1074 return Standard_True;
1076 return Standard_False;
1080 //=======================================================================
1081 //function : IsDisplayed
1083 //=======================================================================
1084 Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
1085 const Standard_Integer theMode) const
1087 if (theIObj.IsNull())
1089 return Standard_False;
1092 if (myObjects.IsBound (theIObj))
1094 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1095 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1096 && aStatus->IsDModeIn (theMode))
1098 return Standard_True;
1102 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
1104 if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
1106 return Standard_True;
1109 return Standard_False;
1112 //=======================================================================
1113 //function : DisplayPriority
1115 //=======================================================================
1116 Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
1118 if (theIObj.IsNull())
1122 else if (!myObjects.IsBound (theIObj))
1127 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1128 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1129 || aStatus->GraphicStatus() == AIS_DS_Erased)
1131 Standard_Integer aDispMode = theIObj->HasDisplayMode()
1132 ? theIObj->DisplayMode()
1133 : (theIObj->AcceptDisplayMode (myDisplayMode)
1136 return myMainPM->DisplayPriority (theIObj, aDispMode);
1141 //=======================================================================
1142 //function : SetDisplayPriority
1144 //=======================================================================
1145 void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
1146 const Standard_Integer thePriority)
1148 if (theIObj.IsNull())
1153 if (!theIObj->HasInteractiveContext())
1155 theIObj->SetContext (this);
1158 if (myObjects.IsBound (theIObj))
1160 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1161 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1162 || aStatus->GraphicStatus() == AIS_DS_Erased)
1164 Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
1165 ? theIObj->DisplayMode()
1166 : (theIObj->AcceptDisplayMode (myDisplayMode)
1169 myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
1172 else if (HasOpenedContext())
1174 myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
1178 //=======================================================================
1179 //function : Redisplay
1181 //=======================================================================
1182 void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
1183 const Standard_Boolean theToUpdateViewer,
1184 const Standard_Boolean theAllModes)
1186 RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
1187 RecomputeSelectionOnly (theIObj);
1190 //=======================================================================
1191 //function : Redisplay
1193 //=======================================================================
1194 void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
1195 const Standard_Integer /*theSign*/,
1196 const Standard_Boolean theToUpdateViewer)
1198 Standard_Boolean isRedisplayed = Standard_False;
1199 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1201 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1202 if (anObj->Type() != theKOI)
1207 Redisplay (anObj, Standard_False);
1208 isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
1212 if (theToUpdateViewer
1215 myMainVwr->Update();
1219 //=======================================================================
1220 //function : RecomputePrsOnly
1222 //=======================================================================
1223 void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
1224 const Standard_Boolean theToUpdateViewer,
1225 const Standard_Boolean theAllModes)
1227 if (theIObj.IsNull())
1232 theIObj->Update (theAllModes);
1233 if (!theToUpdateViewer)
1238 if (HasOpenedContext()
1239 || (myObjects.IsBound (theIObj)
1240 && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
1242 myMainVwr->Update();
1245 //=======================================================================
1246 //function : RecomputeSelectionOnly
1248 //=======================================================================
1249 void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
1256 mgrSelector->RecomputeSelection (theIO);
1258 if (HasOpenedContext())
1260 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1262 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
1267 if (!myObjects.IsBound (theIO) ||
1268 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1273 TColStd_ListOfInteger aModes;
1274 ActivatedModes (theIO, aModes);
1275 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1276 for (; aModesIter.More(); aModesIter.Next())
1278 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
1282 //=======================================================================
1285 //=======================================================================
1286 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1287 const Standard_Boolean theUpdateViewer)
1289 if (theIObj.IsNull())
1294 TColStd_ListOfInteger aPrsModes;
1295 theIObj->ToBeUpdated (aPrsModes);
1296 for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
1298 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1301 mgrSelector->Update(theIObj);
1303 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1305 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1308 if (theUpdateViewer)
1310 if (!myObjects.IsBound (theIObj))
1315 switch (myObjects (theIObj)->GraphicStatus())
1317 case AIS_DS_Displayed:
1318 case AIS_DS_Temporary:
1319 myMainVwr->Update();
1327 //=======================================================================
1328 //function : SetLocation
1330 //=======================================================================
1331 void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
1332 const TopLoc_Location& theLoc)
1334 if (theIObj.IsNull())
1339 if (theIObj->HasTransformation()
1340 && theLoc.IsIdentity())
1342 theIObj->ResetTransformation();
1343 mgrSelector->Update (theIObj, Standard_False);
1346 else if (theLoc.IsIdentity())
1351 // first reset the previous location to properly clean everything...
1352 if (theIObj->HasTransformation())
1354 theIObj->ResetTransformation();
1357 theIObj->SetLocalTransformation (theLoc.Transformation());
1359 if (!HasOpenedContext())
1361 mgrSelector->Update (theIObj, Standard_False);
1365 Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
1366 mgrSelector->Update (theIObj, aTempSel, Standard_False);
1370 //=======================================================================
1371 //function : ResetLocation
1373 //=======================================================================
1374 void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
1376 if (theIObj.IsNull())
1381 theIObj->ResetTransformation();
1382 mgrSelector->Update (theIObj, Standard_False);
1385 //=======================================================================
1386 //function : HasLocation
1388 //=======================================================================
1389 Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
1391 return !theIObj.IsNull()
1392 && theIObj->HasTransformation();
1395 //=======================================================================
1396 //function : Location
1398 //=======================================================================
1399 TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
1401 return theIObj->Transformation();
1404 //=======================================================================
1405 //function : SetDeviationCoefficient
1407 //=======================================================================
1408 void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
1410 myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
1413 //=======================================================================
1414 //function : SetDeviationAngle
1416 //=======================================================================
1417 void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
1419 myDefaultDrawer->SetDeviationCoefficient (theAngle);
1422 //=======================================================================
1423 //function : DeviationAngle
1424 //purpose : Gets deviationAngle
1425 //=======================================================================
1426 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1428 return myDefaultDrawer->DeviationAngle();
1431 //=======================================================================
1432 //function : DeviationCoefficient
1434 //=======================================================================
1435 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1437 return myDefaultDrawer->DeviationCoefficient();
1440 //=======================================================================
1441 //function : SetHLRDeviationCoefficient
1443 //=======================================================================
1444 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
1446 myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
1449 //=======================================================================
1450 //function : HLRDeviationCoefficient
1452 //=======================================================================
1453 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1455 return myDefaultDrawer->HLRDeviationCoefficient();
1458 //=======================================================================
1459 //function : SetHLRAngle
1461 //=======================================================================
1462 void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
1464 myDefaultDrawer->SetHLRAngle (theAngle);
1467 //=======================================================================
1468 //function : SetHLRAngleAndDeviation
1469 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1470 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1471 // of myDefaultDrawer
1472 //=======================================================================
1473 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
1475 Standard_Real anOutAngl, anOutDefl;
1476 HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
1478 myDefaultDrawer->SetHLRAngle (anOutAngl);
1479 myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
1482 //=======================================================================
1483 //function : HLRAngle
1485 //=======================================================================
1486 Standard_Real AIS_InteractiveContext::HLRAngle() const
1488 return myDefaultDrawer->HLRAngle();
1491 //=======================================================================
1492 //function : SetDisplayMode
1494 //=======================================================================
1495 void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
1496 const Standard_Boolean theToUpdateViewer)
1498 if (theMode == myDisplayMode)
1503 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1505 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1506 Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
1507 || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
1508 || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
1511 || anObj->HasDisplayMode()
1512 || !anObj->AcceptDisplayMode (theMode))
1517 Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
1518 if (aStatus->IsDModeIn (myDisplayMode))
1520 aStatus->RemoveDisplayMode (myDisplayMode);
1523 aStatus->AddDisplayMode (theMode);
1524 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1526 myMainPM->Display (anObj, theMode);
1527 if (aStatus->IsSubIntensityOn())
1529 myMainPM->Color (anObj, mySubIntensity, theMode);
1531 myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
1535 myDisplayMode = theMode;
1536 if (theToUpdateViewer)
1538 myMainVwr->Update();
1542 //=======================================================================
1543 //function : SetDisplayMode
1545 //=======================================================================
1546 void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1547 const Standard_Integer theMode,
1548 const Standard_Boolean theToUpdateViewer)
1550 if (!theIObj->HasInteractiveContext())
1552 theIObj->SetContext(this);
1555 if (!myObjects.IsBound (theIObj))
1557 theIObj->SetDisplayMode (theMode);
1560 else if (!theIObj->AcceptDisplayMode (theMode))
1565 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1566 if (aStatus->GraphicStatus() != AIS_DS_Displayed)
1568 theIObj->SetDisplayMode (theMode);
1572 // erase presentations for all display modes different from <aMode>
1573 TColStd_ListOfInteger aModesToRemove;
1574 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
1576 const Standard_Integer anOldMode = aDispModeIter.Value();
1577 if (anOldMode != theMode)
1579 aModesToRemove.Append (anOldMode);
1580 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1582 myMainPM->Unhighlight (theIObj, anOldMode);
1584 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1588 for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
1590 aStatus->RemoveDisplayMode (aRemModeIter.Value());
1593 if (!aStatus->IsDModeIn (theMode))
1595 aStatus->AddDisplayMode (theMode);
1598 myMainPM->Display (theIObj, theMode);
1599 Standard_Integer aDispMode, aHiMode, aSelMode;
1600 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1601 if (aStatus->IsHilighted())
1603 myMainPM->Highlight (theIObj, aHiMode);
1605 if (aStatus->IsSubIntensityOn())
1607 myMainPM->Color (theIObj, mySubIntensity, theMode);
1610 if (theToUpdateViewer)
1612 myMainVwr->Update();
1614 theIObj->SetDisplayMode (theMode);
1617 //=======================================================================
1618 //function : UnsetDisplayMode
1620 //=======================================================================
1621 void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1622 const Standard_Boolean theToUpdateViewer)
1624 if (theIObj.IsNull()
1625 || !theIObj->HasDisplayMode())
1630 if (!myObjects.IsBound (theIObj))
1632 theIObj->UnsetDisplayMode();
1636 const Standard_Integer anOldMode = theIObj->DisplayMode();
1637 if (myDisplayMode == anOldMode)
1642 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
1643 aStatus->RemoveDisplayMode (anOldMode);
1644 if (!aStatus->IsDModeIn(myDisplayMode))
1646 aStatus->AddDisplayMode (myDisplayMode);
1649 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1651 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1653 myMainPM->Unhighlight (theIObj, anOldMode);
1655 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1656 myMainPM->Display (theIObj, myDisplayMode);
1658 Standard_Integer aDispMode, aHiMode, aSelMode;
1659 GetDefModes (theIObj, aDispMode, aHiMode, aSelMode);
1660 if (aStatus->IsHilighted())
1662 myMainPM->Highlight (theIObj, aHiMode);
1664 if (aStatus->IsSubIntensityOn())
1666 myMainPM->Color (theIObj, mySubIntensity, myDisplayMode);
1669 if (theToUpdateViewer)
1671 myMainVwr->Update();
1675 theIObj->UnsetDisplayMode();
1678 //=======================================================================
1679 //function : SetCurrentFacingModel
1681 //=======================================================================
1682 void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
1683 const Aspect_TypeOfFacingModel theModel)
1685 if (!theIObj.IsNull())
1687 theIObj->SetCurrentFacingModel (theModel);
1691 //=======================================================================
1692 //function : redisplayPrsRecModes
1694 //=======================================================================
1695 void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1696 const Standard_Boolean theToUpdateViewer)
1698 if (theIObj->RecomputeEveryPrs())
1700 theIObj->Update (Standard_True);
1701 theIObj->UpdateSelection();
1705 for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
1707 theIObj->Update (aModes.Value(), Standard_False);
1709 theIObj->UpdateSelection();
1710 theIObj->SetRecomputeOk();
1713 if (theToUpdateViewer)
1715 UpdateCurrentViewer();
1719 //=======================================================================
1720 //function : redisplayPrsModes
1722 //=======================================================================
1723 void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1724 const Standard_Boolean theToUpdateViewer)
1726 if (theIObj->RecomputeEveryPrs())
1728 theIObj->Update (Standard_True);
1729 theIObj->UpdateSelection();
1733 TColStd_ListOfInteger aModes;
1734 theIObj->ToBeUpdated (aModes);
1735 for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
1737 theIObj->Update (aModeIter.Value(), Standard_False);
1739 theIObj->SetRecomputeOk();
1742 if (theToUpdateViewer)
1744 UpdateCurrentViewer();
1748 //=======================================================================
1749 //function : SetColor
1751 //=======================================================================
1752 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1753 const Quantity_NameOfColor theColor,
1754 const Standard_Boolean theToUpdateViewer)
1756 SetColor (theIObj, Quantity_Color(theColor), theToUpdateViewer);
1759 //=======================================================================
1760 //function : SetColor
1762 //=======================================================================
1763 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1764 const Quantity_Color& theColor,
1765 const Standard_Boolean theToUpdateViewer)
1767 if (theIObj.IsNull())
1772 if (!theIObj->HasInteractiveContext())
1774 theIObj->SetContext (this);
1776 theIObj->SetColor (theColor);
1777 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1780 //=======================================================================
1781 //function : SetDeviationCoefficient
1783 //=======================================================================
1784 void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1785 const Standard_Real theCoefficient,
1786 const Standard_Boolean theToUpdateViewer)
1788 if (theIObj.IsNull())
1793 if (!theIObj->HasInteractiveContext())
1795 theIObj->SetContext (this);
1798 // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
1799 if (theIObj->Type() != AIS_KOI_Object
1800 && theIObj->Type() != AIS_KOI_Shape)
1804 else if (theIObj->Signature() != 0)
1809 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1810 aShape->SetOwnDeviationCoefficient (theCoefficient);
1811 redisplayPrsModes (theIObj, theToUpdateViewer);
1814 //=======================================================================
1815 //function : SetHLRDeviationCoefficient
1817 //=======================================================================
1818 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1819 const Standard_Real theCoefficient,
1820 const Standard_Boolean theToUpdateViewer)
1822 if (theIObj.IsNull())
1827 if (!theIObj->HasInteractiveContext())
1829 theIObj->SetContext (this);
1832 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1833 if (theIObj->Type() != AIS_KOI_Object
1834 && theIObj->Type() != AIS_KOI_Shape)
1838 else if (theIObj->Signature() != 0)
1843 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1844 aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
1845 redisplayPrsModes (theIObj, theToUpdateViewer);
1848 //=======================================================================
1849 //function : SetDeviationAngle
1851 //=======================================================================
1852 void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1853 const Standard_Real theAngle,
1854 const Standard_Boolean theToUpdateViewer)
1856 if (theIObj.IsNull())
1861 if (!theIObj->HasInteractiveContext())
1863 theIObj->SetContext (this);
1866 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1867 if (theIObj->Type() != AIS_KOI_Shape)
1871 else if (theIObj->Signature() != 0)
1876 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1877 aShape->SetOwnDeviationAngle (theAngle);
1878 redisplayPrsModes (theIObj, theToUpdateViewer);
1881 //=======================================================================
1882 //function : SetAngleAndDeviation
1884 //=======================================================================
1885 void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1886 const Standard_Real theAngle,
1887 const Standard_Boolean theToUpdateViewer)
1889 if (theIObj.IsNull())
1894 if (!theIObj->HasInteractiveContext())
1896 theIObj->SetContext (this);
1899 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1900 if (theIObj->Type() != AIS_KOI_Shape)
1904 if (theIObj->Signature() != 0)
1909 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1910 aShape->SetAngleAndDeviation (theAngle);
1912 if (theIObj->RecomputeEveryPrs())
1914 theIObj->Update (Standard_True);
1915 theIObj->UpdateSelection();
1919 Update (theIObj, theToUpdateViewer);
1923 //=======================================================================
1924 //function : SetHLRAngleAndDeviation
1926 //=======================================================================
1927 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1928 const Standard_Real theAngle,
1929 const Standard_Boolean theToUpdateViewer)
1931 if (theIObj.IsNull())
1936 if (!theIObj->HasInteractiveContext())
1938 theIObj->SetContext (this);
1941 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1942 if (theIObj->Type() != AIS_KOI_Shape)
1946 if (theIObj->Signature() != 0)
1950 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1951 aShape->SetHLRAngleAndDeviation (theAngle);
1952 redisplayPrsModes (theIObj, theToUpdateViewer);
1955 //=======================================================================
1956 //function : SetHLRDeviationAngle
1958 //=======================================================================
1959 void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1960 const Standard_Real theAngle,
1961 const Standard_Boolean theToUpdateViewer)
1963 if (theIObj.IsNull())
1968 if (!theIObj->HasInteractiveContext())
1970 theIObj->SetContext (this);
1973 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1974 if (theIObj->Type() != AIS_KOI_Shape)
1978 if (theIObj->Signature() != 0)
1982 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1983 aShape->SetOwnHLRDeviationAngle (theAngle);
1984 redisplayPrsModes (theIObj, theToUpdateViewer);
1987 //=======================================================================
1988 //function : UnsetColor
1990 //=======================================================================
1991 void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
1992 const Standard_Boolean theToUpdateViewer)
1994 if (theIObj.IsNull())
1999 theIObj->UnsetColor();
2000 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2003 //=======================================================================
2004 //function : HasColor
2006 //=======================================================================
2007 Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
2009 return theIObj->HasColor();
2012 //=======================================================================
2015 //=======================================================================
2016 Quantity_NameOfColor AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj) const
2018 return theIObj->Color();
2021 //=======================================================================
2024 //=======================================================================
2025 void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
2026 Quantity_Color& theColor) const
2028 theIObj->Color (theColor);
2031 //=======================================================================
2034 //=======================================================================
2035 Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
2037 return theIObj->Width();
2040 //=======================================================================
2041 //function : SetWidth
2043 //=======================================================================
2044 void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2045 const Standard_Real theWidth,
2046 const Standard_Boolean theToUpdateViewer)
2048 if (theIObj.IsNull())
2053 if (!theIObj->HasInteractiveContext())
2055 theIObj->SetContext (this);
2058 theIObj->SetWidth (theWidth);
2059 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2062 //=======================================================================
2063 //function : UnsetWidth
2065 //=======================================================================
2066 void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2067 const Standard_Boolean theToUpdateViewer)
2069 if (theIObj.IsNull())
2074 theIObj->UnsetWidth();
2075 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2078 //=======================================================================
2079 //function : SetMaterial
2081 //=======================================================================
2082 void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2083 const Graphic3d_NameOfMaterial theName,
2084 const Standard_Boolean theToUpdateViewer)
2086 if (theIObj.IsNull())
2091 if (!theIObj->HasInteractiveContext())
2093 theIObj->SetContext (this);
2096 theIObj->SetMaterial (theName);
2097 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2100 //=======================================================================
2101 //function : UnsetMaterial
2103 //=======================================================================
2104 void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2105 const Standard_Boolean theToUpdateViewer)
2107 if (theIObj.IsNull())
2111 theIObj->UnsetMaterial();
2112 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2115 //=======================================================================
2116 //function : SetTransparency
2118 //=======================================================================
2119 void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2120 const Standard_Real theValue,
2121 const Standard_Boolean theToUpdateViewer)
2123 if (theIObj.IsNull())
2128 if (!theIObj->HasInteractiveContext())
2130 theIObj->SetContext (this);
2133 if (!theIObj->IsTransparent()
2134 && theValue <= 0.05)
2139 if (theValue <= 0.05)
2141 UnsetTransparency (theIObj, theToUpdateViewer);
2145 theIObj->SetTransparency (theValue);
2146 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2149 //=======================================================================
2150 //function : UnsetTransparency
2152 //=======================================================================
2153 void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2154 const Standard_Boolean theToUpdateViewer)
2156 if (theIObj.IsNull())
2161 theIObj->UnsetTransparency();
2162 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2165 //=======================================================================
2166 //function : SetSelectedAspect
2168 //=======================================================================
2169 void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
2170 const Standard_Boolean theIsGlobalChange,
2171 const Standard_Boolean theToUpdateViewer)
2173 if (HasOpenedContext())
2178 Standard_Boolean isFound = Standard_False;
2179 Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString());
2180 for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
2182 isFound = Standard_True;
2183 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
2184 anObj->SetAspect (theAspect, theIsGlobalChange);
2188 && theToUpdateViewer)
2190 myMainVwr->Update();
2194 //=======================================================================
2195 //function : SetLocalAttributes
2197 //=======================================================================
2198 void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2199 const Handle(Prs3d_Drawer)& theDrawer,
2200 const Standard_Boolean theToUpdateViewer)
2202 if (theIObj.IsNull())
2207 if (!theIObj->HasInteractiveContext())
2209 theIObj->SetContext (this);
2212 theIObj->SetAttributes (theDrawer);
2213 Update (theIObj, theToUpdateViewer);
2216 //=======================================================================
2217 //function : UnsetLocalAttributes
2219 //=======================================================================
2220 void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2221 const Standard_Boolean theToUpdateViewer)
2223 if (theIObj.IsNull())
2228 if (!theIObj->HasInteractiveContext())
2230 theIObj->SetContext (this);
2232 theIObj->UnsetAttributes();
2233 Update (theIObj, theToUpdateViewer);
2236 //=======================================================================
2239 //=======================================================================
2240 void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
2241 TCollection_ExtendedString& theStatus) const
2244 if (theIObj.IsNull()
2245 || !myObjects.IsBound (theIObj))
2250 theStatus += "\t ____________________________________________";
2251 theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2252 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2253 switch (aStatus->GraphicStatus())
2255 case AIS_DS_Displayed:
2257 theStatus += "\t| -->Displayed\n";
2262 theStatus += "\t| -->Erased\n";
2269 theStatus += "\t| Active Display Modes in the MainViewer :\n";
2270 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2272 theStatus += "\t|\t Mode ";
2273 theStatus += TCollection_AsciiString (aDispModeIter.Value());
2276 if (IsCurrent (theIObj)) theStatus +="\t| Current\n";
2277 if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
2279 theStatus += "\t| Active Selection Modes in the MainViewer :\n";
2280 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2282 theStatus += "\t\t Mode ";
2283 theStatus += TCollection_AsciiString (aSelModeIter.Value());
2286 theStatus += "\t ____________________________________________";
2289 //=======================================================================
2290 //function : GetDefModes
2292 //=======================================================================
2293 void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
2294 Standard_Integer& theDispMode,
2295 Standard_Integer& theHiMode,
2296 Standard_Integer& theSelMode) const
2298 if (theIObj.IsNull())
2303 theDispMode = theIObj->HasDisplayMode()
2304 ? theIObj->DisplayMode()
2305 : (theIObj->AcceptDisplayMode (myDisplayMode)
2308 theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
2309 theSelMode = theIObj->HasSelectionMode() ? theIObj->SelectionMode() : -1;
2312 //=======================================================================
2313 //function : EraseGlobal
2315 //=======================================================================
2316 void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2317 const Standard_Boolean theToUpdateviewer)
2319 if (theIObj.IsNull()
2320 || !myObjects.IsBound (theIObj))
2325 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2327 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2328 if (aStatus->GraphicStatus() == AIS_DS_Temporary
2329 || aStatus->GraphicStatus() == AIS_DS_Erased)
2334 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2336 if (aStatus->IsHilighted())
2338 if (IsCurrent (theIObj))
2340 AddOrRemoveCurrentObject (theIObj, Standard_False);
2342 else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2344 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2348 myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
2351 if (IsCurrent (theIObj)
2352 && !aStatus->IsDModeIn (aDispMode))
2354 myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
2357 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2359 mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
2361 aStatus->SetGraphicStatus (AIS_DS_Erased);
2363 if (theToUpdateviewer)
2365 myMainVwr->Update();
2369 //=======================================================================
2370 //function : ClearGlobal
2372 //=======================================================================
2373 void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2374 const Standard_Boolean theToUpdateviewer)
2376 if (theIObj.IsNull()
2377 || !myObjects.IsBound (theIObj))
2379 // for cases when reference shape of connected interactives was not displayed
2380 // but its selection primitives were calculated
2381 mgrSelector->Remove (theIObj);
2385 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2386 for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
2388 if (aStatus->IsHilighted())
2390 if (IsCurrent (theIObj))
2392 AddOrRemoveCurrentObject (theIObj, theToUpdateviewer);
2394 else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
2396 myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
2399 myMainPM->Erase (theIObj, aDispModeIter.Value());
2400 myMainPM->Clear (theIObj, aDispModeIter.Value());
2401 if (theIObj->HasHilightMode())
2403 Standard_Integer im = theIObj->HilightMode();
2404 myMainPM->Unhighlight (theIObj, im);
2405 myMainPM->Erase (theIObj, im);
2409 // Object removes from Detected sequence
2410 for(Standard_Integer aDetIter = 1; aDetIter < myAISDetectedSeq.Length(); ++aDetIter)
2412 Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
2414 && anObj != theIObj)
2416 myAISDetectedSeq.Remove (aDetIter);
2420 if (myLastinMain == theIObj)
2422 myLastinMain.Nullify();
2424 if (myLastPicked == theIObj)
2426 myLastPicked.Nullify();
2429 // remove IO from the selection manager to avoid memory leaks
2430 mgrSelector->Remove (theIObj);
2432 myObjects.UnBind (theIObj);
2433 myMainVwr->Viewer()->UnregisterObject (theIObj);
2434 for (myMainVwr->InitDefinedViews(); myMainVwr->MoreDefinedViews(); myMainVwr->NextDefinedViews())
2436 myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj);
2439 if (theToUpdateviewer
2440 && aStatus->GraphicStatus() == AIS_DS_Displayed)
2442 myMainVwr->Update();
2446 //=======================================================================
2447 //function : ClearGlobalPrs
2449 //=======================================================================
2450 void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
2451 const Standard_Integer theMode,
2452 const Standard_Boolean theToUpdateViewer)
2454 if (theIObj.IsNull()
2455 || !myObjects.IsBound (theIObj))
2460 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2461 if (aStatus->IsDModeIn (theMode))
2463 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2464 if (aDispMode == theMode
2465 && myMainPM->IsHighlighted (theIObj, theMode))
2467 myMainPM->Unhighlight (theIObj, theMode);
2470 myMainPM->Erase (theIObj, theMode);
2471 myMainPM->Clear (theIObj, theMode);
2474 if (aStatus->GraphicStatus() == AIS_DS_Displayed
2475 && theToUpdateViewer)
2477 myMainVwr->Update();
2481 //=======================================================================
2482 //function : DrawHiddenLine
2484 //=======================================================================
2485 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
2487 return myDefaultDrawer->DrawHiddenLine();
2490 //=======================================================================
2491 //function : EnableDrawHiddenLine
2493 //=======================================================================
2494 void AIS_InteractiveContext::EnableDrawHiddenLine() const
2496 myDefaultDrawer->EnableDrawHiddenLine();
2499 //=======================================================================
2500 //function : DisableDrawHiddenLine
2502 //=======================================================================
2503 void AIS_InteractiveContext::DisableDrawHiddenLine() const
2505 myDefaultDrawer->DisableDrawHiddenLine();
2508 //=======================================================================
2509 //function : HiddenLineAspect
2511 //=======================================================================
2512 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
2514 return myDefaultDrawer->HiddenLineAspect();
2517 //=======================================================================
2518 //function : SetHiddenLineAspect
2520 //=======================================================================
2521 void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
2523 myDefaultDrawer->SetHiddenLineAspect (theAspect);
2526 //=======================================================================
2527 //function : SetIsoNumber
2529 //=======================================================================
2530 void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
2531 const AIS_TypeOfIso theType)
2536 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2539 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2542 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2543 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2548 //=======================================================================
2549 //function : IsoNumber
2551 //=======================================================================
2552 Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
2556 case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
2557 case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
2558 case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
2559 ? myDefaultDrawer->UIsoAspect()->Number()
2565 //=======================================================================
2566 //function : IsoOnPlane
2568 //=======================================================================
2569 void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
2571 myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
2574 //=======================================================================
2575 //function : IsoOnPlane
2577 //=======================================================================
2578 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2580 return myDefaultDrawer->IsoOnPlane();
2583 //=======================================================================
2584 //function : SetSelectionMode
2586 //=======================================================================
2587 void AIS_InteractiveContext::SetSelectionMode (const Handle(AIS_InteractiveObject)& ,
2588 const Standard_Integer )
2593 //=======================================================================
2594 //function : UnsetSelectionMode
2596 //=======================================================================
2597 void AIS_InteractiveContext::UnsetSelectionMode (const Handle(AIS_InteractiveObject)& )
2602 //=======================================================================
2603 //function : SetPixelTolerance
2604 //purpose : Disables the mechanism of adaptive tolerance calculation in
2605 // SelectMgr_ViewerSelector and sets the given tolerance for ALL
2606 // sensitive entities activated. For more information, see
2607 // SelectMgr_ViewerSelector.hxx
2608 //=======================================================================
2609 void AIS_InteractiveContext::SetPixelTolerance (const Standard_Real thePrecision)
2611 if (HasOpenedContext())
2613 myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
2617 myMainSel->SetPixelTolerance (thePrecision);
2621 //=======================================================================
2622 //function : PixelTolerance
2624 //=======================================================================
2625 Standard_Real AIS_InteractiveContext::PixelTolerance() const
2627 return HasOpenedContext()
2628 ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
2629 : myMainSel->PixelTolerance();
2632 //=======================================================================
2633 //function : IsInLocal
2635 //=======================================================================
2636 Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
2637 Standard_Integer& theIndex) const
2639 if (theIObj.IsNull())
2641 return Standard_False;
2644 // if it exists at neutral point 0 index is returned
2645 if (myObjects.IsBound (theIObj))
2648 return Standard_False;
2651 for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
2653 if (myLocalContexts.IsBound (aCtxIter))
2655 if(myLocalContexts (aCtxIter)->IsIn (theIObj))
2657 theIndex = aCtxIter;
2658 return Standard_True;
2663 return Standard_False;
2666 //=======================================================================
2667 //function : InitAttributes
2669 //=======================================================================
2670 void AIS_InteractiveContext::InitAttributes()
2672 mgrSelector->Add (myMainSel);
2673 myCurrentName = AIS_Context_NewCurName();
2674 mySelectionName = AIS_Context_NewSelName();
2676 AIS_Selection::CreateSelection (mySelectionName.ToCString());
2677 AIS_Selection::CreateSelection (myCurrentName.ToCString());
2679 myDefaultDrawer->SetShadingAspectGlobal (Standard_False);
2680 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
2681 myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
2683 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2684 Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
2685 aLineAspect->SetColor (Quantity_NOC_GRAY20);
2686 aLineAspect->SetWidth (1.0);
2687 aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
2689 // tolerance to 2 pixels...
2690 SetPixelTolerance (2.0);
2692 // Customizing the drawer for trihedrons and planes...
2693 Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
2694 const Standard_Real aLength = 100.0;
2695 aTrihAspect->SetAxisLength (aLength, aLength, aLength);
2696 const Quantity_NameOfColor aColor = Quantity_NOC_LIGHTSTEELBLUE4;
2697 aTrihAspect->FirstAxisAspect() ->SetColor (aColor);
2698 aTrihAspect->SecondAxisAspect()->SetColor (aColor);
2699 aTrihAspect->ThirdAxisAspect() ->SetColor (aColor);
2701 Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
2702 const Standard_Real aPlaneLength = 200.0;
2703 aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
2704 aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
2707 //=======================================================================
2708 //function : TrihedronSize
2710 //=======================================================================
2711 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2713 return myDefaultDrawer->DatumAspect()->FirstAxisLength();
2716 //=======================================================================
2717 //function : SetTrihedronSize
2719 //=======================================================================
2720 void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
2721 const Standard_Boolean /*updateviewer*/)
2723 myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
2724 Redisplay (AIS_KOI_Datum, 3, Standard_False);
2725 Redisplay (AIS_KOI_Datum, 4, Standard_True);
2728 //=======================================================================
2729 //function : SetPlaneSize
2731 //=======================================================================
2732 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
2733 const Standard_Real theValY,
2734 const Standard_Boolean /*updateviewer*/)
2736 myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
2737 Redisplay (AIS_KOI_Datum, 7);
2740 //=======================================================================
2741 //function : SetPlaneSize
2743 //=======================================================================
2744 void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
2745 const Standard_Boolean theToUpdateViewer)
2747 SetPlaneSize (theVal, theVal, theToUpdateViewer);
2750 //=======================================================================
2751 //function : PlaneSize
2753 //=======================================================================
2754 Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
2755 Standard_Real& theY) const
2757 theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2758 theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2759 return (Abs (theX - theY) <= Precision::Confusion());
2762 //=======================================================================
2763 //function : SetAutoActivateSelection
2765 //=======================================================================
2766 void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
2768 myIsAutoActivateSelMode = theIsAuto;
2771 //=======================================================================
2772 //function : GetAutoActivateSelection
2774 //=======================================================================
2775 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2777 return myIsAutoActivateSelMode;
2780 //=======================================================================
2781 //function : SetZLayer
2783 //=======================================================================
2784 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2785 const Standard_Integer theLayerId)
2787 if (theIObj.IsNull())
2790 theIObj->SetZLayer (theLayerId);
2793 //=======================================================================
2794 //function : GetZLayer
2796 //=======================================================================
2797 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2799 return !theIObj.IsNull()
2801 : Graphic3d_ZLayerId_UNKNOWN;
2804 //=======================================================================
2805 //function : RebuildSelectionStructs
2806 //purpose : Rebuilds 1st level of BVH selection forcibly
2807 //=======================================================================
2808 void AIS_InteractiveContext::RebuildSelectionStructs()
2810 myMainSel->RebuildObjectsTree (Standard_True);
2813 //=======================================================================
2814 //function : Disconnect
2815 //purpose : Disconnects selectable object from an assembly and updates selection structures
2816 //=======================================================================
2817 void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly,
2818 const Handle(AIS_InteractiveObject)& theObjToDisconnect)
2820 if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive"))
2822 const Handle(AIS_MultipleConnectedInteractive)& theObj =
2823 Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly);
2824 theObj->Disconnect (theObjToDisconnect);
2825 mgrSelector->Remove (theObjToDisconnect);
2827 else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect == NULL)
2829 const Handle(AIS_ConnectedInteractive)& theObj =
2830 Handle(AIS_ConnectedInteractive)::DownCast (theAssembly);
2831 theObj->Disconnect();
2832 mgrSelector->Remove (theObj);
2838 //=======================================================================
2839 //function : FitSelected
2840 //purpose : Fits the view corresponding to the bounds of selected objects
2841 //=======================================================================
2842 void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
2843 const Standard_Real theMargin,
2844 const Standard_Boolean theToUpdate)
2846 Standard_CString aSelName = HasOpenedContext() ?
2847 myLocalContexts (myCurLocalIndex)->SelectionName().ToCString()
2848 : myCurrentName.ToCString();
2850 Bnd_Box aBndSelected;
2852 const Handle(AIS_Selection)& aSelection = AIS_Selection::Selection (aSelName);
2853 AIS_MapOfObjectOwners anObjectOwnerMap;
2854 for (aSelection->Init(); aSelection->More(); aSelection->Next())
2856 const Handle(AIS_InteractiveObject)& anObj =
2857 Handle(AIS_InteractiveObject)::DownCast (aSelection->Value());
2858 if (!anObj.IsNull())
2860 if (anObj->IsInfinite())
2864 anObj->BoundingBox (aTmpBnd);
2865 aBndSelected.Add (aTmpBnd);
2869 const Handle(SelectMgr_EntityOwner)& anOwner =
2870 Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Value());
2871 if (anOwner.IsNull())
2874 Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap;
2875 if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap))
2877 anOwnerMap = new SelectMgr_IndexedMapOfOwner();
2878 anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap);
2881 anOwnerMap->Add (anOwner);
2885 for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next())
2887 const Handle(SelectMgr_SelectableObject) anObject = anIter.Key();
2888 Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue());
2889 aBndSelected.Add (aTmpBox);
2892 anObjectOwnerMap.Clear();
2894 if (aBndSelected.IsVoid())
2897 theView->FitAll (aBndSelected, theMargin, theToUpdate);