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