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 | |
679ecdee |
15 | |
42cf5bc1 |
16 | #include <Geom_Transformation.hxx> |
679ecdee |
17 | #include <Graphic3d_GraphicDriver.hxx> |
42cf5bc1 |
18 | #include <Graphic3d_StructureManager.hxx> |
19 | #include <Prs3d_Presentation.hxx> |
679ecdee |
20 | #include <Prs3d_PresentationShadow.hxx> |
42cf5bc1 |
21 | #include <Prs3d_ShadingAspect.hxx> |
22 | #include <PrsMgr_ModedPresentation.hxx> |
7fd59977 |
23 | #include <PrsMgr_PresentableObject.hxx> |
24 | #include <PrsMgr_Presentation.hxx> |
42cf5bc1 |
25 | #include <PrsMgr_PresentationManager.hxx> |
7fd59977 |
26 | #include <PrsMgr_Presentations.hxx> |
42cf5bc1 |
27 | #include <Standard_NoSuchObject.hxx> |
28 | #include <Standard_Type.hxx> |
7fd59977 |
29 | #include <TColStd_ListIteratorOfListOfTransient.hxx> |
679ecdee |
30 | #include <V3d_View.hxx> |
42cf5bc1 |
31 | #include <Visual3d_View.hxx> |
32 | #include <Visual3d_ViewManager.hxx> |
679ecdee |
33 | |
34 | // ======================================================================= |
35 | // function : PrsMgr_PresentationManager |
36 | // purpose : |
37 | // ======================================================================= |
a1954302 |
38 | PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Visual3d_ViewManager)& theStructureManager) |
679ecdee |
39 | : myStructureManager (theStructureManager), |
a1954302 |
40 | myImmediateModeOn (0), |
41 | mySelectionColor (Quantity_NOC_GRAY99) |
679ecdee |
42 | { |
43 | // |
44 | } |
7fd59977 |
45 | |
679ecdee |
46 | // ======================================================================= |
47 | // function : Display |
48 | // purpose : |
49 | // ======================================================================= |
50 | void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
51 | const Standard_Integer theMode) |
7fd59977 |
52 | { |
0717ddc1 |
53 | if (thePrsObj->HasOwnPresentations()) |
679ecdee |
54 | { |
a1954302 |
55 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True); |
0717ddc1 |
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 | } |
7fd59977 |
69 | } |
7fd59977 |
70 | else |
679ecdee |
71 | { |
0717ddc1 |
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); |
679ecdee |
78 | } |
7fd59977 |
79 | } |
80 | |
679ecdee |
81 | // ======================================================================= |
82 | // function : Erase |
83 | // purpose : |
84 | // ======================================================================= |
85 | void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
86 | const Standard_Integer theMode) |
7fd59977 |
87 | { |
0717ddc1 |
88 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
89 | { |
90 | Erase (anIter.Value(), theMode); |
91 | } |
92 | |
a1954302 |
93 | PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
94 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
eef7fc64 |
95 | { |
a1954302 |
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 | } |
eef7fc64 |
108 | } |
7fd59977 |
109 | } |
110 | |
679ecdee |
111 | // ======================================================================= |
112 | // function : Clear |
113 | // purpose : |
114 | // ======================================================================= |
115 | void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
116 | const Standard_Integer theMode) |
7fd59977 |
117 | { |
0717ddc1 |
118 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
119 | { |
120 | Clear (anIter.Value(), theMode); |
121 | } |
122 | |
a1954302 |
123 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
124 | if (!aPrs.IsNull()) |
679ecdee |
125 | { |
a1954302 |
126 | aPrs->Clear(); |
679ecdee |
127 | } |
7fd59977 |
128 | } |
129 | |
679ecdee |
130 | // ======================================================================= |
131 | // function : SetVisibility |
132 | // purpose : |
133 | // ======================================================================= |
0717ddc1 |
134 | void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
eb4320f2 |
135 | const Standard_Integer theMode, |
136 | const Standard_Boolean theValue) |
137 | { |
0717ddc1 |
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); |
eb4320f2 |
148 | } |
7fd59977 |
149 | |
679ecdee |
150 | // ======================================================================= |
151 | // function : Highlight |
152 | // purpose : |
153 | // ======================================================================= |
154 | void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
155 | const Standard_Integer theMode) |
7fd59977 |
156 | { |
0717ddc1 |
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 | |
a1954302 |
166 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True); |
679ecdee |
167 | if (aPrs->MustBeUpdated()) |
168 | { |
169 | Update (thePrsObj, theMode); |
7fd59977 |
170 | } |
7fd59977 |
171 | |
679ecdee |
172 | if (myImmediateModeOn > 0) |
173 | { |
174 | Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); |
a1954302 |
175 | aShadow->Highlight (Aspect_TOHM_COLOR, mySelectionColor); |
679ecdee |
176 | AddToImmediateList (aShadow); |
177 | } |
178 | else |
179 | { |
a1954302 |
180 | aPrs->Highlight (Aspect_TOHM_COLOR, mySelectionColor); |
679ecdee |
181 | } |
7fd59977 |
182 | } |
183 | |
679ecdee |
184 | // ======================================================================= |
185 | // function : Unhighlight |
186 | // purpose : |
187 | // ======================================================================= |
188 | void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
189 | const Standard_Integer theMode) |
7fd59977 |
190 | { |
0717ddc1 |
191 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
192 | { |
193 | Unhighlight (anIter.Value(), theMode); |
194 | } |
195 | |
a1954302 |
196 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
197 | if (!aPrs.IsNull()) |
679ecdee |
198 | { |
a1954302 |
199 | aPrs->Unhighlight(); |
7fd59977 |
200 | } |
201 | } |
202 | |
679ecdee |
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 | { |
0717ddc1 |
211 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
212 | { |
213 | SetDisplayPriority (anIter.Value(), theMode, theNewPrior); |
214 | } |
215 | |
a1954302 |
216 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
217 | if (!aPrs.IsNull()) |
679ecdee |
218 | { |
a1954302 |
219 | aPrs->SetDisplayPriority (theNewPrior); |
679ecdee |
220 | } |
221 | } |
7fd59977 |
222 | |
679ecdee |
223 | // ======================================================================= |
224 | // function : DisplayPriority |
225 | // purpose : |
226 | // ======================================================================= |
227 | Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
228 | const Standard_Integer theMode) const |
7fd59977 |
229 | { |
0717ddc1 |
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 | |
a1954302 |
239 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
240 | return !aPrs.IsNull() |
241 | ? aPrs->DisplayPriority() |
242 | : 0; |
7fd59977 |
243 | } |
244 | |
679ecdee |
245 | // ======================================================================= |
246 | // function : IsDisplayed |
247 | // purpose : |
248 | // ======================================================================= |
249 | Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
250 | const Standard_Integer theMode) const |
7fd59977 |
251 | { |
0717ddc1 |
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 | |
a1954302 |
260 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
261 | return !aPrs.IsNull() |
262 | && aPrs->IsDisplayed(); |
7fd59977 |
263 | } |
264 | |
679ecdee |
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 | { |
0717ddc1 |
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 | |
a1954302 |
280 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
281 | return !aPrs.IsNull() |
282 | && aPrs->IsHighlighted(); |
679ecdee |
283 | } |
7fd59977 |
284 | |
679ecdee |
285 | // ======================================================================= |
286 | // function : Update |
287 | // purpose : |
288 | // ======================================================================= |
289 | void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
290 | const Standard_Integer theMode) const |
291 | { |
0717ddc1 |
292 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
293 | { |
294 | Update (anIter.Value(), theMode); |
295 | } |
7fd59977 |
296 | |
679ecdee |
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 | } |
7fd59977 |
305 | |
679ecdee |
306 | // ======================================================================= |
307 | // function : BeginImmediateDraw |
308 | // purpose : |
309 | // ======================================================================= |
310 | void PrsMgr_PresentationManager::BeginImmediateDraw() |
311 | { |
312 | if (++myImmediateModeOn > 1) |
313 | { |
314 | return; |
7fd59977 |
315 | } |
679ecdee |
316 | |
317 | ClearImmediateDraw(); |
7fd59977 |
318 | } |
679ecdee |
319 | |
320 | // ======================================================================= |
321 | // function : ClearImmediateDraw |
322 | // purpose : |
323 | // ======================================================================= |
324 | void PrsMgr_PresentationManager::ClearImmediateDraw() |
325 | { |
c3282ec1 |
326 | for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) |
679ecdee |
327 | { |
c3282ec1 |
328 | anIter.Value()->Erase(); |
679ecdee |
329 | } |
330 | |
c3282ec1 |
331 | for (PrsMgr_ListOfPresentations::Iterator anIter (myViewDependentImmediateList); anIter.More(); anIter.Next()) |
679ecdee |
332 | { |
c3282ec1 |
333 | anIter.Value()->Erase(); |
679ecdee |
334 | } |
335 | |
7fd59977 |
336 | myImmediateList.Clear(); |
c3282ec1 |
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 | } |
7fd59977 |
390 | } |
391 | |
679ecdee |
392 | // ======================================================================= |
393 | // function : EndImmediateDraw |
394 | // purpose : |
395 | // ======================================================================= |
c3282ec1 |
396 | void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_Viewer)& theViewer) |
679ecdee |
397 | { |
398 | if (--myImmediateModeOn > 0) |
399 | { |
400 | return; |
401 | } |
402 | |
c3282ec1 |
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 |
679ecdee |
417 | for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) |
418 | { |
c3282ec1 |
419 | anIter.Value()->Erase(); |
679ecdee |
420 | } |
c3282ec1 |
421 | for (PrsMgr_ListOfPresentations::Iterator anIter (myViewDependentImmediateList); anIter.More(); anIter.Next()) |
679ecdee |
422 | { |
c3282ec1 |
423 | anIter.Value()->Erase(); |
679ecdee |
424 | } |
c3282ec1 |
425 | myViewDependentImmediateList.Clear(); |
426 | |
427 | displayImmediate (theViewer); |
679ecdee |
428 | } |
7fd59977 |
429 | |
679ecdee |
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; |
7fd59977 |
446 | } |
679ecdee |
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 | { |
0717ddc1 |
459 | if (!thePrsObj->HasOwnPresentations()) |
460 | return Standard_False; |
461 | |
679ecdee |
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; |
7fd59977 |
471 | } |
472 | } |
679ecdee |
473 | return Standard_False; |
7fd59977 |
474 | } |
475 | |
679ecdee |
476 | // ======================================================================= |
477 | // function : Presentation |
478 | // purpose : |
479 | // ======================================================================= |
480 | Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
a1954302 |
481 | const Standard_Integer theMode, |
a272ed94 |
482 | const Standard_Boolean theToCreate, |
483 | const Handle(PrsMgr_PresentableObject)& theSelObj) const |
679ecdee |
484 | { |
485 | const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
679ecdee |
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 | } |
7fd59977 |
496 | |
a1954302 |
497 | if (!theToCreate) |
498 | { |
499 | return Handle(PrsMgr_Presentation)(); |
500 | } |
7fd59977 |
501 | |
af324faa |
502 | Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj); |
a1954302 |
503 | aPrs->SetZLayer (thePrsObj->ZLayer()); |
a272ed94 |
504 | aPrs->Presentation()->CStructure()->ViewAffinity = myStructureManager->ObjectAffinity (!theSelObj.IsNull() ? theSelObj : thePrsObj); |
679ecdee |
505 | thePrsObj->Presentations().Append (PrsMgr_ModedPresentation (aPrs, theMode)); |
506 | thePrsObj->Fill (this, aPrs, theMode); |
7fd59977 |
507 | |
679ecdee |
508 | // set layer index accordingly to object's presentations |
679ecdee |
509 | aPrs->SetUpdateStatus (Standard_False); |
a1954302 |
510 | return aPrs; |
679ecdee |
511 | } |
7fd59977 |
512 | |
679ecdee |
513 | // ======================================================================= |
514 | // function : RemovePresentation |
515 | // purpose : |
516 | // ======================================================================= |
a1954302 |
517 | Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
518 | const Standard_Integer theMode) |
7fd59977 |
519 | { |
679ecdee |
520 | PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); |
521 | for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) |
522 | { |
a1954302 |
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) |
679ecdee |
527 | { |
528 | aPrsList.Remove (aPrsIter); |
a1954302 |
529 | return Standard_True; |
679ecdee |
530 | } |
531 | } |
a1954302 |
532 | return Standard_False; |
679ecdee |
533 | } |
7fd59977 |
534 | |
679ecdee |
535 | // ======================================================================= |
536 | // function : SetZLayer |
537 | // purpose : |
538 | // ======================================================================= |
539 | void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
540 | const Standard_Integer theLayerId) |
541 | { |
0717ddc1 |
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 | } |
a1954302 |
550 | |
551 | thePrsObj->SetZLayer (theLayerId); |
679ecdee |
552 | } |
7fd59977 |
553 | |
679ecdee |
554 | // ======================================================================= |
555 | // function : GetZLayer |
556 | // purpose : |
557 | // ======================================================================= |
558 | Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const |
559 | { |
a1954302 |
560 | return thePrsObj->ZLayer(); |
679ecdee |
561 | } |
7fd59977 |
562 | |
679ecdee |
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 | { |
a1954302 |
572 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObject, theMode, Standard_True); |
573 | Handle(PrsMgr_Presentation) aPrsOther = Presentation (theOtherObject, theOtherMode, Standard_True); |
574 | aPrs->Connect (aPrsOther); |
7fd59977 |
575 | } |
576 | |
679ecdee |
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 | { |
af324faa |
585 | Presentation (thePrsObj, theMode)->Transform (theTransformation); |
679ecdee |
586 | } |
7fd59977 |
587 | |
7fd59977 |
588 | |
679ecdee |
589 | // ======================================================================= |
590 | // function : Color |
591 | // purpose : |
592 | // ======================================================================= |
593 | void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
594 | const Quantity_NameOfColor theColor, |
a272ed94 |
595 | const Standard_Integer theMode, |
c3282ec1 |
596 | const Handle(PrsMgr_PresentableObject)& theSelObj, |
597 | const Standard_Integer theImmediateStructLayerId) |
7fd59977 |
598 | { |
0717ddc1 |
599 | for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) |
600 | { |
c3282ec1 |
601 | Color (anIter.Value(), theColor, theMode, NULL, theImmediateStructLayerId); |
0717ddc1 |
602 | } |
603 | if (!thePrsObj->HasOwnPresentations()) |
604 | { |
605 | return; |
606 | } |
607 | |
a272ed94 |
608 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True, theSelObj); |
679ecdee |
609 | if (aPrs->MustBeUpdated()) |
610 | { |
611 | Update (thePrsObj, theMode); |
612 | } |
59f45b7c |
613 | |
679ecdee |
614 | if (myImmediateModeOn > 0) |
615 | { |
616 | Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); |
c3282ec1 |
617 | aShadow->SetZLayer (theImmediateStructLayerId); |
618 | aShadow->SetClipPlanes (aPrs->Presentation()->GetClipPlanes()); |
619 | aShadow->CStructure()->IsForHighlight = 1; |
a1954302 |
620 | aShadow->Highlight (Aspect_TOHM_COLOR, theColor); |
679ecdee |
621 | AddToImmediateList (aShadow); |
622 | } |
623 | else |
624 | { |
a1954302 |
625 | aPrs->Highlight (Aspect_TOHM_COLOR, theColor); |
679ecdee |
626 | } |
627 | } |
628 | |
629 | // ======================================================================= |
630 | // function : BoundBox |
631 | // purpose : |
632 | // ======================================================================= |
a1954302 |
633 | void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
679ecdee |
634 | const Standard_Integer theMode) |
59f45b7c |
635 | { |
a1954302 |
636 | Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True); |
637 | if (aPrs->MustBeUpdated()) |
679ecdee |
638 | { |
a1954302 |
639 | Update (thePrsObj, theMode); |
59f45b7c |
640 | } |
a1954302 |
641 | aPrs->Highlight (Aspect_TOHM_BOUNDBOX, mySelectionColor); |
59f45b7c |
642 | } |
643 | |
679ecdee |
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 | } |
59f45b7c |
658 | |
679ecdee |
659 | // ======================================================================= |
660 | // function : SetShadingAspect |
661 | // purpose : |
662 | // ======================================================================= |
a1954302 |
663 | void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObj, |
679ecdee |
664 | const Handle(Prs3d_ShadingAspect)& theShadingAspect, |
665 | const Standard_Integer theMode) |
59f45b7c |
666 | { |
a1954302 |
667 | const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); |
668 | if (!aPrs.IsNull()) |
59f45b7c |
669 | { |
a1954302 |
670 | aPrs->SetShadingAspect (theShadingAspect); |
59f45b7c |
671 | } |
679ecdee |
672 | } |