Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1995-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 | /*********************************************************************** |
16 | ||
17 | FONCTION : | |
18 | ---------- | |
19 | Classe Visual3d_View.cxx : | |
20 | ||
21 | ||
81bba717 | 22 | Declaration of variables specific to views. |
7fd59977 | 23 | |
81bba717 | 24 | A view is defined by : |
25 | - ViewManager | |
26 | - ContextView | |
7fd59977 | 27 | |
28 | HISTORIQUE DES MODIFICATIONS : | |
29 | -------------------------------- | |
30 | Mars 1992 : NW,JPB,CAL ; Creation. | |
31 | 04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ... | |
32 | 22-04-97 : CAL ; Ajout du Plot. | |
33 | 03-06-97 : FMN ; Correction calcul SetRatio | |
34 | 06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED. | |
35 | 28-07-97 : PCT ; Ajout lumiere frontale headlight. | |
36 | 19-09-97 : CAL ; Remplacement de Window->Position par Window->Size; | |
37 | 17-10-97 : CAL ; Le Projects nouveau est arrive. (NewProjects) | |
38 | 24-10-97 : CAL ; Retrait de DownCast. | |
39 | 24-10-97 : CAL ; Retrait des DataStructure (Vieille maquette inutilisee). | |
40 | 17-11-97 : FMN ; Ajout DoResize dans Resized() | |
41 | 20-11-97 : CAL ; Disparition de la dependance avec math | |
42 | ??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe. | |
43 | ??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures | |
44 | 07-08-97 : PCT ; ajout support texture mapping | |
7fd59977 | 45 | 15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset |
46 | 15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED | |
47 | 26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner | |
48 | 06-02-98 : FMN ; CTS19079: TOP TEN: Probleme de highlight dans EDesigner. | |
49 | 05-03-98 : CAL ; GraphicTransform que si Trsf non invalidante | |
50 | 27-03-98 : CAL ; Ajout de TheStructure = devant Compute (...) !!!! | |
51 | 16-04-98 : CAL ; Remise a ID de la Trsf sur la COMPUTED | |
52 | 20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED. | |
53 | 24-06-98 : CAL ; PRO14526 SetTransparency sur une vue non active. | |
54 | 17-07-98 : CAL ; PRO14872 test sur aTrsf dans ::SetTransform. | |
55 | 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1) | |
56 | 22-09-98 : BGN ; S3989 (anciennement S3819) | |
57 | TypeOfTriedron* from Aspect (pas Visual3d) | |
58 | 06-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie. | |
59 | 16-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie. | |
60 | 02-11-98 : CAL ; Retrait de OSD::SetSignal. | |
61 | 18-11-98 : FMN ; Correction sur la gestion de la perspective | |
62 | 02-12-98 : CAL ; S4062. Ajout des layers. | |
63 | 13-09-99 : GG ; GER61454 Adds LightLimit() and PlaneLimit() methods | |
64 | 10-11-99 : GG ; PRO19603 Add Redraw( area ) method | |
65 | 14-01-00 : GG ; IMP140100 Add ViewManager( ) method | |
66 | 22-10-01 : SAV ; Added EnableDepthTest() method. | |
67 | 30-04-02 : JMB ; MyDisplayStructure : use a Map instead of a Set (very bad performance | |
68 | in data access when a lot of objects are used) | |
69 | Will improve performance of selection mechanisms | |
70 | ||
71 | ************************************************************************/ | |
72 | ||
73 | #define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes | |
74 | // positions. | |
75 | ||
7fd59977 | 76 | #define GER61454 //GG 14-09-99 Activates model clipping planes |
77 | ||
7fd59977 | 78 | #define RIC120302 //GG Add a NEW SetWindow method which enable |
79 | // to connect a graphic widget and context to OGL. | |
80 | ||
b8ddfc2f | 81 | //BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API |
82 | //BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API | |
7fd59977 | 83 | |
b8ddfc2f | 84 | //OCC1188 SAV Added methods to set background image |
7fd59977 | 85 | |
86 | /*----------------------------------------------------------------------*/ | |
87 | /* | |
88 | * Constantes | |
89 | */ | |
90 | ||
91 | #define NO_DEBUG | |
92 | #define NO_DESTROY | |
93 | #define NO_TRACE | |
94 | #define NO_TRACE_ACCEPT | |
95 | #define NO_TRACE_CLEAR | |
96 | #define NO_TRACE_CONNECT | |
97 | #define NO_TRACE_HIGH | |
98 | #define NO_TRACE_COMP | |
99 | #define NO_TRACE_TRSF | |
100 | #define NO_TRACE_DISPLAY | |
101 | #define NO_TRACE_ISCOMP | |
102 | #define NO_TRACE_LENGTH | |
103 | #define NO_TRACE_LAYER | |
104 | ||
105 | /*----------------------------------------------------------------------*/ | |
106 | /* | |
107 | * Includes | |
108 | */ | |
109 | ||
110 | #ifdef WNT | |
111 | #include <windows.h> | |
112 | #endif | |
113 | ||
114 | // for the class | |
115 | #include <Visual3d_View.ixx> | |
116 | #include <Visual3d_View.pxx> | |
117 | #include <Visual3d_DepthCueingDefinitionError.hxx> | |
118 | #include <Visual3d_ZClippingDefinitionError.hxx> | |
119 | ||
120 | #ifdef OLD_METHOD | |
121 | #include <math_Vector.hxx> | |
122 | #endif /* OLD_METHOD */ | |
123 | ||
124 | #include <OSD.hxx> | |
125 | ||
126 | #include <Graphic3d_Structure.hxx> | |
127 | #include <Graphic3d_MapOfStructure.hxx> | |
128 | #include <Graphic3d_MapIteratorOfMapOfStructure.hxx> | |
129 | #include <Graphic3d_DataStructureManager.hxx> | |
130 | ||
131 | #include <Graphic3d_GraphicDriver.hxx> | |
7fd59977 | 132 | |
133 | #include <Graphic3d_Vector.hxx> | |
134 | #include <Graphic3d_Vertex.hxx> | |
135 | ||
136 | #include <Visual3d_Light.hxx> | |
137 | #include <Visual3d_SetOfLight.hxx> | |
138 | #include <Visual3d_HSetOfLight.hxx> | |
679ecdee | 139 | #include <Visual3d_HSetOfView.hxx> |
7fd59977 | 140 | #include <Visual3d_SetIteratorOfSetOfLight.hxx> |
7fd59977 | 141 | #include <Visual3d_SetIteratorOfSetOfView.hxx> |
142 | ||
143 | #include <Graphic3d_TextureEnv.hxx> | |
144 | ||
145 | #include <TColStd_HArray2OfReal.hxx> | |
146 | ||
4fe56619 | 147 | #if (defined(_WIN32) || defined(__WIN32__)) |
148 | #include <WNT_Window.hxx> | |
149 | #elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) | |
150 | #include <Cocoa_Window.hxx> | |
7fd59977 | 151 | #else |
4fe56619 | 152 | #include <Xw_Window.hxx> |
153 | #endif | |
7fd59977 | 154 | |
155 | #include <float.h> | |
156 | ||
157 | //-Aliases | |
158 | ||
159 | //-Global data definitions | |
160 | ||
161 | //-Constructors | |
162 | ||
163 | Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager): | |
164 | MyContext (), | |
7fd59977 | 165 | MyTOCOMPUTESequence (), |
166 | MyCOMPUTEDSequence (), | |
167 | MyDisplayedStructure () | |
168 | { | |
7fd59977 | 169 | |
7fd59977 | 170 | MyPtrViewManager = AManager.operator->(); |
7fd59977 | 171 | MyCView.ViewId = int (AManager->Identification (this)); |
172 | MyCView.Active = 0; | |
173 | MyCView.IsDeleted = 0; | |
174 | ||
bf75be98 | 175 | MyCView.WsId = -1; |
176 | MyCView.DefWindow.IsDefined = 0; | |
7fd59977 | 177 | |
bf75be98 | 178 | MyCView.Context.NbActiveLight = 0; |
7fd59977 | 179 | |
7fd59977 | 180 | MyCView.Context.ZBufferActivity = -1; |
181 | ||
bd92cc2a | 182 | IsInitialized = Standard_False; |
7fd59977 | 183 | ComputedModeIsActive = Standard_False; |
184 | MyCView.Backfacing = 0; | |
7fd59977 | 185 | |
7fd59977 | 186 | MyCView.ptrUnderLayer = 0; |
187 | MyCView.ptrOverLayer = 0; | |
188 | MyCView.GContext = 0; | |
189 | MyCView.GDisplayCB = 0; | |
190 | MyCView.GClientData = 0; | |
191 | ||
dc3fe572 | 192 | MyGraphicDriver = MyViewManager->GraphicDriver(); |
7fd59977 | 193 | |
194 | } | |
195 | ||
7fd59977 | 196 | //-Methods, in order |
197 | // RIC120302 | |
198 | void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow, | |
199 | const Aspect_RenderingContext AContext, | |
200 | const Aspect_GraphicCallbackProc& ADisplayCB, | |
201 | const Standard_Address AClientData) | |
202 | { | |
203 | if (IsDeleted ()) return; | |
204 | ||
205 | if (IsDefined ()) | |
206 | Visual3d_ViewDefinitionError::Raise ("Window already defined"); | |
207 | ||
208 | MyCView.GContext = AContext; | |
209 | MyCView.GDisplayCB = ADisplayCB; | |
210 | MyCView.GClientData = AClientData; | |
211 | SetWindow(AWindow); | |
212 | } | |
213 | // RIC120302 | |
214 | ||
4fe56619 | 215 | void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow) |
216 | { | |
b5ac8292 | 217 | if (IsDeleted ()) return; |
7fd59977 | 218 | |
b5ac8292 | 219 | if (IsDefined ()) |
220 | { | |
221 | Visual3d_ViewDefinitionError::Raise ("Window already defined"); | |
222 | } | |
4fe56619 | 223 | |
b5ac8292 | 224 | MyWindow = theWindow; |
225 | MyCView.WsId = MyCView.ViewId; | |
226 | MyCView.DefWindow.IsDefined = 1; | |
4fe56619 | 227 | #if (defined(_WIN32) || defined(__WIN32__)) |
228 | const Handle(WNT_Window) aWin = Handle(WNT_Window)::DownCast (theWindow); | |
229 | MyCView.DefWindow.XWindow = (HWND )(aWin->HWindow()); | |
230 | MyCView.DefWindow.XParentWindow = (HWND )(aWin->HParentWindow()); | |
231 | WNT_WindowData* aWinData = (WNT_WindowData* )GetWindowLongPtr ((HWND )(aWin->HWindow()), GWLP_USERDATA); | |
232 | aWinData->WNT_WDriver_Ptr = (void* )this; | |
233 | aWinData->WNT_VMgr = (void* )MyPtrViewManager; | |
234 | #elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) | |
235 | const Handle(Cocoa_Window) aWin = Handle(Cocoa_Window)::DownCast (theWindow); | |
236 | MyCView.DefWindow.XWindow = (Aspect_Drawable )aWin->HView(); | |
237 | MyCView.DefWindow.XParentWindow = NULL; | |
238 | //MyCView.DefWindow.XParentWindow = aWin->HParentWindow(); | |
7fd59977 | 239 | #else |
4fe56619 | 240 | const Handle(Xw_Window) aWin = Handle(Xw_Window)::DownCast (theWindow); |
241 | MyCView.DefWindow.XWindow = aWin->XWindow(); | |
ed97f43c | 242 | //MyCView.DefWindow.XParentWindow = aWin->XParentWindow(); |
7fd59977 | 243 | #endif |
7fd59977 | 244 | |
245 | Standard_Integer Width, Height; | |
4fe56619 | 246 | theWindow->Size (Width, Height); |
7fd59977 | 247 | |
248 | MyCView.DefWindow.dx = float( Width ); | |
249 | MyCView.DefWindow.dy = float( Height ); | |
250 | ||
251 | Standard_Real R, G, B; | |
252 | MyBackground = MyWindow->Background (); | |
253 | (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB); | |
254 | MyCView.DefWindow.Background.r = float (R); | |
255 | MyCView.DefWindow.Background.g = float (G); | |
256 | MyCView.DefWindow.Background.b = float (B); | |
257 | ||
258 | UpdateView (); | |
259 | if (! MyGraphicDriver->View (MyCView)) | |
260 | Visual3d_ViewDefinitionError::Raise ("Association failed"); | |
261 | ||
262 | MyGradientBackground = MyWindow->GradientBackground(); | |
263 | SetGradientBackground(MyGradientBackground,1); | |
264 | ||
81bba717 | 265 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 266 | MyGraphicDriver->SetVisualisation (MyCView); |
267 | MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ()); | |
268 | MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ()); | |
269 | MyGraphicDriver->ClipLimit (MyCView, AWait); | |
270 | MyGraphicDriver->Environment(MyCView); | |
271 | ||
71c4f9c6 | 272 | // Make view manager z layer list consistent with the view's list. |
273 | MyViewManager->InstallZLayers (this); | |
274 | ||
81bba717 | 275 | // Update planses of model clipping |
7fd59977 | 276 | UpdatePlanes (); |
277 | ||
bf75be98 | 278 | // Update light sources |
7fd59977 | 279 | UpdateLights (); |
280 | ||
281 | /* | |
81bba717 | 282 | * Association view-window does not cause the display |
283 | * of structures that can be displayed in the new view. | |
284 | * In fact, association view-window is done, but the | |
285 | * display is produced only if the view is activated (Activate). | |
7fd59977 | 286 | */ |
287 | ||
288 | SetRatio (); | |
289 | ||
290 | } | |
291 | ||
292 | Handle(Aspect_Window) Visual3d_View::Window () const { | |
293 | ||
294 | if (! IsDefined ()) | |
295 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
296 | ||
297 | return (MyWindow); | |
298 | ||
299 | } | |
300 | ||
301 | Standard_Boolean Visual3d_View::IsDefined () const { | |
302 | ||
303 | if (MyCView.DefWindow.IsDefined) | |
304 | return (Standard_True); | |
305 | else | |
306 | return (Standard_False); | |
307 | ||
308 | } | |
309 | ||
310 | Standard_Boolean Visual3d_View::IsDeleted () const { | |
311 | ||
312 | if (MyCView.IsDeleted) | |
313 | return (Standard_True); | |
314 | else | |
315 | return (Standard_False); | |
316 | ||
317 | } | |
318 | ||
319 | void Visual3d_View::Destroy () { | |
320 | ||
321 | #ifdef DESTROY | |
322 | cout << "Visual3d_View::Destroy (" << Identification () << ")\n"; | |
323 | #endif | |
324 | ||
325 | // Since MyPtrViewManager can be already distroyed, | |
326 | // avoid attempts to access it in SetBackground() | |
327 | MyPtrViewManager = 0; | |
328 | Remove (); | |
329 | ||
330 | } | |
331 | ||
332 | void Visual3d_View::Remove () { | |
333 | ||
334 | #ifdef DESTROY | |
335 | cout << "Visual3d_View::Remove (" << Identification () << ")" << endl; | |
336 | #endif | |
337 | ||
338 | if (IsDeleted ()) return; | |
339 | if (! IsDefined ()) return; | |
340 | ||
341 | MyTOCOMPUTESequence.Clear (); | |
342 | MyCOMPUTEDSequence.Clear (); | |
343 | MyDisplayedStructure.Clear (); | |
344 | ||
345 | Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB); | |
346 | Aspect_Background BlackBackground (BlackColor); | |
347 | SetBackground (BlackBackground); | |
348 | ||
349 | Aspect_GradientBackground BlackGradBackground; | |
350 | SetGradientBackground (BlackGradBackground,0); | |
351 | ||
352 | if (MyPtrViewManager) | |
353 | MyPtrViewManager->UnIdentification( MyCView.ViewId ); | |
354 | ||
355 | MyGraphicDriver->RemoveView (MyCView); | |
356 | ||
357 | MyCView.WsId = -1; | |
358 | MyCView.IsDeleted = 1; | |
359 | MyCView.DefWindow.IsDefined = 0; | |
360 | ||
bd92cc2a | 361 | IsInitialized = Standard_False; |
362 | ||
7fd59977 | 363 | MyWindow.Nullify (); |
364 | ||
365 | } | |
366 | ||
367 | void Visual3d_View::Resized () { | |
368 | ||
369 | if (IsDeleted ()) return; | |
370 | ||
371 | if (! IsDefined ()) | |
372 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
373 | MyWindow->DoResize() ; | |
374 | SetRatio (); | |
375 | ||
376 | } | |
377 | ||
b5ac8292 | 378 | void Visual3d_View::SetRatio() |
379 | { | |
380 | if (IsDeleted()) | |
381 | { | |
382 | return; | |
383 | } | |
7fd59977 | 384 | |
b5ac8292 | 385 | Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode(); |
7fd59977 | 386 | |
b5ac8292 | 387 | MyViewManager->SetUpdateMode (Aspect_TOU_WAIT); |
7fd59977 | 388 | |
b5ac8292 | 389 | Standard_Integer aWidth, aHeight; |
7fd59977 | 390 | |
b5ac8292 | 391 | MyWindow->Size (aWidth, aHeight); |
7fd59977 | 392 | |
b5ac8292 | 393 | if( aWidth > 0 && aHeight > 0 ) |
394 | { | |
395 | Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight; | |
7fd59977 | 396 | |
b5ac8292 | 397 | MyCView.DefWindow.dx = Standard_ShortReal (aWidth); |
398 | MyCView.DefWindow.dy = Standard_ShortReal (aHeight); | |
7fd59977 | 399 | |
b5ac8292 | 400 | MyGraphicDriver->RatioWindow (MyCView); |
7fd59977 | 401 | |
b5ac8292 | 402 | // Update camera aspect |
403 | Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera; | |
7fd59977 | 404 | |
b5ac8292 | 405 | if (!aCamera.IsNull()) |
406 | { | |
407 | aCamera->SetAspect (aRatio); | |
408 | } | |
7fd59977 | 409 | |
b5ac8292 | 410 | if (!myDefaultCamera.IsNull()) |
411 | { | |
412 | myDefaultCamera->SetAspect (aRatio); | |
413 | } | |
414 | } | |
7fd59977 | 415 | |
b5ac8292 | 416 | MyViewManager->SetUpdateMode (UpdateMode); |
417 | if (UpdateMode == Aspect_TOU_ASAP) | |
418 | Update(); | |
7fd59977 | 419 | } |
420 | ||
12381341 | 421 | void Visual3d_View::UpdateLights() |
422 | { | |
423 | if (IsDeleted() | |
424 | || !IsDefined()) | |
425 | { | |
426 | return; | |
427 | } | |
7fd59977 | 428 | |
12381341 | 429 | if (MyContext.Model() == Visual3d_TOM_NONE) |
430 | { | |
431 | // activate only a white ambient light | |
432 | Graphic3d_CLight aCLight; | |
433 | aCLight.Type = Visual3d_TOLS_AMBIENT; | |
434 | aCLight.IsHeadlight = Standard_False; | |
435 | aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f; | |
7fd59977 | 436 | |
7fd59977 | 437 | MyCView.Context.NbActiveLight = 1; |
12381341 | 438 | MyCView.Context.ActiveLight = &aCLight; |
439 | MyGraphicDriver->SetLight (MyCView); | |
440 | MyCView.Context.ActiveLight = NULL; | |
441 | return; | |
7fd59977 | 442 | } |
7fd59977 | 443 | |
12381341 | 444 | MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(), |
445 | MyGraphicDriver->InquireLightLimit()); | |
446 | if (MyCView.Context.NbActiveLight < 1) | |
447 | { | |
4fe9ad57 | 448 | MyGraphicDriver->SetLight (MyCView); |
12381341 | 449 | return; |
450 | } | |
7fd59977 | 451 | |
12381341 | 452 | // parcing of light sources |
453 | MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight]; | |
454 | for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter) | |
455 | { | |
456 | MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight(); | |
457 | } | |
458 | MyGraphicDriver->SetLight (MyCView); | |
459 | delete[] MyCView.Context.ActiveLight; | |
460 | MyCView.Context.ActiveLight = NULL; | |
7fd59977 | 461 | } |
462 | ||
51b10cd4 | 463 | void Visual3d_View::UpdatePlanes() |
4269bd1b | 464 | { |
51b10cd4 | 465 | MyCView.Context.ClipPlanes = MyContext.ClipPlanes(); |
4269bd1b | 466 | if (IsDeleted() || !IsDefined()) |
51b10cd4 | 467 | { |
4269bd1b | 468 | return; |
51b10cd4 | 469 | } |
7fd59977 | 470 | |
4269bd1b | 471 | MyGraphicDriver->SetClipPlanes (MyCView); |
7fd59977 | 472 | } |
473 | ||
474 | void Visual3d_View::SetBackground (const Aspect_Background& ABack) { | |
475 | ||
476 | if (IsDeleted ()) return; | |
477 | ||
478 | if (! IsDefined ()) | |
479 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
480 | ||
81bba717 | 481 | // At this level, only GL can update the background. |
482 | // It is not necessary to call MyWindow->SetBackground (ABack); as | |
483 | // this method starts update of window background by X | |
484 | // (if the windowing is X) | |
7fd59977 | 485 | |
486 | Standard_Real R, G, B; | |
487 | MyBackground = ABack; | |
488 | (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB); | |
489 | MyCView.DefWindow.Background.r = float (R); | |
490 | MyCView.DefWindow.Background.g = float (G); | |
491 | MyCView.DefWindow.Background.b = float (B); | |
492 | ||
493 | MyGraphicDriver->Background (MyCView); | |
494 | ||
495 | if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP) | |
496 | Update (); | |
497 | ||
498 | } | |
499 | ||
500 | void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update) | |
501 | { | |
502 | ||
503 | if (IsDeleted ()) return; | |
504 | ||
505 | if (! IsDefined ()) | |
506 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
507 | ||
508 | MyGradientBackground = ABack; | |
509 | Quantity_Color aCol1,aCol2; | |
510 | MyGradientBackground.Colors(aCol1,aCol2); | |
511 | MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod()); | |
512 | ||
513 | if ( update ) | |
514 | Update (); | |
515 | else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP) | |
516 | Update(); | |
517 | } | |
518 | ||
519 | void Visual3d_View::SetBackgroundImage( const Standard_CString FileName, | |
520 | const Aspect_FillMethod FillStyle, | |
521 | const Standard_Boolean update ) | |
522 | { | |
7fd59977 | 523 | if ( IsDeleted() ) |
524 | return; | |
525 | if ( !IsDefined() ) | |
526 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
527 | ||
528 | MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle ); | |
529 | ||
530 | if ( update ) | |
531 | Update(); | |
532 | else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) | |
533 | Update(); | |
7fd59977 | 534 | } |
535 | ||
536 | void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle, | |
537 | const Standard_Boolean update ) | |
538 | { | |
7fd59977 | 539 | if ( IsDeleted() ) |
540 | return; | |
541 | if ( !IsDefined() ) | |
542 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
543 | ||
544 | MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle ); | |
545 | ||
546 | if ( update ) | |
547 | Update(); | |
548 | else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) | |
549 | Update(); | |
7fd59977 | 550 | } |
551 | ||
552 | Aspect_Background Visual3d_View::Background () const { | |
553 | ||
554 | return (MyBackground); | |
555 | ||
556 | } | |
557 | ||
558 | void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle, | |
559 | const Standard_Boolean update ) | |
560 | { | |
561 | if ( IsDeleted() ) | |
562 | return; | |
563 | if ( !IsDefined() ) | |
564 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
565 | ||
566 | MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle ); | |
567 | ||
568 | if ( update ) | |
569 | Update(); | |
570 | else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) | |
571 | Update(); | |
572 | ||
573 | } | |
574 | ||
575 | Aspect_GradientBackground Visual3d_View::GradientBackground () const { | |
576 | ||
577 | return MyGradientBackground; | |
578 | ||
579 | } | |
580 | ||
b5ac8292 | 581 | // ======================================================================= |
582 | // function : DefaultCamera | |
583 | // purpose : | |
584 | // ======================================================================= | |
585 | const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const | |
586 | { | |
587 | return myDefaultCamera; | |
7fd59977 | 588 | } |
589 | ||
b5ac8292 | 590 | // ======================================================================= |
591 | // function : Camera | |
592 | // purpose : | |
593 | // ======================================================================= | |
594 | const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const{ return MyCView.Context.Camera;} | |
7fd59977 | 595 | |
b5ac8292 | 596 | // ======================================================================= |
597 | // function : SetCamera | |
598 | // purpose : | |
599 | // ======================================================================= | |
600 | void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera) | |
601 | { | |
602 | MyCView.Context.Camera = theCamera; | |
7fd59977 | 603 | |
b5ac8292 | 604 | MyGraphicDriver->SetCamera (MyCView); |
7fd59977 | 605 | |
b5ac8292 | 606 | if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP) |
607 | { | |
608 | Update(); | |
609 | } | |
7fd59977 | 610 | } |
611 | ||
b5ac8292 | 612 | // ======================================================================= |
613 | // function : SetViewOrientationDefault | |
614 | // purpose : | |
615 | // ======================================================================= | |
616 | void Visual3d_View::SetViewOrientationDefault () | |
617 | { | |
618 | if (myDefaultCamera.IsNull()) | |
619 | { | |
620 | myDefaultCamera = new Graphic3d_Camera(); | |
621 | } | |
7fd59977 | 622 | |
b5ac8292 | 623 | myDefaultCamera->CopyOrientationData (MyCView.Context.Camera); |
7fd59977 | 624 | } |
625 | ||
b5ac8292 | 626 | // ======================================================================= |
627 | // function : ViewOrientationReset | |
628 | // purpose : | |
629 | // ======================================================================= | |
630 | void Visual3d_View::ViewOrientationReset () | |
631 | { | |
632 | if (IsDeleted()) | |
633 | { | |
634 | return; | |
635 | } | |
7fd59977 | 636 | |
b5ac8292 | 637 | if (!myDefaultCamera.IsNull()) |
638 | { | |
639 | MyCView.Context.Camera->CopyOrientationData (myDefaultCamera); | |
640 | } | |
7fd59977 | 641 | |
b5ac8292 | 642 | if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP) |
643 | { | |
644 | Update(); | |
645 | } | |
7fd59977 | 646 | } |
647 | ||
b5ac8292 | 648 | // ======================================================================= |
649 | // function : SetViewMappingDefault | |
650 | // purpose : | |
651 | // ======================================================================= | |
652 | void Visual3d_View::SetViewMappingDefault() | |
653 | { | |
654 | if (myDefaultCamera.IsNull()) | |
655 | { | |
656 | myDefaultCamera = new Graphic3d_Camera(); | |
657 | } | |
658 | myDefaultCamera->CopyMappingData (MyCView.Context.Camera); | |
7fd59977 | 659 | } |
660 | ||
b5ac8292 | 661 | // ======================================================================= |
662 | // function : ViewMappingReset | |
663 | // purpose : | |
664 | // ======================================================================= | |
665 | void Visual3d_View::ViewMappingReset () | |
666 | { | |
667 | if (IsDeleted ()) | |
668 | { | |
669 | return; | |
670 | } | |
7fd59977 | 671 | |
b5ac8292 | 672 | if (!myDefaultCamera.IsNull()) |
673 | { | |
674 | MyCView.Context.Camera->CopyMappingData (myDefaultCamera); | |
675 | } | |
7fd59977 | 676 | |
b5ac8292 | 677 | if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP) |
678 | { | |
679 | Update(); | |
680 | } | |
7fd59977 | 681 | } |
682 | ||
683 | void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) { | |
684 | ||
685 | if (IsDeleted ()) return; | |
686 | ||
687 | Visual3d_TypeOfVisualization OldVisualMode; | |
688 | Visual3d_TypeOfVisualization NewVisualMode; | |
689 | ||
bf75be98 | 690 | // To manage display only in case of |
81bba717 | 691 | // change of visualisation mode. |
7fd59977 | 692 | OldVisualMode = MyContext.Visualization (); |
693 | NewVisualMode = CTX.Visualization (); | |
694 | ||
695 | Visual3d_TypeOfModel OldModel; | |
696 | Visual3d_TypeOfModel NewModel; | |
697 | ||
bf75be98 | 698 | // To manage change of visualisation only in case |
81bba717 | 699 | // of change of mode of visualisation or of type of shading. |
7fd59977 | 700 | OldModel = MyContext.Model (); |
701 | NewModel = CTX.Model (); | |
702 | ||
703 | Standard_Boolean OldAliasingMode; | |
704 | Standard_Boolean NewAliasingMode; | |
705 | ||
81bba717 | 706 | // To manage antialiasing only in case of change. |
7fd59977 | 707 | OldAliasingMode = MyContext.AliasingIsOn (); |
708 | NewAliasingMode = CTX.AliasingIsOn (); | |
709 | ||
710 | Standard_Boolean OldDepthCueingMode; | |
711 | Standard_Boolean NewDepthCueingMode; | |
712 | ||
713 | Standard_Real OldDepthCueingFrontPlane; | |
714 | Standard_Real NewDepthCueingFrontPlane; | |
715 | Standard_Real OldDepthCueingBackPlane; | |
716 | Standard_Real NewDepthCueingBackPlane; | |
717 | ||
81bba717 | 718 | // To manage the depth cueing only in case of change. |
7fd59977 | 719 | OldDepthCueingMode = MyContext.DepthCueingIsOn (); |
720 | NewDepthCueingMode = CTX.DepthCueingIsOn (); | |
721 | ||
722 | OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane (); | |
723 | NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane (); | |
724 | OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane (); | |
725 | NewDepthCueingBackPlane = CTX.DepthCueingBackPlane (); | |
726 | ||
727 | Standard_Boolean OldFrontZClippingMode; | |
728 | Standard_Boolean NewFrontZClippingMode; | |
729 | Standard_Boolean OldBackZClippingMode; | |
730 | Standard_Boolean NewBackZClippingMode; | |
731 | ||
732 | Standard_Real OldZClippingFrontPlane; | |
733 | Standard_Real NewZClippingFrontPlane; | |
734 | Standard_Real OldZClippingBackPlane; | |
735 | Standard_Real NewZClippingBackPlane; | |
736 | ||
81bba717 | 737 | // To manage the Zclipping only in case of change. |
7fd59977 | 738 | OldFrontZClippingMode = MyContext.FrontZClippingIsOn (); |
739 | NewFrontZClippingMode = CTX.FrontZClippingIsOn (); | |
740 | OldBackZClippingMode = MyContext.BackZClippingIsOn (); | |
741 | NewBackZClippingMode = CTX.BackZClippingIsOn (); | |
742 | ||
743 | OldZClippingFrontPlane = MyContext.ZClippingFrontPlane (); | |
744 | NewZClippingFrontPlane = CTX.ZClippingFrontPlane (); | |
745 | OldZClippingBackPlane = MyContext.ZClippingBackPlane (); | |
746 | NewZClippingBackPlane = CTX.ZClippingBackPlane (); | |
747 | ||
bf75be98 | 748 | Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv(); |
749 | Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv(); | |
7fd59977 | 750 | |
bf75be98 | 751 | Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail(); |
752 | Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail(); | |
7fd59977 | 753 | |
754 | MyContext = CTX; | |
755 | ||
756 | UpdateView (); | |
757 | ||
81bba717 | 758 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 759 | if (IsDefined ()) { |
81bba717 | 760 | // management of visualization modes and types of shading. |
7fd59977 | 761 | if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel)) |
762 | MyGraphicDriver->SetVisualisation (MyCView); | |
763 | ||
81bba717 | 764 | // management of antialiasing. |
7fd59977 | 765 | if (OldAliasingMode != NewAliasingMode) |
766 | MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode); | |
767 | ||
81bba717 | 768 | // management of depth_cueing. |
7fd59977 | 769 | if ((OldDepthCueingMode != NewDepthCueingMode) || |
770 | (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) || | |
771 | (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) { | |
772 | #ifdef BUC60572 | |
773 | if( NewDepthCueingMode && | |
774 | (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) ) | |
775 | Visual3d_DepthCueingDefinitionError::Raise | |
776 | ("Bad value for DepthCueingPlanes position"); | |
777 | #endif | |
778 | MyGraphicDriver->DepthCueing | |
779 | (MyCView, NewDepthCueingMode); | |
780 | } | |
781 | ||
81bba717 | 782 | // management of Zclipping |
7fd59977 | 783 | if ((OldFrontZClippingMode != NewFrontZClippingMode) || |
784 | (OldBackZClippingMode != NewBackZClippingMode) || | |
785 | (OldZClippingFrontPlane != NewZClippingFrontPlane) || | |
786 | (OldZClippingBackPlane != NewZClippingBackPlane)) { | |
787 | #ifdef BUC60572 | |
788 | if( NewBackZClippingMode && NewFrontZClippingMode && | |
789 | (NewZClippingBackPlane >= NewZClippingFrontPlane) ) | |
790 | Visual3d_ZClippingDefinitionError::Raise | |
791 | ("Bad value for ZClippingPlanes position"); | |
792 | #endif | |
793 | MyGraphicDriver->ClipLimit (MyCView, AWait); | |
794 | } | |
795 | ||
81bba717 | 796 | // management of textures |
bf75be98 | 797 | if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail)) |
798 | { | |
7fd59977 | 799 | MyGraphicDriver->Environment(MyCView); |
bf75be98 | 800 | } |
7fd59977 | 801 | |
81bba717 | 802 | // Update of planes of model clipping |
7fd59977 | 803 | UpdatePlanes (); |
804 | ||
bf75be98 | 805 | // Update of light sources |
7fd59977 | 806 | UpdateLights (); |
807 | } | |
808 | ||
809 | if (OldVisualMode != NewVisualMode) { | |
810 | ||
811 | /* | |
81bba717 | 812 | * Change of context => |
813 | * Remove structures that cannot be displayed | |
814 | * in the new visualisation mode. | |
815 | * It is not necessary to warn ViewManager as | |
816 | * this structure should not disappear from | |
817 | * the list of structures displayed in it. | |
7fd59977 | 818 | */ |
819 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
820 | Visual3d_TypeOfAnswer Answer; | |
821 | ||
822 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
823 | ||
824 | Graphic3d_SequenceOfStructure FooSequence; | |
825 | ||
826 | while (S1Iterator.More ()) { | |
827 | Answer = AcceptDisplay (S1Iterator.Key ()); | |
bf75be98 | 828 | // If the structure can't be displayed in the |
81bba717 | 829 | // new context of the view, it is removed. |
7fd59977 | 830 | if ((Answer == Visual3d_TOA_NO) || |
831 | (Answer == Visual3d_TOA_COMPUTE)) | |
832 | //Erase (S1Iterator.Key (), Aspect_TOU_WAIT); | |
833 | FooSequence.Append (S1Iterator.Key ()); | |
834 | ||
81bba717 | 835 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 836 | S1Iterator.Next (); |
837 | } | |
838 | ||
839 | Standard_Integer Length = FooSequence.Length (); | |
81bba717 | 840 | // The stored structures are removed |
7fd59977 | 841 | for (i=1; i<=Length; i++) |
842 | Erase (FooSequence.Value (i), Aspect_TOU_WAIT); | |
843 | if (Length != 0) FooSequence.Clear (); | |
844 | ||
845 | /* | |
81bba717 | 846 | * Change of context => |
bf75be98 | 847 | * Display structures that can be displayed |
81bba717 | 848 | * with the new visualisation mode. |
bf75be98 | 849 | * All structures with status Displayed are removed from the ViewManager |
850 | * and displayed in the view directly, if the structure is not already | |
81bba717 | 851 | * displayed and if the view accepts it in its context. |
7fd59977 | 852 | */ |
853 | ||
854 | i = MyViewManager->NumberOfDisplayedStructures (); | |
855 | Graphic3d_MapOfStructure Map; | |
856 | MyViewManager->DisplayedStructures(Map); | |
857 | Graphic3d_MapIteratorOfMapOfStructure it(Map); | |
858 | ||
859 | for (; it.More(); it.Next()) { | |
860 | Handle(Graphic3d_Structure) SG = it.Key(); | |
861 | if (! IsDisplayed (SG)) { | |
862 | Answer = AcceptDisplay(SG); | |
bf75be98 | 863 | // If the structure can be displayed in the |
81bba717 | 864 | // new context of the view, it is displayed. |
7fd59977 | 865 | if ((Answer == Visual3d_TOA_YES) || |
866 | (Answer == Visual3d_TOA_COMPUTE)) | |
867 | //Display (MyViewManager->DisplayedStructure (j), | |
868 | //Aspect_TOU_WAIT); | |
869 | FooSequence.Append (SG); | |
870 | } | |
871 | } | |
872 | ||
873 | Length = FooSequence.Length (); | |
81bba717 | 874 | // The stored structures are displayed |
7fd59977 | 875 | for (i=1; i<=Length; i++) |
876 | Display (FooSequence.Value (i), Aspect_TOU_WAIT); | |
877 | if (Length != 0) FooSequence.Clear (); | |
878 | } | |
879 | ||
880 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
881 | ||
882 | } | |
883 | ||
884 | const Visual3d_ContextView& Visual3d_View::Context () const { | |
885 | ||
886 | return (MyContext); | |
887 | ||
888 | } | |
889 | ||
890 | void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const | |
891 | { | |
892 | ||
893 | if (IsDeleted ()) return; | |
894 | ||
895 | Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure); | |
896 | ||
897 | while (Iterator.More ()) { | |
898 | SG.Add (Iterator.Key ()); | |
899 | ||
81bba717 | 900 | // Iterator.Next () is located on the next structure |
7fd59977 | 901 | Iterator.Next (); |
902 | } | |
903 | ||
904 | } | |
905 | ||
906 | void Visual3d_View::Activate () { | |
907 | ||
908 | if (IsDeleted ()) return; | |
909 | ||
910 | if (! IsDefined ()) | |
911 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
912 | ||
913 | if (! IsActive ()) { | |
914 | ||
915 | MyGraphicDriver->ActivateView (MyCView); | |
916 | MyGraphicDriver->Background (MyCView); | |
917 | MyGraphicDriver->Transparency | |
918 | (MyCView, MyViewManager->Transparency ()); | |
919 | ||
920 | MyCView.Active = 1; | |
921 | ||
922 | /* | |
81bba717 | 923 | * Activation of a new view => |
924 | * Display structures that can be displayed in this new view. | |
925 | * All structures with status | |
bf75be98 | 926 | * Displayed in ViewManager are returned and displayed in |
927 | * the view directly, if the structure is not already | |
81bba717 | 928 | * displayed and if the view accepts it in its context. |
7fd59977 | 929 | */ |
930 | ||
931 | Visual3d_TypeOfAnswer Answer; | |
932 | Graphic3d_MapOfStructure Map; | |
933 | MyViewManager->DisplayedStructures(Map); | |
934 | Graphic3d_MapIteratorOfMapOfStructure it(Map); | |
935 | ||
936 | for (; it.More(); it.Next()) { | |
937 | Handle(Graphic3d_Structure) SG = it.Key(); | |
938 | if (! IsDisplayed (SG)) { | |
939 | Answer = AcceptDisplay(SG); | |
81bba717 | 940 | // If the structure can be displayed in the |
941 | // new context of the view, it is displayed. | |
7fd59977 | 942 | if ((Answer == Visual3d_TOA_YES) || |
943 | (Answer == Visual3d_TOA_COMPUTE)) | |
944 | Display (SG,Aspect_TOU_WAIT); | |
945 | } | |
946 | } | |
947 | ||
948 | } | |
949 | ||
81bba717 | 950 | // If the activation/desactivation of ZBuffer should be automatic |
951 | // depending on the presence or absence of facets. | |
7fd59977 | 952 | if (MyViewManager->ZBufferAuto ()) { |
953 | Standard_Boolean BContainsFacet = ContainsFacet (); | |
954 | Standard_Boolean BZBuffer = ZBufferIsActivated (); | |
81bba717 | 955 | // If the view contains facets |
956 | // and if ZBuffer is not active | |
7fd59977 | 957 | if (BContainsFacet && ! BZBuffer) |
958 | SetZBufferActivity (1); | |
81bba717 | 959 | // If the view does not contain facets |
960 | // and if ZBuffer is active | |
7fd59977 | 961 | if (! BContainsFacet && BZBuffer) |
962 | SetZBufferActivity (0); | |
963 | } | |
964 | ||
965 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
966 | ||
967 | } | |
968 | ||
969 | Standard_Boolean Visual3d_View::IsActive () const { | |
970 | ||
971 | if (IsDeleted ()) return (Standard_False); | |
972 | ||
973 | if (MyCView.Active) | |
974 | return (Standard_True); | |
975 | else | |
976 | return (Standard_False); | |
977 | ||
978 | } | |
979 | ||
980 | void Visual3d_View::Deactivate () { | |
981 | ||
982 | if (IsDeleted ()) return; | |
983 | ||
984 | if (! IsDefined ()) | |
985 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
986 | ||
987 | if (IsActive ()) { | |
988 | ||
989 | MyGraphicDriver->DeactivateView (MyCView); | |
990 | ||
991 | /* | |
81bba717 | 992 | * Deactivation of a view => |
993 | * Removal of structures displayed in this view. | |
994 | * All structures with status | |
bf75be98 | 995 | * Displayed in ViewManager are returned and removed from |
996 | * the view directly, if the structure is not already | |
81bba717 | 997 | * displayed and if the view accepts it in its context. |
998 | */ | |
7fd59977 | 999 | |
1000 | Visual3d_TypeOfAnswer Answer; | |
1001 | Graphic3d_MapOfStructure Map; | |
1002 | MyViewManager->DisplayedStructures(Map); | |
1003 | Graphic3d_MapIteratorOfMapOfStructure it(Map); | |
1004 | ||
1005 | for (; it.More(); it.Next()) { | |
1006 | Handle(Graphic3d_Structure) SG = it.Key(); | |
1007 | if (! IsDisplayed (SG)) { | |
1008 | Answer = AcceptDisplay(SG); | |
81bba717 | 1009 | // If the structure was displayed it is removed. |
7fd59977 | 1010 | if ((Answer == Visual3d_TOA_YES) || |
1011 | (Answer == Visual3d_TOA_COMPUTE)) | |
1012 | Erase (SG,Aspect_TOU_WAIT); | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1017 | ||
81bba717 | 1018 | // No action currently possible in the view |
7fd59977 | 1019 | MyCView.Active = 0; |
1020 | } | |
1021 | ||
1022 | } | |
1023 | ||
679ecdee | 1024 | void Visual3d_View::Redraw() |
1025 | { | |
1026 | Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0); | |
7fd59977 | 1027 | } |
1028 | ||
679ecdee | 1029 | void Visual3d_View::Redraw (const Standard_Integer theX, |
1030 | const Standard_Integer theY, | |
1031 | const Standard_Integer theWidth, | |
1032 | const Standard_Integer theHeight) | |
1033 | { | |
1034 | Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), | |
1035 | theX, theY, theWidth, theHeight); | |
7fd59977 | 1036 | } |
1037 | ||
679ecdee | 1038 | void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer, |
1039 | const Handle(Visual3d_Layer)& theOverLayer) | |
1040 | { | |
1041 | Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0); | |
1042 | } | |
7fd59977 | 1043 | |
679ecdee | 1044 | void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer, |
1045 | const Handle(Visual3d_Layer)& theOverLayer, | |
1046 | const Standard_Integer theX, | |
1047 | const Standard_Integer theY, | |
1048 | const Standard_Integer theWidth, | |
1049 | const Standard_Integer theHeight) | |
1050 | { | |
1051 | if (IsDeleted() | |
1052 | || !IsDefined() | |
1053 | || !IsActive() | |
1054 | || !MyWindow->IsMapped()) | |
1055 | { | |
1056 | return; | |
1057 | } | |
7fd59977 | 1058 | |
679ecdee | 1059 | if (MyGraphicDriver->IsDeviceLost()) |
1060 | { | |
1061 | MyViewManager->RecomputeStructures(); | |
1062 | MyViewManager->RecomputeStructures (myImmediateStructures); | |
1063 | MyGraphicDriver->ResetDeviceLostFlag(); | |
1064 | } | |
7fd59977 | 1065 | |
679ecdee | 1066 | // set up Z buffer state before redrawing |
1067 | if (MyViewManager->ZBufferAuto()) | |
1068 | { | |
1069 | const Standard_Boolean hasFacet = ContainsFacet(); | |
1070 | const Standard_Boolean hasZBuffer = ZBufferIsActivated(); | |
1071 | // if the view contains facets and if ZBuffer is not active | |
1072 | if (hasFacet && !hasZBuffer) | |
1073 | { | |
1074 | SetZBufferActivity (1); | |
1075 | } | |
1076 | // if the view contains only facets and if ZBuffer is active | |
1077 | if (!hasFacet && hasZBuffer) | |
1078 | { | |
1079 | SetZBufferActivity (0); | |
1080 | } | |
1081 | } | |
7fd59977 | 1082 | |
679ecdee | 1083 | Aspect_CLayer2d anOverCLayer, anUnderCLayer; |
1084 | anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL; | |
1085 | if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer(); | |
1086 | if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer(); | |
1087 | MyGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight); | |
7fd59977 | 1088 | } |
1089 | ||
679ecdee | 1090 | void Visual3d_View::RedrawImmediate() |
1091 | { | |
1092 | RedrawImmediate (MyViewManager->UnderLayer(), MyViewManager->OverLayer()); | |
1093 | } | |
7fd59977 | 1094 | |
679ecdee | 1095 | void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer, |
1096 | const Handle(Visual3d_Layer)& theOverLayer) | |
1097 | { | |
1098 | if (IsDeleted() | |
1099 | || !IsDefined() | |
1100 | || !IsActive() | |
1101 | || !MyWindow->IsMapped()) | |
1102 | { | |
1103 | return; | |
1104 | } | |
7fd59977 | 1105 | |
679ecdee | 1106 | Aspect_CLayer2d anOverCLayer, anUnderCLayer; |
1107 | anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL; | |
1108 | if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer(); | |
1109 | if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer(); | |
1110 | MyGraphicDriver->RedrawImmediate (MyCView, anUnderCLayer, anOverCLayer); | |
1111 | } | |
7fd59977 | 1112 | |
679ecdee | 1113 | void Visual3d_View::Invalidate() |
1114 | { | |
1115 | MyGraphicDriver->Invalidate (MyCView); | |
7fd59977 | 1116 | } |
1117 | ||
679ecdee | 1118 | void Visual3d_View::Update() |
b5ac8292 | 1119 | { |
1120 | IsInitialized = Standard_True; | |
b5ac8292 | 1121 | Compute (); |
7fd59977 | 1122 | |
679ecdee | 1123 | Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0); |
7fd59977 | 1124 | } |
1125 | ||
679ecdee | 1126 | void Visual3d_View::Update (const Handle(Visual3d_Layer)& theUnderLayer, |
1127 | const Handle(Visual3d_Layer)& theOverLayer) | |
1128 | { | |
1129 | IsInitialized = Standard_True; | |
1130 | Compute (); | |
7fd59977 | 1131 | |
679ecdee | 1132 | Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0); |
7fd59977 | 1133 | } |
1134 | ||
1135 | Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const { | |
1136 | ||
81bba717 | 1137 | // Return type of visualization of the view |
7fd59977 | 1138 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
1139 | ||
81bba717 | 1140 | // Return type of visualization of the structure |
7fd59977 | 1141 | Graphic3d_TypeOfStructure StructType = AStructure->Visual (); |
1142 | ||
1143 | Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO; | |
1144 | ||
1145 | if (StructType == Graphic3d_TOS_ALL) | |
81bba717 | 1146 | // The structure accepts any type of view |
7fd59977 | 1147 | Result = Visual3d_TOA_YES; |
1148 | else { | |
1149 | if ((StructType == Graphic3d_TOS_SHADING) | |
1150 | && (ViewType == Visual3d_TOV_SHADING)) | |
1151 | Result = Visual3d_TOA_YES; | |
1152 | if ((StructType == Graphic3d_TOS_WIREFRAME) | |
1153 | && (ViewType == Visual3d_TOV_WIREFRAME)) | |
1154 | Result = Visual3d_TOA_YES; | |
1155 | if ((StructType == Graphic3d_TOS_COMPUTED) | |
1156 | && (ViewType == Visual3d_TOV_WIREFRAME)) | |
1157 | Result = Visual3d_TOA_COMPUTE; | |
1158 | if ((StructType == Graphic3d_TOS_COMPUTED) | |
1159 | && (ViewType == Visual3d_TOV_SHADING)) | |
1160 | Result = Visual3d_TOA_COMPUTE; | |
1161 | } | |
1162 | ||
1163 | #ifdef TRACE_ACCEPT | |
1164 | if (Result == Visual3d_TOA_YES) | |
1165 | cout << "YES = Visual3d_View" << MyCView.ViewId | |
1166 | << "::AcceptDisplay (" << AStructure->Identification () << ")\n"; | |
1167 | if (Result == Visual3d_TOA_NO) | |
1168 | cout << "NO = Visual3d_View" << MyCView.ViewId | |
1169 | << "::AcceptDisplay (" << AStructure->Identification () << ")\n"; | |
1170 | if (Result == Visual3d_TOA_COMPUTE) | |
1171 | cout << "COMPUTE = Visual3d_View" << MyCView.ViewId | |
1172 | << "::AcceptDisplay (" << AStructure->Identification () << ")\n"; | |
1173 | cout << flush; | |
1174 | #endif | |
1175 | ||
1176 | return (Result); | |
1177 | ||
1178 | } | |
1179 | ||
35e08fe8 | 1180 | void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer /*OldPriority*/, const Standard_Integer NewPriority) { |
7fd59977 | 1181 | |
1182 | if (IsDeleted ()) return; | |
1183 | if (! IsDefined ()) return; | |
1184 | if (! IsActive ()) return; | |
1185 | if (! IsDisplayed (AStructure)) return; | |
1186 | ||
1187 | Standard_Integer Index = IsComputed (AStructure); | |
de75ed09 | 1188 | if (Index != 0 && ComputedMode()) |
7fd59977 | 1189 | { |
1190 | #ifdef TRACE | |
1191 | Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification (); | |
1192 | cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority (" | |
1193 | << AStructure->Identification () << "/" << StructId | |
1194 | << ", " << OldPriority << ", " << NewPriority << ")\n"; | |
1195 | cout << flush; | |
1196 | #endif | |
63bcc448 | 1197 | MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure())); |
1198 | MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), NewPriority); | |
7fd59977 | 1199 | } |
63bcc448 | 1200 | else |
1201 | { | |
7fd59977 | 1202 | #ifdef TRACE |
1203 | Standard_Integer StructId = AStructure->Identification (); | |
1204 | cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority (" | |
1205 | << AStructure->Identification () << "/" << StructId | |
1206 | << ", " << OldPriority << ", " << NewPriority << ")\n"; | |
1207 | cout << flush; | |
1208 | #endif | |
63bcc448 | 1209 | MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure())); |
1210 | MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), NewPriority); | |
7fd59977 | 1211 | } |
1212 | ||
1213 | } | |
1214 | ||
1215 | void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) { | |
1216 | ||
1217 | #ifdef TRACE_CLEAR | |
1218 | cout << "Visual3d_View" << MyCView.ViewId << "::Clear (" | |
1219 | << AStructure->Identification () << ")\n"; | |
1220 | cout << flush; | |
1221 | #endif | |
1222 | ||
1223 | Standard_Integer Index = IsComputed (AStructure); | |
1224 | if (Index != 0) { | |
1225 | #ifdef TRACE_CLEAR | |
81bba717 | 1226 | cout << "Structure " << AStructure->Identification () |
1227 | << " calculated in the view " | |
1228 | << Identification () << ", by structure " | |
7fd59977 | 1229 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 1230 | << " is emptied.\n"; |
7fd59977 | 1231 | cout << flush; |
1232 | #endif | |
1233 | MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction); | |
1234 | MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False); | |
1235 | } | |
1236 | ||
1237 | } | |
1238 | ||
1239 | void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) { | |
1240 | ||
1241 | #ifdef TRACE_CONNECT | |
1242 | cout << "Visual3d_View" << MyCView.ViewId << "::Connect (" | |
1243 | << AMother->Identification () | |
1244 | << ADaughter->Identification () << ")\n"; | |
1245 | cout << flush; | |
1246 | #endif | |
1247 | ||
1248 | Standard_Integer IndexM = IsComputed (AMother); | |
1249 | Standard_Integer IndexD = IsComputed (ADaughter); | |
1250 | ||
1251 | if (IndexM != 0 && IndexD != 0) { | |
1252 | #ifdef TRACE_CONNECT | |
81bba717 | 1253 | cout << "Structure " << AMother->Identification () |
1254 | << " is connected to structure " | |
7fd59977 | 1255 | << ADaughter->Identification () << endl; |
81bba717 | 1256 | cout << "These structures are calculated.\n"; |
1257 | cout << "In the view " << Identification () | |
1258 | << "Structure " | |
7fd59977 | 1259 | << MyCOMPUTEDSequence.Value (IndexM)->Identification () |
81bba717 | 1260 | << " is connected to the structure " |
7fd59977 | 1261 | << MyCOMPUTEDSequence.Value (IndexD)->Identification () |
1262 | << endl; | |
1263 | #endif | |
1264 | MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD)); | |
1265 | } | |
1266 | ||
1267 | } | |
1268 | ||
1269 | void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) { | |
1270 | ||
1271 | #ifdef TRACE_CONNECT | |
1272 | cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect (" | |
1273 | << AMother->Identification () | |
1274 | << ADaughter->Identification () << ")\n"; | |
1275 | cout << flush; | |
1276 | #endif | |
1277 | ||
1278 | Standard_Integer IndexM = IsComputed (AMother); | |
1279 | Standard_Integer IndexD = IsComputed (ADaughter); | |
1280 | ||
1281 | if (IndexM != 0 && IndexD != 0) { | |
1282 | #ifdef TRACE_CONNECT | |
81bba717 | 1283 | cout << "Structure " << AMother->Identification () |
1284 | << " is disconnected from the structure " | |
7fd59977 | 1285 | << ADaughter->Identification () << endl; |
81bba717 | 1286 | cout << "These structures are calculated.\n"; |
1287 | cout << "In the view " << Identification () | |
1288 | << "Structure " | |
7fd59977 | 1289 | << MyCOMPUTEDSequence.Value (IndexM)->Identification () |
81bba717 | 1290 | << " is disconnected from the structure " |
7fd59977 | 1291 | << MyCOMPUTEDSequence.Value (IndexD)->Identification () |
1292 | << endl; | |
1293 | #endif | |
1294 | MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD)); | |
1295 | } | |
1296 | ||
1297 | } | |
1298 | ||
679ecdee | 1299 | Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure, |
1300 | const Standard_Boolean theIsSingleView) | |
1301 | { | |
1302 | if (!myImmediateStructures.Add (theStructure)) | |
1303 | { | |
1304 | return Standard_False; | |
1305 | } | |
1306 | ||
1307 | if (theIsSingleView) | |
1308 | { | |
1309 | Handle_Visual3d_HSetOfView aViews = MyViewManager->DefinedView(); | |
1310 | for (Visual3d_SetIteratorOfSetOfView aViewIter (aViews->Set()); aViewIter.More(); aViewIter.Next()) | |
1311 | { | |
1312 | if (aViewIter.Value().Access() != this) | |
1313 | { | |
1314 | aViewIter.Value()->EraseImmediate (theStructure); | |
1315 | } | |
1316 | } | |
1317 | } | |
1318 | ||
1319 | MyGraphicDriver->DisplayImmediateStructure (MyCView, *theStructure->CStructure()); | |
1320 | return Standard_True; | |
1321 | } | |
1322 | ||
1323 | Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure) | |
1324 | { | |
1325 | const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure); | |
1326 | if (isErased) | |
1327 | { | |
1328 | MyGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure()); | |
1329 | } | |
1330 | ||
1331 | return isErased; | |
1332 | } | |
1333 | ||
1334 | Standard_Boolean Visual3d_View::ClearImmediate() | |
1335 | { | |
1336 | if (myImmediateStructures.IsEmpty()) | |
1337 | { | |
1338 | return Standard_False; | |
1339 | } | |
1340 | ||
1341 | for (Graphic3d_MapIteratorOfMapOfStructure anIter (myImmediateStructures); anIter.More(); anIter.Next()) | |
1342 | { | |
1343 | MyGraphicDriver->EraseImmediateStructure (MyCView, *anIter.Key()->CStructure()); | |
1344 | } | |
1345 | myImmediateStructures.Clear(); | |
1346 | return Standard_True; | |
1347 | } | |
1348 | ||
7fd59977 | 1349 | void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) { |
1350 | ||
1351 | Display (AStructure, MyViewManager->UpdateMode ()); | |
1352 | ||
1353 | } | |
1354 | ||
1355 | void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) { | |
1356 | ||
1357 | if (IsDeleted ()) return; | |
1358 | if (! IsDefined ()) return; | |
1359 | if (! IsActive ()) return; | |
1360 | ||
81bba717 | 1361 | // If Display on a structure present in the list |
bf75be98 | 1362 | // of calculated structures while it is not |
81bba717 | 1363 | // or more, of calculated type => |
1364 | // - removes it as well as the associated old computed | |
1365 | // THis happens when hlhsr becomes again of type e | |
1366 | // non computed after SetVisual. | |
7fd59977 | 1367 | Standard_Integer Index = IsComputed (AStructure); |
1368 | ||
1369 | if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) { | |
7fd59977 | 1370 | MyTOCOMPUTESequence.Remove (Index); |
1371 | MyCOMPUTEDSequence.Remove (Index); | |
7fd59977 | 1372 | Index = 0; |
1373 | } | |
1374 | ||
1375 | Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure); | |
1376 | ||
7fd59977 | 1377 | if (Answer == Visual3d_TOA_NO) { |
7fd59977 | 1378 | return; |
1379 | } | |
1380 | ||
de75ed09 | 1381 | if (!ComputedMode()) |
1382 | { | |
1383 | Answer = Visual3d_TOA_YES; | |
1384 | } | |
7fd59977 | 1385 | |
1386 | if (Answer == Visual3d_TOA_YES ) { | |
7fd59977 | 1387 | if (IsDisplayed (AStructure)) return; |
63bcc448 | 1388 | MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), AStructure->DisplayPriority()); |
7fd59977 | 1389 | MyDisplayedStructure.Add (AStructure); |
1390 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
1391 | } | |
1392 | ||
1393 | if (Answer == Visual3d_TOA_COMPUTE) { | |
7fd59977 | 1394 | if (Index != 0) { |
81bba717 | 1395 | // Already computed, is COMPUTED still valid? |
7fd59977 | 1396 | Standard_Integer OldStructId = |
1397 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
1398 | ||
81bba717 | 1399 | // Case COMPUTED valide |
7fd59977 | 1400 | if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) { |
81bba717 | 1401 | // to be displayed |
7fd59977 | 1402 | if (! IsDisplayed (AStructure)) { |
1403 | MyDisplayedStructure.Add (AStructure); | |
63bcc448 | 1404 | MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), AStructure->DisplayPriority ()); |
7fd59977 | 1405 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); |
1406 | } | |
1407 | return; | |
1408 | } | |
1409 | ||
81bba717 | 1410 | // Case COMPUTED invalid |
7fd59977 | 1411 | else { |
81bba717 | 1412 | // Is there another valid representation ? |
1413 | // Find in the sequence of already calculated structures | |
1414 | // 1/ Structure having the same Owner as <AStructure> | |
1415 | // 2/ That is not <AStructure> | |
1416 | // 3/ The COMPUTED which of is valid | |
7fd59977 | 1417 | Standard_Integer NewIndex = HaveTheSameOwner (AStructure); |
1418 | ||
81bba717 | 1419 | // Case of COMPUTED invalid, WITH a valid of replacement |
7fd59977 | 1420 | if (NewIndex != 0) { |
81bba717 | 1421 | // to be displayed |
7fd59977 | 1422 | if (! IsDisplayed (AStructure)) { |
1423 | MyCOMPUTEDSequence.SetValue | |
1424 | (Index, MyCOMPUTEDSequence.Value (NewIndex)); | |
1425 | OldStructId = MyCOMPUTEDSequence.Value (NewIndex)-> | |
1426 | Identification (); | |
1427 | MyDisplayedStructure.Add (AStructure); | |
63bcc448 | 1428 | MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (NewIndex)->CStructure()), AStructure->DisplayPriority ()); |
7fd59977 | 1429 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); |
1430 | } | |
1431 | return; | |
1432 | } | |
1433 | ||
81bba717 | 1434 | // Cas COMPUTED invalid, WITHOUT a valid of replacement |
7fd59977 | 1435 | else { |
bf75be98 | 1436 | // COMPUTED is removed if displayed |
7fd59977 | 1437 | if (IsDisplayed (AStructure)) |
63bcc448 | 1438 | MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure())); |
7fd59977 | 1439 | } |
1440 | } | |
1441 | } // if (Index != 0) | |
1442 | ||
1443 | // Compute + Validation | |
1444 | #ifdef OLD | |
1445 | Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this); | |
1446 | #else | |
1447 | Handle(Graphic3d_Structure) TheStructure; | |
1448 | TColStd_Array2OfReal ATrsf (0, 3, 0, 3); | |
1449 | AStructure->Transform (ATrsf); | |
1450 | if (Index != 0) { | |
1451 | TColStd_Array2OfReal Ident (0, 3, 0, 3); | |
1452 | Standard_Integer ii, jj; | |
1453 | for (ii=0; ii<=3; ii++) | |
1454 | for (jj=0; jj<=3; jj++) | |
1455 | Ident (ii, jj) = (ii == jj ? 1.0 : 0.0); | |
1456 | TheStructure = MyCOMPUTEDSequence.Value (Index); | |
1457 | TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE); | |
1458 | if (AStructure->IsTransformed ()) { | |
1459 | AStructure->Compute (this, ATrsf, TheStructure); | |
1460 | } | |
1461 | else { | |
1462 | AStructure->Compute (this, TheStructure); | |
1463 | } | |
1464 | } | |
1465 | else { | |
1466 | if (AStructure->IsTransformed ()) { | |
1467 | TheStructure = AStructure->Compute (this, ATrsf); | |
1468 | } | |
1469 | else { | |
1470 | TheStructure = AStructure->Compute (this); | |
1471 | } | |
1472 | } | |
1473 | #endif | |
1474 | TheStructure->SetHLRValidation (Standard_True); | |
1475 | ||
81bba717 | 1476 | // TOCOMPUTE and COMPUTED associated to sequences are added |
7fd59977 | 1477 | MyTOCOMPUTESequence.Append (AStructure); |
1478 | MyCOMPUTEDSequence.Append (TheStructure); | |
1479 | ||
81bba717 | 1480 | // The previous are removed if necessary |
7fd59977 | 1481 | if (Index != 0) { |
1482 | MyTOCOMPUTESequence.Remove (Index); | |
1483 | MyCOMPUTEDSequence.Remove (Index); | |
1484 | } | |
1485 | ||
81bba717 | 1486 | // Return type of visualisation of the view |
7fd59977 | 1487 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
1488 | ||
81bba717 | 1489 | // Of which type will be the computed ? |
7fd59977 | 1490 | Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) && |
1491 | (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING)); | |
1492 | ||
1493 | Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) && | |
1494 | (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME)); | |
1495 | ||
1496 | if (ComputeWireframe) | |
1497 | TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME); | |
1498 | if (ComputeShading) | |
1499 | TheStructure->SetVisual (Graphic3d_TOS_SHADING); | |
1500 | ||
1501 | if (! ComputeShading && ! ComputeWireframe) | |
1502 | Answer = Visual3d_TOA_NO; | |
1503 | else | |
1504 | Answer = AcceptDisplay (TheStructure); | |
1505 | ||
1506 | if (AStructure->IsHighlighted()) { | |
1507 | TheStructure->SetHighlightColor (AStructure->HighlightColor ()); | |
1508 | TheStructure->GraphicHighlight (Aspect_TOHM_COLOR); | |
1509 | } | |
1510 | ||
bf75be98 | 1511 | // It is displayed only if the calculated structure |
81bba717 | 1512 | // has a proper type corresponding to the one of the view. |
7fd59977 | 1513 | if (Answer != Visual3d_TOA_NO) { |
1514 | if (! IsDisplayed (AStructure)) | |
1515 | MyDisplayedStructure.Add (AStructure); | |
63bcc448 | 1516 | MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority ()); |
7fd59977 | 1517 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); |
1518 | } | |
1519 | } // Visual3d_TOA_COMPUTE | |
1520 | } | |
1521 | ||
1522 | void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) { | |
1523 | ||
1524 | if (IsDeleted ()) return; | |
1525 | ||
1526 | Erase (AStructure, MyViewManager->UpdateMode ()); | |
1527 | ||
1528 | } | |
1529 | ||
1530 | void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) { | |
1531 | ||
1532 | Standard_Integer StructId; | |
1533 | ||
1534 | if (IsDeleted ()) return; | |
1535 | ||
bf75be98 | 1536 | // No test on window as the structure is displayed only if |
81bba717 | 1537 | // the window exists, so only one test is enough. |
7fd59977 | 1538 | if (IsDisplayed (AStructure)) { |
1539 | Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure); | |
1540 | ||
de75ed09 | 1541 | if (!ComputedMode()) |
1542 | { | |
1543 | Answer = Visual3d_TOA_YES; | |
1544 | } | |
7fd59977 | 1545 | |
1546 | if (Answer != Visual3d_TOA_COMPUTE) { | |
63bcc448 | 1547 | MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure())); |
7fd59977 | 1548 | } |
1549 | ||
1550 | if (Answer == Visual3d_TOA_COMPUTE) { | |
1551 | Standard_Integer Index = IsComputed (AStructure); | |
1552 | #ifdef TRACE_COMP | |
1553 | cout << "Visual3d_View" << MyCView.ViewId << "::Erase (" | |
1554 | << AStructure->Identification () << ");\n"; | |
1555 | cout << "Index : " << Index << "\n"; | |
1556 | cout << flush; | |
1557 | #endif | |
de75ed09 | 1558 | |
1559 | if (Index != 0 && ComputedMode()) | |
7fd59977 | 1560 | { |
1561 | StructId = | |
1562 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
1563 | #ifdef TRACE_COMP | |
1564 | cout << "Structure " << AStructure->Identification () | |
81bba717 | 1565 | << " calculated, in the view " |
1566 | << Identification () << ", by the structure " | |
1567 | << StructId << " is removed. \n"; | |
7fd59977 | 1568 | cout << flush; |
1569 | #endif | |
63bcc448 | 1570 | MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure())); |
7fd59977 | 1571 | } |
81bba717 | 1572 | // else is impossible |
7fd59977 | 1573 | } |
1574 | MyDisplayedStructure.Remove (AStructure); | |
1575 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
1576 | } | |
1577 | ||
1578 | } | |
1579 | ||
1580 | void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) { | |
1581 | ||
1582 | #ifdef TRACE_HIGH | |
1583 | cout << "Visual3d_View" << MyCView.ViewId << "::Highlight (" | |
1584 | << AStructure->Identification () << ")\n"; | |
1585 | cout << flush; | |
1586 | #endif | |
1587 | ||
1588 | Standard_Integer Index = IsComputed (AStructure); | |
1589 | if (Index != 0) { | |
1590 | #ifdef TRACE_HIGH | |
81bba717 | 1591 | cout << "Structure " << AStructure->Identification () |
1592 | << " calculated, in the view " | |
1593 | << Identification () << ", by the structure " | |
7fd59977 | 1594 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 1595 | << " passes in highlight mode.\n"; |
7fd59977 | 1596 | cout << flush; |
1597 | #endif | |
1598 | (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor | |
1599 | (AStructure->HighlightColor ()); | |
1600 | (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod); | |
1601 | } | |
1602 | ||
1603 | } | |
1604 | ||
1605 | void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) { | |
1606 | ||
1607 | #ifdef TRACE_TRSF | |
1608 | cout << "Visual3d_View" << MyCView.ViewId << "::Transform (" | |
1609 | << AStructure->Identification () << ")\n"; | |
1610 | cout << flush; | |
1611 | #endif | |
1612 | ||
1613 | Standard_Integer Index = IsComputed (AStructure); | |
1614 | if (Index != 0) { | |
1615 | #ifdef TRACE_TRSF | |
81bba717 | 1616 | cout << "The structure " << AStructure->Identification () |
1617 | << " calculated, in the view " | |
1618 | << Identification () << ", by the structure " | |
7fd59977 | 1619 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 1620 | << " is transformed.\n"; |
7fd59977 | 1621 | cout << flush; |
1622 | #endif | |
81bba717 | 1623 | // Test is somewhat light ! |
1624 | // trsf is transferred only if it is : | |
1625 | // a translation | |
1626 | // a scale | |
7fd59977 | 1627 | if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0. |
1628 | || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0. | |
1629 | || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.) | |
1630 | ReCompute (AStructure); | |
1631 | else | |
1632 | MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf); | |
1633 | } | |
1634 | ||
1635 | } | |
1636 | ||
1637 | void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) { | |
1638 | ||
1639 | #ifdef TRACE_HIGH | |
1640 | cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight (" | |
1641 | << AStructure->Identification () << ")\n"; | |
1642 | cout << flush; | |
1643 | #endif | |
1644 | ||
1645 | Standard_Integer Index = IsComputed (AStructure); | |
1646 | if (Index != 0) { | |
1647 | #ifdef TRACE_HIGH | |
81bba717 | 1648 | cout << "Structure " << AStructure->Identification () |
1649 | << " calculated, in the view " | |
1650 | << Identification () << ", by the structure " | |
7fd59977 | 1651 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 1652 | << " passes in unhighlight mode.\n"; |
7fd59977 | 1653 | cout << flush; |
1654 | #endif | |
1655 | MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight (); | |
1656 | } | |
1657 | ||
1658 | ||
1659 | } | |
1660 | ||
1661 | Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const { | |
1662 | ||
1663 | Standard_Integer StrId = AStructure->Identification (); | |
1664 | ||
1665 | Standard_Integer Result = 0; | |
1666 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
1667 | ||
1668 | // Recherche de la structure <AStructure> dans la | |
1669 | // sequence des structures deja calculees | |
1670 | for (Standard_Integer i=1; i<=Length && Result==0; i++) | |
1671 | if ((MyTOCOMPUTESequence.Value (i))->Identification () | |
1672 | == StrId) Result = i; | |
1673 | #ifdef TRACE_ISCOMP | |
81bba717 | 1674 | cout << "\n In the view " << Identification () << " the structure "; |
7fd59977 | 1675 | if (Result != 0) |
81bba717 | 1676 | cout << StrId << " is calculated by " |
7fd59977 | 1677 | << MyCOMPUTEDSequence.Value (Result)->Identification () |
1678 | << "\n" << flush; | |
1679 | else | |
81bba717 | 1680 | cout << StrId << " is not calculated\n" << flush; |
7fd59977 | 1681 | #endif |
1682 | ||
1683 | #ifdef TRACE_LENGTH | |
1684 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
1685 | cout << "In Visual3d_View::IsComputed, "; | |
1686 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
1687 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
1688 | << "\n" << flush; | |
1689 | } | |
1690 | #endif | |
1691 | ||
1692 | return (Result); | |
1693 | ||
1694 | } | |
1695 | ||
1696 | Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const { | |
1697 | ||
1698 | Standard_Boolean Result = Standard_False; | |
1699 | ||
1700 | if (IsDeleted ()) return Result; | |
1701 | ||
1702 | Result = MyDisplayedStructure.Contains (AStructure); | |
1703 | ||
1704 | return Result; | |
1705 | ||
1706 | } | |
1707 | ||
1708 | #ifdef IMPLEMENTED | |
1709 | Standard_Boolean Visual3d_View::ContainsComputedStructure () const { | |
1710 | ||
1711 | Standard_Boolean Result = Standard_False; | |
1712 | ||
1713 | if (MyDisplayedStructure.IsEmpty ()) return Result; | |
1714 | ||
1715 | Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure); | |
1716 | ||
1717 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
1718 | ||
81bba717 | 1719 | // Stop at the first structure of type TOS_COMPUTED |
7fd59977 | 1720 | while (! Result && Iterator.More ()) { |
1721 | Result = | |
1722 | (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED); | |
1723 | ||
bf75be98 | 1724 | // Iterator.Next () is located on the |
81bba717 | 1725 | // next structure |
7fd59977 | 1726 | Iterator.Next (); |
1727 | } | |
1728 | ||
1729 | return Result; | |
1730 | ||
1731 | } | |
1732 | #endif | |
1733 | ||
1734 | Standard_Boolean Visual3d_View::ContainsFacet () const { | |
1735 | ||
1736 | return ContainsFacet (MyDisplayedStructure); | |
1737 | ||
1738 | } | |
1739 | ||
1740 | Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const { | |
1741 | ||
1742 | Standard_Boolean Result = Standard_False; | |
1743 | ||
1744 | if (ASet.IsEmpty ()) return Result; | |
1745 | ||
1746 | Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet); | |
1747 | ||
81bba717 | 1748 | // Stop at the first structure containing a facet |
7fd59977 | 1749 | for ( Iterator.Initialize (ASet); |
1750 | Iterator.More () && ! Result; | |
1751 | Iterator.Next ()) | |
1752 | Result = (Iterator.Key ())->ContainsFacet (); | |
1753 | ||
1754 | return Result; | |
1755 | ||
1756 | } | |
1757 | ||
197ac94e | 1758 | //============================================================================= |
1759 | //function : MinMaxValues | |
1760 | //purpose : | |
1761 | //============================================================================= | |
1762 | void Visual3d_View::MinMaxValues (Standard_Real& theXMin, | |
1763 | Standard_Real& theYMin, | |
1764 | Standard_Real& theZMin, | |
1765 | Standard_Real& theXMax, | |
1766 | Standard_Real& theYMax, | |
1767 | Standard_Real& theZMax, | |
1768 | const Standard_Boolean theToIgnoreInfiniteFlag) const | |
1769 | { | |
1770 | MinMaxValues (MyDisplayedStructure, | |
1771 | theXMin, theYMin, theZMin, | |
1772 | theXMax, theYMax, theZMax, | |
1773 | theToIgnoreInfiniteFlag); | |
7fd59977 | 1774 | } |
1775 | ||
197ac94e | 1776 | //============================================================================= |
1777 | //function : MinMaxValues | |
1778 | //purpose : | |
1779 | //============================================================================= | |
1780 | void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet, | |
1781 | Standard_Real& theXMin, | |
1782 | Standard_Real& theYMin, | |
1783 | Standard_Real& theZMin, | |
1784 | Standard_Real& theXMax, | |
1785 | Standard_Real& theYMax, | |
1786 | Standard_Real& theZMax, | |
1787 | const Standard_Boolean theToIgnoreInfiniteFlag) const | |
1788 | { | |
1789 | if (theSet.IsEmpty ()) | |
1790 | { | |
1791 | theXMin = RealFirst(); | |
1792 | theYMin = RealFirst(); | |
1793 | theZMin = RealFirst(); | |
7fd59977 | 1794 | |
197ac94e | 1795 | theXMax = RealLast(); |
1796 | theYMax = RealLast(); | |
1797 | theZMax = RealLast(); | |
7fd59977 | 1798 | } |
197ac94e | 1799 | else |
1800 | { | |
1801 | Standard_Real aXm, aYm, aZm, aXM, aYM, aZM; | |
1802 | Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet); | |
7fd59977 | 1803 | |
197ac94e | 1804 | theXMin = RealLast(); |
1805 | theYMin = RealLast(); | |
1806 | theZMin = RealLast(); | |
7fd59977 | 1807 | |
197ac94e | 1808 | theXMax = RealFirst (); |
1809 | theYMax = RealFirst (); | |
1810 | theZMax = RealFirst (); | |
7fd59977 | 1811 | |
197ac94e | 1812 | for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next()) |
1813 | { | |
1814 | const Handle(Graphic3d_Structure)& aStructure = anIterator.Key(); | |
7fd59977 | 1815 | |
197ac94e | 1816 | if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag) |
1817 | { | |
7fd59977 | 1818 | //XMin, YMin .... ZMax are initialized by means of infinite line data |
197ac94e | 1819 | aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, Standard_False); |
1820 | if (aXm != RealFirst() && aXm < theXMin) | |
1821 | { | |
1822 | theXMin = aXm; | |
1823 | } | |
1824 | if (aYm != RealFirst() && aYm < theYMin) | |
1825 | { | |
1826 | theYMin = aYm; | |
1827 | } | |
1828 | if (aZm != RealFirst() && aZm < theZMin) | |
1829 | { | |
1830 | theZMin = aZm; | |
1831 | } | |
1832 | if (aXM != RealLast() && aXM > theXMax) | |
1833 | { | |
1834 | theXMax = aXM; | |
1835 | } | |
1836 | if (aYM != RealLast() && aYM > theYMax) | |
1837 | { | |
1838 | theYMax = aYM; | |
1839 | } | |
1840 | if (aZM != RealLast() && aZM > theZMax) | |
1841 | { | |
1842 | theZMax = aZM; | |
1843 | } | |
7fd59977 | 1844 | } |
197ac94e | 1845 | |
bf75be98 | 1846 | // Only non-empty and non-infinite structures |
81bba717 | 1847 | // are taken into account for calculation of MinMax |
197ac94e | 1848 | if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty()) |
1849 | { | |
1850 | aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag); | |
1851 | ||
1852 | /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */ | |
1853 | //"FitAll" operation ignores object with transform persitence parameter | |
1854 | if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None ) | |
1855 | { | |
1856 | theXMin = Min (aXm, theXMin); | |
1857 | theYMin = Min (aYm, theYMin); | |
1858 | theZMin = Min (aZm, theZMin); | |
1859 | theXMax = Max (aXM, theXMax); | |
1860 | theYMax = Max (aYM, theYMax); | |
1861 | theZMax = Max (aZM, theZMax); | |
7fd59977 | 1862 | } |
197ac94e | 1863 | } |
7fd59977 | 1864 | } |
1865 | ||
81bba717 | 1866 | // The following cases are relevant |
1867 | // For exemple if all structures are empty or infinite | |
197ac94e | 1868 | if (theXMax < theXMin) { aXm = theXMin; theXMin = theXMax; theXMax = aXm; } |
1869 | if (theYMax < theYMin) { aYm = theYMin; theYMin = theYMax; theYMax = aYm; } | |
1870 | if (theZMax < theZMin) { aZm = theZMin; theZMin = theZMax; theZMax = aZm; } | |
7fd59977 | 1871 | } |
7fd59977 | 1872 | } |
1873 | ||
197ac94e | 1874 | //============================================================================= |
1875 | //function : MinMaxValues | |
1876 | //purpose : | |
1877 | //============================================================================= | |
1878 | void Visual3d_View::MinMaxValues (Standard_Real& theXMin, | |
1879 | Standard_Real& theYMin, | |
1880 | Standard_Real& theXMax, | |
1881 | Standard_Real& theYMax, | |
1882 | const Standard_Boolean theToIgnoreInfiniteFlag) const | |
1883 | { | |
1884 | MinMaxValues (MyDisplayedStructure, | |
1885 | theXMin, theYMin, | |
1886 | theXMax, theYMax, | |
1887 | theToIgnoreInfiniteFlag); | |
7fd59977 | 1888 | } |
1889 | ||
197ac94e | 1890 | //============================================================================= |
1891 | //function : MinMaxValues | |
1892 | //purpose : | |
1893 | //============================================================================= | |
1894 | void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet, | |
1895 | Standard_Real& theXMin, | |
1896 | Standard_Real& theYMin, | |
1897 | Standard_Real& theXMax, | |
1898 | Standard_Real& theYMax, | |
1899 | const Standard_Boolean theToIgnoreInfiniteFlag) const | |
1900 | { | |
1901 | Standard_Real aXm, aYm, aZm, aXM, aYM, aZM; | |
1902 | Standard_Real aXp, aYp, aZp; | |
7fd59977 | 1903 | |
197ac94e | 1904 | MinMaxValues (theSet, aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag); |
7fd59977 | 1905 | |
197ac94e | 1906 | Projects (aXm, aYm, aZm, aXp, aYp, aZp); |
1907 | theXMin = aXp; | |
1908 | theYMin = aYp; | |
7fd59977 | 1909 | |
197ac94e | 1910 | Projects (aXM, aYM, aZM, aXp, aYp, aZp); |
1911 | theXMax = aXp; | |
1912 | theYMax = aYp; | |
7fd59977 | 1913 | |
197ac94e | 1914 | if (theXMax < theXMin) { aXp = theXMax; theXMax = theXMin; theXMin = aXp; } |
1915 | if (theYMax < theYMin) { aYp = theYMax; theYMax = theYMin; theYMin = aYp; } | |
7fd59977 | 1916 | } |
1917 | ||
7fd59977 | 1918 | Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const { |
1919 | ||
1920 | Standard_Integer Result = MyDisplayedStructure.Extent (); | |
1921 | ||
1922 | return (Result); | |
1923 | ||
1924 | } | |
1925 | ||
197ac94e | 1926 | //======================================================================= |
1927 | //function : Projects | |
1928 | //purpose : | |
1929 | //======================================================================= | |
1930 | void Visual3d_View::Projects (const Standard_Real theX, | |
1931 | const Standard_Real theY, | |
1932 | const Standard_Real theZ, | |
1933 | Standard_Real& thePX, | |
1934 | Standard_Real& thePY, | |
1935 | Standard_Real& thePZ) const | |
b5ac8292 | 1936 | { |
197ac94e | 1937 | const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera; |
7fd59977 | 1938 | |
197ac94e | 1939 | gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions(); |
1940 | Standard_Real aXSize = aViewSpaceDimensions.X(); | |
1941 | Standard_Real aYSize = aViewSpaceDimensions.Y(); | |
1942 | Standard_Real aZSize = aViewSpaceDimensions.Z(); | |
7fd59977 | 1943 | |
197ac94e | 1944 | gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ)); |
7fd59977 | 1945 | |
197ac94e | 1946 | // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ] |
1947 | thePX = aPoint.X() * aXSize * 0.5; | |
1948 | thePY = aPoint.Y() * aYSize * 0.5; | |
1949 | thePZ = aPoint.Z() * aZSize * 0.5; | |
7fd59977 | 1950 | } |
1951 | ||
1952 | Standard_Integer Visual3d_View::Identification () const { | |
1953 | ||
1954 | return (Standard_Integer (MyCView.ViewId)); | |
1955 | ||
1956 | } | |
1957 | ||
7fd59977 | 1958 | |
1959 | Standard_Boolean Visual3d_View::ZBufferIsActivated () const { | |
1960 | ||
1961 | if (IsDeleted ()) return (Standard_False); | |
1962 | ||
1963 | if ((! IsDefined ()) || (! IsActive ())) return (Standard_False); | |
1964 | ||
81bba717 | 1965 | // -1 => not forced by the programmer => depends on the type of visualisation |
1966 | // 0 ou 1 => forced by the programmer | |
7fd59977 | 1967 | |
1968 | if (MyCView.Context.ZBufferActivity == -1) | |
1969 | if (MyContext.Visualization () == Visual3d_TOV_SHADING) | |
1970 | return (Standard_True); | |
1971 | else | |
1972 | return (Standard_False); | |
1973 | else | |
1974 | if (MyCView.Context.ZBufferActivity) | |
1975 | return (Standard_True); | |
1976 | else | |
1977 | return (Standard_False); | |
1978 | ||
1979 | } | |
1980 | ||
1981 | void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) { | |
1982 | ||
1983 | if (IsDeleted ()) return; | |
1984 | ||
1985 | if ((! IsDefined ()) || (! IsActive ())) return; | |
1986 | ||
1987 | MyGraphicDriver->Transparency (MyCView, AnActivity); | |
1988 | ||
1989 | } | |
1990 | ||
1991 | void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) { | |
1992 | ||
1993 | if (MyCView.Context.ZBufferActivity == AnActivity) return; | |
1994 | ||
1995 | if (IsDeleted ()) return; | |
1996 | ||
1997 | if ((! IsDefined ()) || (! IsActive ())) return; | |
1998 | ||
1999 | MyCView.Context.ZBufferActivity = AnActivity; | |
2000 | MyGraphicDriver->SetVisualisation (MyCView); | |
2001 | ||
2002 | } | |
2003 | ||
2004 | void Visual3d_View::UpdateView () { | |
2005 | ||
2006 | MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0); | |
2007 | MyCView.Context.BackZClipping = | |
2008 | (MyContext.BackZClippingIsOn () ? 1:0); | |
2009 | MyCView.Context.FrontZClipping = | |
2010 | (MyContext.FrontZClippingIsOn() ? 1:0); | |
2011 | MyCView.Context.DepthCueing = | |
2012 | (MyContext.DepthCueingIsOn () ? 1:0); | |
2013 | ||
2014 | MyCView.Context.ZClipFrontPlane = | |
2015 | float (MyContext.ZClippingFrontPlane ()); | |
2016 | MyCView.Context.ZClipBackPlane = | |
2017 | float (MyContext.ZClippingBackPlane ()); | |
2018 | MyCView.Context.DepthFrontPlane = | |
2019 | float (MyContext.DepthCueingFrontPlane ()); | |
2020 | MyCView.Context.DepthBackPlane = | |
2021 | float (MyContext.DepthCueingBackPlane ()); | |
2022 | ||
2023 | MyCView.Context.Model = int (MyContext.Model ()); | |
2024 | MyCView.Context.Visualization = int (MyContext.Visualization ()); | |
2025 | ||
bf75be98 | 2026 | MyCView.Context.TextureEnv = MyContext.TextureEnv(); |
7fd59977 | 2027 | MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail(); |
2028 | ||
2029 | } | |
2030 | ||
2031 | void Visual3d_View::Compute () { | |
2032 | ||
2033 | Standard_Integer i; | |
2034 | Standard_Integer Length = MyCOMPUTEDSequence.Length (); | |
2035 | for (i=1; i<=Length; i++) | |
2036 | (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False); | |
2037 | ||
de75ed09 | 2038 | if (!ComputedMode()) |
2039 | { | |
2040 | return; | |
2041 | } | |
7fd59977 | 2042 | |
2043 | /* | |
81bba717 | 2044 | * Force HLRValidation to False on all structures |
2045 | * calculated in the view. | |
7fd59977 | 2046 | */ |
2047 | #ifdef TRACE_LENGTH | |
2048 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
2049 | cout << "In Visual3d_View::Compute, "; | |
2050 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2051 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2052 | << "\n" << flush; | |
2053 | } | |
2054 | #endif | |
2055 | ||
2056 | /* | |
81bba717 | 2057 | * Change of orientation or of projection type => |
2058 | * Remove structures that were calculated for the | |
2059 | * previous orientation. | |
2060 | * Recalculation of new structures. | |
7fd59977 | 2061 | */ |
2062 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
2063 | Visual3d_TypeOfAnswer Answer; | |
2064 | ||
2065 | i = MyDisplayedStructure.Extent (); | |
2066 | ||
2067 | Graphic3d_SequenceOfStructure FooSequence; | |
2068 | ||
2069 | while (S1Iterator.More ()) { | |
2070 | Answer = AcceptDisplay (S1Iterator.Key ()); | |
81bba717 | 2071 | // If the structure was calculated, it is recalculated. |
7fd59977 | 2072 | if (Answer == Visual3d_TOA_COMPUTE) { |
2073 | #ifdef TRACE | |
2074 | cout << "AcceptDisplay (" | |
2075 | << (S1Iterator.Key ())->Identification () | |
2076 | << ") == Visual3d_TOA_COMPUTE;\n"; | |
2077 | cout << flush; | |
2078 | #endif | |
2079 | //Display (S1Iterator.Key (), Aspect_TOU_WAIT); | |
2080 | FooSequence.Append (S1Iterator.Key ()); | |
2081 | } | |
2082 | ||
81bba717 | 2083 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 2084 | S1Iterator.Next (); |
2085 | } | |
2086 | ||
2087 | Length = FooSequence.Length (); | |
81bba717 | 2088 | // All stored structures are displayed |
7fd59977 | 2089 | for (i=1; i<=Length; i++) |
2090 | Display (FooSequence.Value (i), Aspect_TOU_WAIT); | |
2091 | if (Length != 0) FooSequence.Clear (); | |
2092 | ||
2093 | } | |
2094 | ||
2095 | void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) { | |
de75ed09 | 2096 | if (!ComputedMode()) return; |
7fd59977 | 2097 | |
2098 | if (IsDeleted ()) return; | |
2099 | ||
2100 | if ((! IsDefined ()) || (! IsActive ())) return; | |
2101 | ||
2102 | if (! MyWindow->IsMapped ()) return; | |
2103 | ||
2104 | if (! AStructure->IsDisplayed ()) return; | |
2105 | ||
2106 | Visual3d_TypeOfAnswer Answer; | |
2107 | ||
2108 | Answer = AcceptDisplay (AStructure); | |
2109 | ||
2110 | if (Answer == Visual3d_TOA_COMPUTE) { | |
2111 | Standard_Integer Index = IsComputed (AStructure); | |
2112 | if (Index == 0) { | |
2113 | #ifdef TRACE_COMP | |
81bba717 | 2114 | cout << "Structure " << AStructure->Identification () |
2115 | << " is not calculated in the view " | |
7fd59977 | 2116 | << Identification () << "\n"; |
2117 | cout << flush; | |
2118 | #endif | |
2119 | } | |
2120 | else { | |
2121 | Standard_Integer OldStructId, NewStructId; | |
2122 | OldStructId = | |
2123 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
2124 | #ifdef TRACE_COMP | |
2125 | Standard_Integer StructId = AStructure->Identification (); | |
81bba717 | 2126 | cout << "Structure " << StructId |
2127 | << " calculated, in the view " | |
2128 | << Identification () << ", by the structure " | |
2129 | << OldStructId << " is recalculated.\n"; | |
7fd59977 | 2130 | cout << flush; |
2131 | #endif | |
2132 | ||
2133 | // Compute + Validation | |
2134 | #ifdef OLD | |
2135 | Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this); | |
2136 | #else | |
2137 | Handle(Graphic3d_Structure) TheStructure; | |
2138 | TColStd_Array2OfReal ATrsf (0, 3, 0, 3); | |
2139 | AStructure->Transform (ATrsf); | |
2140 | if (Index != 0) { | |
2141 | TColStd_Array2OfReal Ident (0, 3, 0, 3); | |
2142 | Standard_Integer ii, jj; | |
2143 | for (ii=0; ii<=3; ii++) | |
2144 | for (jj=0; jj<=3; jj++) | |
2145 | Ident (ii, jj) = (ii == jj ? 1.0 : 0.0); | |
2146 | TheStructure = MyCOMPUTEDSequence.Value (Index); | |
2147 | TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE); | |
2148 | if (AStructure->IsTransformed ()) { | |
2149 | AStructure->Compute (this, ATrsf, TheStructure); | |
2150 | } | |
2151 | else { | |
2152 | AStructure->Compute (this, TheStructure); | |
2153 | } | |
2154 | } | |
2155 | else { | |
2156 | if (AStructure->IsTransformed ()) { | |
2157 | TheStructure = AStructure->Compute (this, ATrsf); | |
2158 | } | |
2159 | else { | |
2160 | TheStructure = AStructure->Compute (this); | |
2161 | } | |
2162 | } | |
2163 | #endif | |
2164 | TheStructure->SetHLRValidation (Standard_True); | |
2165 | ||
81bba717 | 2166 | // Return type of visualisation of the view |
7fd59977 | 2167 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
2168 | ||
81bba717 | 2169 | // Of which type will be the computed ? |
7fd59977 | 2170 | Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) && |
2171 | (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING)); | |
2172 | ||
2173 | Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) && | |
2174 | (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME)); | |
2175 | ||
2176 | if (ComputeWireframe) | |
2177 | TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME); | |
2178 | if (ComputeShading) | |
2179 | TheStructure->SetVisual (Graphic3d_TOS_SHADING); | |
2180 | ||
2181 | if (AStructure->IsHighlighted ()) { | |
2182 | TheStructure->SetHighlightColor | |
2183 | (AStructure->HighlightColor ()); | |
2184 | TheStructure->GraphicHighlight (Aspect_TOHM_COLOR); | |
2185 | } | |
2186 | ||
81bba717 | 2187 | // Ot is ranged |
2188 | // Find structure <AStructure> | |
2189 | // in the sequence of structures to be calculated. | |
7fd59977 | 2190 | NewStructId = TheStructure->Identification (); |
2191 | ||
81bba717 | 2192 | // The previous calculation is removed and the new one is dislayed |
63bcc448 | 2193 | MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure())); |
2194 | MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority()); | |
7fd59977 | 2195 | |
2196 | #ifdef TRACE_LENGTH | |
2197 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
2198 | cout << "In Visual3d_View::ReCompute, "; | |
2199 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2200 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2201 | << "\n" << flush; | |
2202 | } | |
2203 | #endif | |
2204 | ||
81bba717 | 2205 | // hlhsr and the new associated compute are added |
7fd59977 | 2206 | MyTOCOMPUTESequence.Append (AStructure); |
2207 | MyCOMPUTEDSequence.Append (TheStructure); | |
2208 | ||
2209 | #ifdef TRACE_LENGTH | |
2210 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
2211 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2212 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2213 | << "\n" << flush; | |
2214 | #endif | |
2215 | ||
bf75be98 | 2216 | // hlhsr and the new associated compute are removed |
7fd59977 | 2217 | |
2218 | MyTOCOMPUTESequence.Remove (Index); | |
2219 | MyCOMPUTEDSequence.Remove (Index); | |
2220 | ||
2221 | #ifdef TRACE_LENGTH | |
2222 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
2223 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2224 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2225 | << "\n" << flush; | |
2226 | #endif | |
2227 | } | |
2228 | } | |
2229 | ||
2230 | } | |
2231 | ||
6942f04a | 2232 | const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const { |
7fd59977 | 2233 | |
2234 | return MyGraphicDriver; | |
2235 | ||
2236 | } | |
2237 | ||
de75ed09 | 2238 | void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& thePlotter) const |
2239 | { | |
2240 | for (Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); S1Iterator.More(); S1Iterator.Next()) | |
2241 | { | |
2242 | Standard_Integer Index = IsComputed (S1Iterator.Key ()); | |
2243 | // displayed structure is plotted as if it was not calculated | |
2244 | if (Index == 0) | |
2245 | (S1Iterator.Key ())->Plot (thePlotter); | |
2246 | else | |
2247 | (MyCOMPUTEDSequence.Value (Index))->Plot (thePlotter); | |
2248 | } | |
7fd59977 | 2249 | } |
2250 | ||
2251 | Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const { | |
2252 | ||
2253 | Standard_Integer Result = 0; | |
2254 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
2255 | ||
bf75be98 | 2256 | // Find in the sequence of already calculated structures |
81bba717 | 2257 | // 1/ Structure with the same Owner as <AStructure> |
2258 | // 2/ Which is not <AStructure> | |
2259 | // 3/ COMPUTED which of is valid | |
7fd59977 | 2260 | for (Standard_Integer i=1; i<=Length && Result==0; i++) |
2261 | if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ()) | |
2262 | && (MyTOCOMPUTESequence.Value (i)->Identification () != | |
2263 | AStructure->Identification ()) | |
2264 | && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i; | |
2265 | ||
2266 | return (Result); | |
2267 | ||
2268 | } | |
2269 | ||
2270 | Standard_Address Visual3d_View::CView () const { | |
2271 | ||
2272 | return Standard_Address (&MyCView); | |
2273 | ||
2274 | } | |
2275 | ||
2276 | ||
2277 | // Triedron methods : the Triedron is a non-zoomable object. | |
2278 | ||
2279 | void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor, | |
2280 | const Quantity_NameOfColor YColor, | |
2281 | const Quantity_NameOfColor ZColor, | |
2282 | const Standard_Real SizeRatio, | |
2283 | const Standard_Real AxisDiametr, | |
2284 | const Standard_Integer NbFacettes) { | |
2285 | MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor, | |
2286 | SizeRatio, AxisDiametr, NbFacettes); | |
2287 | } | |
2288 | ||
2289 | ||
2290 | ||
2291 | void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, | |
2292 | const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) { | |
2293 | ||
2294 | MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe); | |
2295 | ||
2296 | } | |
2297 | ||
2298 | void Visual3d_View::TriedronErase () { | |
2299 | ||
2300 | MyGraphicDriver->TriedronErase (MyCView); | |
2301 | ||
2302 | ||
2303 | } | |
2304 | ||
2305 | void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) { | |
2306 | ||
2307 | MyGraphicDriver->TriedronEcho (MyCView,AType); | |
2308 | ||
2309 | } | |
2310 | ||
fd03ee4b | 2311 | static Standard_Boolean checkFloat(const Standard_Real value) |
7fd59977 | 2312 | { |
2313 | return value > -FLT_MAX && value < FLT_MAX; | |
2314 | } | |
2315 | ||
fd03ee4b | 2316 | static void SetMinMaxValuesCallback(Visual3d_View* theView) |
7fd59977 | 2317 | { |
2318 | Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; | |
fd03ee4b | 2319 | theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax); |
7fd59977 | 2320 | |
2321 | if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) && | |
2322 | checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax)) | |
2323 | { | |
fd03ee4b | 2324 | Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver()); |
7fd59977 | 2325 | driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin, |
2326 | (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax); | |
2327 | } | |
2328 | } | |
2329 | ||
13a22457 S |
2330 | Standard_Boolean Visual3d_View::GetGraduatedTrihedron |
2331 | (/* Names of axes */ | |
2332 | TCollection_ExtendedString& xname, | |
2333 | TCollection_ExtendedString& yname, | |
2334 | TCollection_ExtendedString& zname, | |
2335 | /* Draw names */ | |
2336 | Standard_Boolean& xdrawname, | |
2337 | Standard_Boolean& ydrawname, | |
2338 | Standard_Boolean& zdrawname, | |
2339 | /* Draw values */ | |
2340 | Standard_Boolean& xdrawvalues, | |
2341 | Standard_Boolean& ydrawvalues, | |
2342 | Standard_Boolean& zdrawvalues, | |
2343 | /* Draw grid */ | |
2344 | Standard_Boolean& drawgrid, | |
2345 | /* Draw axes */ | |
2346 | Standard_Boolean& drawaxes, | |
2347 | /* Number of splits along axes */ | |
2348 | Standard_Integer& nbx, | |
2349 | Standard_Integer& nby, | |
2350 | Standard_Integer& nbz, | |
2351 | /* Offset for drawing values */ | |
2352 | Standard_Integer& xoffset, | |
2353 | Standard_Integer& yoffset, | |
2354 | Standard_Integer& zoffset, | |
2355 | /* Offset for drawing names of axes */ | |
2356 | Standard_Integer& xaxisoffset, | |
2357 | Standard_Integer& yaxisoffset, | |
2358 | Standard_Integer& zaxisoffset, | |
2359 | /* Draw tickmarks */ | |
2360 | Standard_Boolean& xdrawtickmarks, | |
2361 | Standard_Boolean& ydrawtickmarks, | |
2362 | Standard_Boolean& zdrawtickmarks, | |
2363 | /* Length of tickmarks */ | |
2364 | Standard_Integer& xtickmarklength, | |
2365 | Standard_Integer& ytickmarklength, | |
2366 | Standard_Integer& ztickmarklength, | |
2367 | /* Grid color */ | |
2368 | Quantity_Color& gridcolor, | |
2369 | /* Colors of axis names */ | |
2370 | Quantity_Color& xnamecolor, | |
2371 | Quantity_Color& ynamecolor, | |
2372 | Quantity_Color& znamecolor, | |
2373 | /* Colors of axis and values */ | |
2374 | Quantity_Color& xcolor, | |
2375 | Quantity_Color& ycolor, | |
2376 | Quantity_Color& zcolor, | |
2377 | /* Name of font for names of axes */ | |
2378 | TCollection_AsciiString& fontOfNames, | |
2379 | /* Style of names of axes */ | |
eeaaaefb | 2380 | Font_FontAspect& styleOfNames, |
13a22457 S |
2381 | /* Size of names of axes */ |
2382 | Standard_Integer& sizeOfNames, | |
2383 | /* Name of font for values */ | |
2384 | TCollection_AsciiString& fontOfValues, | |
2385 | /* Style of values */ | |
eeaaaefb | 2386 | Font_FontAspect& styleOfValues, |
13a22457 S |
2387 | /* Size of values */ |
2388 | Standard_Integer& sizeOfValues) const | |
7fd59977 | 2389 | { |
13a22457 S |
2390 | if (!MyGTrihedron.ptrVisual3dView) |
2391 | return Standard_False; | |
2392 | ||
2393 | /* Names of axes */ | |
2394 | xname = MyGTrihedron.xname; | |
bf75be98 | 2395 | yname = MyGTrihedron.yname; |
13a22457 S |
2396 | zname = MyGTrihedron.zname; |
2397 | /* Draw names */ | |
bf75be98 | 2398 | xdrawname = MyGTrihedron.xdrawname; |
2399 | ydrawname = MyGTrihedron.ydrawname; | |
13a22457 S |
2400 | zdrawname = MyGTrihedron.zdrawname; |
2401 | /* Draw values */ | |
bf75be98 | 2402 | xdrawvalues = MyGTrihedron.xdrawvalues; |
2403 | ydrawvalues = MyGTrihedron.ydrawvalues; | |
13a22457 S |
2404 | zdrawvalues = MyGTrihedron.zdrawvalues; |
2405 | /* Draw grid */ | |
2406 | drawgrid = MyGTrihedron.drawgrid; | |
2407 | /* Draw axes */ | |
2408 | drawaxes = MyGTrihedron.drawaxes; | |
2409 | /* Number of splits along axes */ | |
2410 | nbx = MyGTrihedron.nbx; | |
2411 | nby = MyGTrihedron.nby; | |
2412 | nbz = MyGTrihedron.nbz; | |
2413 | /* Offset for drawing values */ | |
2414 | xoffset = MyGTrihedron.xoffset; | |
2415 | yoffset = MyGTrihedron.yoffset; | |
2416 | zoffset = MyGTrihedron.zoffset; | |
2417 | /* Offset for drawing names of axes */ | |
2418 | xaxisoffset = MyGTrihedron.xaxisoffset; | |
2419 | yaxisoffset = MyGTrihedron.yaxisoffset; | |
2420 | zaxisoffset = MyGTrihedron.zaxisoffset; | |
2421 | /* Draw tickmarks */ | |
2422 | xdrawtickmarks = MyGTrihedron.xdrawtickmarks; | |
2423 | ydrawtickmarks = MyGTrihedron.ydrawtickmarks; | |
2424 | zdrawtickmarks = MyGTrihedron.zdrawtickmarks; | |
2425 | /* Length of tickmarks */ | |
2426 | xtickmarklength = MyGTrihedron.xtickmarklength; | |
2427 | ytickmarklength = MyGTrihedron.ytickmarklength; | |
2428 | ztickmarklength = MyGTrihedron.ztickmarklength; | |
2429 | /* Grid color */ | |
2430 | gridcolor = MyGTrihedron.gridcolor; | |
2431 | /* Colors of axis names */ | |
2432 | xnamecolor = MyGTrihedron.xnamecolor; | |
2433 | ynamecolor = MyGTrihedron.ynamecolor; | |
2434 | znamecolor = MyGTrihedron.znamecolor; | |
2435 | /* Colors of axis and values */ | |
2436 | xcolor = MyGTrihedron.xcolor; | |
2437 | ycolor = MyGTrihedron.ycolor; | |
2438 | zcolor = MyGTrihedron.zcolor; | |
2439 | /* Name of font for names of axes */ | |
2440 | fontOfNames = MyGTrihedron.fontOfNames; | |
2441 | /* Style of names of axes */ | |
2442 | styleOfNames = MyGTrihedron.styleOfNames; | |
2443 | /* Size of names of axes */ | |
2444 | sizeOfNames = MyGTrihedron.sizeOfNames; | |
2445 | /* Name of font for values */ | |
2446 | fontOfValues = MyGTrihedron.fontOfValues; | |
2447 | /* Style of values */ | |
2448 | styleOfValues = MyGTrihedron.styleOfValues; | |
2449 | /* Size of values */ | |
2450 | sizeOfValues = MyGTrihedron.sizeOfValues; | |
2451 | ||
2452 | return Standard_True; | |
2453 | } | |
2454 | ||
2455 | void Visual3d_View::GraduatedTrihedronDisplay | |
2456 | (/* Names of axes */ | |
2457 | const TCollection_ExtendedString &xname, | |
2458 | const TCollection_ExtendedString &yname, | |
2459 | const TCollection_ExtendedString &zname, | |
2460 | /* Draw names */ | |
2461 | const Standard_Boolean xdrawname, | |
2462 | const Standard_Boolean ydrawname, | |
2463 | const Standard_Boolean zdrawname, | |
2464 | /* Draw values */ | |
2465 | const Standard_Boolean xdrawvalues, | |
2466 | const Standard_Boolean ydrawvalues, | |
2467 | const Standard_Boolean zdrawvalues, | |
2468 | /* Draw grid */ | |
2469 | const Standard_Boolean drawgrid, | |
2470 | /* Draw axes */ | |
2471 | const Standard_Boolean drawaxes, | |
2472 | /* Number of splits along axes */ | |
2473 | const Standard_Integer nbx, | |
2474 | const Standard_Integer nby, | |
2475 | const Standard_Integer nbz, | |
2476 | /* Offset for drawing values */ | |
2477 | const Standard_Integer xoffset, | |
2478 | const Standard_Integer yoffset, | |
2479 | const Standard_Integer zoffset, | |
2480 | /* Offset for drawing names of axes */ | |
2481 | const Standard_Integer xaxisoffset, | |
2482 | const Standard_Integer yaxisoffset, | |
2483 | const Standard_Integer zaxisoffset, | |
2484 | /* Draw tickmarks */ | |
2485 | const Standard_Boolean xdrawtickmarks, | |
2486 | const Standard_Boolean ydrawtickmarks, | |
2487 | const Standard_Boolean zdrawtickmarks, | |
2488 | /* Length of tickmarks */ | |
2489 | const Standard_Integer xtickmarklength, | |
2490 | const Standard_Integer ytickmarklength, | |
2491 | const Standard_Integer ztickmarklength, | |
2492 | /* Grid color */ | |
2493 | const Quantity_Color& gridcolor, | |
2494 | /* Colors of axis names */ | |
2495 | const Quantity_Color& xnamecolor, | |
2496 | const Quantity_Color& ynamecolor, | |
2497 | const Quantity_Color& znamecolor, | |
2498 | /* Colors of axis and values */ | |
2499 | const Quantity_Color& xcolor, | |
2500 | const Quantity_Color& ycolor, | |
2501 | const Quantity_Color& zcolor, | |
2502 | /* Name of font for names of axes */ | |
2503 | const TCollection_AsciiString &fontOfNames, | |
2504 | /* Style of names of axes */ | |
eeaaaefb | 2505 | const Font_FontAspect styleOfNames, |
13a22457 S |
2506 | /* Size of names of axes */ |
2507 | const Standard_Integer sizeOfNames, | |
2508 | /* Name of font for values */ | |
2509 | const TCollection_AsciiString &fontOfValues, | |
2510 | /* Style of values */ | |
eeaaaefb | 2511 | const Font_FontAspect styleOfValues, |
13a22457 S |
2512 | /* Size of values */ |
2513 | const Standard_Integer sizeOfValues) | |
7fd59977 | 2514 | { |
13a22457 S |
2515 | /* Names of axes */ |
2516 | MyGTrihedron.xname = xname; | |
2517 | MyGTrihedron.yname = yname; | |
2518 | MyGTrihedron.zname = zname; | |
2519 | /* Draw names */ | |
2520 | MyGTrihedron.xdrawname = xdrawname; | |
2521 | MyGTrihedron.ydrawname = ydrawname; | |
2522 | MyGTrihedron.zdrawname = zdrawname; | |
2523 | /* Draw values */ | |
2524 | MyGTrihedron.xdrawvalues = xdrawvalues; | |
2525 | MyGTrihedron.ydrawvalues = ydrawvalues; | |
2526 | MyGTrihedron.zdrawvalues = zdrawvalues; | |
2527 | /* Draw grid */ | |
2528 | MyGTrihedron.drawgrid = drawgrid; | |
2529 | /* Draw axes */ | |
2530 | MyGTrihedron.drawaxes = drawaxes; | |
2531 | /* Number of splits along axes */ | |
2532 | MyGTrihedron.nbx = nbx; | |
2533 | MyGTrihedron.nby = nby; | |
2534 | MyGTrihedron.nbz = nbz; | |
2535 | /* Offset for drawing values */ | |
2536 | MyGTrihedron.xoffset = xoffset; | |
2537 | MyGTrihedron.yoffset = yoffset; | |
2538 | MyGTrihedron.zoffset = zoffset; | |
2539 | /* Offset for drawing names of axes */ | |
2540 | MyGTrihedron.xaxisoffset = xaxisoffset; | |
2541 | MyGTrihedron.yaxisoffset = yaxisoffset; | |
2542 | MyGTrihedron.zaxisoffset = zaxisoffset; | |
2543 | /* Draw tickmarks */ | |
2544 | MyGTrihedron.xdrawtickmarks = xdrawtickmarks; | |
2545 | MyGTrihedron.ydrawtickmarks = ydrawtickmarks; | |
2546 | MyGTrihedron.zdrawtickmarks = zdrawtickmarks; | |
2547 | /* Length of tickmarks */ | |
2548 | MyGTrihedron.xtickmarklength = xtickmarklength; | |
2549 | MyGTrihedron.ytickmarklength = ytickmarklength; | |
2550 | MyGTrihedron.ztickmarklength = ztickmarklength; | |
2551 | /* Grid color */ | |
2552 | MyGTrihedron.gridcolor = gridcolor; | |
2553 | /* Colors of axis names */ | |
2554 | MyGTrihedron.xnamecolor = xnamecolor; | |
2555 | MyGTrihedron.ynamecolor = ynamecolor; | |
2556 | MyGTrihedron.znamecolor = znamecolor; | |
2557 | /* Colors of axis and values */ | |
2558 | MyGTrihedron.xcolor = xcolor; | |
2559 | MyGTrihedron.ycolor = ycolor; | |
2560 | MyGTrihedron.zcolor = zcolor; | |
2561 | /* Name of font for names of axes */ | |
2562 | MyGTrihedron.fontOfNames = fontOfNames; | |
2563 | /* Style of names of axes */ | |
2564 | MyGTrihedron.styleOfNames = styleOfNames; | |
2565 | /* Size of names of axes */ | |
2566 | MyGTrihedron.sizeOfNames = sizeOfNames; | |
2567 | /* Name of font for values */ | |
2568 | MyGTrihedron.fontOfValues = fontOfValues; | |
2569 | /* Style of values */ | |
2570 | MyGTrihedron.styleOfValues = styleOfValues; | |
2571 | /* Size of values */ | |
2572 | MyGTrihedron.sizeOfValues = sizeOfValues; | |
2573 | ||
2574 | MyGTrihedron.ptrVisual3dView = this; | |
2575 | MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback; | |
2576 | MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron); | |
7fd59977 | 2577 | } |
2578 | ||
2579 | void Visual3d_View::GraduatedTrihedronErase() | |
2580 | { | |
13a22457 | 2581 | MyGTrihedron.ptrVisual3dView = NULL; |
7fd59977 | 2582 | MyGraphicDriver->GraduatedTrihedronErase(MyCView); |
2583 | } | |
2584 | ||
2585 | const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const { | |
2586 | ||
2587 | return (MyViewManager->UnderLayer ()); | |
2588 | ||
2589 | } | |
2590 | ||
2591 | const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const { | |
2592 | ||
2593 | return (MyViewManager->OverLayer ()); | |
2594 | ||
2595 | } | |
2596 | ||
2597 | Standard_Integer Visual3d_View::LightLimit() const { | |
2598 | ||
2599 | Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit (); | |
2600 | // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight); | |
2601 | return maxlight; | |
2602 | } | |
2603 | ||
2604 | Standard_Integer Visual3d_View::PlaneLimit() const { | |
2605 | ||
2606 | Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit (); | |
2607 | // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane); | |
2608 | return maxplane; | |
2609 | } | |
2610 | ||
bf75be98 | 2611 | Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const |
2612 | { | |
2613 | return MyPtrViewManager; | |
7fd59977 | 2614 | } |
7fd59977 | 2615 | |
de75ed09 | 2616 | void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) |
2617 | { | |
2618 | if ((aMode && ComputedModeIsActive) || | |
2619 | (!aMode && !ComputedModeIsActive)) | |
2620 | { | |
2621 | return; | |
2622 | } | |
7fd59977 | 2623 | |
2624 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure ); | |
2625 | Visual3d_TypeOfAnswer Answer; | |
2626 | Standard_Integer StructId; | |
2627 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
773f53f1 | 2628 | ComputedModeIsActive = aMode; |
2629 | if (!ComputedModeIsActive) { | |
7fd59977 | 2630 | |
2631 | while ( S1Iterator.More () ) { | |
2632 | ||
2633 | Answer = AcceptDisplay ( S1Iterator.Key () ); | |
2634 | ||
2635 | if ( Answer == Visual3d_TOA_COMPUTE ) { | |
2636 | ||
2637 | Standard_Integer Index = IsComputed ( S1Iterator.Key () ); | |
2638 | ||
2639 | if ( Index != 0 ) { | |
2640 | ||
2641 | StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification (); | |
2642 | ||
63bcc448 | 2643 | MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure())); |
2644 | MyGraphicDriver->DisplayStructure (MyCView, *(S1Iterator.Key()->CStructure()), S1Iterator.Key()->DisplayPriority()); | |
7fd59977 | 2645 | } // end if ( Index != 0 ) . . . |
2646 | ||
2647 | } // end if ( Answer . . . ) | |
2648 | ||
2649 | S1Iterator.Next (); | |
2650 | ||
2651 | } // end while | |
2652 | ||
2653 | } else { | |
2654 | ||
2655 | while ( S1Iterator.More () ) { | |
2656 | ||
2657 | Answer = AcceptDisplay ( S1Iterator.Key () ); | |
2658 | ||
2659 | if ( Answer == Visual3d_TOA_COMPUTE ) { | |
2660 | ||
2661 | Standard_Integer Index = IsComputed ( S1Iterator.Key () ); | |
2662 | ||
2663 | if ( Index != 0 ) { | |
2664 | ||
2665 | StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification (); | |
2666 | ||
63bcc448 | 2667 | MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure())); |
2668 | MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), S1Iterator.Key()->DisplayPriority()); | |
7fd59977 | 2669 | |
2670 | Display ( S1Iterator.Key (), Aspect_TOU_WAIT ); | |
2671 | ||
2672 | if ( S1Iterator.Key () -> IsHighlighted () ) { | |
2673 | ||
2674 | if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) { | |
2675 | ||
2676 | MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor ( | |
2677 | S1Iterator.Key () -> | |
2678 | HighlightColor () | |
2679 | ); | |
2680 | MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight ( | |
2681 | Aspect_TOHM_COLOR | |
2682 | ); | |
2683 | } // end if | |
2684 | ||
2685 | } // end if | |
2686 | ||
2687 | } else { | |
2688 | ||
2689 | Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key (); | |
2690 | #ifdef OLD | |
2691 | Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this ); | |
2692 | #else | |
2693 | Handle( Graphic3d_Structure ) TheStructure; | |
2694 | TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 ); | |
2695 | ||
2696 | AStructure -> Transform ( ATrsf ); | |
2697 | ||
2698 | if ( Index != 0 ) { | |
2699 | ||
2700 | TColStd_Array2OfReal Ident ( 0, 3, 0, 3 ); | |
2701 | Standard_Integer ii, jj; | |
2702 | ||
2703 | for ( ii = 0; ii <= 3; ++ii ) | |
2704 | ||
2705 | for ( jj = 0; jj <= 3; ++jj ) | |
2706 | ||
2707 | Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 ); | |
2708 | ||
2709 | TheStructure = MyCOMPUTEDSequence.Value ( Index ); | |
2710 | ||
2711 | TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE ); | |
2712 | ||
2713 | if ( AStructure->IsTransformed () ) | |
2714 | ||
2715 | AStructure -> Compute ( this, ATrsf, TheStructure ); | |
2716 | ||
2717 | else | |
2718 | ||
2719 | AStructure -> Compute ( this, TheStructure ); | |
2720 | ||
2721 | } else { | |
2722 | ||
2723 | if ( AStructure -> IsTransformed () ) | |
2724 | ||
2725 | TheStructure = AStructure -> Compute ( this, ATrsf ); | |
2726 | ||
2727 | else | |
2728 | ||
2729 | TheStructure = AStructure -> Compute ( this ); | |
2730 | ||
2731 | } // end else | |
2732 | #endif // OLD | |
2733 | TheStructure -> SetHLRValidation ( Standard_True ); | |
2734 | ||
2735 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); | |
2736 | ||
2737 | Standard_Boolean ComputeWireframe = | |
2738 | ( ( ViewType == Visual3d_TOV_WIREFRAME ) && | |
2739 | ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING ) | |
2740 | ); | |
2741 | ||
2742 | Standard_Boolean ComputeShading = | |
2743 | ( ( ViewType == Visual3d_TOV_SHADING ) && | |
2744 | ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME ) | |
2745 | ); | |
2746 | ||
2747 | if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME ); | |
2748 | if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING ); | |
2749 | ||
2750 | if ( S1Iterator.Key () -> IsHighlighted () ) { | |
2751 | ||
2752 | TheStructure -> SetHighlightColor ( | |
2753 | S1Iterator.Key () -> HighlightColor () | |
2754 | ); | |
2755 | TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR ); | |
2756 | ||
2757 | } // end if | |
2758 | ||
2759 | Standard_Integer Result = 0; | |
2760 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
2761 | StructId = S1Iterator.Key () -> Identification (); | |
2762 | ||
2763 | for ( i = 1; i <= Length && Result == 0; ++i ) | |
2764 | ||
2765 | if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId ) | |
2766 | ||
2767 | Result = i; | |
2768 | ||
2769 | if ( Result ) | |
2770 | ||
2771 | MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure; | |
2772 | ||
2773 | else { | |
2774 | ||
2775 | MyTOCOMPUTESequence.Append ( S1Iterator.Key () ); | |
2776 | MyCOMPUTEDSequence.Append ( TheStructure ); | |
2777 | ||
2778 | } // end else | |
2779 | ||
63bcc448 | 2780 | MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure())); |
2781 | MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), S1Iterator.Key()->DisplayPriority()); | |
7fd59977 | 2782 | } // end else |
2783 | ||
2784 | } // end if | |
2785 | ||
2786 | S1Iterator.Next (); | |
2787 | ||
2788 | } // end while | |
2789 | ||
2790 | if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update (); | |
2791 | ||
2792 | } // end else | |
2793 | ||
2794 | } // end Visual3d_View :: SetComputedMode | |
2795 | ||
2796 | Standard_Boolean Visual3d_View :: ComputedMode () const { | |
2797 | ||
2798 | return ComputedModeIsActive; | |
2799 | ||
2800 | } // end Visual3d_View :: ComputedMode | |
2801 | ||
2802 | void Visual3d_View :: SetBackFacingModel ( | |
2803 | const Visual3d_TypeOfBackfacingModel aModel | |
2804 | ) { | |
2805 | switch ( aModel ) { | |
2806 | ||
2807 | default: | |
2808 | case Visual3d_TOBM_AUTOMATIC: | |
2809 | MyCView.Backfacing = 0; | |
2810 | break; | |
2811 | ||
2812 | case Visual3d_TOBM_FORCE: | |
2813 | MyCView.Backfacing = 1; | |
2814 | break; | |
2815 | ||
2816 | case Visual3d_TOBM_DISABLE: | |
2817 | MyCView.Backfacing = -1; | |
2818 | break; | |
2819 | ||
2820 | } // end switch | |
2821 | ||
2822 | MyGraphicDriver -> SetBackFacingModel ( MyCView ); | |
2823 | ||
2824 | } // end Visual3d_View :: SetBackFacingModel | |
2825 | ||
2826 | Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const { | |
2827 | ||
2828 | switch ( MyCView.Backfacing ) { | |
2829 | ||
2830 | case 0: | |
2831 | return Visual3d_TOBM_AUTOMATIC; | |
2832 | ||
2833 | case 1: | |
2834 | return Visual3d_TOBM_FORCE; | |
2835 | ||
2836 | } // end switch | |
2837 | ||
2838 | return Visual3d_TOBM_DISABLE; | |
2839 | ||
2840 | } // end Visual3d_View :: BackFacingModel | |
7fd59977 | 2841 | |
2842 | void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const | |
2843 | { | |
7fd59977 | 2844 | MyGraphicDriver->SetDepthTestEnabled( MyCView, enable ); |
7fd59977 | 2845 | } |
2846 | ||
2847 | Standard_Boolean Visual3d_View::IsDepthTestEnabled() const | |
2848 | { | |
7fd59977 | 2849 | return MyGraphicDriver->IsDepthTestEnabled( MyCView ); |
7fd59977 | 2850 | } |
2851 | ||
2852 | void Visual3d_View::ReadDepths(const Standard_Integer x, | |
2853 | const Standard_Integer y, | |
2854 | const Standard_Integer width, | |
2855 | const Standard_Integer height, | |
2856 | const Standard_Address buffer) const | |
2857 | { | |
2858 | MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer ); | |
2859 | } | |
2860 | ||
2861 | Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth, | |
2862 | const Standard_Integer theHeight) | |
2863 | { | |
2864 | return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight ); | |
2865 | } | |
2866 | ||
2867 | void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr) | |
2868 | { | |
2869 | MyGraphicDriver->FBORelease( MyCView, theFBOPtr ); | |
2870 | } | |
2871 | ||
2872 | void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr, | |
2873 | Standard_Integer& theWidth, Standard_Integer& theHeight, | |
2874 | Standard_Integer& theWidthMax, Standard_Integer& theHeightMax) | |
2875 | { | |
2876 | MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr, | |
2877 | theWidth, theHeight, | |
2878 | theWidthMax, theHeightMax ); | |
2879 | } | |
2880 | ||
2881 | void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr, | |
2882 | const Standard_Integer theWidth, const Standard_Integer theHeight) | |
2883 | { | |
2884 | MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr, | |
2885 | theWidth, theHeight ); | |
2886 | } | |
2887 | ||
692613e5 | 2888 | Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage, |
2889 | const Graphic3d_BufferType& theBufferType) | |
7fd59977 | 2890 | { |
692613e5 | 2891 | return MyGraphicDriver->BufferDump (MyCView, theImage, theBufferType); |
7fd59977 | 2892 | } |
2893 | ||
2894 | void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const | |
2895 | { | |
7fd59977 | 2896 | MyGraphicDriver->SetGLLightEnabled( MyCView, enable ); |
7fd59977 | 2897 | } |
2898 | ||
2899 | ||
2900 | Standard_Boolean Visual3d_View::IsGLLightEnabled() const | |
2901 | { | |
7fd59977 | 2902 | return MyGraphicDriver->IsGLLightEnabled( MyCView ); |
7fd59977 | 2903 | } |
2904 | ||
5cedc27f K |
2905 | Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName, |
2906 | const Graphic3d_ExportFormat theFormat, | |
2907 | const Graphic3d_SortType theSortType, | |
2908 | const Standard_Real thePrecision, | |
2909 | const Standard_Address theProgressBarFunc, | |
2910 | const Standard_Address theProgressObject) const | |
7fd59977 | 2911 | { |
5cedc27f K |
2912 | Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer(); |
2913 | Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer(); | |
7fd59977 | 2914 | |
5cedc27f K |
2915 | Aspect_CLayer2d anOverCLayer; |
2916 | Aspect_CLayer2d anUnderCLayer; | |
2917 | anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL; | |
7fd59977 | 2918 | |
5cedc27f K |
2919 | if (!anOverLayer.IsNull()) |
2920 | anOverCLayer = anOverLayer->CLayer(); | |
2921 | if (!anUnderLayer.IsNull()) | |
2922 | anUnderCLayer = anUnderLayer->CLayer(); | |
7fd59977 | 2923 | |
5cedc27f K |
2924 | Standard_Integer aWidth, aHeight; |
2925 | Window()->Size (aWidth, aHeight); | |
7fd59977 | 2926 | |
5cedc27f K |
2927 | return MyGraphicDriver->Export (theFileName, theFormat, theSortType, |
2928 | aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer, | |
2929 | thePrecision, theProgressBarFunc, theProgressObject); | |
7fd59977 | 2930 | } |
59f45b7c | 2931 | |
2932 | //======================================================================= | |
2933 | //function : AddZLayer | |
2934 | //purpose : | |
2935 | //======================================================================= | |
2936 | ||
2937 | void Visual3d_View::AddZLayer (const Standard_Integer theLayerId) | |
2938 | { | |
2939 | MyGraphicDriver->AddZLayer (MyCView, theLayerId); | |
2940 | } | |
2941 | ||
2942 | //======================================================================= | |
2943 | //function : RemoveZLayer | |
bf75be98 | 2944 | //purpose : |
59f45b7c | 2945 | //======================================================================= |
2946 | ||
2947 | void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId) | |
2948 | { | |
2949 | MyGraphicDriver->RemoveZLayer (MyCView, theLayerId); | |
2950 | } | |
2951 | ||
2952 | //======================================================================= | |
2953 | //function : ChangeZLayer | |
bf75be98 | 2954 | //purpose : |
59f45b7c | 2955 | //======================================================================= |
2956 | ||
2957 | void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, | |
2958 | const Standard_Integer theLayerId) | |
2959 | { | |
63bcc448 | 2960 | MyGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId); |
59f45b7c | 2961 | } |