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