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