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