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