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 #include <AIS_InteractiveContext.hxx>
19 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
20 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
21 #include <AIS_ConnectedInteractive.hxx>
22 #include <AIS_GlobalStatus.hxx>
23 #include <AIS_InteractiveObject.hxx>
24 #include <AIS_ListIteratorOfListOfInteractive.hxx>
25 #include <AIS_LocalContext.hxx>
26 #include <AIS_LocalStatus.hxx>
27 #include <AIS_MapIteratorOfMapOfInteractive.hxx>
28 #include <AIS_MultipleConnectedInteractive.hxx>
29 #include <AIS_Shape.hxx>
30 #include <AIS_Trihedron.hxx>
31 #include <Geom_Axis2Placement.hxx>
32 #include <Graphic3d_AspectFillArea3d.hxx>
33 #include <HLRBRep.hxx>
34 #include <OSD_Environment.hxx>
35 #include <Precision.hxx>
36 #include <Prs3d_BasicAspect.hxx>
37 #include <Prs3d_DatumAspect.hxx>
38 #include <Prs3d_IsoAspect.hxx>
39 #include <Prs3d_LineAspect.hxx>
40 #include <Prs3d_PlaneAspect.hxx>
41 #include <Prs3d_PointAspect.hxx>
42 #include <Prs3d_ShadingAspect.hxx>
43 #include <PrsMgr_ModedPresentation.hxx>
44 #include <PrsMgr_PresentableObject.hxx>
45 #include <Quantity_Color.hxx>
46 #include <SelectMgr_EntityOwner.hxx>
47 #include <SelectMgr_Filter.hxx>
48 #include <SelectMgr_OrFilter.hxx>
49 #include <SelectMgr_SelectionManager.hxx>
50 #include <Standard_Atomic.hxx>
51 #include <Standard_Transient.hxx>
52 #include <Standard_Type.hxx>
53 #include <StdSelect_ViewerSelector3d.hxx>
54 #include <TCollection_AsciiString.hxx>
55 #include <TCollection_ExtendedString.hxx>
56 #include <TColStd_ListIteratorOfListOfInteger.hxx>
57 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
58 #include <TopLoc_Location.hxx>
59 #include <TopoDS_Shape.hxx>
60 #include <UnitsAPI.hxx>
61 #include <V3d_View.hxx>
62 #include <V3d_Viewer.hxx>
64 IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
68 typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
69 typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners;
71 //! Initialize default highlighting attributes.
72 static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
74 theDrawer->SetMethod (Aspect_TOHM_COLOR);
75 theDrawer->SetDisplayMode (0);
77 theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
78 *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
79 theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
80 *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
81 theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
82 *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
83 theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect());
84 *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect();
85 theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
86 *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
87 theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
88 *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
90 theDrawer->WireAspect()->SetWidth (2.0);
91 theDrawer->LineAspect()->SetWidth (2.0);
92 theDrawer->PlaneAspect()->EdgesAspect()->SetWidth (2.0);
93 theDrawer->FreeBoundaryAspect() ->SetWidth (2.0);
94 theDrawer->UnFreeBoundaryAspect()->SetWidth (2.0);
95 theDrawer->PointAspect()->SetTypeOfMarker (Aspect_TOM_O_POINT);
96 theDrawer->PointAspect()->SetScale (2.0);
98 // the triangulation should be computed using main presentation attributes,
99 // and should not be overridden by highlighting
100 theDrawer->SetAutoTriangulation (Standard_False);
104 //=======================================================================
105 //function : AIS_InteractiveContext
107 //=======================================================================
109 AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
110 mgrSelector(new SelectMgr_SelectionManager()),
111 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())),
112 myMainVwr(MainViewer),
113 myMainSel(new StdSelect_ViewerSelector3d()),
114 myWasLastMain(Standard_False),
115 myToHilightSelected(Standard_True),
116 mySelection(new AIS_Selection()),
117 myFilters(new SelectMgr_OrFilter()),
118 myDefaultDrawer(new Prs3d_Drawer()),
122 myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable),
123 myIsAutoActivateSelMode(Standard_True)
125 myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
126 myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer();
127 myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer();
128 myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer();
129 myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer();
130 myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer();
132 myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default);
133 myDefaultDrawer->SetDisplayMode(0);
135 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic];
136 aStyle->Link (myDefaultDrawer);
137 initDefaultHilightAttributes (aStyle);
138 aStyle->SetZLayer(Graphic3d_ZLayerId_Top);
139 aStyle->SetColor (Quantity_NOC_CYAN1);
142 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic];
143 aStyle->Link (myDefaultDrawer);
144 initDefaultHilightAttributes (aStyle);
145 aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost);
146 aStyle->SetColor (Quantity_NOC_CYAN1);
149 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected];
150 aStyle->Link (myDefaultDrawer);
151 initDefaultHilightAttributes (aStyle);
152 aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
153 aStyle->SetColor (Quantity_NOC_GRAY80);
156 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected];
157 aStyle->Link (myDefaultDrawer);
158 initDefaultHilightAttributes (aStyle);
159 aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
160 aStyle->SetColor (Quantity_NOC_GRAY80);
163 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
164 aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
165 aStyle->SetMethod(Aspect_TOHM_COLOR);
166 aStyle->SetColor (Quantity_NOC_GRAY40);
172 //=======================================================================
173 //function : ~AIS_InteractiveContext
175 //=======================================================================
176 AIS_InteractiveContext::~AIS_InteractiveContext()
178 // clear the current selection
179 mySelection->Clear();
181 // let's remove one reference explicitly. this operation's supposed to
182 // be performed when mgrSelector will be destroyed but anyway...
183 const Handle(SelectMgr_ViewerSelector)& aSelector = myMainSel; // to avoid ambiguity
184 mgrSelector->Remove (aSelector);
186 Handle(AIS_InteractiveContext) aNullContext;
187 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
189 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
190 anObj->SetContext (aNullContext);
191 for (anObj->Init(); anObj->More(); anObj->Next())
193 anObj->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Renew);
198 //=======================================================================
199 //function : UpdateCurrentViewer
201 //=======================================================================
203 void AIS_InteractiveContext::UpdateCurrentViewer()
205 if (!myMainVwr.IsNull())
209 //=======================================================================
210 //function : DisplayedObjects
212 //=======================================================================
213 void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
214 const Standard_Boolean theOnlyFromNeutral) const
216 if (!HasOpenedContext()
217 || theOnlyFromNeutral)
219 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
221 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
223 theListOfIO.Append (anObjIter.Key());
230 TColStd_MapOfTransient aDispMap;
231 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
233 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
235 aDispMap.Add (anObjIter.Key());
239 // parse all local contexts...
240 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
242 const Handle(AIS_LocalContext)& aLocCtx = aCtxIter.Value();
243 aLocCtx->DisplayedObjects (aDispMap);
246 Handle(AIS_InteractiveObject) anObj;
247 for (TColStd_MapIteratorOfMapOfTransient aDispMapIter (aDispMap); aDispMapIter.More(); aDispMapIter.Next())
249 const Handle(Standard_Transient)& aTransient = aDispMapIter.Key();
250 anObj = Handle(AIS_InteractiveObject)::DownCast (aTransient);
251 theListOfIO.Append (anObj);
255 //=======================================================================
256 //function : DisplayedObjects
258 //=======================================================================
259 void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
260 const Standard_Integer theSign,
261 AIS_ListOfInteractive& theListOfIO,
262 const Standard_Boolean /*OnlyFromNeutral*/) const
264 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
267 //=======================================================================
268 //function : ErasedObjects
270 //=======================================================================
271 void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const
273 ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO);
276 //=======================================================================
277 //function : ErasedObjects
279 //=======================================================================
280 void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind,
281 const Standard_Integer theSign,
282 AIS_ListOfInteractive& theListOfIO) const
284 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO);
287 //=======================================================================
288 //function : ObjectsByDisplayStatus
290 //=======================================================================
291 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus,
292 AIS_ListOfInteractive& theListOfIO) const
294 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
296 if (anObjIter.Value()->GraphicStatus() == theStatus)
298 theListOfIO.Append (anObjIter.Key());
303 //=======================================================================
304 //function : ObjectsByDisplayStatus
306 //=======================================================================
307 void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind,
308 const Standard_Integer theSign,
309 const AIS_DisplayStatus theStatus,
310 AIS_ListOfInteractive& theListOfIO) const
312 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
314 if (theStatus != AIS_DS_None
315 && anObjIter.Value()->GraphicStatus() != theStatus)
319 else if (anObjIter.Key()->Type() != theKind)
325 || anObjIter.Key()->Signature() == theSign)
327 theListOfIO.Append (anObjIter.Key());
332 //=======================================================================
333 //function : ObjectsInside
335 //=======================================================================
336 void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO,
337 const AIS_KindOfInteractive theKind,
338 const Standard_Integer theSign) const
340 if (theKind == AIS_KOI_None
343 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
345 theListOfIO.Append (anObjIter.Key());
350 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
352 if (anObjIter.Key()->Type() != theKind)
358 || anObjIter.Key()->Signature() == theSign)
360 theListOfIO.Append (anObjIter.Key());
365 //=======================================================================
366 //function : ObjectsForView
368 //=======================================================================
369 void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO,
370 const Handle(V3d_View)& theView,
371 const Standard_Boolean theIsVisibleInView,
372 const AIS_DisplayStatus theStatus) const
374 Handle(Graphic3d_CView) aViewImpl = theView->View();
375 const Standard_Integer aViewId = aViewImpl->Identification();
376 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
378 if (theStatus != AIS_DS_None
379 && anObjIter.Value()->GraphicStatus() != theStatus)
381 theListOfIO.Append (anObjIter.Key());
385 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key());
386 const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
387 if (isVisible == theIsVisibleInView)
389 theListOfIO.Append (anObjIter.Key());
394 //=======================================================================
397 //=======================================================================
398 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
399 const Standard_Boolean theToUpdateViewer)
401 if (theIObj.IsNull())
406 Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
407 GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
409 Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
410 theToUpdateViewer, theIObj->AcceptShapeDecomposition());
413 //=======================================================================
414 //function : SetViewAffinity
416 //=======================================================================
417 void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj,
418 const Handle(V3d_View)& theView,
419 const Standard_Boolean theIsVisible)
422 || !myObjects.IsBound (theIObj))
427 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj);
428 Handle(Graphic3d_CView) aViewImpl = theView->View();
429 anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True);
432 theView->View()->ChangeHiddenObjects()->Remove (theIObj.get());
436 theView->View()->ChangeHiddenObjects()->Add (theIObj.get());
440 //=======================================================================
443 //=======================================================================
444 void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
445 const Standard_Integer theDispMode,
446 const Standard_Integer theSelectionMode,
447 const Standard_Boolean theToUpdateViewer,
448 const Standard_Boolean theToAllowDecomposition,
449 const AIS_DisplayStatus theDispStatus)
451 if (theIObj.IsNull())
456 if (theDispStatus == AIS_DS_Erased)
458 Erase (theIObj, theToUpdateViewer);
459 Load (theIObj, theSelectionMode, theToAllowDecomposition);
463 setContextToObject (theIObj);
464 if (theDispStatus == AIS_DS_Temporary
465 && !HasOpenedContext())
469 else if (HasOpenedContext())
471 if (theDispStatus == AIS_DS_None
472 || theDispStatus == AIS_DS_Temporary)
474 myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
475 if (theToUpdateViewer)
483 if (!myObjects.IsBound (theIObj))
485 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
486 myObjects.Bind (theIObj, aStatus);
487 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->RegisterObject (theIObj);
488 myMainPM->Display(theIObj, theDispMode);
489 if (theSelectionMode != -1)
491 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
492 if (!mgrSelector->Contains (anObj))
494 mgrSelector->Load (theIObj);
496 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
501 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
502 if (aStatus->GraphicStatus() == AIS_DS_Temporary)
507 // Mark the presentation modes hidden of interactive object different from aDispMode.
508 // Then make sure aDispMode is displayed and maybe highlighted.
509 // Finally, activate selection mode <SelMode> if not yet activated.
510 const Standard_Integer anOldMode = aStatus->DisplayMode();
511 if (anOldMode != theDispMode)
513 if(myMainPM->IsHighlighted (theIObj, anOldMode))
515 unhighlightGlobal (theIObj);
517 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
520 aStatus->SetDisplayMode (theDispMode);
522 myMainPM->Display (theIObj, theDispMode);
523 aStatus->SetGraphicStatus (AIS_DS_Displayed);
524 if (aStatus->IsHilighted())
526 highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode);
528 if (theSelectionMode != -1)
530 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
531 if (!mgrSelector->Contains (anObj))
533 mgrSelector->Load (theIObj);
535 if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
537 if (!aStatus->IsSModeIn (theSelectionMode))
538 aStatus->AddSelectionMode (theSelectionMode);
539 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
544 if (theToUpdateViewer)
550 //=======================================================================
553 //=======================================================================
554 void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
555 const Standard_Integer theSelMode,
556 const Standard_Boolean theToAllowDecomposition)
558 if (theIObj.IsNull())
563 setContextToObject (theIObj);
564 if (HasOpenedContext())
566 myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
571 && !theToAllowDecomposition)
573 if (!myObjects.IsBound (theIObj))
575 Standard_Integer aDispMode, aHiMod, aSelModeDef;
576 GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
577 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, aSelModeDef);
578 myObjects.Bind (theIObj, aStatus);
581 // Register theIObj in the selection manager to prepare further activation of selection
582 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
583 if (!mgrSelector->Contains (anObj))
585 mgrSelector->Load (theIObj);
590 //=======================================================================
593 //=======================================================================
594 void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
595 const Standard_Boolean theToUpdateViewer)
597 if (theIObj.IsNull())
602 if (!theIObj->IsAutoHilight())
604 theIObj->ClearSelected();
607 Standard_Boolean wasInCtx = Standard_False;
608 if (HasOpenedContext())
610 // First it is checked if it is possible to remove in the current local context
611 // then one tries to remove in other local contexts, if they allow it...
612 wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
613 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
615 if (aCtxIter.Value()->AcceptErase())
617 wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
624 EraseGlobal (theIObj, Standard_False);
627 if (theToUpdateViewer)
633 //=======================================================================
634 //function : EraseAll
636 //=======================================================================
637 void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
639 if (HasOpenedContext())
644 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
646 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
648 Erase (anObjIter.Key(), Standard_False);
652 if (theToUpdateViewer)
658 //=======================================================================
659 //function : DisplayAll
661 //=======================================================================
662 void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
664 if (HasOpenedContext())
669 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
671 const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
672 if (aStatus == AIS_DS_Erased)
674 Display (anObjIter.Key(), Standard_False);
678 if (theToUpdateViewer)
684 //=======================================================================
685 //function : DisplaySelected
687 //=======================================================================
688 void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
690 if (HasOpenedContext())
695 Standard_Boolean isFound = Standard_False;
696 for (mySelection->Init(); mySelection->More(); mySelection->Next())
698 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
699 Display (anObj, Standard_False);
700 isFound = Standard_True;
703 if (isFound && theToUpdateViewer)
709 //=======================================================================
710 //function : EraseSelected
712 //=======================================================================
713 void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
715 if (HasOpenedContext())
720 Standard_Boolean isFound = Standard_False;
722 while (mySelection->More())
724 Handle(SelectMgr_EntityOwner) anOwner = mySelection->Value();
725 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
727 Erase (anObj, Standard_False);
728 isFound = Standard_True;
733 if (isFound && theToUpdateViewer)
739 //=======================================================================
742 //=======================================================================
744 Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
745 const Standard_Integer WhichContext)
747 if(anIObj.IsNull()) return Standard_False;
749 if(!HasOpenedContext()) return Standard_False;
750 if(myObjects.IsBound(anIObj)) return Standard_False;
751 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
753 // Protection : if one tries to preserve a temporary object
754 // which is not in the local active context... rob 11-06-97
756 Standard_Integer IsItInLocal = myCurLocalIndex;
757 Standard_Boolean Found(Standard_False);
759 while(IsItInLocal>0 && !Found){
760 if(!myLocalContexts.IsBound(IsItInLocal))
762 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
763 Found = Standard_True;
768 if(!Found) return Standard_False;
771 // const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
772 // myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
774 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
775 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
779 if(LS->IsTemporary()){
780 Standard_Integer DM,HM,SM;
781 GetDefModes(anIObj,DM,HM,SM);
783 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
784 if(LS->DisplayMode()!= DM ){
785 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
786 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
789 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
793 // GS->SubIntensityOn();
794 myObjects.Bind(anIObj,GS);
795 mgrSelector->Load(anIObj);
796 mgrSelector->Activate(anIObj,SM,myMainSel);
798 LS->SetTemporary(Standard_False);
800 return Standard_True;
803 //=======================================================================
804 //function : DisplayStatus
806 //=======================================================================
807 AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
809 if (theIObj.IsNull())
813 else if (myObjects.IsBound (theIObj))
815 return myObjects (theIObj)->GraphicStatus();
818 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
820 if (aCtxIter.Value()->IsIn (theIObj))
822 return AIS_DS_Temporary;
828 //=======================================================================
831 //=======================================================================
832 void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
833 const Standard_Boolean theToUpdateViewer)
835 if (theIObj.IsNull())
840 if (theIObj->HasInteractiveContext())
842 if (theIObj->myCTXPtr != this)
844 throw Standard_ProgramError("AIS_InteractiveContext - object has been displayed in another context!");
846 theIObj->SetContext (Handle(AIS_InteractiveContext)());
849 if (HasOpenedContext())
851 myLocalContexts (myCurLocalIndex)->Remove (theIObj);
852 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
854 if (aCtxIter.Value()->AcceptErase())
856 aCtxIter.Value()->Remove (theIObj);
861 ClearGlobal (theIObj, theToUpdateViewer);
864 //=======================================================================
865 //function : RemoveAll
867 //=======================================================================
868 void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
870 AIS_ListOfInteractive aList;
871 ObjectsInside (aList);
872 for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
874 Remove (aListIterator.Value(), Standard_False);
877 if (theToUpdateViewer)
883 //=======================================================================
884 //function : ClearPrs
886 //=======================================================================
887 void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
888 const Standard_Integer theMode,
889 const Standard_Boolean theToUpdateViewer)
891 if (theIObj.IsNull())
896 if (!HasOpenedContext())
898 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
902 Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
903 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
905 if (aCtxIter.Value()->AcceptErase())
907 wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
912 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
914 else if (theToUpdateViewer)
920 //=======================================================================
921 //function : HilightWithColor
923 //=======================================================================
924 void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj,
925 const Handle(Prs3d_Drawer)& theStyle,
926 const Standard_Boolean theIsToUpdate)
931 setContextToObject (theObj);
932 if (!HasOpenedContext())
934 if (!myObjects.IsBound (theObj))
937 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj);
938 aStatus->SetHilightStatus (Standard_True);
940 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
942 highlightGlobal (theObj, theStyle, aStatus->DisplayMode());
943 aStatus->SetHilightStyle (theStyle);
948 myLocalContexts (myCurLocalIndex)->Hilight (theObj, theStyle);
955 //=======================================================================
956 //function : Unhilight
958 //=======================================================================
959 void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
961 if(anIObj.IsNull()) return;
963 if (!HasOpenedContext())
965 if(!myObjects.IsBound(anIObj)) return;
967 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
968 aStatus->SetHilightStatus (Standard_False);
969 aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
971 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
973 unhighlightGlobal (anIObj);
978 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
980 if(updateviewer) myMainVwr->Update();
983 //=======================================================================
984 //function : IsHilighted
985 //purpose : Returns true if the objects global status is set to highlighted.
986 //=======================================================================
987 Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const
989 if (!HasOpenedContext())
991 if (!myObjects.IsBound (theObj))
992 return Standard_False;
994 return myObjects (theObj)->IsHilighted();
997 Standard_DISABLE_DEPRECATION_WARNINGS
998 Standard_Integer aCtxIdx = HighestIndex();
999 Standard_ENABLE_DEPRECATION_WARNINGS
1000 for (; aCtxIdx >= 1; aCtxIdx--)
1002 if (myLocalContexts.IsBound (aCtxIdx))
1004 if (myLocalContexts (aCtxIdx)->IsHilighted (theObj))
1005 return Standard_True;
1009 return Standard_False;
1012 //=======================================================================
1013 //function : IsHilighted
1014 //purpose : Returns true if the owner is highlighted with selection style.
1015 //=======================================================================
1016 Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const
1018 if (theOwner.IsNull() || !theOwner->HasSelectable())
1019 return Standard_False;
1021 const Handle(AIS_InteractiveObject) anObj =
1022 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1024 if (anObj->GlobalSelOwner() == theOwner)
1026 if (!myObjects.IsBound (anObj))
1027 return Standard_False;
1029 return myObjects (anObj)->IsHilighted();
1032 return theOwner->IsSelected();
1035 //=======================================================================
1036 //function : HighlightStyle
1038 //=======================================================================
1039 Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj,
1040 Handle(Prs3d_Drawer)& theStyle) const
1042 if (HasOpenedContext())
1043 myLocalContexts (myCurLocalIndex)->HighlightStyle (theObj, theStyle);
1045 if (IsHilighted (theObj))
1047 theStyle = myObjects (theObj)->HilightStyle();
1048 return Standard_True;
1053 return Standard_False;
1057 //=======================================================================
1058 //function : HighlightStyle
1060 //=======================================================================
1061 Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
1062 Handle(Prs3d_Drawer)& theStyle) const
1064 if (theOwner.IsNull() || !theOwner->HasSelectable())
1065 return Standard_False;
1067 if (IsHilighted (theOwner))
1069 const Handle(AIS_InteractiveObject) anObj =
1070 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1071 if (anObj->GlobalSelOwner() == theOwner)
1073 theStyle = myObjects (anObj)->HilightStyle();
1077 // since part selection style is not stored in global status,
1078 // check if the object has own selection style. If not, it can
1079 // only be highlighted with default selection style (because
1080 // sub-intensity does not modify any selection states)
1081 theStyle = getSelStyle (anObj, theOwner);
1083 return Standard_True;
1088 return Standard_False;
1092 //=======================================================================
1093 //function : IsDisplayed
1095 //=======================================================================
1097 Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1099 if(anIObj.IsNull()) return Standard_False;
1102 if(myObjects.IsBound(anIObj))
1103 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1104 return Standard_True;
1106 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1107 for(;ItM.More();ItM.Next()){
1108 if(ItM.Value()->IsDisplayed(anIObj))
1109 return Standard_True;
1111 return Standard_False;
1115 //=======================================================================
1116 //function : IsDisplayed
1118 //=======================================================================
1119 Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
1120 const Standard_Integer theMode) const
1122 if (theIObj.IsNull())
1124 return Standard_False;
1127 if (myObjects.IsBound (theIObj))
1129 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1130 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1131 && aStatus->DisplayMode() == theMode)
1133 return Standard_True;
1137 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
1139 if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
1141 return Standard_True;
1144 return Standard_False;
1147 //=======================================================================
1148 //function : DisplayPriority
1150 //=======================================================================
1151 Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
1153 if (theIObj.IsNull())
1157 else if (!myObjects.IsBound (theIObj))
1162 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1163 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1164 || aStatus->GraphicStatus() == AIS_DS_Erased)
1166 Standard_Integer aDispMode = theIObj->HasDisplayMode()
1167 ? theIObj->DisplayMode()
1168 : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
1169 ? myDefaultDrawer->DisplayMode()
1171 return myMainPM->DisplayPriority (theIObj, aDispMode);
1176 //=======================================================================
1177 //function : SetDisplayPriority
1179 //=======================================================================
1180 void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
1181 const Standard_Integer thePriority)
1183 if (theIObj.IsNull())
1188 setContextToObject (theIObj);
1189 if (myObjects.IsBound (theIObj))
1191 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1192 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1193 || aStatus->GraphicStatus() == AIS_DS_Erased)
1195 Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
1196 ? theIObj->DisplayMode()
1197 : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
1198 ? myDefaultDrawer->DisplayMode()
1200 myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
1203 else if (HasOpenedContext())
1205 myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
1209 //=======================================================================
1210 //function : Redisplay
1212 //=======================================================================
1213 void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
1214 const Standard_Boolean theToUpdateViewer,
1215 const Standard_Boolean theAllModes)
1217 RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
1218 RecomputeSelectionOnly (theIObj);
1221 //=======================================================================
1222 //function : Redisplay
1224 //=======================================================================
1225 void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
1226 const Standard_Integer /*theSign*/,
1227 const Standard_Boolean theToUpdateViewer)
1229 Standard_Boolean isRedisplayed = Standard_False;
1230 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1232 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1233 if (anObj->Type() != theKOI)
1238 Redisplay (anObj, Standard_False);
1239 isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
1243 if (theToUpdateViewer
1246 myMainVwr->Update();
1250 //=======================================================================
1251 //function : RecomputePrsOnly
1253 //=======================================================================
1254 void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
1255 const Standard_Boolean theToUpdateViewer,
1256 const Standard_Boolean theAllModes)
1258 if (theIObj.IsNull())
1263 theIObj->Update (theAllModes);
1264 if (!theToUpdateViewer)
1269 if (HasOpenedContext()
1270 || (myObjects.IsBound (theIObj)
1271 && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
1273 myMainVwr->Update();
1276 //=======================================================================
1277 //function : RecomputeSelectionOnly
1279 //=======================================================================
1280 void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
1287 mgrSelector->RecomputeSelection (theIO);
1289 if (HasOpenedContext())
1291 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1293 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
1298 if (!myObjects.IsBound (theIO) ||
1299 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1304 TColStd_ListOfInteger aModes;
1305 ActivatedModes (theIO, aModes);
1306 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1307 for (; aModesIter.More(); aModesIter.Next())
1309 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
1313 //=======================================================================
1316 //=======================================================================
1317 void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
1318 const Standard_Boolean theUpdateViewer)
1320 if (theIObj.IsNull())
1325 TColStd_ListOfInteger aPrsModes;
1326 theIObj->ToBeUpdated (aPrsModes);
1327 for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
1329 theIObj->Update (aPrsModesIt.Value(), Standard_False);
1332 mgrSelector->Update(theIObj);
1334 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1336 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1339 if (theUpdateViewer)
1341 if (!myObjects.IsBound (theIObj))
1346 switch (myObjects (theIObj)->GraphicStatus())
1348 case AIS_DS_Displayed:
1349 case AIS_DS_Temporary:
1350 myMainVwr->Update();
1358 //=======================================================================
1359 //function : SetLocation
1361 //=======================================================================
1362 void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
1363 const TopLoc_Location& theLoc)
1365 if (theIObj.IsNull())
1370 if (theIObj->HasTransformation()
1371 && theLoc.IsIdentity())
1373 theIObj->ResetTransformation();
1374 mgrSelector->Update (theIObj, Standard_False);
1377 else if (theLoc.IsIdentity())
1382 // first reset the previous location to properly clean everything...
1383 if (theIObj->HasTransformation())
1385 theIObj->ResetTransformation();
1388 theIObj->SetLocalTransformation (theLoc.Transformation());
1390 if (!HasOpenedContext())
1392 mgrSelector->Update (theIObj, Standard_False);
1396 Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
1397 mgrSelector->Update (theIObj, aTempSel, Standard_False);
1400 // if the object or its part is highlighted dynamically, it is necessary to apply location transformation
1401 // to its highlight structure immediately
1402 if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj))
1404 const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
1405 myLastPicked->UpdateHighlightTrsf (myMainVwr,
1411 //=======================================================================
1412 //function : ResetLocation
1414 //=======================================================================
1415 void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
1417 if (theIObj.IsNull())
1422 theIObj->ResetTransformation();
1423 mgrSelector->Update (theIObj, Standard_False);
1426 //=======================================================================
1427 //function : HasLocation
1429 //=======================================================================
1430 Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
1432 return !theIObj.IsNull()
1433 && theIObj->HasTransformation();
1436 //=======================================================================
1437 //function : Location
1439 //=======================================================================
1440 TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
1442 return theIObj->Transformation();
1445 //=======================================================================
1446 //function : SetDeviationCoefficient
1448 //=======================================================================
1449 void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
1451 myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
1454 //=======================================================================
1455 //function : SetDeviationAngle
1457 //=======================================================================
1458 void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
1460 myDefaultDrawer->SetDeviationAngle (theAngle);
1463 //=======================================================================
1464 //function : DeviationAngle
1465 //purpose : Gets deviationAngle
1466 //=======================================================================
1467 Standard_Real AIS_InteractiveContext::DeviationAngle() const
1469 return myDefaultDrawer->DeviationAngle();
1472 //=======================================================================
1473 //function : DeviationCoefficient
1475 //=======================================================================
1476 Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
1478 return myDefaultDrawer->DeviationCoefficient();
1481 //=======================================================================
1482 //function : SetHLRDeviationCoefficient
1484 //=======================================================================
1485 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
1487 myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
1490 //=======================================================================
1491 //function : HLRDeviationCoefficient
1493 //=======================================================================
1494 Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
1496 return myDefaultDrawer->HLRDeviationCoefficient();
1499 //=======================================================================
1500 //function : SetHLRAngle
1502 //=======================================================================
1503 void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
1505 myDefaultDrawer->SetHLRAngle (theAngle);
1508 //=======================================================================
1509 //function : SetHLRAngleAndDeviation
1510 //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1511 // and set them in myHLRAngle and in myHLRDeviationCoefficient
1512 // of myDefaultDrawer
1513 //=======================================================================
1514 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
1516 Standard_Real anOutAngl, anOutDefl;
1517 HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
1519 myDefaultDrawer->SetHLRAngle (anOutAngl);
1520 myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
1523 //=======================================================================
1524 //function : HLRAngle
1526 //=======================================================================
1527 Standard_Real AIS_InteractiveContext::HLRAngle() const
1529 return myDefaultDrawer->HLRAngle();
1532 //=======================================================================
1533 //function : SetDisplayMode
1535 //=======================================================================
1536 void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode,
1537 const Standard_Boolean theToUpdateViewer)
1539 if (theMode == myDefaultDrawer->DisplayMode())
1544 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1546 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1547 Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
1548 || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
1549 || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
1552 || anObj->HasDisplayMode()
1553 || !anObj->AcceptDisplayMode (theMode))
1558 Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
1559 aStatus->SetDisplayMode (theMode);
1561 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1563 myMainPM->Display (anObj, theMode);
1564 if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj))
1566 myMainPM->BeginImmediateDraw();
1567 unhighlightGlobal (anObj);
1568 myMainPM->EndImmediateDraw (myMainVwr);
1570 if (aStatus->IsSubIntensityOn())
1572 highlightWithSubintensity (anObj, theMode);
1574 myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False);
1578 myDefaultDrawer->SetDisplayMode (theMode);
1579 if (theToUpdateViewer)
1581 myMainVwr->Update();
1585 //=======================================================================
1586 //function : SetDisplayMode
1588 //=======================================================================
1589 void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1590 const Standard_Integer theMode,
1591 const Standard_Boolean theToUpdateViewer)
1593 setContextToObject (theIObj);
1594 if (!myObjects.IsBound (theIObj))
1596 theIObj->SetDisplayMode (theMode);
1599 else if (!theIObj->AcceptDisplayMode (theMode))
1604 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1605 if (aStatus->GraphicStatus() != AIS_DS_Displayed)
1607 aStatus->SetDisplayMode (theMode);
1608 theIObj->SetDisplayMode (theMode);
1612 // erase presentations for all display modes different from <aMode>
1613 const Standard_Integer anOldMode = aStatus->DisplayMode();
1614 if (anOldMode != theMode)
1616 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1618 unhighlightGlobal (theIObj);
1620 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1623 aStatus->SetDisplayMode (theMode);
1625 myMainPM->Display (theIObj, theMode);
1626 if (aStatus->IsHilighted())
1628 highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode);
1630 if (aStatus->IsSubIntensityOn())
1632 highlightWithSubintensity (theIObj, theMode);
1635 if (theToUpdateViewer)
1637 myMainVwr->Update();
1639 theIObj->SetDisplayMode (theMode);
1642 //=======================================================================
1643 //function : UnsetDisplayMode
1645 //=======================================================================
1646 void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1647 const Standard_Boolean theToUpdateViewer)
1649 if (theIObj.IsNull()
1650 || !theIObj->HasDisplayMode())
1655 if (!myObjects.IsBound (theIObj))
1657 theIObj->UnsetDisplayMode();
1661 const Standard_Integer anOldMode = theIObj->DisplayMode();
1662 if (myDefaultDrawer->DisplayMode() == anOldMode)
1667 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
1668 aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode());
1670 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1672 if (myMainPM->IsHighlighted (theIObj, anOldMode))
1674 unhighlightGlobal (theIObj);
1676 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
1677 myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode());
1678 if (aStatus->IsHilighted())
1680 highlightSelected (theIObj->GlobalSelOwner());
1682 if (aStatus->IsSubIntensityOn())
1684 highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode());
1687 if (theToUpdateViewer)
1689 myMainVwr->Update();
1693 theIObj->UnsetDisplayMode();
1696 //=======================================================================
1697 //function : SetCurrentFacingModel
1699 //=======================================================================
1700 void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
1701 const Aspect_TypeOfFacingModel theModel)
1703 if (!theIObj.IsNull())
1705 theIObj->SetCurrentFacingModel (theModel);
1709 //=======================================================================
1710 //function : redisplayPrsRecModes
1712 //=======================================================================
1713 void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1714 const Standard_Boolean theToUpdateViewer)
1716 if (theIObj->RecomputeEveryPrs())
1718 theIObj->Update (Standard_True);
1719 theIObj->UpdateSelection();
1723 for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
1725 theIObj->Update (aModes.Value(), Standard_False);
1727 theIObj->UpdateSelection();
1728 theIObj->SetRecomputeOk();
1731 if (theToUpdateViewer)
1733 UpdateCurrentViewer();
1737 //=======================================================================
1738 //function : redisplayPrsModes
1740 //=======================================================================
1741 void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1742 const Standard_Boolean theToUpdateViewer)
1744 if (theIObj->RecomputeEveryPrs())
1746 theIObj->Update (Standard_True);
1747 theIObj->UpdateSelection();
1751 TColStd_ListOfInteger aModes;
1752 theIObj->ToBeUpdated (aModes);
1753 for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
1755 theIObj->Update (aModeIter.Value(), Standard_False);
1757 theIObj->SetRecomputeOk();
1760 if (theToUpdateViewer)
1762 UpdateCurrentViewer();
1766 //=======================================================================
1767 //function : SetColor
1769 //=======================================================================
1770 void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1771 const Quantity_Color& theColor,
1772 const Standard_Boolean theToUpdateViewer)
1774 if (theIObj.IsNull())
1779 setContextToObject (theIObj);
1780 theIObj->SetColor (theColor);
1781 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1784 //=======================================================================
1785 //function : SetIsoOnTriangulation
1787 //=======================================================================
1788 void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theIsEnabled,
1789 const Handle(AIS_InteractiveObject)& theObject)
1791 if (theObject.IsNull())
1796 theObject->SetIsoOnTriangulation (theIsEnabled);
1799 //=======================================================================
1800 //function : SetDeviationCoefficient
1802 //=======================================================================
1803 void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1804 const Standard_Real theCoefficient,
1805 const Standard_Boolean theToUpdateViewer)
1807 if (theIObj.IsNull())
1812 // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
1813 setContextToObject (theIObj);
1814 if (theIObj->Type() != AIS_KOI_Object
1815 && theIObj->Type() != AIS_KOI_Shape)
1819 else if (theIObj->Signature() != 0)
1824 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1825 aShape->SetOwnDeviationCoefficient (theCoefficient);
1826 redisplayPrsModes (theIObj, theToUpdateViewer);
1829 //=======================================================================
1830 //function : SetHLRDeviationCoefficient
1832 //=======================================================================
1833 void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1834 const Standard_Real theCoefficient,
1835 const Standard_Boolean theToUpdateViewer)
1837 if (theIObj.IsNull())
1842 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1843 setContextToObject (theIObj);
1844 if (theIObj->Type() != AIS_KOI_Object
1845 && theIObj->Type() != AIS_KOI_Shape)
1849 else if (theIObj->Signature() != 0)
1854 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1855 aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
1856 redisplayPrsModes (theIObj, theToUpdateViewer);
1859 //=======================================================================
1860 //function : SetDeviationAngle
1862 //=======================================================================
1863 void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1864 const Standard_Real theAngle,
1865 const Standard_Boolean theToUpdateViewer)
1867 if (theIObj.IsNull())
1872 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1873 setContextToObject (theIObj);
1874 if (theIObj->Type() != AIS_KOI_Shape)
1878 else if (theIObj->Signature() != 0)
1883 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1884 aShape->SetOwnDeviationAngle (theAngle);
1885 redisplayPrsModes (theIObj, theToUpdateViewer);
1888 //=======================================================================
1889 //function : SetAngleAndDeviation
1891 //=======================================================================
1892 void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1893 const Standard_Real theAngle,
1894 const Standard_Boolean theToUpdateViewer)
1896 if (theIObj.IsNull())
1901 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1902 setContextToObject (theIObj);
1903 if (theIObj->Type() != AIS_KOI_Shape)
1907 if (theIObj->Signature() != 0)
1912 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1913 aShape->SetAngleAndDeviation (theAngle);
1915 if (theIObj->RecomputeEveryPrs())
1917 theIObj->Update (Standard_True);
1918 theIObj->UpdateSelection();
1922 Update (theIObj, theToUpdateViewer);
1926 //=======================================================================
1927 //function : SetHLRAngleAndDeviation
1929 //=======================================================================
1930 void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1931 const Standard_Real theAngle,
1932 const Standard_Boolean theToUpdateViewer)
1934 if (theIObj.IsNull())
1939 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1940 setContextToObject (theIObj);
1941 if (theIObj->Type() != AIS_KOI_Shape)
1945 if (theIObj->Signature() != 0)
1949 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1950 aShape->SetHLRAngleAndDeviation (theAngle);
1951 redisplayPrsModes (theIObj, theToUpdateViewer);
1954 //=======================================================================
1955 //function : SetHLRDeviationAngle
1957 //=======================================================================
1958 void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1959 const Standard_Real theAngle,
1960 const Standard_Boolean theToUpdateViewer)
1962 if (theIObj.IsNull())
1967 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
1968 setContextToObject (theIObj);
1969 if (theIObj->Type() != AIS_KOI_Shape)
1973 if (theIObj->Signature() != 0)
1977 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1978 aShape->SetOwnHLRDeviationAngle (theAngle);
1979 redisplayPrsModes (theIObj, theToUpdateViewer);
1982 //=======================================================================
1983 //function : UnsetColor
1985 //=======================================================================
1986 void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
1987 const Standard_Boolean theToUpdateViewer)
1989 if (theIObj.IsNull())
1994 theIObj->UnsetColor();
1995 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1998 //=======================================================================
1999 //function : HasColor
2001 //=======================================================================
2002 Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
2004 return theIObj->HasColor();
2007 //=======================================================================
2010 //=======================================================================
2011 void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
2012 Quantity_Color& theColor) const
2014 theIObj->Color (theColor);
2017 //=======================================================================
2020 //=======================================================================
2021 Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
2023 return theIObj->Width();
2026 //=======================================================================
2027 //function : SetWidth
2029 //=======================================================================
2030 void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2031 const Standard_Real theWidth,
2032 const Standard_Boolean theToUpdateViewer)
2034 if (theIObj.IsNull())
2039 setContextToObject (theIObj);
2040 theIObj->SetWidth (theWidth);
2041 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2042 if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj))
2044 if (myLastinMain->IsAutoHilight())
2046 const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2047 myLastinMain->HilightWithColor (myMainPM,
2048 myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain),
2053 theIObj->HilightOwnerWithColor (myMainPM,
2054 myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain),
2060 //=======================================================================
2061 //function : UnsetWidth
2063 //=======================================================================
2064 void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2065 const Standard_Boolean theToUpdateViewer)
2067 if (theIObj.IsNull())
2072 theIObj->UnsetWidth();
2073 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2076 //=======================================================================
2077 //function : SetMaterial
2079 //=======================================================================
2080 void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2081 const Graphic3d_MaterialAspect& theMaterial,
2082 const Standard_Boolean theToUpdateViewer)
2084 if (theIObj.IsNull())
2089 setContextToObject (theIObj);
2090 theIObj->SetMaterial (theMaterial);
2091 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2094 //=======================================================================
2095 //function : UnsetMaterial
2097 //=======================================================================
2098 void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2099 const Standard_Boolean theToUpdateViewer)
2101 if (theIObj.IsNull())
2105 theIObj->UnsetMaterial();
2106 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2109 //=======================================================================
2110 //function : SetTransparency
2112 //=======================================================================
2113 void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2114 const Standard_Real theValue,
2115 const Standard_Boolean theToUpdateViewer)
2117 if (theIObj.IsNull())
2122 setContextToObject (theIObj);
2123 if (!theIObj->IsTransparent()
2124 && theValue <= 0.005)
2129 if (theValue <= 0.005)
2131 UnsetTransparency (theIObj, theToUpdateViewer);
2135 theIObj->SetTransparency (theValue);
2136 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2139 //=======================================================================
2140 //function : UnsetTransparency
2142 //=======================================================================
2143 void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2144 const Standard_Boolean theToUpdateViewer)
2146 if (theIObj.IsNull())
2151 theIObj->UnsetTransparency();
2152 redisplayPrsRecModes (theIObj, theToUpdateViewer);
2155 //=======================================================================
2156 //function : SetSelectedAspect
2158 //=======================================================================
2159 void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
2160 const Standard_Boolean theToUpdateViewer)
2162 if (HasOpenedContext())
2167 Standard_Boolean isFound = Standard_False;
2168 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
2170 isFound = Standard_True;
2171 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
2172 anObj->SetAspect (theAspect);
2175 if (isFound && theToUpdateViewer)
2177 myMainVwr->Update();
2181 //=======================================================================
2182 //function : SetLocalAttributes
2184 //=======================================================================
2185 void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2186 const Handle(Prs3d_Drawer)& theDrawer,
2187 const Standard_Boolean theToUpdateViewer)
2189 if (theIObj.IsNull())
2194 setContextToObject (theIObj);
2195 theIObj->SetAttributes (theDrawer);
2196 Update (theIObj, theToUpdateViewer);
2199 //=======================================================================
2200 //function : UnsetLocalAttributes
2202 //=======================================================================
2203 void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2204 const Standard_Boolean theToUpdateViewer)
2206 if (theIObj.IsNull())
2211 setContextToObject (theIObj);
2212 theIObj->UnsetAttributes();
2213 Update (theIObj, theToUpdateViewer);
2216 //=======================================================================
2219 //=======================================================================
2220 void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
2221 TCollection_ExtendedString& theStatus) const
2224 if (theIObj.IsNull()
2225 || !myObjects.IsBound (theIObj))
2230 theStatus += "\t ____________________________________________";
2231 theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2232 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2233 switch (aStatus->GraphicStatus())
2235 case AIS_DS_Displayed:
2237 theStatus += "\t| -->Displayed\n";
2242 theStatus += "\t| -->Erased\n";
2249 theStatus += "\t| Active Display Modes in the MainViewer :\n";
2250 theStatus += "\t|\t Mode ";
2251 theStatus += TCollection_AsciiString (aStatus->DisplayMode());
2254 if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
2256 theStatus += "\t| Active Selection Modes in the MainViewer :\n";
2257 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2259 theStatus += "\t\t Mode ";
2260 theStatus += TCollection_AsciiString (aSelModeIter.Value());
2263 theStatus += "\t ____________________________________________";
2266 //=======================================================================
2267 //function : GetDefModes
2269 //=======================================================================
2270 void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
2271 Standard_Integer& theDispMode,
2272 Standard_Integer& theHiMode,
2273 Standard_Integer& theSelMode) const
2275 if (theIObj.IsNull())
2280 theDispMode = theIObj->HasDisplayMode()
2281 ? theIObj->DisplayMode()
2282 : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
2283 ? myDefaultDrawer->DisplayMode()
2285 theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
2286 theSelMode = theIObj->GlobalSelectionMode();
2289 //=======================================================================
2290 //function : EraseGlobal
2292 //=======================================================================
2293 void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2294 const Standard_Boolean theToUpdateviewer)
2296 if (theIObj.IsNull()
2297 || !myObjects.IsBound (theIObj))
2302 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2304 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2305 if (aStatus->GraphicStatus() == AIS_DS_Temporary
2306 || aStatus->GraphicStatus() == AIS_DS_Erased)
2311 if (aStatus->IsHilighted())
2313 Standard_DISABLE_DEPRECATION_WARNINGS
2314 if (IsCurrent (theIObj))
2316 AddOrRemoveCurrentObject (theIObj, Standard_False);
2318 else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode()))
2320 unhighlightGlobal (theIObj);
2322 Standard_ENABLE_DEPRECATION_WARNINGS
2325 myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
2327 if (aStatus->IsHilighted()
2328 && theIObj->HasHilightMode())
2330 unhighlightGlobal (theIObj);
2333 if (!myLastPicked.IsNull()
2334 && myLastPicked->IsSameSelectable (theIObj))
2336 clearDynamicHighlight();
2339 if (IsSelected (theIObj)
2340 && aStatus->DisplayMode() != aDispMode)
2342 myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
2345 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2347 mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
2349 aStatus->ClearSelectionModes();
2350 aStatus->SetGraphicStatus (AIS_DS_Erased);
2352 if (theToUpdateviewer)
2354 myMainVwr->Update();
2358 //=======================================================================
2359 //function : unhighlightOwners
2361 //=======================================================================
2362 void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject)
2364 SelectMgr_SequenceOfOwner aSeq;
2365 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
2367 if (aSelIter.Value()->IsSameSelectable (theObject))
2369 aSeq.Append (aSelIter.Value());
2372 for (SelectMgr_SequenceOfOwner::Iterator aDelIter (aSeq); aDelIter.More(); aDelIter.Next())
2374 AddOrRemoveSelected (aDelIter.Value(), Standard_False);
2378 //=======================================================================
2379 //function : ClearGlobal
2381 //=======================================================================
2382 void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2383 const Standard_Boolean theToUpdateviewer)
2385 if (theIObj.IsNull()
2386 || !myObjects.IsBound (theIObj))
2388 // for cases when reference shape of connected interactives was not displayed
2389 // but its selection primitives were calculated
2390 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
2391 mgrSelector->Remove (anObj);
2395 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2396 unhighlightOwners (theIObj);
2398 myMainPM->Erase (theIObj, -1);
2400 // Object removes from Detected sequence
2401 Standard_DISABLE_DEPRECATION_WARNINGS
2402 for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();)
2404 Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter));
2405 Handle(AIS_InteractiveObject) anObj;
2406 if (!aPicked.IsNull())
2408 anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable());
2412 && anObj == theIObj)
2414 myDetectedSeq.Remove (aDetIter);
2415 if (myCurDetected == aDetIter)
2417 myCurDetected = Min (myDetectedSeq.Upper(), aDetIter);
2419 if (myCurHighlighted == aDetIter)
2421 myCurHighlighted = 0;
2429 Standard_ENABLE_DEPRECATION_WARNINGS
2431 // remove IO from the selection manager to avoid memory leaks
2432 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
2433 mgrSelector->Remove (anObj);
2435 myObjects.UnBind (theIObj);
2436 myMainVwr->StructureManager()->UnregisterObject (theIObj);
2438 for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next())
2440 aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
2443 if (!myLastinMain.IsNull())
2445 if (myLastinMain->IsSameSelectable (theIObj)
2446 || myLastPicked->IsSameSelectable(theIObj))
2448 clearDynamicHighlight();
2449 myLastinMain.Nullify();
2450 myLastPicked.Nullify();
2454 if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed)
2456 myMainVwr->Update();
2460 //=======================================================================
2461 //function : ClearGlobalPrs
2463 //=======================================================================
2464 void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
2465 const Standard_Integer theMode,
2466 const Standard_Boolean theToUpdateViewer)
2468 if (theIObj.IsNull()
2469 || !myObjects.IsBound (theIObj))
2474 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2475 if (aStatus->DisplayMode() == theMode)
2477 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2478 if (aDispMode == theMode
2479 && myMainPM->IsHighlighted (theIObj, theMode))
2481 unhighlightGlobal (theIObj);
2484 myMainPM->Erase (theIObj, theMode);
2487 if (aStatus->GraphicStatus() == AIS_DS_Displayed
2488 && theToUpdateViewer)
2490 myMainVwr->Update();
2494 //=======================================================================
2495 //function : DrawHiddenLine
2497 //=======================================================================
2498 Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
2500 return myDefaultDrawer->DrawHiddenLine();
2503 //=======================================================================
2504 //function : EnableDrawHiddenLine
2506 //=======================================================================
2507 void AIS_InteractiveContext::EnableDrawHiddenLine() const
2509 myDefaultDrawer->EnableDrawHiddenLine();
2512 //=======================================================================
2513 //function : DisableDrawHiddenLine
2515 //=======================================================================
2516 void AIS_InteractiveContext::DisableDrawHiddenLine() const
2518 myDefaultDrawer->DisableDrawHiddenLine();
2521 //=======================================================================
2522 //function : HiddenLineAspect
2524 //=======================================================================
2525 Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
2527 return myDefaultDrawer->HiddenLineAspect();
2530 //=======================================================================
2531 //function : SetHiddenLineAspect
2533 //=======================================================================
2534 void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
2536 myDefaultDrawer->SetHiddenLineAspect (theAspect);
2539 //=======================================================================
2540 //function : SetIsoNumber
2542 //=======================================================================
2543 void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
2544 const AIS_TypeOfIso theType)
2549 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2552 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2555 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2556 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2561 //=======================================================================
2562 //function : IsoNumber
2564 //=======================================================================
2565 Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
2569 case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
2570 case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
2571 case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
2572 ? myDefaultDrawer->UIsoAspect()->Number()
2578 //=======================================================================
2579 //function : IsoOnPlane
2581 //=======================================================================
2582 void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
2584 myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
2587 //=======================================================================
2588 //function : IsoOnPlane
2590 //=======================================================================
2591 Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
2593 return myDefaultDrawer->IsoOnPlane();
2596 //=======================================================================
2597 //function : IsoOnTriangulation
2599 //=======================================================================
2600 void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theToSwitchOn)
2602 myDefaultDrawer->SetIsoOnTriangulation (theToSwitchOn);
2605 //=======================================================================
2606 //function : IsoOnTriangulation
2608 //=======================================================================
2609 Standard_Boolean AIS_InteractiveContext::IsoOnTriangulation() const
2611 return myDefaultDrawer->IsoOnTriangulation();
2614 //function : SetPixelTolerance
2615 //purpose : Disables the mechanism of adaptive tolerance calculation in
2616 // SelectMgr_ViewerSelector and sets the given tolerance for ALL
2617 // sensitive entities activated. For more information, see
2618 // SelectMgr_ViewerSelector.hxx
2619 //=======================================================================
2620 void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
2622 if (HasOpenedContext())
2624 myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
2628 myMainSel->SetPixelTolerance (thePrecision);
2632 //=======================================================================
2633 //function : PixelTolerance
2635 //=======================================================================
2636 Standard_Integer AIS_InteractiveContext::PixelTolerance() const
2638 return HasOpenedContext()
2639 ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
2640 : myMainSel->PixelTolerance();
2643 //=======================================================================
2644 //function : SetSelectionSensitivity
2645 //purpose : Allows to manage sensitivity of a particular selection of interactive object theObject
2646 //=======================================================================
2647 void AIS_InteractiveContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject,
2648 const Standard_Integer theMode,
2649 const Standard_Integer theNewSensitivity)
2651 if (HasOpenedContext())
2653 myLocalContexts (myCurLocalIndex)->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
2657 mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
2660 //=======================================================================
2661 //function : IsInLocal
2663 //=======================================================================
2664 Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
2665 Standard_Integer& theIndex) const
2667 if (theIObj.IsNull())
2669 return Standard_False;
2672 // if it exists at neutral point 0 index is returned
2673 if (myObjects.IsBound (theIObj))
2676 return Standard_False;
2679 for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
2681 if (myLocalContexts.IsBound (aCtxIter))
2683 if(myLocalContexts (aCtxIter)->IsIn (theIObj))
2685 theIndex = aCtxIter;
2686 return Standard_True;
2691 return Standard_False;
2694 //=======================================================================
2695 //function : InitAttributes
2697 //=======================================================================
2698 void AIS_InteractiveContext::InitAttributes()
2700 mgrSelector->Add (myMainSel);
2702 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
2703 myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
2705 // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2706 Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
2707 aLineAspect->SetColor (Quantity_NOC_GRAY20);
2708 aLineAspect->SetWidth (1.0);
2709 aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
2711 // tolerance to 2 pixels...
2712 SetPixelTolerance (2);
2714 // Customizing the drawer for trihedrons and planes...
2715 Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
2716 const Standard_Real aLength = 100.0;
2717 aTrihAspect->SetAxisLength (aLength, aLength, aLength);
2718 const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4;
2719 aTrihAspect->LineAspect(Prs3d_DP_XAxis)->SetColor (aColor);
2720 aTrihAspect->LineAspect(Prs3d_DP_YAxis)->SetColor (aColor);
2721 aTrihAspect->LineAspect(Prs3d_DP_ZAxis)->SetColor (aColor);
2723 Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
2724 const Standard_Real aPlaneLength = 200.0;
2725 aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
2726 aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
2729 //=======================================================================
2730 //function : TrihedronSize
2732 //=======================================================================
2733 Standard_Real AIS_InteractiveContext::TrihedronSize() const
2735 return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis);
2738 //=======================================================================
2739 //function : SetTrihedronSize
2741 //=======================================================================
2742 void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
2743 const Standard_Boolean /*updateviewer*/)
2745 myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
2746 Redisplay (AIS_KOI_Datum, 3, Standard_False);
2747 Redisplay (AIS_KOI_Datum, 4, Standard_True);
2750 //=======================================================================
2751 //function : SetPlaneSize
2753 //=======================================================================
2754 void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
2755 const Standard_Real theValY,
2756 const Standard_Boolean theToUpdateViewer)
2758 myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
2759 Redisplay (AIS_KOI_Datum, 7, theToUpdateViewer);
2762 //=======================================================================
2763 //function : SetPlaneSize
2765 //=======================================================================
2766 void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
2767 const Standard_Boolean theToUpdateViewer)
2769 SetPlaneSize (theVal, theVal, theToUpdateViewer);
2772 //=======================================================================
2773 //function : PlaneSize
2775 //=======================================================================
2776 Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
2777 Standard_Real& theY) const
2779 theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2780 theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2781 return (Abs (theX - theY) <= Precision::Confusion());
2784 //=======================================================================
2785 //function : SetAutoActivateSelection
2787 //=======================================================================
2788 void AIS_InteractiveContext::SetAutoActivateSelection (const Standard_Boolean theIsAuto)
2790 myIsAutoActivateSelMode = theIsAuto;
2793 //=======================================================================
2794 //function : GetAutoActivateSelection
2796 //=======================================================================
2797 Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
2799 return myIsAutoActivateSelMode;
2802 //=======================================================================
2803 //function : SetZLayer
2805 //=======================================================================
2806 void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
2807 const Standard_Integer theLayerId)
2809 if (theIObj.IsNull())
2812 theIObj->SetZLayer (theLayerId);
2815 //=======================================================================
2816 //function : GetZLayer
2818 //=======================================================================
2819 Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
2821 return !theIObj.IsNull()
2823 : Graphic3d_ZLayerId_UNKNOWN;
2826 //=======================================================================
2827 //function : RebuildSelectionStructs
2828 //purpose : Rebuilds 1st level of BVH selection forcibly
2829 //=======================================================================
2830 void AIS_InteractiveContext::RebuildSelectionStructs()
2832 myMainSel->RebuildObjectsTree (Standard_True);
2835 //=======================================================================
2836 //function : Disconnect
2837 //purpose : Disconnects selectable object from an assembly and updates selection structures
2838 //=======================================================================
2839 void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly,
2840 const Handle(AIS_InteractiveObject)& theObjToDisconnect)
2842 if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive"))
2844 Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly));
2845 theObj->Disconnect (theObjToDisconnect);
2846 const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity
2847 mgrSelector->Remove (anObj);
2849 else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull())
2851 Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly));
2852 theObj->Disconnect();
2853 const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity
2854 mgrSelector->Remove (anObj);
2860 //=======================================================================
2861 //function : FitSelected
2862 //purpose : Fits the view corresponding to the bounds of selected objects
2863 //=======================================================================
2864 void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
2866 FitSelected (theView, 0.01, Standard_True);
2869 //=======================================================================
2870 //function : FitSelected
2871 //purpose : Fits the view corresponding to the bounds of selected objects
2872 //=======================================================================
2873 void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
2874 const Standard_Real theMargin,
2875 const Standard_Boolean theToUpdate)
2877 const Handle(AIS_Selection)& aSelection = HasOpenedContext() ?
2878 myLocalContexts(myCurLocalIndex)->Selection() : mySelection;
2880 Bnd_Box aBndSelected;
2882 AIS_MapOfObjectOwners anObjectOwnerMap;
2883 for (aSelection->Init(); aSelection->More(); aSelection->Next())
2885 const Handle(SelectMgr_EntityOwner)& anOwner = aSelection->Value();
2886 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
2887 if (anObj->IsInfinite())
2892 if (anOwner == anObj->GlobalSelOwner())
2895 anObj->BoundingBox (aTmpBnd);
2896 aBndSelected.Add (aTmpBnd);
2900 Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap;
2901 if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap))
2903 anOwnerMap = new SelectMgr_IndexedMapOfOwner();
2904 anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap);
2907 anOwnerMap->Add (anOwner);
2911 for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next())
2913 const Handle(SelectMgr_SelectableObject) anObject = anIter.Key();
2914 Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue());
2915 aBndSelected.Add (aTmpBox);
2918 anObjectOwnerMap.Clear();
2920 if (aBndSelected.IsVoid())
2923 theView->FitAll (aBndSelected, theMargin, theToUpdate);
2926 //=======================================================================
2927 //function : SetTransformPersistence
2929 //=======================================================================
2930 void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
2931 const Handle(Graphic3d_TransformPers)& theTrsfPers)
2933 theObject->SetTransformPersistence (theTrsfPers);
2934 if (!myObjects.IsBound (theObject))
2939 mgrSelector->UpdateSelection (theObject);
2941 const Standard_Integer aLayerId = myObjects.Find (theObject)->GetLayerIndex();
2942 const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
2943 for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
2945 anActiveViewIter.Value()->View()->InvalidateBVHData (aLayerId);
2946 anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId);