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