b311480e |
1 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | #include <PrsMgr_PresentationManager.ixx> |
679ecdee |
16 | |
17 | #include <Graphic3d_GraphicDriver.hxx> |
18 | #include <Prs3d_PresentationShadow.hxx> |
7fd59977 |
19 | #include <PrsMgr_PresentableObject.hxx> |
20 | #include <PrsMgr_Presentation.hxx> |
21 | #include <PrsMgr_Presentations.hxx> |
22 | #include <PrsMgr_ModedPresentation.hxx> |
23 | #include <TColStd_ListIteratorOfListOfTransient.hxx> |
679ecdee |
24 | #include <V3d_View.hxx> |
25 | #include <Visual3d_View.hxx> |
26 | #include <Visual3d_Layer.hxx> |
27 | |
28 | // ======================================================================= |
29 | // function : PrsMgr_PresentationManager |
30 | // purpose : |
31 | // ======================================================================= |
32 | PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager) |
33 | : myStructureManager (theStructureManager), |
34 | myImmediateModeOn (0) |
35 | { |
36 | // |
37 | } |
7fd59977 |
38 | |
679ecdee |
39 | // ======================================================================= |
40 | // function : Display |
41 | // purpose : |
42 | // ======================================================================= |
43 | void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
44 | const Standard_Integer theMode) |
7fd59977 |
45 | { |
0717ddc1 |
46 | if (thePrsObj->HasOwnPresentations()) |
679ecdee |
47 | { |
0717ddc1 |
48 | if (!HasPresentation (thePrsObj, theMode)) |
49 | { |
50 | AddPresentation (thePrsObj, theMode); |
51 | } |
679ecdee |
52 | |
0717ddc1 |
53 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
679ecdee |
54 | |
0717ddc1 |
55 | if (aPrs.IsNull()) return; |
56 | |
57 | if (aPrs->MustBeUpdated()) |
58 | { |
59 | Update (thePrsObj, theMode); |
60 | } |
61 | |
62 | if (myImmediateModeOn > 0) |
63 | { |
64 | AddToImmediateList (aPrs->Presentation()); |
65 | } |
66 | else |
67 | { |
68 | aPrs->Display(); |
69 | } |
7fd59977 |
70 | } |
7fd59977 |
71 | else |
679ecdee |
72 | { |
0717ddc1 |
73 | thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode); |
74 | } |
75 | |
76 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
77 | { |
78 | Display (anIter.Value(), theMode); |
679ecdee |
79 | } |
7fd59977 |
80 | } |
81 | |
679ecdee |
82 | // ======================================================================= |
83 | // function : Erase |
84 | // purpose : |
85 | // ======================================================================= |
86 | void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
87 | const Standard_Integer theMode) |
7fd59977 |
88 | { |
0717ddc1 |
89 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
90 | { |
91 | Erase (anIter.Value(), theMode); |
92 | } |
93 | |
679ecdee |
94 | if (HasPresentation (thePrsObj, theMode)) |
eef7fc64 |
95 | { |
679ecdee |
96 | Presentation (thePrsObj, theMode)->Erase(); |
97 | RemovePresentation (thePrsObj, theMode); |
eef7fc64 |
98 | } |
7fd59977 |
99 | } |
100 | |
679ecdee |
101 | // ======================================================================= |
102 | // function : Clear |
103 | // purpose : |
104 | // ======================================================================= |
105 | void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
106 | const Standard_Integer theMode) |
7fd59977 |
107 | { |
0717ddc1 |
108 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
109 | { |
110 | Clear (anIter.Value(), theMode); |
111 | } |
112 | |
679ecdee |
113 | if (HasPresentation (thePrsObj, theMode)) |
114 | { |
115 | Presentation (thePrsObj, theMode)->Clear(); |
116 | } |
7fd59977 |
117 | } |
118 | |
679ecdee |
119 | // ======================================================================= |
120 | // function : SetVisibility |
121 | // purpose : |
122 | // ======================================================================= |
0717ddc1 |
123 | void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
eb4320f2 |
124 | const Standard_Integer theMode, |
125 | const Standard_Boolean theValue) |
126 | { |
0717ddc1 |
127 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
128 | { |
129 | SetVisibility (anIter.Value(), theMode, theValue); |
130 | } |
131 | if (!thePrsObj->HasOwnPresentations()) |
132 | { |
133 | return; |
134 | } |
135 | |
136 | Presentation (thePrsObj, theMode)->SetVisible (theValue); |
eb4320f2 |
137 | } |
7fd59977 |
138 | |
679ecdee |
139 | // ======================================================================= |
140 | // function : Highlight |
141 | // purpose : |
142 | // ======================================================================= |
143 | void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
144 | const Standard_Integer theMode) |
7fd59977 |
145 | { |
0717ddc1 |
146 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
147 | { |
148 | Highlight (anIter.Value(), theMode); |
149 | } |
150 | if (!thePrsObj->HasOwnPresentations()) |
151 | { |
152 | return; |
153 | } |
154 | |
679ecdee |
155 | if (!HasPresentation (thePrsObj, theMode)) |
156 | { |
157 | AddPresentation (thePrsObj, theMode); |
7fd59977 |
158 | } |
679ecdee |
159 | |
0717ddc1 |
160 | if (!HasPresentation (thePrsObj, theMode)) return; |
161 | |
af324faa |
162 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
679ecdee |
163 | if (aPrs->MustBeUpdated()) |
164 | { |
165 | Update (thePrsObj, theMode); |
7fd59977 |
166 | } |
7fd59977 |
167 | |
679ecdee |
168 | if (myImmediateModeOn > 0) |
169 | { |
170 | Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); |
171 | aShadow->Highlight(); |
172 | AddToImmediateList (aShadow); |
173 | } |
174 | else |
175 | { |
176 | aPrs->Highlight(); |
177 | } |
7fd59977 |
178 | } |
179 | |
679ecdee |
180 | // ======================================================================= |
181 | // function : Unhighlight |
182 | // purpose : |
183 | // ======================================================================= |
184 | void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
185 | const Standard_Integer theMode) |
7fd59977 |
186 | { |
0717ddc1 |
187 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
188 | { |
189 | Unhighlight (anIter.Value(), theMode); |
190 | } |
191 | |
679ecdee |
192 | if (HasPresentation (thePrsObj, theMode)) |
193 | { |
194 | Presentation (thePrsObj, theMode)->Unhighlight(); |
7fd59977 |
195 | } |
196 | } |
197 | |
679ecdee |
198 | // ======================================================================= |
199 | // function : SetDisplayPriority |
200 | // purpose : |
201 | // ======================================================================= |
202 | void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
203 | const Standard_Integer theMode, |
204 | const Standard_Integer theNewPrior) const |
205 | { |
0717ddc1 |
206 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
207 | { |
208 | SetDisplayPriority (anIter.Value(), theMode, theNewPrior); |
209 | } |
210 | |
679ecdee |
211 | if (HasPresentation (thePrsObj, theMode)) |
212 | { |
213 | Presentation (thePrsObj, theMode)->SetDisplayPriority (theNewPrior); |
214 | } |
215 | } |
7fd59977 |
216 | |
679ecdee |
217 | // ======================================================================= |
218 | // function : DisplayPriority |
219 | // purpose : |
220 | // ======================================================================= |
221 | Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
222 | const Standard_Integer theMode) const |
7fd59977 |
223 | { |
0717ddc1 |
224 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
225 | { |
226 | Standard_Integer aPriority = DisplayPriority (anIter.Value(), theMode); |
227 | if (aPriority != 0) |
228 | { |
229 | return aPriority; |
230 | } |
231 | } |
232 | |
679ecdee |
233 | return HasPresentation (thePrsObj, theMode) |
234 | ? Presentation (thePrsObj, theMode)->DisplayPriority() |
235 | : 0; |
7fd59977 |
236 | } |
237 | |
679ecdee |
238 | // ======================================================================= |
239 | // function : IsDisplayed |
240 | // purpose : |
241 | // ======================================================================= |
242 | Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
243 | const Standard_Integer theMode) const |
7fd59977 |
244 | { |
0717ddc1 |
245 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
246 | { |
247 | if (IsDisplayed (anIter.Value(), theMode)) |
248 | { |
249 | return Standard_True; |
250 | } |
251 | } |
252 | |
679ecdee |
253 | return HasPresentation (thePrsObj, theMode) |
254 | && Presentation (thePrsObj, theMode)->IsDisplayed(); |
7fd59977 |
255 | } |
256 | |
679ecdee |
257 | // ======================================================================= |
258 | // function : IsHighlighted |
259 | // purpose : |
260 | // ======================================================================= |
261 | Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
262 | const Standard_Integer theMode) const |
263 | { |
0717ddc1 |
264 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
265 | { |
266 | if (IsHighlighted (anIter.Value(), theMode)) |
267 | { |
268 | return Standard_True; |
269 | } |
270 | } |
271 | |
679ecdee |
272 | return HasPresentation (thePrsObj, theMode) |
273 | && Presentation (thePrsObj, theMode)->IsHighlighted(); |
274 | } |
7fd59977 |
275 | |
679ecdee |
276 | // ======================================================================= |
277 | // function : Update |
278 | // purpose : |
279 | // ======================================================================= |
280 | void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
281 | const Standard_Integer theMode) const |
282 | { |
0717ddc1 |
283 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
284 | { |
285 | Update (anIter.Value(), theMode); |
286 | } |
679ecdee |
287 | if (!HasPresentation(thePrsObj, theMode)) |
288 | { |
289 | return; |
290 | } |
7fd59977 |
291 | |
679ecdee |
292 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
293 | if (!aPrs.IsNull()) |
294 | { |
295 | aPrs->Clear(); |
296 | thePrsObj->Fill (this, aPrs, theMode); |
297 | aPrs->SetUpdateStatus (Standard_False); |
298 | } |
299 | } |
7fd59977 |
300 | |
679ecdee |
301 | // ======================================================================= |
302 | // function : BeginImmediateDraw |
303 | // purpose : |
304 | // ======================================================================= |
305 | void PrsMgr_PresentationManager::BeginImmediateDraw() |
306 | { |
307 | if (++myImmediateModeOn > 1) |
308 | { |
309 | return; |
7fd59977 |
310 | } |
679ecdee |
311 | |
312 | ClearImmediateDraw(); |
7fd59977 |
313 | } |
679ecdee |
314 | |
315 | // ======================================================================= |
316 | // function : ClearImmediateDraw |
317 | // purpose : |
318 | // ======================================================================= |
319 | void PrsMgr_PresentationManager::ClearImmediateDraw() |
320 | { |
321 | if (myImmediateView.IsNull()) |
322 | { |
323 | myImmediateList.Clear(); |
324 | return; |
325 | } |
326 | |
327 | for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) |
328 | { |
329 | myImmediateView->View()->EraseImmediate (anIter.Value()); |
330 | } |
331 | |
7fd59977 |
332 | myImmediateList.Clear(); |
679ecdee |
333 | myImmediateView.Nullify(); |
7fd59977 |
334 | } |
335 | |
679ecdee |
336 | // ======================================================================= |
337 | // function : EndImmediateDraw |
338 | // purpose : |
339 | // ======================================================================= |
340 | void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_View)& theView) |
341 | { |
342 | if (--myImmediateModeOn > 0) |
343 | { |
344 | return; |
345 | } |
346 | |
347 | for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) |
348 | { |
349 | theView->View()->DisplayImmediate (anIter.Value(), Standard_True); |
350 | } |
351 | if (!myImmediateList.IsEmpty()) |
352 | { |
353 | myImmediateView = theView; |
354 | } |
355 | } |
7fd59977 |
356 | |
679ecdee |
357 | // ======================================================================= |
358 | // function : AddToImmediateList |
359 | // purpose : |
360 | //======================================================================= |
361 | void PrsMgr_PresentationManager::AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs) |
362 | { |
363 | if (myImmediateModeOn < 1) |
364 | { |
365 | return; |
366 | } |
367 | |
368 | for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) |
369 | { |
370 | if (anIter.Value() == thePrs) |
371 | { |
372 | return; |
7fd59977 |
373 | } |
679ecdee |
374 | } |
375 | |
376 | myImmediateList.Append (thePrs); |
377 | } |
378 | |
379 | // ======================================================================= |
380 | // function : HasPresentation |
381 | // purpose : |
382 | // ======================================================================= |
383 | Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
384 | const Standard_Integer theMode) const |
385 | { |
0717ddc1 |
386 | if (!thePrsObj->HasOwnPresentations()) |
387 | return Standard_False; |
388 | |
679ecdee |
389 | const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
390 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
391 | { |
392 | const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter); |
393 | const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager(); |
394 | if (theMode == aModedPrs.Mode() |
395 | && this == aPrsMgr) |
396 | { |
397 | return Standard_True; |
7fd59977 |
398 | } |
399 | } |
679ecdee |
400 | return Standard_False; |
7fd59977 |
401 | } |
402 | |
679ecdee |
403 | // ======================================================================= |
404 | // function : Presentation |
405 | // purpose : |
406 | // ======================================================================= |
407 | Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
408 | const Standard_Integer theMode) const |
409 | { |
410 | const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
411 | if (aPrsList.IsEmpty()) |
412 | { |
413 | return Handle(PrsMgr_Presentation)(); |
414 | } |
7fd59977 |
415 | |
679ecdee |
416 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
417 | { |
418 | const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter); |
419 | const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager(); |
420 | if (theMode == aModedPrs.Mode() |
421 | && this == aPrsMgr) |
422 | { |
423 | return aModedPrs.Presentation(); |
424 | } |
425 | } |
7fd59977 |
426 | |
0179bbc6 |
427 | return Handle(PrsMgr_Presentation)(); |
679ecdee |
428 | } |
7fd59977 |
429 | |
679ecdee |
430 | // ======================================================================= |
431 | // function : AddPresentation |
432 | // purpose : |
433 | // ======================================================================= |
434 | void PrsMgr_PresentationManager::AddPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
435 | const Standard_Integer theMode) |
436 | { |
af324faa |
437 | Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj); |
679ecdee |
438 | thePrsObj->Presentations().Append (PrsMgr_ModedPresentation (aPrs, theMode)); |
439 | thePrsObj->Fill (this, aPrs, theMode); |
7fd59977 |
440 | |
679ecdee |
441 | // set layer index accordingly to object's presentations |
442 | const Standard_Integer aZLayerId = GetZLayer (thePrsObj); |
443 | if (aZLayerId >= 0) |
444 | { |
445 | aPrs->SetZLayer (aZLayerId); |
446 | } |
447 | aPrs->SetUpdateStatus (Standard_False); |
448 | } |
7fd59977 |
449 | |
679ecdee |
450 | // ======================================================================= |
451 | // function : RemovePresentation |
452 | // purpose : |
453 | // ======================================================================= |
454 | void PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
455 | const Standard_Integer theMode) |
7fd59977 |
456 | { |
679ecdee |
457 | PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
458 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
459 | { |
460 | if (theMode == aPrsList (aPrsIter).Mode()) |
461 | // && this == aPrsMgr) ?? |
462 | { |
463 | aPrsList.Remove (aPrsIter); |
464 | break; |
465 | } |
466 | } |
467 | } |
7fd59977 |
468 | |
679ecdee |
469 | // ======================================================================= |
470 | // function : SetZLayer |
471 | // purpose : |
472 | // ======================================================================= |
473 | void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
474 | const Standard_Integer theLayerId) |
475 | { |
0717ddc1 |
476 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
477 | { |
478 | SetZLayer (anIter.Value(), theLayerId); |
479 | } |
480 | if (!thePrsObj->HasOwnPresentations()) |
481 | { |
482 | return; |
483 | } |
679ecdee |
484 | PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
485 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
486 | { |
487 | Handle(PrsMgr_Presentation) aPrs = aPrsList.ChangeValue (aPrsIter).Presentation(); |
488 | if (aPrs->PresentationManager() == this) |
489 | { |
490 | aPrs->SetZLayer (theLayerId); |
491 | } |
492 | } |
493 | } |
7fd59977 |
494 | |
679ecdee |
495 | // ======================================================================= |
496 | // function : GetZLayer |
497 | // purpose : |
498 | // ======================================================================= |
499 | Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const |
500 | { |
0717ddc1 |
501 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
502 | { |
503 | Standard_Integer aLayer = GetZLayer (anIter.Value()); |
504 | if (aLayer != -1) |
505 | { |
506 | return aLayer; |
507 | } |
508 | } |
509 | if (!thePrsObj->HasOwnPresentations()) |
510 | { |
511 | return -1; |
512 | } |
679ecdee |
513 | const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
514 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
515 | { |
516 | Handle(PrsMgr_Presentation) aPrs = aPrsList.Value (aPrsIter).Presentation(); |
517 | if (aPrs->PresentationManager() == this) |
518 | { |
519 | return aPrs->GetZLayer(); |
7fd59977 |
520 | } |
7fd59977 |
521 | } |
679ecdee |
522 | return -1; |
523 | } |
7fd59977 |
524 | |
679ecdee |
525 | // ======================================================================= |
526 | // function : Connect |
527 | // purpose : |
528 | // ======================================================================= |
529 | void PrsMgr_PresentationManager::Connect (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
530 | const Handle(PrsMgr_PresentableObject)& theOtherObject, |
531 | const Standard_Integer theMode, |
532 | const Standard_Integer theOtherMode) |
533 | { |
534 | if (!HasPresentation (thePrsObject, theMode)) |
535 | { |
536 | AddPresentation (thePrsObject, theMode); |
537 | } |
538 | if (!HasPresentation (theOtherObject, theOtherMode)) |
539 | { |
540 | AddPresentation (theOtherObject, theOtherMode); |
541 | } |
01d5be80 |
542 | Presentation (thePrsObject, theMode)->Connect (Presentation (theOtherObject, theOtherMode)); |
7fd59977 |
543 | } |
544 | |
679ecdee |
545 | // ======================================================================= |
546 | // function : Transform |
547 | // purpose : |
548 | // ======================================================================= |
549 | void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
550 | const Handle(Geom_Transformation)& theTransformation, |
551 | const Standard_Integer theMode) |
552 | { |
af324faa |
553 | Presentation (thePrsObj, theMode)->Transform (theTransformation); |
679ecdee |
554 | } |
7fd59977 |
555 | |
7fd59977 |
556 | |
679ecdee |
557 | // ======================================================================= |
558 | // function : Color |
559 | // purpose : |
560 | // ======================================================================= |
561 | void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
562 | const Quantity_NameOfColor theColor, |
563 | const Standard_Integer theMode) |
7fd59977 |
564 | { |
0717ddc1 |
565 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
566 | { |
567 | Color (anIter.Value(), theColor, theMode); |
568 | } |
569 | if (!thePrsObj->HasOwnPresentations()) |
570 | { |
571 | return; |
572 | } |
573 | |
679ecdee |
574 | if (!HasPresentation (thePrsObj, theMode)) |
575 | { |
576 | AddPresentation (thePrsObj, theMode); |
7fd59977 |
577 | } |
7fd59977 |
578 | |
0717ddc1 |
579 | if (!HasPresentation (thePrsObj, theMode)) return; |
580 | |
af324faa |
581 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
679ecdee |
582 | if (aPrs->MustBeUpdated()) |
583 | { |
584 | Update (thePrsObj, theMode); |
585 | } |
59f45b7c |
586 | |
679ecdee |
587 | if (myImmediateModeOn > 0) |
588 | { |
589 | Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); |
590 | aShadow->Color (theColor); |
591 | AddToImmediateList (aShadow); |
592 | } |
593 | else |
594 | { |
595 | aPrs->Color (theColor); |
596 | } |
597 | } |
598 | |
599 | // ======================================================================= |
600 | // function : BoundBox |
601 | // purpose : |
602 | // ======================================================================= |
603 | void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
604 | const Standard_Integer theMode) |
59f45b7c |
605 | { |
679ecdee |
606 | if (!HasPresentation (thePrsObject, theMode)) |
59f45b7c |
607 | { |
679ecdee |
608 | AddPresentation (thePrsObject, theMode); |
609 | } |
610 | else if (Presentation (thePrsObject, theMode)->MustBeUpdated()) |
611 | { |
612 | Update (thePrsObject, theMode); |
59f45b7c |
613 | } |
af324faa |
614 | Presentation (thePrsObject, theMode)->BoundBox(); |
59f45b7c |
615 | } |
616 | |
679ecdee |
617 | // ======================================================================= |
618 | // function : SetShadingAspect |
619 | // purpose : |
620 | // ======================================================================= |
621 | void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
622 | const Quantity_NameOfColor theColor, |
623 | const Graphic3d_NameOfMaterial theMaterial, |
624 | const Standard_Integer theMode) |
625 | { |
626 | Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect(); |
627 | anAspect->SetColor (theColor); |
628 | anAspect->SetMaterial (theMaterial); |
629 | SetShadingAspect (thePrsObject, anAspect, theMode); |
630 | } |
59f45b7c |
631 | |
679ecdee |
632 | // ======================================================================= |
633 | // function : SetShadingAspect |
634 | // purpose : |
635 | // ======================================================================= |
636 | void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject, |
637 | const Handle(Prs3d_ShadingAspect)& theShadingAspect, |
638 | const Standard_Integer theMode) |
59f45b7c |
639 | { |
679ecdee |
640 | if (HasPresentation (thePrsObject, theMode)) |
59f45b7c |
641 | { |
af324faa |
642 | Presentation (thePrsObject, theMode)->SetShadingAspect (theShadingAspect); |
59f45b7c |
643 | } |
679ecdee |
644 | } |