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