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