0030824: Visualization, PrsMgr_PresentableObject - A new flag to disable automatic...
[occt.git] / src / PrsMgr / PrsMgr_PresentationManager.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <PrsMgr_PresentationManager.hxx>
16
17 #include <Geom_Transformation.hxx>
18 #include <Graphic3d_GraphicDriver.hxx>
19 #include <Prs3d_Drawer.hxx>
20 #include <Prs3d_Presentation.hxx>
21 #include <Prs3d_PresentationShadow.hxx>
22 #include <PrsMgr_PresentableObject.hxx>
23 #include <PrsMgr_Presentation.hxx>
24 #include <PrsMgr_Presentations.hxx>
25 #include <Standard_NoSuchObject.hxx>
26 #include <Standard_Type.hxx>
27 #include <TColStd_ListIteratorOfListOfTransient.hxx>
28 #include <V3d_View.hxx>
29
30 IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient)
31
32 // =======================================================================
33 // function : PrsMgr_PresentationManager
34 // purpose  :
35 // =======================================================================
36 PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager)
37 : myStructureManager (theStructureManager),
38   myImmediateModeOn  (0)
39 {
40   //
41 }
42
43 // =======================================================================
44 // function : Display
45 // purpose  :
46 // =======================================================================
47 void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj,
48                                           const Standard_Integer                  theMode)
49 {
50   if (thePrsObj->HasOwnPresentations())
51   {
52     Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True);
53     if (aPrs->MustBeUpdated())
54     {
55       Update (thePrsObj, theMode);
56     }
57
58     if (myImmediateModeOn > 0)
59     {
60       AddToImmediateList (aPrs);
61     }
62     else
63     {
64       aPrs->Display();
65     }
66   }
67   else
68   {
69     thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode);
70   }
71
72   if (thePrsObj->ToPropagateVisualState())
73   {
74     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
75     {
76       Display(anIter.Value(), theMode);
77     }
78   }
79 }
80
81 // =======================================================================
82 // function : Erase
83 // purpose  :
84 // =======================================================================
85 void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj,
86                                         const Standard_Integer                  theMode)
87 {
88   if (thePrsObj->ToPropagateVisualState())
89   {
90     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
91     {
92       Erase(anIter.Value(), theMode);
93     }
94   }
95
96   PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
97   for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More();)
98   {
99     const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
100     if (aPrs.IsNull())
101     {
102       aPrsIter.Next();
103       continue;
104     }
105
106     const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
107     if ((theMode == aPrs->Mode() || theMode == -1)
108      && (this == aPrsMgr))
109     {
110       aPrs->Erase();
111
112       aPrsList.Remove (aPrsIter);
113
114       if (theMode != -1)
115       {
116         return;
117       }
118     }
119     else
120     {
121       aPrsIter.Next();
122     }
123   }
124 }
125
126 // =======================================================================
127 // function : Clear
128 // purpose  :
129 // =======================================================================
130 void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
131                                         const Standard_Integer                  theMode)
132 {
133   if (thePrsObj->ToPropagateVisualState())
134   {
135     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
136     {
137       Clear(anIter.Value(), theMode);
138     }
139   }
140
141   const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
142   if (!aPrs.IsNull())
143   {
144     aPrs->Clear();
145   }
146 }
147
148 // =======================================================================
149 // function : SetVisibility
150 // purpose  :
151 // =======================================================================
152 void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObj,
153                                                 const Standard_Integer theMode,
154                                                 const Standard_Boolean theValue)
155 {
156   if (thePrsObj->ToPropagateVisualState())
157   {
158     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
159     {
160       SetVisibility(anIter.Value(), theMode, theValue);
161     }
162   }
163   if (!thePrsObj->HasOwnPresentations())
164   {
165     return;
166   }
167
168   Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
169   if (!aPrs.IsNull())
170   {
171     aPrs->SetVisible (theValue);
172   }
173 }
174
175 // =======================================================================
176 // function : Unhighlight
177 // purpose  :
178 // =======================================================================
179 void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj)
180 {
181   if (thePrsObj->ToPropagateVisualState())
182   {
183     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
184     {
185       Unhighlight(anIter.Value());
186     }
187   }
188
189   const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
190   for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
191   {
192     const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
193     const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
194     if (this == aPrsMgr
195     &&  aPrs->IsHighlighted())
196     {
197       aPrs->Unhighlight();
198     }
199   }
200 }
201
202 // =======================================================================
203 // function : SetDisplayPriority
204 // purpose  :
205 // =======================================================================
206 void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
207                                                      const Standard_Integer                  theMode,
208                                                      const Standard_Integer                  theNewPrior) const
209 {
210   if (thePrsObj->ToPropagateVisualState())
211   {
212     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
213     {
214       SetDisplayPriority(anIter.Value(), theMode, theNewPrior);
215     }
216   }
217
218   const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
219   if (!aPrs.IsNull())
220   {
221     aPrs->SetDisplayPriority (theNewPrior);
222   }
223 }
224
225 // =======================================================================
226 // function : DisplayPriority
227 // purpose  :
228 // =======================================================================
229 Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
230                                                               const Standard_Integer                  theMode) const
231 {
232   if (thePrsObj->ToPropagateVisualState())
233   {
234     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
235     {
236       Standard_Integer aPriority = DisplayPriority(anIter.Value(), theMode);
237       if (aPriority != 0)
238       {
239         return aPriority;
240       }
241     }
242   }
243
244   const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
245   return !aPrs.IsNull()
246         ? aPrs->DisplayPriority()
247         : 0;
248 }
249
250 // =======================================================================
251 // function : IsDisplayed
252 // purpose  :
253 // =======================================================================
254 Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
255                                                           const Standard_Integer                  theMode) const
256 {
257   if (thePrsObj->ToPropagateVisualState())
258   {
259     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
260     {
261       if (IsDisplayed(anIter.Value(), theMode))
262       {
263         return Standard_True;
264       }
265     }
266   }
267
268   const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
269   return !aPrs.IsNull()
270        && aPrs->IsDisplayed();
271 }
272
273 // =======================================================================
274 // function : IsHighlighted
275 // purpose  :
276 // =======================================================================
277 Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj,
278                                                             const Standard_Integer                  theMode) const
279 {
280   if (thePrsObj->ToPropagateVisualState())
281   {
282     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
283     {
284       if (IsHighlighted(anIter.Value(), theMode))
285       {
286         return Standard_True;
287       }
288     }
289   }
290
291   const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
292   return !aPrs.IsNull()
293        && aPrs->IsHighlighted();
294 }
295
296 // =======================================================================
297 // function : Update
298 // purpose  :
299 // =======================================================================
300 void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj,
301                                          const Standard_Integer                  theMode) const
302 {
303   for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
304   {
305     Update (anIter.Value(), theMode);
306   }
307
308   Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
309   if (!aPrs.IsNull())
310   {
311     aPrs->Clear();
312     thePrsObj->Fill (this, aPrs, theMode);
313     aPrs->SetUpdateStatus (Standard_False);
314   }
315 }
316
317 // =======================================================================
318 // function : BeginImmediateDraw
319 // purpose  :
320 // =======================================================================
321 void PrsMgr_PresentationManager::BeginImmediateDraw()
322 {
323   if (++myImmediateModeOn > 1)
324   {
325     return;
326   }
327
328   ClearImmediateDraw();
329 }
330
331 // =======================================================================
332 // function : ClearImmediateDraw
333 // purpose  :
334 // =======================================================================
335 void PrsMgr_PresentationManager::ClearImmediateDraw()
336 {
337   for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
338   {
339     anIter.Value()->Erase();
340   }
341
342   for (PrsMgr_ListOfPresentations::Iterator anIter (myViewDependentImmediateList); anIter.More(); anIter.Next())
343   {
344     anIter.Value()->Erase();
345   }
346
347   myImmediateList.Clear();
348   myViewDependentImmediateList.Clear();
349 }
350
351 // =======================================================================
352 // function : displayImmediate
353 // purpose  : Handles the structures from myImmediateList and its visibility
354 //            in all views of the viewer given by setting proper affinity
355 // =======================================================================
356 void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& theViewer)
357 {
358   for (V3d_ListOfViewIterator anActiveViewIter (theViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
359   {
360     const Handle(Graphic3d_CView)& aView = anActiveViewIter.Value()->View();
361     for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
362     {
363       const Handle(Prs3d_Presentation)& aPrs = anIter.Value();
364       if (aPrs.IsNull())
365         continue;
366
367       Handle(Graphic3d_Structure) aViewDepPrs;
368       Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs);
369       if (!aShadowPrs.IsNull() && aView->IsComputed (aShadowPrs->ParentId(), aViewDepPrs))
370       {
371         aShadowPrs.Nullify();
372         aShadowPrs = new Prs3d_PresentationShadow (myStructureManager, aViewDepPrs);
373         aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer());
374         aShadowPrs->SetClipPlanes (aViewDepPrs->ClipPlanes());
375         aShadowPrs->CStructure()->IsForHighlight = 1;
376         aShadowPrs->Highlight (aPrs->HighlightStyle());
377         myViewDependentImmediateList.Append (aShadowPrs);
378       }
379       // handles custom highlight presentations which were defined in overridden
380       // HilightOwnerWithColor method of a custom AIS objects and maintain its
381       // visibility in different views on their own
382       else if (aShadowPrs.IsNull())
383       {
384         aPrs->Display();
385         continue;
386       }
387
388       if (!aShadowPrs->IsDisplayed())
389       {
390         aShadowPrs->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
391         aShadowPrs->CStructure()->ViewAffinity->SetVisible (Standard_False);
392         aShadowPrs->Display();
393       }
394
395       Standard_Integer aViewId = aView->Identification();
396       bool isParentVisible = aShadowPrs->ParentAffinity().IsNull() ?
397         Standard_True : aShadowPrs->ParentAffinity()->IsVisible (aViewId);
398       aShadowPrs->CStructure()->ViewAffinity->SetVisible (aViewId, isParentVisible);
399     }
400   }
401 }
402
403 // =======================================================================
404 // function : EndImmediateDraw
405 // purpose  :
406 // =======================================================================
407 void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_Viewer)& theViewer)
408 {
409   if (--myImmediateModeOn > 0)
410   {
411     return;
412   }
413
414   displayImmediate (theViewer);
415 }
416
417 // =======================================================================
418 // function : RedrawImmediate
419 // purpose  : Clears all immediate structures and redisplays with proper
420 //            affinity
421 //=======================================================================
422 void PrsMgr_PresentationManager::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
423 {
424   if (myImmediateList.IsEmpty())
425     return;
426
427   // Clear previously displayed structures
428   for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
429   {
430     anIter.Value()->Erase();
431   }
432   for (PrsMgr_ListOfPresentations::Iterator anIter (myViewDependentImmediateList); anIter.More(); anIter.Next())
433   {
434     anIter.Value()->Erase();
435   }
436   myViewDependentImmediateList.Clear();
437
438   displayImmediate (theViewer);
439 }
440
441 // =======================================================================
442 // function : AddToImmediateList
443 // purpose  :
444 //=======================================================================
445 void PrsMgr_PresentationManager::AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs)
446 {
447   if (myImmediateModeOn < 1)
448   {
449     return;
450   }
451
452   for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
453   {
454     if (anIter.Value() == thePrs)
455     {
456       return;
457     }
458   }
459
460   myImmediateList.Append (thePrs);
461 }
462
463 // =======================================================================
464 // function : HasPresentation
465 // purpose  :
466 // =======================================================================
467 Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
468                                                               const Standard_Integer                  theMode) const
469 {
470   if (!thePrsObj->HasOwnPresentations())
471     return Standard_False;
472
473   const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
474   for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
475   {
476     const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
477     const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
478     if (theMode == aPrs->Mode()
479      && this    == aPrsMgr)
480     {
481       return Standard_True;
482     }
483   }
484   return Standard_False;
485 }
486
487 // =======================================================================
488 // function : Presentation
489 // purpose  :
490 // =======================================================================
491 Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
492                                                                       const Standard_Integer                  theMode,
493                                                                       const Standard_Boolean                  theToCreate,
494                                                                       const Handle(PrsMgr_PresentableObject)& theSelObj) const
495 {
496   const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
497   for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
498   {
499     const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
500     const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
501     if (theMode == aPrs->Mode()
502      && this    == aPrsMgr)
503     {
504       return aPrs;
505     }
506   }
507
508   if (!theToCreate)
509   {
510     return Handle(PrsMgr_Presentation)();
511   }
512
513   Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj, theMode);
514   aPrs->SetZLayer (thePrsObj->ZLayer());
515   aPrs->CStructure()->ViewAffinity = myStructureManager->ObjectAffinity (!theSelObj.IsNull() ? theSelObj : thePrsObj);
516   thePrsObj->Presentations().Append (aPrs);
517   thePrsObj->Fill (this, aPrs, theMode);
518
519   // set layer index accordingly to object's presentations
520   aPrs->SetUpdateStatus (Standard_False);
521   return aPrs;
522 }
523
524 // =======================================================================
525 // function : RemovePresentation
526 // purpose  :
527 // =======================================================================
528 Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
529                                                                  const Standard_Integer                  theMode)
530 {
531   PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
532   for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
533   {
534     const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
535     const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager();
536     if (theMode == aPrs->Mode()
537      && this    == aPrsMgr)
538     {
539       aPrsList.Remove (aPrsIter);
540       return Standard_True;
541     }
542   }
543   return Standard_False;
544 }
545
546 // =======================================================================
547 // function : SetZLayer
548 // purpose  :
549 // =======================================================================
550 void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
551                                             const Graphic3d_ZLayerId                theLayerId)
552 {
553   if (thePrsObj->ToPropagateVisualState())
554   {
555     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
556     {
557       SetZLayer(anIter.Value(), theLayerId);
558     }
559   }
560
561   if (!thePrsObj->HasOwnPresentations())
562   {
563     return;
564   }
565
566   thePrsObj->SetZLayer (theLayerId);
567 }
568
569 // =======================================================================
570 // function : GetZLayer
571 // purpose  :
572 // =======================================================================
573 Graphic3d_ZLayerId PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const
574 {
575   return thePrsObj->ZLayer();
576 }
577
578 // =======================================================================
579 // function : Connect
580 // purpose  :
581 // =======================================================================
582 void PrsMgr_PresentationManager::Connect (const Handle(PrsMgr_PresentableObject)& thePrsObject,
583                                           const Handle(PrsMgr_PresentableObject)& theOtherObject,
584                                           const Standard_Integer                  theMode,
585                                           const Standard_Integer                  theOtherMode)
586 {
587   Handle(PrsMgr_Presentation) aPrs      = Presentation (thePrsObject,   theMode,      Standard_True);
588   Handle(PrsMgr_Presentation) aPrsOther = Presentation (theOtherObject, theOtherMode, Standard_True);
589   aPrs->Connect (aPrsOther.get(), Graphic3d_TOC_DESCENDANT);
590 }
591
592 // =======================================================================
593 // function : Transform
594 // purpose  :
595 // =======================================================================
596 void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObject)& thePrsObj,
597                                             const Handle(Geom_Transformation)&      theTransformation,
598                                             const Standard_Integer                  theMode)
599 {
600   Presentation (thePrsObj, theMode)->SetTransformation (theTransformation);
601 }
602
603 // =======================================================================
604 // function : Color
605 // purpose  :
606 // =======================================================================
607 void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj,
608                                         const Handle(Prs3d_Drawer)& theStyle,
609                                         const Standard_Integer                  theMode,
610                                         const Handle(PrsMgr_PresentableObject)& theSelObj,
611                                         const Standard_Integer theImmediateStructLayerId)
612 {
613   if (thePrsObj->ToPropagateVisualState())
614   {
615     for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
616     {
617       Color(anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
618     }
619   }
620   if (!thePrsObj->HasOwnPresentations())
621   {
622     return;
623   }
624
625   Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True, theSelObj);
626   if (aPrs->MustBeUpdated())
627   {
628     Update (thePrsObj, theMode);
629   }
630
631   if (myImmediateModeOn > 0)
632   {
633     Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs);
634     aShadow->SetZLayer (theImmediateStructLayerId);
635     aShadow->SetClipPlanes (aPrs->ClipPlanes());
636     aShadow->CStructure()->IsForHighlight = 1;
637     aShadow->Highlight (theStyle);
638     AddToImmediateList (aShadow);
639   }
640   else
641   {
642     aPrs->Highlight (theStyle);
643   }
644 }
645
646 namespace
647 {
648   // =======================================================================
649   // function : updatePrsTransformation
650   // purpose  : Internal function that scans thePrsList for shadow presentations
651   //            and applies transformation theTrsf to them in case if parent ID
652   //            of shadow presentation is equal to theRefId
653   // =======================================================================
654   void updatePrsTransformation (const PrsMgr_ListOfPresentations& thePrsList,
655                                 const Standard_Integer theRefId,
656                                 const Handle(Geom_Transformation)& theTrsf)
657   {
658     for (PrsMgr_ListOfPresentations::Iterator anIter (thePrsList); anIter.More(); anIter.Next())
659     {
660       const Handle(Prs3d_Presentation)& aPrs = anIter.Value();
661       if (aPrs.IsNull())
662         continue;
663
664       Handle(Prs3d_PresentationShadow) aShadowPrs = Handle(Prs3d_PresentationShadow)::DownCast (aPrs);
665       if (aShadowPrs.IsNull() || aShadowPrs->ParentId() != theRefId)
666         continue;
667
668       aShadowPrs->CStructure()->SetTransformation (theTrsf);
669     }
670   }
671 }
672
673 // =======================================================================
674 // function : UpdateHighlightTrsf
675 // purpose  :
676 // =======================================================================
677 void PrsMgr_PresentationManager::UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
678                                                       const Handle(PrsMgr_PresentableObject)& theObj,
679                                                       const Standard_Integer theMode,
680                                                       const Handle(PrsMgr_PresentableObject)& theSelObj)
681 {
682   if (theObj.IsNull())
683     return;
684
685   Handle(PrsMgr_Presentation) aPrs = Presentation (!theSelObj.IsNull() ? theSelObj : theObj, theMode, Standard_False);
686   if (aPrs.IsNull())
687   {
688     return;
689   }
690
691   Handle(Geom_Transformation) aTrsf = theObj->LocalTransformationGeom();
692   const Standard_Integer aParentId = aPrs->CStructure()->Id;
693   updatePrsTransformation (myImmediateList, aParentId, aTrsf);
694
695   if (!myViewDependentImmediateList.IsEmpty())
696   {
697     for (V3d_ListOfViewIterator anActiveViewIter (theViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
698     {
699       const Handle(Graphic3d_CView)& aView = anActiveViewIter.Value()->View();
700       Handle(Graphic3d_Structure) aViewDepParentPrs;
701       if (aView->IsComputed (aParentId, aViewDepParentPrs))
702       {
703         updatePrsTransformation (myViewDependentImmediateList,
704                                  aViewDepParentPrs->CStructure()->Id,
705                                  aTrsf);
706       }
707     }
708   }
709 }