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