0029882: Visualization - AcceptDisplayMode() should be redefined in class AIS_Texture...
[occt.git] / src / AIS / AIS_InteractiveContext.cxx
CommitLineData
b311480e 1// Created on: 1997-01-17
2// Created by: Robert COUBLANC
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
d94bed0e 17#include <AIS_InteractiveContext.hxx>
2ec85268 18
7fd59977 19#include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
42cf5bc1 20#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
d94bed0e 21#include <AIS_ConnectedInteractive.hxx>
7fd59977 22#include <AIS_GlobalStatus.hxx>
42cf5bc1 23#include <AIS_InteractiveObject.hxx>
24#include <AIS_ListIteratorOfListOfInteractive.hxx>
25#include <AIS_LocalContext.hxx>
26#include <AIS_LocalStatus.hxx>
7fd59977 27#include <AIS_MapIteratorOfMapOfInteractive.hxx>
42cf5bc1 28#include <AIS_MultipleConnectedInteractive.hxx>
7fd59977 29#include <AIS_Shape.hxx>
42cf5bc1 30#include <AIS_Trihedron.hxx>
31#include <Geom_Axis2Placement.hxx>
7fd59977 32#include <Graphic3d_AspectFillArea3d.hxx>
33#include <HLRBRep.hxx>
42cf5bc1 34#include <OSD_Environment.hxx>
35#include <Precision.hxx>
36#include <Prs3d_BasicAspect.hxx>
7fd59977 37#include <Prs3d_DatumAspect.hxx>
42cf5bc1 38#include <Prs3d_IsoAspect.hxx>
39#include <Prs3d_LineAspect.hxx>
7fd59977 40#include <Prs3d_PlaneAspect.hxx>
f838dac4 41#include <Prs3d_PointAspect.hxx>
42cf5bc1 42#include <Prs3d_ShadingAspect.hxx>
43#include <PrsMgr_ModedPresentation.hxx>
7fd59977 44#include <PrsMgr_PresentableObject.hxx>
42cf5bc1 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>
e33e7e78 50#include <Standard_Atomic.hxx>
42cf5bc1 51#include <Standard_Transient.hxx>
52#include <Standard_Type.hxx>
f751596e 53#include <StdSelect_ViewerSelector3d.hxx>
42cf5bc1 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>
7fd59977 60#include <UnitsAPI.hxx>
42cf5bc1 61#include <V3d_View.hxx>
62#include <V3d_Viewer.hxx>
7fd59977 63
2ec85268 64IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
92efcf78 65
e33e7e78 66namespace
7fd59977 67{
b586500b 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;
f838dac4 70
71 //! Initialize default highlighting attributes.
72 static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
73 {
74 theDrawer->SetMethod (Aspect_TOHM_COLOR);
75 theDrawer->SetDisplayMode (0);
76
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();
89
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);
97
98 // the triangulation should be computed using main presentation attributes,
99 // and should not be overridden by highlighting
100 theDrawer->SetAutoTriangulation (Standard_False);
101 }
2195ab96 102}
7fd59977 103
104//=======================================================================
105//function : AIS_InteractiveContext
106//purpose :
107//=======================================================================
108
109AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer):
110mgrSelector(new SelectMgr_SelectionManager()),
c357e426 111myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())),
7fd59977 112myMainVwr(MainViewer),
113myMainSel(new StdSelect_ViewerSelector3d()),
cbff1e55 114myWasLastMain(Standard_False),
cbff1e55 115myToHilightSelected(Standard_True),
f838dac4 116mySelection(new AIS_Selection()),
7fd59977 117myFilters(new SelectMgr_OrFilter()),
118myDefaultDrawer(new Prs3d_Drawer()),
7fd59977 119myCurLocalIndex(0),
f0cddd16 120myCurDetected(0),
121myCurHighlighted(0),
14c4193d 122myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable),
016e5959 123myIsAutoActivateSelMode(Standard_True)
f838dac4 124{
8c088c52 125 mgrSelector->Add (myMainSel);
f838dac4 126 myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
127 myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer();
128 myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer();
129 myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer();
130 myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer();
131 myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer();
132
133 myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default);
134 myDefaultDrawer->SetDisplayMode(0);
135 {
136 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic];
137 aStyle->Link (myDefaultDrawer);
138 initDefaultHilightAttributes (aStyle);
139 aStyle->SetZLayer(Graphic3d_ZLayerId_Top);
140 aStyle->SetColor (Quantity_NOC_CYAN1);
141 }
142 {
143 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic];
144 aStyle->Link (myDefaultDrawer);
145 initDefaultHilightAttributes (aStyle);
146 aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost);
147 aStyle->SetColor (Quantity_NOC_CYAN1);
148 }
149 {
150 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected];
151 aStyle->Link (myDefaultDrawer);
152 initDefaultHilightAttributes (aStyle);
153 aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
154 aStyle->SetColor (Quantity_NOC_GRAY80);
155 }
156 {
157 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected];
158 aStyle->Link (myDefaultDrawer);
159 initDefaultHilightAttributes (aStyle);
160 aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
161 aStyle->SetColor (Quantity_NOC_GRAY80);
162 }
163 {
164 const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
165 aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
166 aStyle->SetMethod(Aspect_TOHM_COLOR);
167 aStyle->SetColor (Quantity_NOC_GRAY40);
168 }
169
7fd59977 170 InitAttributes();
171}
172
2ec85268 173//=======================================================================
174//function : ~AIS_InteractiveContext
175//purpose :
176//=======================================================================
177AIS_InteractiveContext::~AIS_InteractiveContext()
7fd59977 178{
016e5959 179 // clear the current selection
02974a19 180 mySelection->Clear();
7fd59977 181
182 // let's remove one reference explicitly. this operation's supposed to
183 // be performed when mgrSelector will be destroyed but anyway...
543a9964 184 const Handle(SelectMgr_ViewerSelector)& aSelector = myMainSel; // to avoid ambiguity
185 mgrSelector->Remove (aSelector);
2195ab96 186
da0e82aa 187 Handle(AIS_InteractiveContext) aNullContext;
2195ab96 188 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
da0e82aa 189 {
b5cce1ab 190 const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key();
2195ab96 191 anObj->SetContext (aNullContext);
b5cce1ab 192 for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
c3282ec1 193 {
b5cce1ab 194 aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew);
c3282ec1 195 }
da0e82aa 196 }
7fd59977 197}
198
7fd59977 199//=======================================================================
200//function : UpdateCurrentViewer
201//purpose :
202//=======================================================================
203
204void AIS_InteractiveContext::UpdateCurrentViewer()
205{
206 if (!myMainVwr.IsNull())
207 myMainVwr->Update();
208}
209
7fd59977 210//=======================================================================
211//function : DisplayedObjects
2195ab96 212//purpose :
7fd59977 213//=======================================================================
2195ab96 214void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO,
215 const Standard_Boolean theOnlyFromNeutral) const
7fd59977 216{
2195ab96 217 if (!HasOpenedContext()
218 || theOnlyFromNeutral)
219 {
220 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
221 {
222 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
223 {
224 theListOfIO.Append (anObjIter.Key());
225 }
7fd59977 226 }
2195ab96 227 return;
7fd59977 228 }
7fd59977 229
2195ab96 230 // neutral point
231 TColStd_MapOfTransient aDispMap;
232 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
233 {
234 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
235 {
236 aDispMap.Add (anObjIter.Key());
7fd59977 237 }
2195ab96 238 }
239
240 // parse all local contexts...
241 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
242 {
243 const Handle(AIS_LocalContext)& aLocCtx = aCtxIter.Value();
244 aLocCtx->DisplayedObjects (aDispMap);
245 }
246
247 Handle(AIS_InteractiveObject) anObj;
248 for (TColStd_MapIteratorOfMapOfTransient aDispMapIter (aDispMap); aDispMapIter.More(); aDispMapIter.Next())
249 {
250 const Handle(Standard_Transient)& aTransient = aDispMapIter.Key();
c5f3a425 251 anObj = Handle(AIS_InteractiveObject)::DownCast (aTransient);
2195ab96 252 theListOfIO.Append (anObj);
253 }
7fd59977 254}
2195ab96 255
7fd59977 256//=======================================================================
257//function : DisplayedObjects
2195ab96 258//purpose :
7fd59977 259//=======================================================================
2195ab96 260void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind,
261 const Standard_Integer theSign,
262 AIS_ListOfInteractive& theListOfIO,
263 const Standard_Boolean /*OnlyFromNeutral*/) const
7fd59977 264{
2195ab96 265 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO);
7fd59977 266}
267
7fd59977 268//=======================================================================
269//function : ErasedObjects
2195ab96 270//purpose :
7fd59977 271//=======================================================================
2195ab96 272void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const
7fd59977 273{
2195ab96 274 ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO);
7fd59977 275}
276
277//=======================================================================
278//function : ErasedObjects
2195ab96 279//purpose :
7fd59977 280//=======================================================================
2195ab96 281void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind,
282 const Standard_Integer theSign,
283 AIS_ListOfInteractive& theListOfIO) const
7fd59977 284{
2195ab96 285 ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO);
7fd59977 286}
287
288//=======================================================================
289//function : ObjectsByDisplayStatus
2195ab96 290//purpose :
7fd59977 291//=======================================================================
2195ab96 292void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus,
293 AIS_ListOfInteractive& theListOfIO) const
7fd59977 294{
2195ab96 295 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
296 {
297 if (anObjIter.Value()->GraphicStatus() == theStatus)
298 {
299 theListOfIO.Append (anObjIter.Key());
300 }
7fd59977 301 }
302}
303
304//=======================================================================
305//function : ObjectsByDisplayStatus
2195ab96 306//purpose :
7fd59977 307//=======================================================================
2195ab96 308void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind,
309 const Standard_Integer theSign,
310 const AIS_DisplayStatus theStatus,
311 AIS_ListOfInteractive& theListOfIO) const
312{
313 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
314 {
a1954302 315 if (theStatus != AIS_DS_None
316 && anObjIter.Value()->GraphicStatus() != theStatus)
317 {
318 continue;
319 }
320 else if (anObjIter.Key()->Type() != theKind)
2195ab96 321 {
322 continue;
323 }
7fd59977 324
2195ab96 325 if (theSign == -1
326 || anObjIter.Key()->Signature() == theSign)
327 {
328 theListOfIO.Append (anObjIter.Key());
7fd59977 329 }
330 }
331}
332
333//=======================================================================
334//function : ObjectsInside
2195ab96 335//purpose :
7fd59977 336//=======================================================================
2195ab96 337void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO,
338 const AIS_KindOfInteractive theKind,
339 const Standard_Integer theSign) const
7fd59977 340{
2195ab96 341 if (theKind == AIS_KOI_None
342 && theSign == -1)
343 {
344 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
345 {
346 theListOfIO.Append (anObjIter.Key());
7fd59977 347 }
2195ab96 348 return;
7fd59977 349 }
2195ab96 350
351 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
352 {
353 if (anObjIter.Key()->Type() != theKind)
354 {
355 continue;
356 }
357
358 if (theSign == -1
359 || anObjIter.Key()->Signature() == theSign)
360 {
361 theListOfIO.Append (anObjIter.Key());
7fd59977 362 }
363 }
364}
365
a272ed94 366//=======================================================================
367//function : ObjectsForView
368//purpose :
369//=======================================================================
370void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO,
371 const Handle(V3d_View)& theView,
372 const Standard_Boolean theIsVisibleInView,
373 const AIS_DisplayStatus theStatus) const
374{
c357e426 375 Handle(Graphic3d_CView) aViewImpl = theView->View();
376 const Standard_Integer aViewId = aViewImpl->Identification();
a272ed94 377 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
378 {
379 if (theStatus != AIS_DS_None
380 && anObjIter.Value()->GraphicStatus() != theStatus)
381 {
382 theListOfIO.Append (anObjIter.Key());
383 continue;
384 }
385
c357e426 386 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key());
a272ed94 387 const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
388 if (isVisible == theIsVisibleInView)
389 {
390 theListOfIO.Append (anObjIter.Key());
391 }
392 }
393}
394
7fd59977 395//=======================================================================
396//function : Display
2195ab96 397//purpose :
7fd59977 398//=======================================================================
2195ab96 399void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
400 const Standard_Boolean theToUpdateViewer)
401{
402 if (theIObj.IsNull())
403 {
404 return;
405 }
406
407 Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1;
408 GetDefModes (theIObj, aDispMode, aHiMod, aSelMode);
409
410 Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1,
411 theToUpdateViewer, theIObj->AcceptShapeDecomposition());
412}
7fd59977 413
a272ed94 414//=======================================================================
415//function : SetViewAffinity
416//purpose :
417//=======================================================================
418void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj,
419 const Handle(V3d_View)& theView,
420 const Standard_Boolean theIsVisible)
421{
422 if (theIObj.IsNull()
423 || !myObjects.IsBound (theIObj))
424 {
425 return;
426 }
427
c357e426 428 Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj);
429 Handle(Graphic3d_CView) aViewImpl = theView->View();
430 anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True);
a272ed94 431 if (theIsVisible)
432 {
c04c30b3 433 theView->View()->ChangeHiddenObjects()->Remove (theIObj.get());
a272ed94 434 }
435 else
436 {
c04c30b3 437 theView->View()->ChangeHiddenObjects()->Add (theIObj.get());
a272ed94 438 }
439}
440
2195ab96 441//=======================================================================
442//function : Display
443//purpose :
444//=======================================================================
445void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj,
446 const Standard_Integer theDispMode,
447 const Standard_Integer theSelectionMode,
448 const Standard_Boolean theToUpdateViewer,
a1954302 449 const Standard_Boolean theToAllowDecomposition,
450 const AIS_DisplayStatus theDispStatus)
7fd59977 451{
2195ab96 452 if (theIObj.IsNull())
453 {
454 return;
455 }
7fd59977 456
a1954302 457 if (theDispStatus == AIS_DS_Erased)
458 {
459 Erase (theIObj, theToUpdateViewer);
460 Load (theIObj, theSelectionMode, theToAllowDecomposition);
6194ee76 461 if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theIObj))
462 {
463 (*aStatusPtr)->SetDisplayMode (theDispMode);
464 }
a1954302 465 return;
466 }
467
2ec85268 468 setContextToObject (theIObj);
a1954302 469 if (theDispStatus == AIS_DS_Temporary
470 && !HasOpenedContext())
2195ab96 471 {
a1954302 472 return;
473 }
474 else if (HasOpenedContext())
475 {
476 if (theDispStatus == AIS_DS_None
477 || theDispStatus == AIS_DS_Temporary)
2195ab96 478 {
a1954302 479 myLocalContexts (myCurLocalIndex)->Display (theIObj, theDispMode, theToAllowDecomposition, theSelectionMode);
480 if (theToUpdateViewer)
481 {
482 myMainVwr->Update();
483 }
484 return;
2195ab96 485 }
2195ab96 486 }
7fd59977 487
2195ab96 488 if (!myObjects.IsBound (theIObj))
489 {
490 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode);
491 myObjects.Bind (theIObj, aStatus);
6194ee76 492 myMainVwr->StructureManager()->RegisterObject (theIObj);
2195ab96 493 myMainPM->Display(theIObj, theDispMode);
494 if (theSelectionMode != -1)
495 {
543a9964 496 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
497 if (!mgrSelector->Contains (anObj))
2195ab96 498 {
499 mgrSelector->Load (theIObj);
7fd59977 500 }
2195ab96 501 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
502 }
7fd59977 503 }
7fd59977 504 else
505 {
2195ab96 506 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
a1954302 507 if (aStatus->GraphicStatus() == AIS_DS_Temporary)
2195ab96 508 {
509 return;
510 }
a6964ce6 511
f2b63181 512 // Mark the presentation modes hidden of interactive object different from aDispMode.
2195ab96 513 // Then make sure aDispMode is displayed and maybe highlighted.
514 // Finally, activate selection mode <SelMode> if not yet activated.
3db69e41 515 const Standard_Integer anOldMode = aStatus->DisplayMode();
516 if (anOldMode != theDispMode)
2195ab96 517 {
3db69e41 518 if(myMainPM->IsHighlighted (theIObj, anOldMode))
2195ab96 519 {
f838dac4 520 unhighlightGlobal (theIObj);
2195ab96 521 }
3db69e41 522 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
2195ab96 523 }
7fd59977 524
3db69e41 525 aStatus->SetDisplayMode (theDispMode);
7fd59977 526
2195ab96 527 myMainPM->Display (theIObj, theDispMode);
a1954302 528 aStatus->SetGraphicStatus (AIS_DS_Displayed);
2195ab96 529 if (aStatus->IsHilighted())
530 {
f838dac4 531 highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode);
2195ab96 532 }
533 if (theSelectionMode != -1)
534 {
543a9964 535 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
536 if (!mgrSelector->Contains (anObj))
2195ab96 537 {
538 mgrSelector->Load (theIObj);
7fd59977 539 }
2195ab96 540 if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
541 {
0824e32e 542 if (!aStatus->IsSModeIn (theSelectionMode))
543 aStatus->AddSelectionMode (theSelectionMode);
2195ab96 544 mgrSelector->Activate (theIObj, theSelectionMode, myMainSel);
7fd59977 545 }
7fd59977 546 }
547 }
7fd59977 548
2195ab96 549 if (theToUpdateViewer)
550 {
551 myMainVwr->Update();
552 }
553}
7fd59977 554
555//=======================================================================
556//function : Load
2195ab96 557//purpose :
7fd59977 558//=======================================================================
2195ab96 559void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
560 const Standard_Integer theSelMode,
561 const Standard_Boolean theToAllowDecomposition)
7fd59977 562{
2195ab96 563 if (theIObj.IsNull())
564 {
565 return;
566 }
7fd59977 567
2ec85268 568 setContextToObject (theIObj);
2195ab96 569 if (HasOpenedContext())
570 {
571 myLocalContexts (myCurLocalIndex)->Load (theIObj, theToAllowDecomposition, theSelMode);
572 return;
7fd59977 573 }
7fd59977 574
6194ee76 575 if (!myObjects.IsBound (theIObj))
2195ab96 576 {
6194ee76 577 Standard_Integer aDispMode, aHiMod, aSelModeDef;
578 GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
579 Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef);
580 myObjects.Bind (theIObj, aStatus);
581 myMainVwr->StructureManager()->RegisterObject (theIObj);
582 }
89cc29b0 583
6194ee76 584 // Register theIObj in the selection manager to prepare further activation of selection
585 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
586 if (!mgrSelector->Contains (anObj))
587 {
588 mgrSelector->Load (theIObj);
2195ab96 589 }
590}
7fd59977 591
592//=======================================================================
593//function : Erase
2195ab96 594//purpose :
7fd59977 595//=======================================================================
2195ab96 596void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj,
597 const Standard_Boolean theToUpdateViewer)
7fd59977 598{
2195ab96 599 if (theIObj.IsNull())
600 {
601 return;
602 }
7fd59977 603
2195ab96 604 if (!theIObj->IsAutoHilight())
605 {
606 theIObj->ClearSelected();
7fd59977 607 }
2195ab96 608
609 Standard_Boolean wasInCtx = Standard_False;
610 if (HasOpenedContext())
611 {
612 // First it is checked if it is possible to remove in the current local context
613 // then one tries to remove in other local contexts, if they allow it...
614 wasInCtx = myLocalContexts (myCurLocalIndex)->Erase (theIObj);
615 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
7fd59977 616 {
2195ab96 617 if (aCtxIter.Value()->AcceptErase())
618 {
619 wasInCtx = aCtxIter.Value()->Erase (theIObj) || wasInCtx;
7fd59977 620 }
7fd59977 621 }
2195ab96 622 }
623
624 if (!wasInCtx)
625 {
626 EraseGlobal (theIObj, Standard_False);
627 }
628
629 if (theToUpdateViewer)
630 {
631 myMainVwr->Update();
632 }
7fd59977 633}
7fd59977 634
635//=======================================================================
636//function : EraseAll
2195ab96 637//purpose :
7fd59977 638//=======================================================================
2195ab96 639void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer)
7fd59977 640{
2195ab96 641 if (HasOpenedContext())
eb4320f2 642 {
2195ab96 643 return;
644 }
645
646 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
647 {
648 if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed)
eb4320f2 649 {
2195ab96 650 Erase (anObjIter.Key(), Standard_False);
7fd59977 651 }
652 }
2195ab96 653
654 if (theToUpdateViewer)
655 {
656 myMainVwr->Update();
657 }
7fd59977 658}
659
660//=======================================================================
661//function : DisplayAll
2195ab96 662//purpose :
7fd59977 663//=======================================================================
2195ab96 664void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer)
7fd59977 665{
2195ab96 666 if (HasOpenedContext())
667 {
668 return;
669 }
eb4320f2 670
2195ab96 671 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
672 {
673 const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus();
674 if (aStatus == AIS_DS_Erased)
eb4320f2 675 {
2195ab96 676 Display (anObjIter.Key(), Standard_False);
7fd59977 677 }
678 }
2195ab96 679
680 if (theToUpdateViewer)
681 {
682 myMainVwr->Update();
683 }
7fd59977 684}
685
686//=======================================================================
687//function : DisplaySelected
2195ab96 688//purpose :
7fd59977 689//=======================================================================
2195ab96 690void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer)
7fd59977 691{
2195ab96 692 if (HasOpenedContext())
eb4320f2 693 {
2195ab96 694 return;
7fd59977 695 }
7fd59977 696
b5cce1ab 697 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
2195ab96 698 {
b5cce1ab 699 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
2195ab96 700 Display (anObj, Standard_False);
2195ab96 701 }
7fd59977 702
b5cce1ab 703 if (theToUpdateViewer && !mySelection->Objects().IsEmpty())
2195ab96 704 {
705 myMainVwr->Update();
706 }
707}
7fd59977 708
2195ab96 709//=======================================================================
710//function : EraseSelected
711//purpose :
712//=======================================================================
713void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer)
7fd59977 714{
2195ab96 715 if (HasOpenedContext())
eb4320f2 716 {
2195ab96 717 return;
718 }
719
b5cce1ab 720 Standard_Boolean isFound = Standard_False;
721 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects()))
2195ab96 722 {
b5cce1ab 723 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
2195ab96 724 Erase (anObj, Standard_False);
725 isFound = Standard_True;
726 }
727
728 if (isFound && theToUpdateViewer)
729 {
730 myMainVwr->Update();
7fd59977 731 }
732}
2195ab96 733
7fd59977 734//=======================================================================
735//function :
736//purpose :
737//=======================================================================
738
739Standard_Boolean AIS_InteractiveContext::KeepTemporary(const Handle(AIS_InteractiveObject)& anIObj,
740 const Standard_Integer WhichContext)
741{
742 if(anIObj.IsNull()) return Standard_False;
743
744 if(!HasOpenedContext()) return Standard_False;
745 if(myObjects.IsBound(anIObj)) return Standard_False;
746 if(WhichContext!=-1 && !myLocalContexts.IsBound(WhichContext)) return Standard_False;
747
81bba717 748 // Protection : if one tries to preserve a temporary object
749 // which is not in the local active context... rob 11-06-97
7fd59977 750
751 Standard_Integer IsItInLocal = myCurLocalIndex;
752 Standard_Boolean Found(Standard_False);
753
754 while(IsItInLocal>0 && !Found){
755 if(!myLocalContexts.IsBound(IsItInLocal))
756 IsItInLocal--;
757 else if(myLocalContexts(IsItInLocal)->IsIn(anIObj))
758 Found = Standard_True;
759 else
760 IsItInLocal--;
761 }
762
763 if(!Found) return Standard_False;
764
765
766// const Handle(AIS_LocalStatus)& LS = (WhichContext== -1) ?
767// myLocalContexts(IsItInLocal)->Status(anIObj):myLocalContexts(WhichContext)->Status(anIObj);
768 // CLE
769 // const Handle(AIS_LocalStatus)& LS = myLocalContexts(IsItInLocal)->Status(anIObj);
770 Handle(AIS_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj);
771 // ENDCLE
772
773
774 if(LS->IsTemporary()){
775 Standard_Integer DM,HM,SM;
776 GetDefModes(anIObj,DM,HM,SM);
777
778 SM = LS->SelectionModes().IsEmpty() ? SM : LS->SelectionModes().First();
779 if(LS->DisplayMode()!= DM ){
780 Standard_Integer LSM = LS->SelectionModes().IsEmpty() ? -1 : LS->SelectionModes().First();
781 myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM);
782 }
783
784 Handle (AIS_GlobalStatus) GS = new AIS_GlobalStatus(AIS_DS_Displayed,
785 DM,
786 SM,
787 Standard_False);
788// GS->SubIntensityOn();
789 myObjects.Bind(anIObj,GS);
6194ee76 790 myMainVwr->StructureManager()->RegisterObject (anIObj);
7fd59977 791 mgrSelector->Load(anIObj);
792 mgrSelector->Activate(anIObj,SM,myMainSel);
793
794 LS->SetTemporary(Standard_False);
795 }
796 return Standard_True;
797}
798
7fd59977 799//=======================================================================
2195ab96 800//function : DisplayStatus
801//purpose :
7fd59977 802//=======================================================================
2195ab96 803AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const
7fd59977 804{
2195ab96 805 if (theIObj.IsNull())
806 {
807 return AIS_DS_None;
808 }
809 else if (myObjects.IsBound (theIObj))
810 {
811 return myObjects (theIObj)->GraphicStatus();
812 }
7fd59977 813
2195ab96 814 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
815 {
816 if (aCtxIter.Value()->IsIn (theIObj))
817 {
7fd59977 818 return AIS_DS_Temporary;
2195ab96 819 }
7fd59977 820 }
7fd59977 821 return AIS_DS_None;
7fd59977 822}
823
7fd59977 824//=======================================================================
825//function : Remove
2195ab96 826//purpose :
7fd59977 827//=======================================================================
2195ab96 828void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj,
829 const Standard_Boolean theToUpdateViewer)
7fd59977 830{
2195ab96 831 if (theIObj.IsNull())
832 {
833 return;
7fd59977 834 }
2195ab96 835
2ec85268 836 if (theIObj->HasInteractiveContext())
837 {
838 if (theIObj->myCTXPtr != this)
839 {
9775fa61 840 throw Standard_ProgramError("AIS_InteractiveContext - object has been displayed in another context!");
2ec85268 841 }
842 theIObj->SetContext (Handle(AIS_InteractiveContext)());
843 }
844
2195ab96 845 if (HasOpenedContext())
846 {
847 myLocalContexts (myCurLocalIndex)->Remove (theIObj);
848 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
7fd59977 849 {
2195ab96 850 if (aCtxIter.Value()->AcceptErase())
851 {
852 aCtxIter.Value()->Remove (theIObj);
7fd59977 853 }
7fd59977 854 }
2195ab96 855 }
856
857 ClearGlobal (theIObj, theToUpdateViewer);
7fd59977 858}
859
860//=======================================================================
861//function : RemoveAll
2195ab96 862//purpose :
7fd59977 863//=======================================================================
2195ab96 864void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer)
7fd59977 865{
866 AIS_ListOfInteractive aList;
2195ab96 867 ObjectsInside (aList);
868 for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
869 {
870 Remove (aListIterator.Value(), Standard_False);
7fd59977 871 }
7fd59977 872
2195ab96 873 if (theToUpdateViewer)
874 {
875 myMainVwr->Update();
7fd59977 876 }
7fd59977 877}
878
7fd59977 879//=======================================================================
880//function : ClearPrs
2195ab96 881//purpose :
7fd59977 882//=======================================================================
2195ab96 883void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theIObj,
884 const Standard_Integer theMode,
885 const Standard_Boolean theToUpdateViewer)
7fd59977 886{
2195ab96 887 if (theIObj.IsNull())
888 {
889 return;
890 }
7fd59977 891
2195ab96 892 if (!HasOpenedContext())
893 {
894 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
895 return;
7fd59977 896 }
2195ab96 897
898 Standard_Boolean wasInCtx = myLocalContexts (myCurLocalIndex)->ClearPrs (theIObj, theMode);
899 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
900 {
901 if (aCtxIter.Value()->AcceptErase())
7fd59977 902 {
2195ab96 903 wasInCtx = aCtxIter.Value()->ClearPrs (theIObj, theMode) || wasInCtx;
7fd59977 904 }
2195ab96 905 }
906 if (!wasInCtx)
907 {
908 ClearGlobalPrs (theIObj, theMode, theToUpdateViewer);
909 }
910 else if (theToUpdateViewer)
911 {
912 myMainVwr->Update();
913 }
7fd59977 914}
915
916//=======================================================================
8e5fb5ea 917//function : HilightWithColor
918//purpose :
7fd59977 919//=======================================================================
8e5fb5ea 920void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj,
f838dac4 921 const Handle(Prs3d_Drawer)& theStyle,
8e5fb5ea 922 const Standard_Boolean theIsToUpdate)
7fd59977 923{
8e5fb5ea 924 if (theObj.IsNull())
2195ab96 925 return;
7fd59977 926
2ec85268 927 setContextToObject (theObj);
7fd59977 928 if (!HasOpenedContext())
eb4320f2 929 {
8e5fb5ea 930 if (!myObjects.IsBound (theObj))
2195ab96 931 return;
eb4320f2 932
8e5fb5ea 933 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj);
2195ab96 934 aStatus->SetHilightStatus (Standard_True);
8e5fb5ea 935
2195ab96 936 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
eb4320f2 937 {
f838dac4 938 highlightGlobal (theObj, theStyle, aStatus->DisplayMode());
8e5fb5ea 939 aStatus->SetHilightStyle (theStyle);
7fd59977 940 }
eb4320f2 941 }
7fd59977 942 else
eb4320f2 943 {
8e5fb5ea 944 myLocalContexts (myCurLocalIndex)->Hilight (theObj, theStyle);
eb4320f2 945 }
946
8e5fb5ea 947 if (theIsToUpdate)
2195ab96 948 myMainVwr->Update();
7fd59977 949}
950
951//=======================================================================
952//function : Unhilight
953//purpose :
954//=======================================================================
7fd59977 955void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer)
956{
957 if(anIObj.IsNull()) return;
958
959 if (!HasOpenedContext())
eb4320f2 960 {
961 if(!myObjects.IsBound(anIObj)) return;
7fd59977 962
a1954302 963 const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj);
964 aStatus->SetHilightStatus (Standard_False);
f838dac4 965 aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
eb4320f2 966
a1954302 967 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
eb4320f2 968 {
f838dac4 969 unhighlightGlobal (anIObj);
7fd59977 970 }
eb4320f2 971 }
7fd59977 972 else
eb4320f2 973 {
7fd59977 974 myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
eb4320f2 975 }
7fd59977 976 if(updateviewer) myMainVwr->Update();
977}
978
979//=======================================================================
980//function : IsHilighted
8e5fb5ea 981//purpose : Returns true if the objects global status is set to highlighted.
7fd59977 982//=======================================================================
8e5fb5ea 983Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const
7fd59977 984{
8e5fb5ea 985 if (!HasOpenedContext())
986 {
987 if (!myObjects.IsBound (theObj))
7fd59977 988 return Standard_False;
7fd59977 989
8e5fb5ea 990 return myObjects (theObj)->IsHilighted();
7fd59977 991 }
8e5fb5ea 992
404c8936 993 Standard_DISABLE_DEPRECATION_WARNINGS
994 Standard_Integer aCtxIdx = HighestIndex();
995 Standard_ENABLE_DEPRECATION_WARNINGS
996 for (; aCtxIdx >= 1; aCtxIdx--)
8e5fb5ea 997 {
998 if (myLocalContexts.IsBound (aCtxIdx))
999 {
1000 if (myLocalContexts (aCtxIdx)->IsHilighted (theObj))
7fd59977 1001 return Standard_True;
1002 }
7fd59977 1003 }
8e5fb5ea 1004
7fd59977 1005 return Standard_False;
1006}
1007
c3282ec1 1008//=======================================================================
1009//function : IsHilighted
8e5fb5ea 1010//purpose : Returns true if the owner is highlighted with selection style.
c3282ec1 1011//=======================================================================
8e5fb5ea 1012Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const
c3282ec1 1013{
1014 if (theOwner.IsNull() || !theOwner->HasSelectable())
1015 return Standard_False;
1016
1017 const Handle(AIS_InteractiveObject) anObj =
1018 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1019
8e5fb5ea 1020 if (anObj->GlobalSelOwner() == theOwner)
1021 {
1022 if (!myObjects.IsBound (anObj))
1023 return Standard_False;
1024
1025 return myObjects (anObj)->IsHilighted();
1026 }
1027
1028 return theOwner->IsSelected();
1029}
1030
1031//=======================================================================
1032//function : HighlightStyle
1033//purpose :
1034//=======================================================================
1035Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj,
f838dac4 1036 Handle(Prs3d_Drawer)& theStyle) const
8e5fb5ea 1037{
1038 if (HasOpenedContext())
1039 myLocalContexts (myCurLocalIndex)->HighlightStyle (theObj, theStyle);
1040
1041 if (IsHilighted (theObj))
1042 {
1043 theStyle = myObjects (theObj)->HilightStyle();
1044 return Standard_True;
1045 }
1046 else
1047 {
1048 theStyle.Nullify();
c3282ec1 1049 return Standard_False;
8e5fb5ea 1050 }
1051}
c3282ec1 1052
8e5fb5ea 1053//=======================================================================
1054//function : HighlightStyle
1055//purpose :
1056//=======================================================================
1057Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
f838dac4 1058 Handle(Prs3d_Drawer)& theStyle) const
8e5fb5ea 1059{
1060 if (theOwner.IsNull() || !theOwner->HasSelectable())
1061 return Standard_False;
1062
1063 if (IsHilighted (theOwner))
c3282ec1 1064 {
8e5fb5ea 1065 const Handle(AIS_InteractiveObject) anObj =
1066 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1067 if (anObj->GlobalSelOwner() == theOwner)
c3282ec1 1068 {
8e5fb5ea 1069 theStyle = myObjects (anObj)->HilightStyle();
c3282ec1 1070 }
1071 else
1072 {
8e5fb5ea 1073 // since part selection style is not stored in global status,
1074 // check if the object has own selection style. If not, it can
1075 // only be highlighted with default selection style (because
1076 // sub-intensity does not modify any selection states)
f838dac4 1077 theStyle = getSelStyle (anObj, theOwner);
c3282ec1 1078 }
c3282ec1 1079 return Standard_True;
1080 }
8e5fb5ea 1081 else
1082 {
1083 theStyle.Nullify();
1084 return Standard_False;
1085 }
c3282ec1 1086}
7fd59977 1087
1088//=======================================================================
1089//function : IsDisplayed
1090//purpose :
1091//=======================================================================
1092
1093Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anIObj) const
1094{
1095 if(anIObj.IsNull()) return Standard_False;
1096
1097
1098 if(myObjects.IsBound(anIObj))
1099 if(myObjects(anIObj)->GraphicStatus()==AIS_DS_Displayed)
1100 return Standard_True;
1101
1102 AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts);
1103 for(;ItM.More();ItM.Next()){
1104 if(ItM.Value()->IsDisplayed(anIObj))
1105 return Standard_True;
1106 }
1107 return Standard_False;
1108
1109}
7fd59977 1110
1111//=======================================================================
1112//function : IsDisplayed
2195ab96 1113//purpose :
7fd59977 1114//=======================================================================
2195ab96 1115Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj,
1116 const Standard_Integer theMode) const
7fd59977 1117{
2195ab96 1118 if (theIObj.IsNull())
1119 {
1120 return Standard_False;
1121 }
1122
1123 if (myObjects.IsBound (theIObj))
1124 {
1125 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1126 if (aStatus->GraphicStatus() == AIS_DS_Displayed
b2bafb33 1127 && aStatus->DisplayMode() == theMode)
2195ab96 1128 {
7fd59977 1129 return Standard_True;
2195ab96 1130 }
7fd59977 1131 }
2195ab96 1132
1133 for (AIS_DataMapIteratorOfDataMapOfILC aCtxIter (myLocalContexts); aCtxIter.More(); aCtxIter.Next())
1134 {
1135 if (aCtxIter.Value()->IsDisplayed (theIObj, theMode))
1136 {
7fd59977 1137 return Standard_True;
2195ab96 1138 }
7fd59977 1139 }
1140 return Standard_False;
1141}
1142
7fd59977 1143//=======================================================================
1144//function : DisplayPriority
2195ab96 1145//purpose :
7fd59977 1146//=======================================================================
2195ab96 1147Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const
7fd59977 1148{
2195ab96 1149 if (theIObj.IsNull())
1150 {
1151 return -1;
1152 }
1153 else if (!myObjects.IsBound (theIObj))
1154 {
1155 return 0;
1156 }
eb4320f2 1157
2195ab96 1158 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1159 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1160 || aStatus->GraphicStatus() == AIS_DS_Erased)
eb4320f2 1161 {
2195ab96 1162 Standard_Integer aDispMode = theIObj->HasDisplayMode()
1163 ? theIObj->DisplayMode()
f838dac4 1164 : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
1165 ? myDefaultDrawer->DisplayMode()
2195ab96 1166 : 0);
1167 return myMainPM->DisplayPriority (theIObj, aDispMode);
7fd59977 1168 }
1169 return 0;
1170}
2195ab96 1171
7fd59977 1172//=======================================================================
1173//function : SetDisplayPriority
2195ab96 1174//purpose :
7fd59977 1175//=======================================================================
2195ab96 1176void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj,
1177 const Standard_Integer thePriority)
7fd59977 1178{
2195ab96 1179 if (theIObj.IsNull())
1180 {
7fd59977 1181 return;
2195ab96 1182 }
1183
2ec85268 1184 setContextToObject (theIObj);
2195ab96 1185 if (myObjects.IsBound (theIObj))
1186 {
1187 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1188 if (aStatus->GraphicStatus() == AIS_DS_Displayed
1189 || aStatus->GraphicStatus() == AIS_DS_Erased)
eb4320f2 1190 {
2195ab96 1191 Standard_Integer aDisplayMode = theIObj->HasDisplayMode()
1192 ? theIObj->DisplayMode()
f838dac4 1193 : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
1194 ? myDefaultDrawer->DisplayMode()
2195ab96 1195 : 0);
1196 myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority);
7fd59977 1197 }
1198 }
1199 else if (HasOpenedContext())
eb4320f2 1200 {
2195ab96 1201 myLocalContexts (myCurLocalIndex)->SetDisplayPriority (theIObj, thePriority);
eb4320f2 1202 }
7fd59977 1203}
1204
1205//=======================================================================
1206//function : Redisplay
2195ab96 1207//purpose :
7fd59977 1208//=======================================================================
2195ab96 1209void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj,
1210 const Standard_Boolean theToUpdateViewer,
1211 const Standard_Boolean theAllModes)
7fd59977 1212{
2195ab96 1213 RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes);
1214 RecomputeSelectionOnly (theIObj);
7fd59977 1215}
1216
1217//=======================================================================
1218//function : Redisplay
2195ab96 1219//purpose :
7fd59977 1220//=======================================================================
2195ab96 1221void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI,
1222 const Standard_Integer /*theSign*/,
1223 const Standard_Boolean theToUpdateViewer)
1224{
1225 Standard_Boolean isRedisplayed = Standard_False;
1226 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1227 {
1228 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1229 if (anObj->Type() != theKOI)
1230 {
1231 continue;
7fd59977 1232 }
2195ab96 1233
1234 Redisplay (anObj, Standard_False);
1235 isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed
1236 || isRedisplayed;
7fd59977 1237 }
2195ab96 1238
1239 if (theToUpdateViewer
1240 && isRedisplayed)
eb4320f2 1241 {
1242 myMainVwr->Update();
7fd59977 1243 }
1244}
1245
7fd59977 1246//=======================================================================
1247//function : RecomputePrsOnly
2195ab96 1248//purpose :
7fd59977 1249//=======================================================================
2195ab96 1250void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj,
1251 const Standard_Boolean theToUpdateViewer,
1252 const Standard_Boolean theAllModes)
7fd59977 1253{
2195ab96 1254 if (theIObj.IsNull())
1255 {
1256 return;
1257 }
eb4320f2 1258
2195ab96 1259 theIObj->Update (theAllModes);
1260 if (!theToUpdateViewer)
eb4320f2 1261 {
1262 return;
1263 }
1264
2195ab96 1265 if (HasOpenedContext()
1266 || (myObjects.IsBound (theIObj)
1267 && myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed))
eb4320f2 1268 {
1269 myMainVwr->Update();
7fd59977 1270 }
1271}
1272//=======================================================================
1273//function : RecomputeSelectionOnly
1274//purpose :
1275//=======================================================================
bc677575 1276void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO)
7fd59977 1277{
bc677575 1278 if (theIO.IsNull())
1279 {
1280 return;
1281 }
7fd59977 1282
bc677575 1283 mgrSelector->RecomputeSelection (theIO);
0d969553 1284
bc677575 1285 if (HasOpenedContext())
1286 {
1287 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
eb4320f2 1288 {
bc677575 1289 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIO, Standard_False);
eb4320f2 1290 }
bc677575 1291 return;
1292 }
1293
1294 if (!myObjects.IsBound (theIO) ||
1295 myObjects (theIO)->GraphicStatus() != AIS_DS_Displayed)
1296 {
1297 return;
1298 }
1299
1300 TColStd_ListOfInteger aModes;
1301 ActivatedModes (theIO, aModes);
1302 TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
1303 for (; aModesIter.More(); aModesIter.Next())
1304 {
1305 mgrSelector->Activate (theIO, aModesIter.Value(), myMainSel);
7fd59977 1306 }
1307}
1308
1309//=======================================================================
1310//function : Update
2195ab96 1311//purpose :
7fd59977 1312//=======================================================================
f3889691 1313void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
2195ab96 1314 const Standard_Boolean theUpdateViewer)
7fd59977 1315{
f3889691 1316 if (theIObj.IsNull())
1317 {
1318 return;
1319 }
7fd59977 1320
2195ab96 1321 TColStd_ListOfInteger aPrsModes;
1322 theIObj->ToBeUpdated (aPrsModes);
1323 for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next())
f3889691 1324 {
1325 theIObj->Update (aPrsModesIt.Value(), Standard_False);
7fd59977 1326 }
f3889691 1327
1328 mgrSelector->Update(theIObj);
1329
bc677575 1330 for (Standard_Integer aContextIdx = 1; aContextIdx <= myLocalContexts.Extent(); aContextIdx++)
1331 {
1332 myLocalContexts (aContextIdx)->ClearOutdatedSelection (theIObj, Standard_False);
1333 }
1334
f3889691 1335 if (theUpdateViewer)
1336 {
1337 if (!myObjects.IsBound (theIObj))
1338 {
1339 return;
1340 }
1341
1342 switch (myObjects (theIObj)->GraphicStatus())
1343 {
1344 case AIS_DS_Displayed:
1345 case AIS_DS_Temporary:
1346 myMainVwr->Update();
1347 break;
1348 default:
1349 break;
7fd59977 1350 }
1351 }
1352}
1353
7fd59977 1354//=======================================================================
1355//function : SetLocation
2195ab96 1356//purpose :
7fd59977 1357//=======================================================================
2195ab96 1358void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj,
1359 const TopLoc_Location& theLoc)
7fd59977 1360{
2195ab96 1361 if (theIObj.IsNull())
1362 {
1363 return;
1364 }
7fd59977 1365
2195ab96 1366 if (theIObj->HasTransformation()
1367 && theLoc.IsIdentity())
1368 {
1369 theIObj->ResetTransformation();
1370 mgrSelector->Update (theIObj, Standard_False);
1371 return;
1372 }
1373 else if (theLoc.IsIdentity())
1374 {
7fd59977 1375 return;
1376 }
7fd59977 1377
0d969553 1378 // first reset the previous location to properly clean everything...
2195ab96 1379 if (theIObj->HasTransformation())
1380 {
1381 theIObj->ResetTransformation();
1382 }
7fd59977 1383
2195ab96 1384 theIObj->SetLocalTransformation (theLoc.Transformation());
7fd59977 1385
2195ab96 1386 if (!HasOpenedContext())
1387 {
1388 mgrSelector->Update (theIObj, Standard_False);
1389 }
7fd59977 1390 else
2195ab96 1391 {
1392 Handle(StdSelect_ViewerSelector3d) aTempSel = myLocalContexts (myCurLocalIndex)->MainSelector();
1393 mgrSelector->Update (theIObj, aTempSel, Standard_False);
1394 }
5396886c 1395
1396 // if the object or its part is highlighted dynamically, it is necessary to apply location transformation
1397 // to its highlight structure immediately
8e5fb5ea 1398 if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj))
5396886c 1399 {
7bbccb5f 1400 const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
5396886c 1401 myLastPicked->UpdateHighlightTrsf (myMainVwr,
1402 myMainPM,
7bbccb5f 1403 aHiMod);
5396886c 1404 }
7fd59977 1405}
2195ab96 1406
7fd59977 1407//=======================================================================
1408//function : ResetLocation
2195ab96 1409//purpose :
7fd59977 1410//=======================================================================
2195ab96 1411void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj)
7fd59977 1412{
2195ab96 1413 if (theIObj.IsNull())
1414 {
1415 return;
1416 }
7fd59977 1417
2195ab96 1418 theIObj->ResetTransformation();
1419 mgrSelector->Update (theIObj, Standard_False);
7fd59977 1420}
1421
1422//=======================================================================
1423//function : HasLocation
2195ab96 1424//purpose :
7fd59977 1425//=======================================================================
2195ab96 1426Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const
7fd59977 1427{
2195ab96 1428 return !theIObj.IsNull()
1429 && theIObj->HasTransformation();
7fd59977 1430}
1431
2195ab96 1432//=======================================================================
1433//function : Location
1434//purpose :
1435//=======================================================================
1436TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const
7fd59977 1437{
2195ab96 1438 return theIObj->Transformation();
7fd59977 1439}
1440
1441//=======================================================================
1442//function : SetDeviationCoefficient
2195ab96 1443//purpose :
7fd59977 1444//=======================================================================
2195ab96 1445void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient)
7fd59977 1446{
2195ab96 1447 myDefaultDrawer->SetDeviationCoefficient (theCoefficient);
7fd59977 1448}
2195ab96 1449
7fd59977 1450//=======================================================================
1451//function : SetDeviationAngle
2195ab96 1452//purpose :
7fd59977 1453//=======================================================================
2195ab96 1454void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle)
7fd59977 1455{
e19792fa 1456 myDefaultDrawer->SetDeviationAngle (theAngle);
7fd59977 1457}
1458
1459//=======================================================================
1460//function : DeviationAngle
1461//purpose : Gets deviationAngle
1462//=======================================================================
7fd59977 1463Standard_Real AIS_InteractiveContext::DeviationAngle() const
1464{
2195ab96 1465 return myDefaultDrawer->DeviationAngle();
7fd59977 1466}
1467
1468//=======================================================================
1469//function : DeviationCoefficient
2195ab96 1470//purpose :
7fd59977 1471//=======================================================================
2195ab96 1472Standard_Real AIS_InteractiveContext::DeviationCoefficient() const
7fd59977 1473{
1474 return myDefaultDrawer->DeviationCoefficient();
1475}
2195ab96 1476
7fd59977 1477//=======================================================================
1478//function : SetHLRDeviationCoefficient
2195ab96 1479//purpose :
7fd59977 1480//=======================================================================
2195ab96 1481void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
7fd59977 1482{
2195ab96 1483 myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient);
7fd59977 1484}
1485
1486//=======================================================================
1487//function : HLRDeviationCoefficient
2195ab96 1488//purpose :
7fd59977 1489//=======================================================================
2195ab96 1490Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const
7fd59977 1491{
1492 return myDefaultDrawer->HLRDeviationCoefficient();
1493}
1494
1495//=======================================================================
1496//function : SetHLRAngle
2195ab96 1497//purpose :
7fd59977 1498//=======================================================================
2195ab96 1499void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle)
7fd59977 1500{
2195ab96 1501 myDefaultDrawer->SetHLRAngle (theAngle);
7fd59977 1502}
1503
1504//=======================================================================
1505//function : SetHLRAngleAndDeviation
1506//purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient
1507// and set them in myHLRAngle and in myHLRDeviationCoefficient
1508// of myDefaultDrawer
1509//=======================================================================
2195ab96 1510void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle)
7fd59977 1511{
2195ab96 1512 Standard_Real anOutAngl, anOutDefl;
1513 HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl);
7fd59977 1514
2195ab96 1515 myDefaultDrawer->SetHLRAngle (anOutAngl);
1516 myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl);
7fd59977 1517}
1518
1519//=======================================================================
1520//function : HLRAngle
2195ab96 1521//purpose :
7fd59977 1522//=======================================================================
7fd59977 1523Standard_Real AIS_InteractiveContext::HLRAngle() const
1524{
1525 return myDefaultDrawer->HLRAngle();
1526}
1527
1528//=======================================================================
1529//function : SetDisplayMode
2195ab96 1530//purpose :
7fd59977 1531//=======================================================================
e5d7e249 1532void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode,
1533 const Standard_Boolean theToUpdateViewer)
7fd59977 1534{
f838dac4 1535 if (theMode == myDefaultDrawer->DisplayMode())
2195ab96 1536 {
1537 return;
1538 }
7fd59977 1539
2195ab96 1540 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
1541 {
1542 Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
1543 Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape))
1544 || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive))
1545 || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive));
7fd59977 1546
2195ab96 1547 if (!toProcess
1548 || anObj->HasDisplayMode()
1549 || !anObj->AcceptDisplayMode (theMode))
1550 {
1551 continue;
1552 }
1553
1554 Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
3db69e41 1555 aStatus->SetDisplayMode (theMode);
2195ab96 1556
2195ab96 1557 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1558 {
2195ab96 1559 myMainPM->Display (anObj, theMode);
8e5fb5ea 1560 if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj))
c3282ec1 1561 {
1562 myMainPM->BeginImmediateDraw();
f838dac4 1563 unhighlightGlobal (anObj);
c3282ec1 1564 myMainPM->EndImmediateDraw (myMainVwr);
1565 }
2195ab96 1566 if (aStatus->IsSubIntensityOn())
7fd59977 1567 {
8e5fb5ea 1568 highlightWithSubintensity (anObj, theMode);
7fd59977 1569 }
f838dac4 1570 myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False);
2195ab96 1571 }
1572 }
1573
f838dac4 1574 myDefaultDrawer->SetDisplayMode (theMode);
2195ab96 1575 if (theToUpdateViewer)
1576 {
1577 myMainVwr->Update();
1578 }
7fd59977 1579}
1580
1581//=======================================================================
1582//function : SetDisplayMode
2195ab96 1583//purpose :
7fd59977 1584//=======================================================================
2195ab96 1585void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1586 const Standard_Integer theMode,
1587 const Standard_Boolean theToUpdateViewer)
7fd59977 1588{
2ec85268 1589 setContextToObject (theIObj);
2195ab96 1590 if (!myObjects.IsBound (theIObj))
1591 {
1592 theIObj->SetDisplayMode (theMode);
1593 return;
1594 }
1595 else if (!theIObj->AcceptDisplayMode (theMode))
1596 {
1597 return;
1598 }
eb4320f2 1599
2195ab96 1600 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
1601 if (aStatus->GraphicStatus() != AIS_DS_Displayed)
1602 {
b2bafb33 1603 aStatus->SetDisplayMode (theMode);
2195ab96 1604 theIObj->SetDisplayMode (theMode);
1605 return;
1606 }
a6964ce6 1607
2195ab96 1608 // erase presentations for all display modes different from <aMode>
3db69e41 1609 const Standard_Integer anOldMode = aStatus->DisplayMode();
1610 if (anOldMode != theMode)
2195ab96 1611 {
3db69e41 1612 if (myMainPM->IsHighlighted (theIObj, anOldMode))
2195ab96 1613 {
f838dac4 1614 unhighlightGlobal (theIObj);
7fd59977 1615 }
3db69e41 1616 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
7fd59977 1617 }
2195ab96 1618
3db69e41 1619 aStatus->SetDisplayMode (theMode);
2195ab96 1620
1621 myMainPM->Display (theIObj, theMode);
2195ab96 1622 if (aStatus->IsHilighted())
1623 {
f838dac4 1624 highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode);
2195ab96 1625 }
1626 if (aStatus->IsSubIntensityOn())
1627 {
8e5fb5ea 1628 highlightWithSubintensity (theIObj, theMode);
2195ab96 1629 }
1630
1631 if (theToUpdateViewer)
1632 {
1633 myMainVwr->Update();
1634 }
1635 theIObj->SetDisplayMode (theMode);
7fd59977 1636}
1637
1638//=======================================================================
1639//function : UnsetDisplayMode
2195ab96 1640//purpose :
7fd59977 1641//=======================================================================
2195ab96 1642void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj,
1643 const Standard_Boolean theToUpdateViewer)
7fd59977 1644{
2195ab96 1645 if (theIObj.IsNull()
1646 || !theIObj->HasDisplayMode())
1647 {
1648 return;
1649 }
1650
1651 if (!myObjects.IsBound (theIObj))
1652 {
1653 theIObj->UnsetDisplayMode();
1654 return;
1655 }
1656
1657 const Standard_Integer anOldMode = theIObj->DisplayMode();
f838dac4 1658 if (myDefaultDrawer->DisplayMode() == anOldMode)
2195ab96 1659 {
1660 return;
1661 }
1662
1663 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
f838dac4 1664 aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode());
2195ab96 1665
1666 if (aStatus->GraphicStatus() == AIS_DS_Displayed)
1667 {
1668 if (myMainPM->IsHighlighted (theIObj, anOldMode))
7fd59977 1669 {
f838dac4 1670 unhighlightGlobal (theIObj);
2195ab96 1671 }
1672 myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
f838dac4 1673 myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode());
2195ab96 1674 if (aStatus->IsHilighted())
1675 {
8e5fb5ea 1676 highlightSelected (theIObj->GlobalSelOwner());
2195ab96 1677 }
1678 if (aStatus->IsSubIntensityOn())
1679 {
f838dac4 1680 highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode());
7fd59977 1681 }
2195ab96 1682
1683 if (theToUpdateViewer)
1684 {
1685 myMainVwr->Update();
1686 }
1687 }
1688
1689 theIObj->UnsetDisplayMode();
7fd59977 1690}
1691
1692//=======================================================================
1693//function : SetCurrentFacingModel
2195ab96 1694//purpose :
7fd59977 1695//=======================================================================
2195ab96 1696void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj,
1697 const Aspect_TypeOfFacingModel theModel)
b8ddfc2f 1698{
2195ab96 1699 if (!theIObj.IsNull())
1700 {
1701 theIObj->SetCurrentFacingModel (theModel);
1702 }
7fd59977 1703}
7fd59977 1704
1705//=======================================================================
2195ab96 1706//function : redisplayPrsRecModes
1707//purpose :
7fd59977 1708//=======================================================================
2195ab96 1709void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj,
1710 const Standard_Boolean theToUpdateViewer)
7fd59977 1711{
2195ab96 1712 if (theIObj->RecomputeEveryPrs())
1713 {
36132a2e 1714 theIObj->Update (Standard_True);
1715 theIObj->UpdateSelection();
2195ab96 1716 }
1717 else
1718 {
1719 for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next())
1720 {
1721 theIObj->Update (aModes.Value(), Standard_False);
1722 }
28ee613b 1723 theIObj->UpdateSelection();
2195ab96 1724 theIObj->SetRecomputeOk();
1725 }
1726
1727 if (theToUpdateViewer)
1728 {
1729 UpdateCurrentViewer();
1730 }
7fd59977 1731}
1732
2195ab96 1733//=======================================================================
1734//function : redisplayPrsModes
1735//purpose :
1736//=======================================================================
1737void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj,
1738 const Standard_Boolean theToUpdateViewer)
7fd59977 1739{
2195ab96 1740 if (theIObj->RecomputeEveryPrs())
1741 {
36132a2e 1742 theIObj->Update (Standard_True);
1743 theIObj->UpdateSelection();
2195ab96 1744 }
7fd59977 1745 else
2195ab96 1746 {
1747 TColStd_ListOfInteger aModes;
1748 theIObj->ToBeUpdated (aModes);
1749 for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
7fd59977 1750 {
2195ab96 1751 theIObj->Update (aModeIter.Value(), Standard_False);
7fd59977 1752 }
2195ab96 1753 theIObj->SetRecomputeOk();
1754 }
7fd59977 1755
2195ab96 1756 if (theToUpdateViewer)
1757 {
1758 UpdateCurrentViewer();
1759 }
7fd59977 1760}
1761
2195ab96 1762//=======================================================================
1763//function : SetColor
1764//purpose :
1765//=======================================================================
1766void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj,
1767 const Quantity_Color& theColor,
1768 const Standard_Boolean theToUpdateViewer)
7fd59977 1769{
2195ab96 1770 if (theIObj.IsNull())
1771 {
1772 return;
1773 }
7fd59977 1774
2ec85268 1775 setContextToObject (theIObj);
2195ab96 1776 theIObj->SetColor (theColor);
1777 redisplayPrsRecModes (theIObj, theToUpdateViewer);
1778}
7fd59977 1779
5ad8c033 1780//=======================================================================
1781//function : SetIsoOnTriangulation
1782//purpose :
1783//=======================================================================
1784void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theIsEnabled,
1785 const Handle(AIS_InteractiveObject)& theObject)
1786{
1787 if (theObject.IsNull())
1788 {
1789 return;
1790 }
1791
1792 theObject->SetIsoOnTriangulation (theIsEnabled);
1793}
1794
2195ab96 1795//=======================================================================
1796//function : SetDeviationCoefficient
1797//purpose :
1798//=======================================================================
1799void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1800 const Standard_Real theCoefficient,
1801 const Standard_Boolean theToUpdateViewer)
1802{
1803 if (theIObj.IsNull())
1804 {
1805 return;
1806 }
7fd59977 1807
2195ab96 1808 // to be modified after the related methods of AIS_Shape are passed to InteractiveObject
2ec85268 1809 setContextToObject (theIObj);
2195ab96 1810 if (theIObj->Type() != AIS_KOI_Object
1811 && theIObj->Type() != AIS_KOI_Shape)
1812 {
1813 return;
1814 }
1815 else if (theIObj->Signature() != 0)
1816 {
1817 return;
1818 }
1819
1820 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1821 aShape->SetOwnDeviationCoefficient (theCoefficient);
1822 redisplayPrsModes (theIObj, theToUpdateViewer);
7fd59977 1823}
1824
1825//=======================================================================
1826//function : SetHLRDeviationCoefficient
2195ab96 1827//purpose :
7fd59977 1828//=======================================================================
2195ab96 1829void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
1830 const Standard_Real theCoefficient,
1831 const Standard_Boolean theToUpdateViewer)
7fd59977 1832{
2195ab96 1833 if (theIObj.IsNull())
1834 {
1835 return;
1836 }
1837
81bba717 1838 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2ec85268 1839 setContextToObject (theIObj);
2195ab96 1840 if (theIObj->Type() != AIS_KOI_Object
1841 && theIObj->Type() != AIS_KOI_Shape)
1842 {
1843 return;
1844 }
1845 else if (theIObj->Signature() != 0)
1846 {
1847 return;
1848 }
7fd59977 1849
2195ab96 1850 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1851 aShape->SetOwnHLRDeviationCoefficient (theCoefficient);
1852 redisplayPrsModes (theIObj, theToUpdateViewer);
7fd59977 1853}
1854
7fd59977 1855//=======================================================================
1856//function : SetDeviationAngle
2195ab96 1857//purpose :
7fd59977 1858//=======================================================================
2195ab96 1859void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1860 const Standard_Real theAngle,
1861 const Standard_Boolean theToUpdateViewer)
7fd59977 1862{
2195ab96 1863 if (theIObj.IsNull())
1864 {
1865 return;
1866 }
1867
e33e7e78 1868 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2ec85268 1869 setContextToObject (theIObj);
2195ab96 1870 if (theIObj->Type() != AIS_KOI_Shape)
1871 {
1872 return;
1873 }
1874 else if (theIObj->Signature() != 0)
1875 {
1876 return;
1877 }
7fd59977 1878
2195ab96 1879 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1880 aShape->SetOwnDeviationAngle (theAngle);
1881 redisplayPrsModes (theIObj, theToUpdateViewer);
7fd59977 1882}
2195ab96 1883
7fd59977 1884//=======================================================================
2195ab96 1885//function : SetAngleAndDeviation
1886//purpose :
7fd59977 1887//=======================================================================
2195ab96 1888void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1889 const Standard_Real theAngle,
1890 const Standard_Boolean theToUpdateViewer)
7fd59977 1891{
2195ab96 1892 if (theIObj.IsNull())
1893 {
1894 return;
1895 }
1896
e33e7e78 1897 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2ec85268 1898 setContextToObject (theIObj);
2195ab96 1899 if (theIObj->Type() != AIS_KOI_Shape)
1900 {
1901 return;
1902 }
1903 if (theIObj->Signature() != 0)
1904 {
1905 return;
1906 }
7fd59977 1907
2195ab96 1908 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1909 aShape->SetAngleAndDeviation (theAngle);
7fd59977 1910
2195ab96 1911 if (theIObj->RecomputeEveryPrs())
1912 {
36132a2e 1913 theIObj->Update (Standard_True);
1914 theIObj->UpdateSelection();
2195ab96 1915 }
7fd59977 1916 else
2195ab96 1917 {
1918 Update (theIObj, theToUpdateViewer);
1919 }
7fd59977 1920}
1921
1922//=======================================================================
2195ab96 1923//function : SetHLRAngleAndDeviation
1924//purpose :
7fd59977 1925//=======================================================================
2195ab96 1926void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
1927 const Standard_Real theAngle,
1928 const Standard_Boolean theToUpdateViewer)
7fd59977 1929{
2195ab96 1930 if (theIObj.IsNull())
1931 {
1932 return;
1933 }
7fd59977 1934
e33e7e78 1935 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2ec85268 1936 setContextToObject (theIObj);
2195ab96 1937 if (theIObj->Type() != AIS_KOI_Shape)
1938 {
1939 return;
1940 }
1941 if (theIObj->Signature() != 0)
1942 {
1943 return;
1944 }
1945 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1946 aShape->SetHLRAngleAndDeviation (theAngle);
1947 redisplayPrsModes (theIObj, theToUpdateViewer);
7fd59977 1948}
1949
1950//=======================================================================
1951//function : SetHLRDeviationAngle
2195ab96 1952//purpose :
7fd59977 1953//=======================================================================
2195ab96 1954void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
1955 const Standard_Real theAngle,
1956 const Standard_Boolean theToUpdateViewer)
7fd59977 1957{
2195ab96 1958 if (theIObj.IsNull())
1959 {
1960 return;
1961 }
7fd59977 1962
2195ab96 1963 // To be modified after the related methods of AIS_Shape are passed to InteractiveObject
2ec85268 1964 setContextToObject (theIObj);
2195ab96 1965 if (theIObj->Type() != AIS_KOI_Shape)
1966 {
1967 return;
1968 }
1969 if (theIObj->Signature() != 0)
1970 {
1971 return;
1972 }
1973 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj);
1974 aShape->SetOwnHLRDeviationAngle (theAngle);
1975 redisplayPrsModes (theIObj, theToUpdateViewer);
7fd59977 1976}
1977
1978//=======================================================================
1979//function : UnsetColor
2195ab96 1980//purpose :
7fd59977 1981//=======================================================================
2195ab96 1982void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj,
1983 const Standard_Boolean theToUpdateViewer)
7fd59977 1984{
2195ab96 1985 if (theIObj.IsNull())
1986 {
1987 return;
1988 }
1989
1990 theIObj->UnsetColor();
1991 redisplayPrsRecModes (theIObj, theToUpdateViewer);
7fd59977 1992}
1993
1994//=======================================================================
1995//function : HasColor
2195ab96 1996//purpose :
7fd59977 1997//=======================================================================
2195ab96 1998Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const
7fd59977 1999{
2195ab96 2000 return theIObj->HasColor();
7fd59977 2001}
2002
2195ab96 2003//=======================================================================
2004//function : Color
2005//purpose :
2006//=======================================================================
2007void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj,
2008 Quantity_Color& theColor) const
7fd59977 2009{
2195ab96 2010 theIObj->Color (theColor);
7fd59977 2011}
7fd59977 2012
2013//=======================================================================
2014//function : Width
2195ab96 2015//purpose :
7fd59977 2016//=======================================================================
2195ab96 2017Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const
7fd59977 2018{
2195ab96 2019 return theIObj->Width();
7fd59977 2020}
2021
2022//=======================================================================
2023//function : SetWidth
2195ab96 2024//purpose :
7fd59977 2025//=======================================================================
2195ab96 2026void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2027 const Standard_Real theWidth,
2028 const Standard_Boolean theToUpdateViewer)
7fd59977 2029{
2195ab96 2030 if (theIObj.IsNull())
2031 {
2032 return;
2033 }
2034
2ec85268 2035 setContextToObject (theIObj);
2195ab96 2036 theIObj->SetWidth (theWidth);
2037 redisplayPrsRecModes (theIObj, theToUpdateViewer);
8e5fb5ea 2038 if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj))
c3282ec1 2039 {
2040 if (myLastinMain->IsAutoHilight())
2041 {
f838dac4 2042 const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
8e5fb5ea 2043 myLastinMain->HilightWithColor (myMainPM,
f838dac4 2044 myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain),
8e5fb5ea 2045 aHiMode);
c3282ec1 2046 }
2047 else
2048 {
8e5fb5ea 2049 theIObj->HilightOwnerWithColor (myMainPM,
f838dac4 2050 myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain),
8e5fb5ea 2051 myLastinMain);
c3282ec1 2052 }
2053 }
7fd59977 2054}
2055
2056//=======================================================================
2057//function : UnsetWidth
2195ab96 2058//purpose :
7fd59977 2059//=======================================================================
2195ab96 2060void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj,
2061 const Standard_Boolean theToUpdateViewer)
7fd59977 2062{
2195ab96 2063 if (theIObj.IsNull())
2064 {
2065 return;
2066 }
2067
2068 theIObj->UnsetWidth();
2069 redisplayPrsRecModes (theIObj, theToUpdateViewer);
7fd59977 2070}
2071
2072//=======================================================================
2073//function : SetMaterial
2195ab96 2074//purpose :
7fd59977 2075//=======================================================================
2195ab96 2076void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
87432b82 2077 const Graphic3d_MaterialAspect& theMaterial,
2195ab96 2078 const Standard_Boolean theToUpdateViewer)
7fd59977 2079{
2195ab96 2080 if (theIObj.IsNull())
2081 {
2082 return;
2083 }
2084
2ec85268 2085 setContextToObject (theIObj);
87432b82 2086 theIObj->SetMaterial (theMaterial);
2195ab96 2087 redisplayPrsRecModes (theIObj, theToUpdateViewer);
7fd59977 2088}
2089
2090//=======================================================================
2091//function : UnsetMaterial
2195ab96 2092//purpose :
7fd59977 2093//=======================================================================
2195ab96 2094void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj,
2095 const Standard_Boolean theToUpdateViewer)
7fd59977 2096{
2195ab96 2097 if (theIObj.IsNull())
2098 {
2099 return;
2100 }
2101 theIObj->UnsetMaterial();
2102 redisplayPrsRecModes (theIObj, theToUpdateViewer);
7fd59977 2103}
2104
2105//=======================================================================
2106//function : SetTransparency
2195ab96 2107//purpose :
7fd59977 2108//=======================================================================
2195ab96 2109void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2110 const Standard_Real theValue,
2111 const Standard_Boolean theToUpdateViewer)
7fd59977 2112{
2195ab96 2113 if (theIObj.IsNull())
2114 {
2115 return;
2116 }
2117
2ec85268 2118 setContextToObject (theIObj);
2195ab96 2119 if (!theIObj->IsTransparent()
f838dac4 2120 && theValue <= 0.005)
a6964ce6 2121 {
2122 return;
2123 }
2124
f838dac4 2125 if (theValue <= 0.005)
2195ab96 2126 {
2127 UnsetTransparency (theIObj, theToUpdateViewer);
7fd59977 2128 return;
2129 }
a6964ce6 2130
2195ab96 2131 theIObj->SetTransparency (theValue);
2132 redisplayPrsRecModes (theIObj, theToUpdateViewer);
7fd59977 2133}
2134
2135//=======================================================================
2136//function : UnsetTransparency
2195ab96 2137//purpose :
7fd59977 2138//=======================================================================
2195ab96 2139void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj,
2140 const Standard_Boolean theToUpdateViewer)
7fd59977 2141{
2195ab96 2142 if (theIObj.IsNull())
2143 {
2144 return;
2145 }
7fd59977 2146
2195ab96 2147 theIObj->UnsetTransparency();
2148 redisplayPrsRecModes (theIObj, theToUpdateViewer);
7fd59977 2149}
2150
2195ab96 2151//=======================================================================
2152//function : SetSelectedAspect
2153//purpose :
2154//=======================================================================
2155void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
2195ab96 2156 const Standard_Boolean theToUpdateViewer)
2157{
2158 if (HasOpenedContext())
2159 {
2160 return;
2161 }
2162
2163 Standard_Boolean isFound = Standard_False;
02974a19 2164 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
2195ab96 2165 {
2166 isFound = Standard_True;
02974a19 2167 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
2831708b 2168 anObj->SetAspect (theAspect);
2195ab96 2169 }
2170
016e5959 2171 if (isFound && theToUpdateViewer)
2195ab96 2172 {
2173 myMainVwr->Update();
7fd59977 2174 }
2175}
7fd59977 2176
2177//=======================================================================
2178//function : SetLocalAttributes
2195ab96 2179//purpose :
7fd59977 2180//=======================================================================
2195ab96 2181void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
6262338c 2182 const Handle(Prs3d_Drawer)& theDrawer,
2195ab96 2183 const Standard_Boolean theToUpdateViewer)
7fd59977 2184{
2195ab96 2185 if (theIObj.IsNull())
2186 {
2187 return;
2188 }
2189
2ec85268 2190 setContextToObject (theIObj);
2195ab96 2191 theIObj->SetAttributes (theDrawer);
2192 Update (theIObj, theToUpdateViewer);
7fd59977 2193}
2194
2195//=======================================================================
2196//function : UnsetLocalAttributes
2195ab96 2197//purpose :
7fd59977 2198//=======================================================================
2195ab96 2199void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj,
2200 const Standard_Boolean theToUpdateViewer)
7fd59977 2201{
2195ab96 2202 if (theIObj.IsNull())
2203 {
2204 return;
2205 }
7fd59977 2206
2ec85268 2207 setContextToObject (theIObj);
2195ab96 2208 theIObj->UnsetAttributes();
2209 Update (theIObj, theToUpdateViewer);
2210}
7fd59977 2211
2212//=======================================================================
2213//function : Status
2195ab96 2214//purpose :
7fd59977 2215//=======================================================================
2195ab96 2216void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj,
2217 TCollection_ExtendedString& theStatus) const
7fd59977 2218{
2195ab96 2219 theStatus = "";
2220 if (theIObj.IsNull()
2221 || !myObjects.IsBound (theIObj))
2222 {
2223 return;
2224 }
7fd59977 2225
2195ab96 2226 theStatus += "\t ____________________________________________";
2227 theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
2228 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
2229 switch (aStatus->GraphicStatus())
2230 {
7fd59977 2231 case AIS_DS_Displayed:
2195ab96 2232 {
2233 theStatus += "\t| -->Displayed\n";
7fd59977 2234 break;
2235 }
2195ab96 2236 case AIS_DS_Erased:
2237 {
2238 theStatus += "\t| -->Erased\n";
2239 break;
7fd59977 2240 }
2195ab96 2241 default:
2242 break;
2243 }
2244
2245 theStatus += "\t| Active Display Modes in the MainViewer :\n";
3db69e41 2246 theStatus += "\t|\t Mode ";
2247 theStatus += TCollection_AsciiString (aStatus->DisplayMode());
2248 theStatus += "\n";
2249
2195ab96 2250 if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
7fd59977 2251
2195ab96 2252 theStatus += "\t| Active Selection Modes in the MainViewer :\n";
2253 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2254 {
2255 theStatus += "\t\t Mode ";
2256 theStatus += TCollection_AsciiString (aSelModeIter.Value());
2257 theStatus += "\n";
2258 }
2259 theStatus += "\t ____________________________________________";
2260}
7fd59977 2261
2262//=======================================================================
2263//function : GetDefModes
2195ab96 2264//purpose :
7fd59977 2265//=======================================================================
2195ab96 2266void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj,
2267 Standard_Integer& theDispMode,
2268 Standard_Integer& theHiMode,
2269 Standard_Integer& theSelMode) const
7fd59977 2270{
2195ab96 2271 if (theIObj.IsNull())
2272 {
2273 return;
2274 }
7fd59977 2275
2195ab96 2276 theDispMode = theIObj->HasDisplayMode()
2277 ? theIObj->DisplayMode()
f838dac4 2278 : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode())
2279 ? myDefaultDrawer->DisplayMode()
2195ab96 2280 : 0);
2281 theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
c3282ec1 2282 theSelMode = theIObj->GlobalSelectionMode();
2195ab96 2283}
7fd59977 2284
2285//=======================================================================
2286//function : EraseGlobal
2195ab96 2287//purpose :
7fd59977 2288//=======================================================================
2195ab96 2289void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2290 const Standard_Boolean theToUpdateviewer)
7fd59977 2291{
2195ab96 2292 if (theIObj.IsNull()
2293 || !myObjects.IsBound (theIObj))
2294 {
2295 return;
2296 }
7fd59977 2297
2195ab96 2298 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
2299
a1954302 2300 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2301 if (aStatus->GraphicStatus() == AIS_DS_Temporary
2302 || aStatus->GraphicStatus() == AIS_DS_Erased)
2195ab96 2303 {
a1954302 2304 return;
2305 }
2195ab96 2306
3db69e41 2307 if (aStatus->IsHilighted())
a1954302 2308 {
404c8936 2309 Standard_DISABLE_DEPRECATION_WARNINGS
3db69e41 2310 if (IsCurrent (theIObj))
2195ab96 2311 {
3db69e41 2312 AddOrRemoveCurrentObject (theIObj, Standard_False);
2313 }
2314 else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode()))
2315 {
f838dac4 2316 unhighlightGlobal (theIObj);
2195ab96 2317 }
404c8936 2318 Standard_ENABLE_DEPRECATION_WARNINGS
a1954302 2319 }
2195ab96 2320
3db69e41 2321 myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
2322
4f51d9d7 2323 if (aStatus->IsHilighted()
2324 && theIObj->HasHilightMode())
2325 {
f838dac4 2326 unhighlightGlobal (theIObj);
4f51d9d7 2327 }
2328
2329 if (!myLastPicked.IsNull()
8e5fb5ea 2330 && myLastPicked->IsSameSelectable (theIObj))
4f51d9d7 2331 {
731c9b5b 2332 clearDynamicHighlight();
4f51d9d7 2333 }
2334
905b0e31 2335 // make sure highlighting presentations are properly erased
2336 theIObj->ErasePresentations (false);
2337
c3282ec1 2338 if (IsSelected (theIObj)
3db69e41 2339 && aStatus->DisplayMode() != aDispMode)
a1954302 2340 {
2341 myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
2342 }
2343
2344 for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next())
2345 {
2346 mgrSelector->Deactivate (theIObj, aSelModeIter.Value(), myMainSel);
7fd59977 2347 }
c3282ec1 2348 aStatus->ClearSelectionModes();
2195ab96 2349 aStatus->SetGraphicStatus (AIS_DS_Erased);
a1954302 2350
2351 if (theToUpdateviewer)
2352 {
2353 myMainVwr->Update();
2354 }
7fd59977 2355}
2356
c3282ec1 2357//=======================================================================
2358//function : unhighlightOwners
2359//purpose :
2360//=======================================================================
2361void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject)
2362{
02974a19 2363 SelectMgr_SequenceOfOwner aSeq;
2364 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
c3282ec1 2365 {
a3d4053c 2366 if (aSelIter.Value()->IsSameSelectable (theObject))
c3282ec1 2367 {
02974a19 2368 aSeq.Append (aSelIter.Value());
c3282ec1 2369 }
02974a19 2370 }
2371 for (SelectMgr_SequenceOfOwner::Iterator aDelIter (aSeq); aDelIter.More(); aDelIter.Next())
2372 {
2373 AddOrRemoveSelected (aDelIter.Value(), Standard_False);
c3282ec1 2374 }
2375}
2376
7fd59977 2377//=======================================================================
2378//function : ClearGlobal
2195ab96 2379//purpose :
7fd59977 2380//=======================================================================
2195ab96 2381void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj,
2382 const Standard_Boolean theToUpdateviewer)
7fd59977 2383{
2195ab96 2384 if (theIObj.IsNull()
2385 || !myObjects.IsBound (theIObj))
2386 {
f751596e 2387 // for cases when reference shape of connected interactives was not displayed
2388 // but its selection primitives were calculated
543a9964 2389 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
2390 mgrSelector->Remove (anObj);
2195ab96 2391 return;
2392 }
2393
2394 Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
c3282ec1 2395 unhighlightOwners (theIObj);
7fd59977 2396
e2d7642f 2397 myMainPM->Erase (theIObj, -1);
905b0e31 2398 theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased
4f51d9d7 2399
2195ab96 2400 // Object removes from Detected sequence
404c8936 2401 Standard_DISABLE_DEPRECATION_WARNINGS
f2a88e54 2402 for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();)
7fd59977 2403 {
f2a88e54 2404 Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter));
2405 Handle(AIS_InteractiveObject) anObj;
2406 if (!aPicked.IsNull())
2407 {
2408 anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable());
2409 }
2410
2195ab96 2411 if (!anObj.IsNull()
f2a88e54 2412 && anObj == theIObj)
2195ab96 2413 {
f0cddd16 2414 myDetectedSeq.Remove (aDetIter);
f2a88e54 2415 if (myCurDetected == aDetIter)
2416 {
2417 myCurDetected = Min (myDetectedSeq.Upper(), aDetIter);
2418 }
2419 if (myCurHighlighted == aDetIter)
2420 {
2421 myCurHighlighted = 0;
2422 }
2423 }
2424 else
2425 {
2426 aDetIter++;
2195ab96 2427 }
7fd59977 2428 }
404c8936 2429 Standard_ENABLE_DEPRECATION_WARNINGS
7fd59977 2430
2195ab96 2431 // remove IO from the selection manager to avoid memory leaks
543a9964 2432 const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity
2433 mgrSelector->Remove (anObj);
7fd59977 2434
2195ab96 2435 myObjects.UnBind (theIObj);
c357e426 2436 myMainVwr->StructureManager()->UnregisterObject (theIObj);
6a24c6de 2437
2438 for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next())
a272ed94 2439 {
6a24c6de 2440 aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
a272ed94 2441 }
7fd59977 2442
1beb58d7 2443 if (!myLastinMain.IsNull())
2444 {
2445 if (myLastinMain->IsSameSelectable (theIObj)
2446 || myLastPicked->IsSameSelectable(theIObj))
2447 {
731c9b5b 2448 clearDynamicHighlight();
1beb58d7 2449 myLastinMain.Nullify();
f2a88e54 2450 myLastPicked.Nullify();
1beb58d7 2451 }
2452 }
c3282ec1 2453
2454 if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed)
eb4320f2 2455 {
2456 myMainVwr->Update();
2457 }
7fd59977 2458}
2459
2460//=======================================================================
2461//function : ClearGlobalPrs
2195ab96 2462//purpose :
7fd59977 2463//=======================================================================
2195ab96 2464void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj,
2465 const Standard_Integer theMode,
2466 const Standard_Boolean theToUpdateViewer)
7fd59977 2467{
2195ab96 2468 if (theIObj.IsNull()
2469 || !myObjects.IsBound (theIObj))
2470 {
2471 return;
2472 }
2473
2474 const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
3db69e41 2475 if (aStatus->DisplayMode() == theMode)
2195ab96 2476 {
2477 const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
2478 if (aDispMode == theMode
2479 && myMainPM->IsHighlighted (theIObj, theMode))
2480 {
f838dac4 2481 unhighlightGlobal (theIObj);
2195ab96 2482 }
2483
2484 myMainPM->Erase (theIObj, theMode);
7fd59977 2485 }
eb4320f2 2486
2195ab96 2487 if (aStatus->GraphicStatus() == AIS_DS_Displayed
2488 && theToUpdateViewer)
2489 {
7fd59977 2490 myMainVwr->Update();
2195ab96 2491 }
7fd59977 2492}
2493
8a590580 2494//=======================================================================
2495//function : ClearDetected
2496//purpose :
2497//=======================================================================
2498Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRedrawImmediate)
2499{
2500 myCurDetected = 0;
2501 myCurHighlighted = 0;
2502 myDetectedSeq.Clear();
2503 myLastPicked = myLastinMain;
2504 myWasLastMain = Standard_True;
2505 Standard_Boolean toUpdate = Standard_False;
2506 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
2507 {
2508 toUpdate = Standard_True;
2509 clearDynamicHighlight();
2510 }
2511 myLastinMain.Nullify();
2512 myLastPicked.Nullify();
2513 myMainSel->ClearPicked();
2514 if (toUpdate && theToRedrawImmediate)
2515 {
2516 myMainVwr->RedrawImmediate();
2517 }
2518 return toUpdate;
2519}
2520
7fd59977 2521//=======================================================================
2522//function : DrawHiddenLine
2195ab96 2523//purpose :
7fd59977 2524//=======================================================================
2195ab96 2525Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const
2526{
7fd59977 2527 return myDefaultDrawer->DrawHiddenLine();
2528}
2529
2530//=======================================================================
2531//function : EnableDrawHiddenLine
2195ab96 2532//purpose :
7fd59977 2533//=======================================================================
2195ab96 2534void AIS_InteractiveContext::EnableDrawHiddenLine() const
2535{
7fd59977 2536 myDefaultDrawer->EnableDrawHiddenLine();
2537}
2538
2539//=======================================================================
2540//function : DisableDrawHiddenLine
2195ab96 2541//purpose :
7fd59977 2542//=======================================================================
2195ab96 2543void AIS_InteractiveContext::DisableDrawHiddenLine() const
2544{
7fd59977 2545 myDefaultDrawer->DisableDrawHiddenLine();
2546}
2547
2548//=======================================================================
2549//function : HiddenLineAspect
2195ab96 2550//purpose :
7fd59977 2551//=======================================================================
2195ab96 2552Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const
2553{
7fd59977 2554 return myDefaultDrawer->HiddenLineAspect();
2555}
2556
2557//=======================================================================
2558//function : SetHiddenLineAspect
2195ab96 2559//purpose :
7fd59977 2560//=======================================================================
2195ab96 2561void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const
2562{
2563 myDefaultDrawer->SetHiddenLineAspect (theAspect);
7fd59977 2564}
2565
2566//=======================================================================
2567//function : SetIsoNumber
2195ab96 2568//purpose :
7fd59977 2569//=======================================================================
2195ab96 2570void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb,
2571 const AIS_TypeOfIso theType)
7fd59977 2572{
2195ab96 2573 switch (theType)
2574 {
2575 case AIS_TOI_IsoU:
2576 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2577 break;
2578 case AIS_TOI_IsoV:
2579 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2580 break;
2581 case AIS_TOI_Both:
2582 myDefaultDrawer->UIsoAspect()->SetNumber (theNb);
2583 myDefaultDrawer->VIsoAspect()->SetNumber (theNb);
2584 break;
7fd59977 2585 }
2586}
2195ab96 2587
7fd59977 2588//=======================================================================
2589//function : IsoNumber
2195ab96 2590//purpose :
7fd59977 2591//=======================================================================
2195ab96 2592Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType)
7fd59977 2593{
2195ab96 2594 switch (theType)
2595 {
2596 case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number();
2597 case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number();
2598 case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
2599 ? myDefaultDrawer->UIsoAspect()->Number()
2600 : -1;
7fd59977 2601 }
2602 return 0;
2603}
2604
2605//=======================================================================
2606//function : IsoOnPlane
2195ab96 2607//purpose :
7fd59977 2608//=======================================================================
2195ab96 2609void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn)
7fd59977 2610{
2195ab96 2611 myDefaultDrawer->SetIsoOnPlane (theToSwitchOn);
7fd59977 2612}
2613
2614//=======================================================================
2615//function : IsoOnPlane
2195ab96 2616//purpose :
7fd59977 2617//=======================================================================
2195ab96 2618Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
7fd59977 2619{
2620 return myDefaultDrawer->IsoOnPlane();
2621}
2622
3c982548 2623//=======================================================================
5ad8c033 2624//function : IsoOnTriangulation
2625//purpose :
2626//=======================================================================
2627void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theToSwitchOn)
2628{
2629 myDefaultDrawer->SetIsoOnTriangulation (theToSwitchOn);
2630}
2631
2632//=======================================================================
2633//function : IsoOnTriangulation
2634//purpose :
2635//=======================================================================
2636Standard_Boolean AIS_InteractiveContext::IsoOnTriangulation() const
2637{
2638 return myDefaultDrawer->IsoOnTriangulation();
2639}
2640
51004f1c 2641//=======================================================================
3c982548 2642//function : SetPixelTolerance
51004f1c 2643//purpose :
3c982548 2644//=======================================================================
3bf9a45f 2645void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
2195ab96 2646{
2647 if (HasOpenedContext())
2648 {
2649 myLocalContexts (myCurLocalIndex)->SetPixelTolerance (thePrecision);
2650 }
2651 else
2652 {
2653 myMainSel->SetPixelTolerance (thePrecision);
7fd59977 2654 }
2655}
3c982548 2656
2657//=======================================================================
2658//function : PixelTolerance
2195ab96 2659//purpose :
3c982548 2660//=======================================================================
3bf9a45f 2661Standard_Integer AIS_InteractiveContext::PixelTolerance() const
2195ab96 2662{
2663 return HasOpenedContext()
2664 ? myLocalContexts (myCurLocalIndex)->PixelTolerance()
2665 : myMainSel->PixelTolerance();
3c982548 2666}
7fd59977 2667
8a1170ad 2668//=======================================================================
2669//function : SetSelectionSensitivity
2670//purpose : Allows to manage sensitivity of a particular selection of interactive object theObject
2671//=======================================================================
2672void AIS_InteractiveContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject,
2673 const Standard_Integer theMode,
2674 const Standard_Integer theNewSensitivity)
2675{
2676 if (HasOpenedContext())
2677 {
2678 myLocalContexts (myCurLocalIndex)->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
2679 return;
2680 }
2681
2682 mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity);
2683}
2684
7fd59977 2685//=======================================================================
2686//function : IsInLocal
2195ab96 2687//purpose :
7fd59977 2688//=======================================================================
2195ab96 2689Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_InteractiveObject)& theIObj,
2690 Standard_Integer& theIndex) const
7fd59977 2691{
2195ab96 2692 if (theIObj.IsNull())
2693 {
2694 return Standard_False;
2695 }
2696
81bba717 2697 // if it exists at neutral point 0 index is returned
2195ab96 2698 if (myObjects.IsBound (theIObj))
2699 {
2700 theIndex = 0;
7fd59977 2701 return Standard_False;
2702 }
2195ab96 2703
2704 for (Standard_Integer aCtxIter = 1; aCtxIter <= myLocalContexts.Extent(); ++aCtxIter)
2705 {
2706 if (myLocalContexts.IsBound (aCtxIter))
2707 {
2708 if(myLocalContexts (aCtxIter)->IsIn (theIObj))
2709 {
2710 theIndex = aCtxIter;
7fd59977 2711 return Standard_True;
7fd59977 2712 }
2713 }
2714 }
2195ab96 2715 theIndex = -1;
7fd59977 2716 return Standard_False;
2195ab96 2717}
2718
7fd59977 2719//=======================================================================
2720//function : InitAttributes
2195ab96 2721//purpose :
7fd59977 2722//=======================================================================
7fd59977 2723void AIS_InteractiveContext::InitAttributes()
2724{
7fd59977 2725
2195ab96 2726 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
2727 myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
7fd59977 2728
2729// myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
2195ab96 2730 Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect();
2731 aLineAspect->SetColor (Quantity_NOC_GRAY20);
2732 aLineAspect->SetWidth (1.0);
2733 aLineAspect->SetTypeOfLine (Aspect_TOL_DASH);
7fd59977 2734
28ee613b 2735 // tolerance to 2 pixels...
3bf9a45f 2736 SetPixelTolerance (2);
7fd59977 2737
2738 // Customizing the drawer for trihedrons and planes...
2195ab96 2739 Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect();
2740 const Standard_Real aLength = 100.0;
2741 aTrihAspect->SetAxisLength (aLength, aLength, aLength);
87432b82 2742 const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4;
bc001a40 2743 aTrihAspect->LineAspect(Prs3d_DP_XAxis)->SetColor (aColor);
2744 aTrihAspect->LineAspect(Prs3d_DP_YAxis)->SetColor (aColor);
2745 aTrihAspect->LineAspect(Prs3d_DP_ZAxis)->SetColor (aColor);
7fd59977 2746
2195ab96 2747 Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect();
2748 const Standard_Real aPlaneLength = 200.0;
2749 aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength);
2750 aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE);
7fd59977 2751}
2752
7fd59977 2753//=======================================================================
2754//function : TrihedronSize
2195ab96 2755//purpose :
7fd59977 2756//=======================================================================
2757Standard_Real AIS_InteractiveContext::TrihedronSize() const
2758{
bc001a40 2759 return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis);
7fd59977 2760}
2195ab96 2761
7fd59977 2762//=======================================================================
2763//function : SetTrihedronSize
2195ab96 2764//purpose :
7fd59977 2765//=======================================================================
2195ab96 2766void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal,
2767 const Standard_Boolean /*updateviewer*/)
7fd59977 2768{
2195ab96 2769 myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal);
2770 Redisplay (AIS_KOI_Datum, 3, Standard_False);
2771 Redisplay (AIS_KOI_Datum, 4, Standard_True);
7fd59977 2772}
2773
7fd59977 2774//=======================================================================
2775//function : SetPlaneSize
2195ab96 2776//purpose :
7fd59977 2777//=======================================================================
2195ab96 2778void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX,
2779 const Standard_Real theValY,
0577ae8c 2780 const Standard_Boolean theToUpdateViewer)
7fd59977 2781{
2195ab96 2782 myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY);
0577ae8c 2783 Redisplay (AIS_KOI_Datum, 7, theToUpdateViewer);
7fd59977 2784}
2785
2786//=======================================================================
2787//function : SetPlaneSize
2195ab96 2788//purpose :
7fd59977 2789//=======================================================================
2195ab96 2790void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal,
2791 const Standard_Boolean theToUpdateViewer)
7fd59977 2792{
2195ab96 2793 SetPlaneSize (theVal, theVal, theToUpdateViewer);
7fd59977 2794}
2795
2796//=======================================================================
2797//function : PlaneSize
2195ab96 2798//purpose :
7fd59977 2799//=======================================================================
2195ab96 2800Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX,
2801 Standard_Real& theY) const
7fd59977 2802{
2195ab96 2803 theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
2804 theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
2805 return (Abs (theX - theY) <= Precision::Confusion());
7fd59977 2806}
2807
59f45b7c 2808//=======================================================================
2809//function : SetZLayer
2195ab96 2810//purpose :
59f45b7c 2811//=======================================================================
59f45b7c 2812void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
8f138407 2813 const Graphic3d_ZLayerId theLayerId)
59f45b7c 2814{
2195ab96 2815 if (theIObj.IsNull())
59f45b7c 2816 return;
2817
a1954302 2818 theIObj->SetZLayer (theLayerId);
59f45b7c 2819}
2820
2821//=======================================================================
2822//function : GetZLayer
2195ab96 2823//purpose :
59f45b7c 2824//=======================================================================
8f138407 2825Graphic3d_ZLayerId AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
59f45b7c 2826{
a1954302 2827 return !theIObj.IsNull()
2828 ? theIObj->ZLayer()
2829 : Graphic3d_ZLayerId_UNKNOWN;
59f45b7c 2830}
f751596e 2831
2832//=======================================================================
2833//function : RebuildSelectionStructs
2834//purpose : Rebuilds 1st level of BVH selection forcibly
2835//=======================================================================
2836void AIS_InteractiveContext::RebuildSelectionStructs()
2837{
2838 myMainSel->RebuildObjectsTree (Standard_True);
2839}
2840
2841//=======================================================================
2842//function : Disconnect
2843//purpose : Disconnects selectable object from an assembly and updates selection structures
2844//=======================================================================
2845void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly,
2846 const Handle(AIS_InteractiveObject)& theObjToDisconnect)
2847{
2848 if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive"))
2849 {
c5f3a425 2850 Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly));
f751596e 2851 theObj->Disconnect (theObjToDisconnect);
543a9964 2852 const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity
2853 mgrSelector->Remove (anObj);
f751596e 2854 }
c04c30b3 2855 else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull())
f751596e 2856 {
c5f3a425 2857 Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly));
f751596e 2858 theObj->Disconnect();
543a9964 2859 const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity
2860 mgrSelector->Remove (anObj);
f751596e 2861 }
2862 else
2863 return;
2864}
b586500b 2865
0577ae8c 2866//=======================================================================
2867//function : FitSelected
2868//purpose : Fits the view corresponding to the bounds of selected objects
2869//=======================================================================
2870void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
2871{
2872 FitSelected (theView, 0.01, Standard_True);
2873}
2874
b586500b 2875//=======================================================================
2876//function : FitSelected
2877//purpose : Fits the view corresponding to the bounds of selected objects
2878//=======================================================================
2879void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
2880 const Standard_Real theMargin,
2881 const Standard_Boolean theToUpdate)
2882{
b5cce1ab 2883 const Handle(AIS_Selection)& aSelection = HasOpenedContext()
2884 ? myLocalContexts(myCurLocalIndex)->Selection()
2885 : mySelection;
b586500b 2886 Bnd_Box aBndSelected;
b586500b 2887 AIS_MapOfObjectOwners anObjectOwnerMap;
b5cce1ab 2888 for (AIS_NListOfEntityOwner::Iterator aSelIter (aSelection->Objects()); aSelIter.More(); aSelIter.Next())
b586500b 2889 {
b5cce1ab 2890 const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
02974a19 2891 Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
2892 if (anObj->IsInfinite())
b586500b 2893 {
02974a19 2894 continue;
2895 }
b586500b 2896
02974a19 2897 if (anOwner == anObj->GlobalSelOwner())
2898 {
b586500b 2899 Bnd_Box aTmpBnd;
2900 anObj->BoundingBox (aTmpBnd);
2901 aBndSelected.Add (aTmpBnd);
2902 }
2903 else
2904 {
b586500b 2905 Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap;
2906 if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap))
2907 {
2908 anOwnerMap = new SelectMgr_IndexedMapOfOwner();
2909 anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap);
2910 }
2911
2912 anOwnerMap->Add (anOwner);
2913 }
2914 }
2915
2916 for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next())
2917 {
2918 const Handle(SelectMgr_SelectableObject) anObject = anIter.Key();
2919 Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue());
2920 aBndSelected.Add (aTmpBox);
2921 }
2922
2923 anObjectOwnerMap.Clear();
2924
2925 if (aBndSelected.IsVoid())
2926 return;
2927
2928 theView->FitAll (aBndSelected, theMargin, theToUpdate);
2929}
1d92133e 2930
2931//=======================================================================
2932//function : SetTransformPersistence
2933//purpose :
2934//=======================================================================
2935void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
778cd667 2936 const Handle(Graphic3d_TransformPers)& theTrsfPers)
1d92133e 2937{
778cd667 2938 theObject->SetTransformPersistence (theTrsfPers);
1d92133e 2939 if (!myObjects.IsBound (theObject))
2940 {
2941 return;
2942 }
2943
2944 mgrSelector->UpdateSelection (theObject);
2945
2946 const Standard_Integer aLayerId = myObjects.Find (theObject)->GetLayerIndex();
2947 const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
6a24c6de 2948 for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
1d92133e 2949 {
6a24c6de 2950 anActiveViewIter.Value()->View()->InvalidateBVHData (aLayerId);
2951 anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId);
1d92133e 2952 }
2953}