Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1995-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS | |
3 | // | |
4 | // The content of this file is subject to the Open CASCADE Technology Public | |
5 | // License Version 6.5 (the "License"). You may not use the content of this file | |
6 | // except in compliance with the License. Please obtain a copy of the License | |
7 | // at http://www.opencascade.org and read it completely before using this file. | |
8 | // | |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
11 | // | |
12 | // The Original Code and all software distributed under the License is | |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
14 | // Initial Developer hereby disclaims all such warranties, including without | |
15 | // limitation, any warranties of merchantability, fitness for a particular | |
16 | // purpose or non-infringement. Please see the License for the specific terms | |
17 | // and conditions governing the rights and limitations under the License. | |
18 | ||
7fd59977 | 19 | /*********************************************************************** |
20 | ||
21 | FONCTION : | |
22 | ---------- | |
23 | Classe Visual3d_View.cxx : | |
24 | ||
25 | ||
81bba717 | 26 | Declaration of variables specific to views. |
7fd59977 | 27 | |
81bba717 | 28 | A view is defined by : |
29 | - ViewManager | |
30 | - ContextView | |
31 | - ViewMapping | |
32 | - ViewOrientation | |
7fd59977 | 33 | |
34 | HISTORIQUE DES MODIFICATIONS : | |
35 | -------------------------------- | |
36 | Mars 1992 : NW,JPB,CAL ; Creation. | |
37 | 04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ... | |
38 | 22-04-97 : CAL ; Ajout du Plot. | |
39 | 03-06-97 : FMN ; Correction calcul SetRatio | |
40 | 06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED. | |
41 | 28-07-97 : PCT ; Ajout lumiere frontale headlight. | |
42 | 19-09-97 : CAL ; Remplacement de Window->Position par Window->Size; | |
43 | 17-10-97 : CAL ; Le Projects nouveau est arrive. (NewProjects) | |
44 | 24-10-97 : CAL ; Retrait de DownCast. | |
45 | 24-10-97 : CAL ; Retrait des DataStructure (Vieille maquette inutilisee). | |
46 | 17-11-97 : FMN ; Ajout DoResize dans Resized() | |
47 | 20-11-97 : CAL ; Disparition de la dependance avec math | |
48 | ??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe. | |
49 | ??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures | |
50 | 07-08-97 : PCT ; ajout support texture mapping | |
51 | 05-01-98 : CAL ; Ajout de AnimationMode | |
52 | 15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset | |
53 | 15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED | |
54 | 26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner | |
55 | 06-02-98 : FMN ; CTS19079: TOP TEN: Probleme de highlight dans EDesigner. | |
56 | 05-03-98 : CAL ; GraphicTransform que si Trsf non invalidante | |
57 | 27-03-98 : CAL ; Ajout de TheStructure = devant Compute (...) !!!! | |
58 | 16-04-98 : CAL ; Remise a ID de la Trsf sur la COMPUTED | |
59 | 20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED. | |
60 | 24-06-98 : CAL ; PRO14526 SetTransparency sur une vue non active. | |
61 | 17-07-98 : CAL ; PRO14872 test sur aTrsf dans ::SetTransform. | |
62 | 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1) | |
63 | 22-09-98 : BGN ; S3989 (anciennement S3819) | |
64 | TypeOfTriedron* from Aspect (pas Visual3d) | |
65 | 06-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie. | |
66 | 16-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie. | |
67 | 02-11-98 : CAL ; Retrait de OSD::SetSignal. | |
68 | 18-11-98 : FMN ; Correction sur la gestion de la perspective | |
69 | 02-12-98 : CAL ; S4062. Ajout des layers. | |
70 | 13-09-99 : GG ; GER61454 Adds LightLimit() and PlaneLimit() methods | |
71 | 10-11-99 : GG ; PRO19603 Add Redraw( area ) method | |
72 | 14-01-00 : GG ; IMP140100 Add ViewManager( ) method | |
73 | 22-10-01 : SAV ; Added EnableDepthTest() method. | |
74 | 30-04-02 : JMB ; MyDisplayStructure : use a Map instead of a Set (very bad performance | |
75 | in data access when a lot of objects are used) | |
76 | Will improve performance of selection mechanisms | |
77 | ||
78 | ************************************************************************/ | |
79 | ||
80 | #define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes | |
81 | // positions. | |
82 | ||
83 | #define BUC60570 //GG 14-09-99 Don't activates lighting | |
84 | // when the view shading model is NONE. | |
85 | ||
86 | #define GER61454 //GG 14-09-99 Activates model clipping planes | |
87 | ||
88 | #define IMP140100 //GG14-01-00 Add ViewManager( ) method | |
89 | ||
90 | #define G003 //EUG 30-09-00 Degeneration management | |
91 | // Backfacing management | |
92 | ||
93 | #define RIC120302 //GG Add a NEW SetWindow method which enable | |
94 | // to connect a graphic widget and context to OGL. | |
95 | ||
96 | #define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing | |
97 | from higher API */ | |
98 | #define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting | |
99 | from higher API */ | |
100 | ||
101 | #define OCC1188 //SAV Added methods to set background image | |
102 | ||
103 | /*----------------------------------------------------------------------*/ | |
104 | /* | |
105 | * Constantes | |
106 | */ | |
107 | ||
108 | #define NO_DEBUG | |
109 | #define NO_DESTROY | |
110 | #define NO_TRACE | |
111 | #define NO_TRACE_ACCEPT | |
112 | #define NO_TRACE_CLEAR | |
113 | #define NO_TRACE_CONNECT | |
114 | #define NO_TRACE_HIGH | |
115 | #define NO_TRACE_COMP | |
116 | #define NO_TRACE_TRSF | |
117 | #define NO_TRACE_DISPLAY | |
118 | #define NO_TRACE_ISCOMP | |
119 | #define NO_TRACE_LENGTH | |
120 | #define NO_TRACE_LAYER | |
121 | ||
122 | /*----------------------------------------------------------------------*/ | |
123 | /* | |
124 | * Includes | |
125 | */ | |
126 | ||
127 | #ifdef WNT | |
128 | #include <windows.h> | |
129 | #endif | |
130 | ||
131 | // for the class | |
132 | #include <Visual3d_View.ixx> | |
133 | #include <Visual3d_View.pxx> | |
134 | #include <Visual3d_DepthCueingDefinitionError.hxx> | |
135 | #include <Visual3d_ZClippingDefinitionError.hxx> | |
136 | ||
137 | #ifdef OLD_METHOD | |
138 | #include <math_Vector.hxx> | |
139 | #endif /* OLD_METHOD */ | |
140 | ||
141 | #include <OSD.hxx> | |
142 | ||
143 | #include <Graphic3d_Structure.hxx> | |
144 | #include <Graphic3d_MapOfStructure.hxx> | |
145 | #include <Graphic3d_MapIteratorOfMapOfStructure.hxx> | |
146 | #include <Graphic3d_DataStructureManager.hxx> | |
147 | ||
148 | #include <Graphic3d_GraphicDriver.hxx> | |
149 | #include <Graphic3d_GraphicDevice.hxx> | |
150 | ||
151 | #include <Graphic3d_Vector.hxx> | |
152 | #include <Graphic3d_Vertex.hxx> | |
153 | ||
154 | #include <Visual3d_Light.hxx> | |
155 | #include <Visual3d_SetOfLight.hxx> | |
156 | #include <Visual3d_HSetOfLight.hxx> | |
157 | #include <Visual3d_SetIteratorOfSetOfLight.hxx> | |
158 | ||
159 | #include <Visual3d_ClipPlane.hxx> | |
160 | #include <Visual3d_SetOfClipPlane.hxx> | |
161 | #include <Visual3d_HSetOfClipPlane.hxx> | |
162 | #include <Visual3d_SetIteratorOfSetOfClipPlane.hxx> | |
163 | ||
164 | #include <Visual3d_SetIteratorOfSetOfView.hxx> | |
165 | ||
166 | #include <Graphic3d_TextureEnv.hxx> | |
167 | ||
168 | #include <TColStd_HArray2OfReal.hxx> | |
169 | ||
170 | #ifndef WNT | |
171 | # include <Xw_Window.hxx> | |
172 | #else | |
173 | # include <WNT_Window.hxx> | |
174 | #endif // WNT | |
175 | ||
176 | #include <float.h> | |
177 | ||
178 | //-Aliases | |
179 | ||
180 | //-Global data definitions | |
181 | ||
182 | //-Constructors | |
183 | ||
184 | Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager): | |
185 | MyContext (), | |
186 | MyViewMapping (), | |
187 | MyViewMappingReset (), | |
188 | MyViewOrientation (), | |
189 | MyViewOrientationReset (), | |
190 | MyTransformation (0, 3, 0, 3), | |
191 | MyMatrixOfMapping (0, 3, 0, 3), | |
192 | MyMatrixOfOrientation (0, 3, 0, 3), | |
193 | MyTOCOMPUTESequence (), | |
194 | MyCOMPUTEDSequence (), | |
195 | MyDisplayedStructure () | |
196 | { | |
197 | Standard_Integer i, j; | |
198 | ||
199 | #ifdef IMP140100 | |
200 | MyPtrViewManager = AManager.operator->(); | |
201 | #else | |
202 | MyPtrViewManager = (void *) AManager.operator->(); | |
203 | #endif | |
204 | ||
205 | memset (&MyCView, 0, sizeof(MyCView)); | |
206 | MyCView.ViewId = int (AManager->Identification (this)); | |
207 | MyCView.Active = 0; | |
208 | MyCView.IsDeleted = 0; | |
209 | ||
210 | MyCView.WsId = -1; | |
211 | MyCView.DefWindow.IsDefined = 0; | |
212 | ||
213 | MyCView.Context.NbActiveLight = 0; | |
214 | MyCView.Context.NbActivePlane = 0; | |
215 | #ifdef GER61454 | |
216 | MyCView.Context.ActivePlane = NULL; | |
217 | #endif | |
218 | ||
219 | for (i=0; i<=3; i++) | |
220 | for (j=0; j<=3; j++) | |
221 | if (i == j) MyTransformation (i, j) = 1.0; | |
222 | else MyTransformation (i, j) = 0.0; | |
223 | ||
224 | Standard_Real X, Y, Z; | |
225 | ||
226 | (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z); | |
227 | MyCView.Orientation.ViewReferencePoint.x = float (X); | |
228 | MyCView.Orientation.ViewReferencePoint.y = float (Y); | |
229 | MyCView.Orientation.ViewReferencePoint.z = float (Z); | |
230 | (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z); | |
231 | MyCView.Orientation.ViewReferencePlane.x = float (X); | |
232 | MyCView.Orientation.ViewReferencePlane.y = float (Y); | |
233 | MyCView.Orientation.ViewReferencePlane.z = float (Z); | |
234 | (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z); | |
235 | MyCView.Orientation.ViewReferenceUp.x = float (X); | |
236 | MyCView.Orientation.ViewReferenceUp.y = float (Y); | |
237 | MyCView.Orientation.ViewReferenceUp.z = float (Z); | |
238 | ||
239 | Standard_Real Sx, Sy, Sz; | |
240 | ||
241 | MyViewOrientation.AxialScale(Sx, Sy, Sz); | |
242 | MyCView.Orientation.ViewScaleX = float (Sx); | |
243 | MyCView.Orientation.ViewScaleY = float (Sy); | |
244 | MyCView.Orientation.ViewScaleZ = float (Sz); | |
245 | ||
246 | // NKV : 23/07/07 - Define custom MODELVIEW matrix | |
247 | MyCView.Orientation.IsCustomMatrix = 0; | |
248 | memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) ); | |
249 | MyCView.Orientation.ModelViewMatrix[0][0] = | |
250 | MyCView.Orientation.ModelViewMatrix[1][1] = | |
251 | MyCView.Orientation.ModelViewMatrix[2][2] = | |
252 | MyCView.Orientation.ModelViewMatrix[3][3] = 1.; | |
253 | // | |
254 | ||
255 | Standard_Real um, vm, uM, vM; | |
256 | ||
257 | MyCView.Mapping.Projection = int (MyViewMapping.Projection ()); | |
258 | (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z); | |
259 | MyCView.Mapping.ProjectionReferencePoint.x = float (X); | |
260 | MyCView.Mapping.ProjectionReferencePoint.y = float (Y); | |
261 | MyCView.Mapping.ProjectionReferencePoint.z = float (Z); | |
262 | MyCView.Mapping.ViewPlaneDistance = | |
263 | float (MyViewMapping.ViewPlaneDistance ()); | |
264 | MyCView.Mapping.BackPlaneDistance = | |
265 | float (MyViewMapping.BackPlaneDistance ()); | |
266 | MyCView.Mapping.FrontPlaneDistance = | |
267 | float (MyViewMapping.FrontPlaneDistance ()); | |
268 | MyViewMapping.WindowLimit (um, vm, uM, vM); | |
269 | MyCView.Mapping.WindowLimit.um = float (um); | |
270 | MyCView.Mapping.WindowLimit.vm = float (vm); | |
271 | MyCView.Mapping.WindowLimit.uM = float (uM); | |
272 | MyCView.Mapping.WindowLimit.vM = float (vM); | |
273 | ||
274 | // NKV : 23/07/07 - Define custom MODELVIEW matrix | |
275 | MyCView.Mapping.IsCustomMatrix = 0; | |
276 | memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) ); | |
277 | MyCView.Mapping.ProjectionMatrix[0][0] = | |
278 | MyCView.Mapping.ProjectionMatrix[1][1] = | |
279 | MyCView.Mapping.ProjectionMatrix[2][2] = | |
280 | MyCView.Mapping.ProjectionMatrix[3][3] = 1.; | |
281 | // | |
282 | ||
283 | MyCView.Context.ZBufferActivity = -1; | |
284 | ||
285 | MyMatOfMapIsModified = Standard_True; | |
286 | MyMatOfOriIsModified = Standard_True; | |
287 | MyMatOfMapIsEvaluated = Standard_False; | |
288 | MyMatOfOriIsEvaluated = Standard_False; | |
289 | ||
290 | DegenerateModeIsActive = Standard_False; | |
291 | AnimationModeIsActive = Standard_False; | |
292 | #ifdef G003 | |
293 | MyCView.IsDegenerates = 0; | |
294 | MyCView.IsDegeneratesPrev = 0; | |
295 | ComputedModeIsActive = Standard_False; | |
296 | MyCView.Backfacing = 0; | |
297 | #endif // G003 | |
298 | ||
7fd59977 | 299 | MyCView.ptrUnderLayer = 0; |
300 | MyCView.ptrOverLayer = 0; | |
301 | MyCView.GContext = 0; | |
302 | MyCView.GDisplayCB = 0; | |
303 | MyCView.GClientData = 0; | |
304 | ||
305 | Handle(Aspect_GraphicDriver) agd = | |
306 | (MyViewManager->GraphicDevice ())->GraphicDriver (); | |
307 | ||
308 | MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd; | |
309 | ||
310 | } | |
311 | ||
312 | Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX): | |
313 | MyTransformation (0, 3, 0, 3), | |
314 | MyMatrixOfMapping (0, 3, 0, 3), | |
315 | MyMatrixOfOrientation (0, 3, 0, 3), | |
316 | MyTOCOMPUTESequence (), | |
317 | MyCOMPUTEDSequence (), | |
318 | MyDisplayedStructure () | |
319 | { | |
320 | Standard_Integer i, j; | |
321 | ||
322 | #ifdef IMP140100 | |
323 | MyPtrViewManager = AManager.operator->(); | |
324 | #else | |
325 | MyPtrViewManager = (void *) AManager.operator->(); | |
326 | #endif | |
327 | ||
328 | MyViewOrientation = VO; | |
329 | MyViewMapping = VM; | |
330 | MyContext = CTX; | |
331 | MyViewOrientationReset = VO; | |
332 | MyViewMappingReset = VM; | |
333 | ||
334 | memset (&MyCView, 0, sizeof(MyCView)); | |
335 | MyCView.ViewId = int (AManager->Identification (this)); | |
336 | MyCView.Active = 0; | |
337 | MyCView.IsDeleted = 0; | |
338 | ||
339 | MyCView.WsId = -1; | |
340 | MyCView.DefWindow.IsDefined = 0; | |
341 | ||
342 | MyCView.Context.NbActiveLight = 0; | |
343 | MyCView.Context.NbActivePlane = 0; | |
344 | #ifdef GER61454 | |
345 | MyCView.Context.ActivePlane = NULL; | |
346 | #endif | |
347 | ||
348 | for (i=0; i<=3; i++) | |
349 | for (j=0; j<=3; j++) | |
350 | if (i == j) MyTransformation (i, j) = 1.0; | |
351 | else MyTransformation (i, j) = 0.0; | |
352 | ||
353 | Standard_Real X, Y, Z; | |
354 | ||
355 | (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z); | |
356 | MyCView.Orientation.ViewReferencePoint.x = float (X); | |
357 | MyCView.Orientation.ViewReferencePoint.y = float (Y); | |
358 | MyCView.Orientation.ViewReferencePoint.z = float (Z); | |
359 | (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z); | |
360 | MyCView.Orientation.ViewReferencePlane.x = float (X); | |
361 | MyCView.Orientation.ViewReferencePlane.y = float (Y); | |
362 | MyCView.Orientation.ViewReferencePlane.z = float (Z); | |
363 | (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z); | |
364 | MyCView.Orientation.ViewReferenceUp.x = float (X); | |
365 | MyCView.Orientation.ViewReferenceUp.y = float (Y); | |
366 | MyCView.Orientation.ViewReferenceUp.z = float (Z); | |
367 | ||
368 | Standard_Real Sx, Sy, Sz; | |
369 | ||
370 | MyViewOrientation.AxialScale(Sx, Sy, Sz); | |
371 | MyCView.Orientation.ViewScaleX = float (Sx); | |
372 | MyCView.Orientation.ViewScaleY = float (Sy); | |
373 | MyCView.Orientation.ViewScaleZ = float (Sz); | |
374 | ||
375 | // NKV : 23/07/07 - Define custom MODELVIEW matrix | |
376 | if (MyViewOrientation.IsCustomMatrix()) { | |
377 | MyCView.Orientation.IsCustomMatrix = 1; | |
378 | for ( i = 0; i < 4; i++) | |
379 | for ( j = 0; j < 4; j++) | |
380 | MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j); | |
381 | } | |
382 | else { | |
383 | MyCView.Orientation.IsCustomMatrix = 0; | |
384 | memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) ); | |
385 | MyCView.Orientation.ModelViewMatrix[0][0] = | |
386 | MyCView.Orientation.ModelViewMatrix[1][1] = | |
387 | MyCView.Orientation.ModelViewMatrix[2][2] = | |
388 | MyCView.Orientation.ModelViewMatrix[3][3] = 1.; | |
389 | } | |
390 | // | |
391 | ||
392 | Standard_Real um, vm, uM, vM; | |
393 | ||
394 | MyCView.Mapping.Projection = int (MyViewMapping.Projection ()); | |
395 | (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z); | |
396 | MyCView.Mapping.ProjectionReferencePoint.x = float (X); | |
397 | MyCView.Mapping.ProjectionReferencePoint.y = float (Y); | |
398 | MyCView.Mapping.ProjectionReferencePoint.z = float (Z); | |
399 | MyCView.Mapping.ViewPlaneDistance = | |
400 | float (MyViewMapping.ViewPlaneDistance ()); | |
401 | MyCView.Mapping.BackPlaneDistance = | |
402 | float (MyViewMapping.BackPlaneDistance ()); | |
403 | MyCView.Mapping.FrontPlaneDistance = | |
404 | float (MyViewMapping.FrontPlaneDistance ()); | |
405 | MyViewMapping.WindowLimit (um, vm, uM, vM); | |
406 | MyCView.Mapping.WindowLimit.um = float (um); | |
407 | MyCView.Mapping.WindowLimit.vm = float (vm); | |
408 | MyCView.Mapping.WindowLimit.uM = float (uM); | |
409 | MyCView.Mapping.WindowLimit.vM = float (vM); | |
410 | ||
411 | // NKV : 23/07/07 - Define custom MODELVIEW matrix | |
412 | if (MyViewMapping.IsCustomMatrix()) { | |
413 | MyCView.Mapping.IsCustomMatrix = 1; | |
414 | for ( i = 0; i < 4; i++) | |
415 | for ( j = 0; j < 4; j++) | |
416 | MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j); | |
417 | } | |
418 | else { | |
419 | MyCView.Mapping.IsCustomMatrix = 0; | |
420 | memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) ); | |
421 | MyCView.Mapping.ProjectionMatrix[0][0] = | |
422 | MyCView.Mapping.ProjectionMatrix[1][1] = | |
423 | MyCView.Mapping.ProjectionMatrix[2][2] = | |
424 | MyCView.Mapping.ProjectionMatrix[3][3] = 1.; | |
425 | } | |
426 | // | |
427 | ||
428 | MyCView.Context.ZBufferActivity = -1; | |
429 | ||
430 | MyMatOfMapIsModified = Standard_True; | |
431 | MyMatOfOriIsModified = Standard_True; | |
432 | MyMatOfMapIsEvaluated = Standard_False; | |
433 | MyMatOfOriIsEvaluated = Standard_False; | |
434 | #ifdef G003 | |
435 | AnimationModeIsActive = Standard_False; | |
436 | MyCView.IsDegenerates = 0; | |
437 | MyCView.IsDegeneratesPrev = 0; | |
438 | ComputedModeIsActive = Standard_False; | |
439 | #endif // G003 | |
440 | ||
7fd59977 | 441 | MyCView.ptrUnderLayer = 0; |
442 | MyCView.ptrOverLayer = 0; | |
443 | MyCView.GContext = 0; | |
444 | MyCView.GDisplayCB = 0; | |
445 | MyCView.GClientData = 0; | |
446 | ||
447 | Handle(Aspect_GraphicDriver) agd = | |
448 | (MyViewManager->GraphicDevice ())->GraphicDriver (); | |
449 | ||
450 | MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd; | |
451 | ||
452 | } | |
453 | ||
454 | //-Destructors | |
455 | ||
456 | //-Methods, in order | |
457 | // RIC120302 | |
458 | void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow, | |
459 | const Aspect_RenderingContext AContext, | |
460 | const Aspect_GraphicCallbackProc& ADisplayCB, | |
461 | const Standard_Address AClientData) | |
462 | { | |
463 | if (IsDeleted ()) return; | |
464 | ||
465 | if (IsDefined ()) | |
466 | Visual3d_ViewDefinitionError::Raise ("Window already defined"); | |
467 | ||
468 | MyCView.GContext = AContext; | |
469 | MyCView.GDisplayCB = ADisplayCB; | |
470 | MyCView.GClientData = AClientData; | |
471 | SetWindow(AWindow); | |
472 | } | |
473 | // RIC120302 | |
474 | ||
475 | void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow) { | |
476 | ||
477 | if (IsDeleted ()) return; | |
478 | ||
479 | if (IsDefined ()) | |
480 | Visual3d_ViewDefinitionError::Raise ("Window already defined"); | |
481 | ||
482 | MyWindow = AWindow; | |
483 | MyCView.WsId = MyCView.ViewId; | |
484 | MyCView.DefWindow.IsDefined = 1; | |
485 | #ifndef WNT | |
486 | const Handle(Xw_Window) theWindow = *(Handle(Xw_Window) *) &AWindow; | |
487 | MyCView.DefWindow.XWindow = theWindow->XWindow (); | |
488 | #ifdef RIC120302 | |
489 | MyCView.DefWindow.XParentWindow = theWindow->XParentWindow (); | |
490 | #endif | |
491 | #else | |
492 | WNT_WindowData* wd; | |
493 | const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow; | |
494 | MyCView.DefWindow.XWindow = ( HWND )(theWindow->HWindow()); | |
495 | #ifdef RIC120302 | |
496 | MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow()); | |
497 | #endif | |
f54e0336 | 498 | wd = ( WNT_WindowData* )GetWindowLongPtr (( HWND )(theWindow->HWindow()), GWLP_USERDATA); |
7fd59977 | 499 | wd -> WNT_WDriver_Ptr = ( void* )this; |
500 | wd -> WNT_VMgr = ( void* )MyPtrViewManager; | |
501 | #endif /* WNT */ | |
502 | ||
503 | Standard_Integer Width, Height; | |
504 | AWindow->Size (Width, Height); | |
505 | ||
506 | MyCView.DefWindow.dx = float( Width ); | |
507 | MyCView.DefWindow.dy = float( Height ); | |
508 | ||
509 | Standard_Real R, G, B; | |
510 | MyBackground = MyWindow->Background (); | |
511 | (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB); | |
512 | MyCView.DefWindow.Background.r = float (R); | |
513 | MyCView.DefWindow.Background.g = float (G); | |
514 | MyCView.DefWindow.Background.b = float (B); | |
515 | ||
516 | UpdateView (); | |
517 | if (! MyGraphicDriver->View (MyCView)) | |
518 | Visual3d_ViewDefinitionError::Raise ("Association failed"); | |
519 | ||
520 | MyGradientBackground = MyWindow->GradientBackground(); | |
521 | SetGradientBackground(MyGradientBackground,1); | |
522 | ||
81bba717 | 523 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 524 | MyGraphicDriver->SetVisualisation (MyCView); |
525 | MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ()); | |
526 | MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ()); | |
527 | MyGraphicDriver->ClipLimit (MyCView, AWait); | |
528 | MyGraphicDriver->Environment(MyCView); | |
529 | ||
71c4f9c6 | 530 | // Make view manager z layer list consistent with the view's list. |
531 | MyViewManager->InstallZLayers (this); | |
532 | ||
81bba717 | 533 | // Update planses of model clipping |
7fd59977 | 534 | UpdatePlanes (); |
535 | ||
81bba717 | 536 | // Update light sources |
7fd59977 | 537 | UpdateLights (); |
538 | ||
539 | /* | |
81bba717 | 540 | * Association view-window does not cause the display |
541 | * of structures that can be displayed in the new view. | |
542 | * In fact, association view-window is done, but the | |
543 | * display is produced only if the view is activated (Activate). | |
7fd59977 | 544 | */ |
545 | ||
546 | SetRatio (); | |
547 | ||
548 | } | |
549 | ||
550 | Handle(Aspect_Window) Visual3d_View::Window () const { | |
551 | ||
552 | if (! IsDefined ()) | |
553 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
554 | ||
555 | return (MyWindow); | |
556 | ||
557 | } | |
558 | ||
559 | Standard_Boolean Visual3d_View::IsDefined () const { | |
560 | ||
561 | if (MyCView.DefWindow.IsDefined) | |
562 | return (Standard_True); | |
563 | else | |
564 | return (Standard_False); | |
565 | ||
566 | } | |
567 | ||
568 | Standard_Boolean Visual3d_View::IsDeleted () const { | |
569 | ||
570 | if (MyCView.IsDeleted) | |
571 | return (Standard_True); | |
572 | else | |
573 | return (Standard_False); | |
574 | ||
575 | } | |
576 | ||
577 | void Visual3d_View::Destroy () { | |
578 | ||
579 | #ifdef DESTROY | |
580 | cout << "Visual3d_View::Destroy (" << Identification () << ")\n"; | |
581 | #endif | |
582 | ||
583 | // Since MyPtrViewManager can be already distroyed, | |
584 | // avoid attempts to access it in SetBackground() | |
585 | MyPtrViewManager = 0; | |
586 | Remove (); | |
587 | ||
588 | } | |
589 | ||
590 | void Visual3d_View::Remove () { | |
591 | ||
592 | #ifdef DESTROY | |
593 | cout << "Visual3d_View::Remove (" << Identification () << ")" << endl; | |
594 | #endif | |
595 | ||
596 | if (IsDeleted ()) return; | |
597 | if (! IsDefined ()) return; | |
598 | ||
599 | MyTOCOMPUTESequence.Clear (); | |
600 | MyCOMPUTEDSequence.Clear (); | |
601 | MyDisplayedStructure.Clear (); | |
602 | ||
603 | Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB); | |
604 | Aspect_Background BlackBackground (BlackColor); | |
605 | SetBackground (BlackBackground); | |
606 | ||
607 | Aspect_GradientBackground BlackGradBackground; | |
608 | SetGradientBackground (BlackGradBackground,0); | |
609 | ||
610 | if (MyPtrViewManager) | |
611 | MyPtrViewManager->UnIdentification( MyCView.ViewId ); | |
612 | ||
613 | MyGraphicDriver->RemoveView (MyCView); | |
614 | ||
615 | MyCView.WsId = -1; | |
616 | MyCView.IsDeleted = 1; | |
617 | MyCView.DefWindow.IsDefined = 0; | |
618 | ||
619 | MyMatOfMapIsModified = Standard_True; | |
620 | MyMatOfOriIsModified = Standard_True; | |
621 | MyMatOfMapIsEvaluated = Standard_False; | |
622 | MyMatOfOriIsEvaluated = Standard_False; | |
623 | ||
624 | MyWindow.Nullify (); | |
625 | ||
626 | } | |
627 | ||
628 | void Visual3d_View::Resized () { | |
629 | ||
630 | if (IsDeleted ()) return; | |
631 | ||
632 | if (! IsDefined ()) | |
633 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
634 | MyWindow->DoResize() ; | |
635 | SetRatio (); | |
636 | ||
637 | } | |
638 | ||
639 | void Visual3d_View::SetRatio () { | |
640 | ||
641 | if (IsDeleted ()) return; | |
642 | ||
643 | Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode (); | |
644 | MyViewManager->SetUpdateMode (Aspect_TOU_WAIT); | |
645 | ||
646 | Standard_Real Umin, Vmin, Umax, Vmax; | |
647 | Standard_Integer Dxw, Dyw; | |
648 | Standard_Real Dxv, Dyv; | |
649 | Standard_Real Xc, Yc; | |
650 | Standard_Real Rap; | |
651 | ||
652 | Rap = 0. ; | |
653 | MyWindow->Size (Dxw, Dyw); | |
654 | MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ; | |
655 | Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ; | |
656 | Dxv = Umax - Umin ; Dyv = Vmax - Vmin ; | |
657 | if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ; | |
658 | if( Rap > 0.0 ) { | |
659 | ||
660 | if( Dxv <= Dyv ) | |
661 | { | |
662 | if (Rap <= 1.0) | |
663 | { | |
664 | Dyv = Dxv; | |
665 | Dxv = Dxv/Rap; | |
666 | } | |
667 | else | |
668 | { | |
669 | Dxv = Dxv; | |
670 | Dyv = Dxv*Rap; | |
671 | } | |
672 | } | |
673 | else | |
674 | { | |
675 | if (Rap <= 1.0) | |
676 | { | |
677 | Dxv = Dyv/Rap; | |
678 | Dyv = Dyv; | |
679 | } | |
680 | else | |
681 | { | |
682 | Dxv = Dyv; | |
683 | Dyv = Dyv*Rap; | |
684 | } | |
685 | } | |
686 | ||
687 | Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ; | |
688 | Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ; | |
689 | ||
690 | MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ; | |
691 | ||
81bba717 | 692 | // Update before SetViewMapping. |
7fd59977 | 693 | |
694 | MyCView.DefWindow.dx = float( Dxw ); | |
695 | MyCView.DefWindow.dy = float( Dyw ); | |
696 | ||
697 | SetViewMapping (MyViewMapping); | |
698 | // SetViewMappingDefault (); | |
81bba717 | 699 | // FMN+ Update Ratio for MyViewMappingReset |
7fd59977 | 700 | |
701 | MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ; | |
702 | Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ; | |
703 | Dxv = Umax - Umin ; Dyv = Vmax - Vmin ; | |
704 | ||
705 | if( Dxv <= Dyv ) | |
706 | { | |
707 | if (Rap <= 1.0) | |
708 | { | |
709 | Dyv = Dxv; | |
710 | Dxv = Dxv/Rap; | |
711 | } | |
712 | else | |
713 | { | |
714 | Dxv = Dxv; | |
715 | Dyv = Dxv*Rap; | |
716 | } | |
717 | } | |
718 | else | |
719 | { | |
720 | if (Rap <= 1.0) | |
721 | { | |
722 | Dxv = Dyv/Rap; | |
723 | Dyv = Dyv; | |
724 | } | |
725 | else | |
726 | { | |
727 | Dxv = Dyv; | |
728 | Dyv = Dyv*Rap; | |
729 | } | |
730 | } | |
731 | ||
732 | Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ; | |
733 | Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ; | |
734 | ||
735 | MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ; | |
736 | ||
81bba717 | 737 | // FMN- Update Ratio for MyViewMappingReset |
7fd59977 | 738 | |
739 | MyGraphicDriver->RatioWindow (MyCView); | |
740 | } | |
741 | ||
81bba717 | 742 | // Force recalculation of 2 matrices. |
7fd59977 | 743 | // |
81bba717 | 744 | // The current view can help to reconstruct a copied view |
745 | // that is itself. Owing to SetWindow and SetRatio the | |
746 | // recalculation of matrices of this new view is imposed. | |
7fd59977 | 747 | MyMatOfMapIsEvaluated = Standard_False; |
748 | MyMatOfOriIsEvaluated = Standard_False; | |
749 | ||
750 | MyViewManager->SetUpdateMode (UpdateMode); | |
751 | if (UpdateMode == Aspect_TOU_ASAP) Update (); | |
752 | ||
753 | } | |
754 | ||
755 | void Visual3d_View::UpdateLights () { | |
756 | ||
757 | Standard_Integer i, j; | |
758 | CALL_DEF_LIGHT *lights=NULL; | |
759 | ||
760 | #ifdef BUC60570 | |
761 | if( MyContext.Model() == Visual3d_TOM_NONE ) { | |
762 | // Activates only a white ambient light | |
763 | MyCView.Context.NbActiveLight = 1; | |
764 | lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight]; | |
765 | MyCView.Context.ActiveLight = lights; | |
766 | ||
767 | lights[0].WsId = MyCView.ViewId; | |
768 | lights[0].ViewId = MyCView.ViewId; | |
769 | lights[0].LightType = int (Visual3d_TOLS_AMBIENT); | |
770 | lights[0].Active = 1; | |
771 | lights[0].LightId = 0; | |
772 | lights[0].Headlight = 0; | |
773 | lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.; | |
774 | } else { | |
775 | #endif | |
776 | i = MyContext.NumberOfActivatedLights (); | |
777 | j = MyGraphicDriver->InquireLightLimit (); | |
778 | MyCView.Context.NbActiveLight = (i > j ? j : i); | |
779 | ||
780 | if (MyCView.Context.NbActiveLight > 0) { | |
781 | ||
81bba717 | 782 | // Dynamic Allocation |
7fd59977 | 783 | lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight]; |
784 | ||
785 | MyCView.Context.ActiveLight = lights; | |
786 | ||
787 | Standard_Real X, Y, Z; | |
788 | ||
789 | Standard_Real LightConcentration; | |
790 | Standard_Real LightAttenuation1; | |
791 | Standard_Real LightAttenuation2; | |
792 | Standard_Real LightAngle; | |
793 | Quantity_Color LightColor; | |
794 | Graphic3d_Vertex LightPosition; | |
795 | Graphic3d_Vector LightDirection; | |
796 | Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT; | |
797 | ||
81bba717 | 798 | // Parcing of light sources |
7fd59977 | 799 | for (j=0; j<MyCView.Context.NbActiveLight; j++) { |
800 | LightType = (MyContext.ActivatedLight (j+1))->LightType (); | |
801 | ||
802 | lights[j].WsId = MyCView.ViewId; | |
803 | lights[j].ViewId = MyCView.ViewId; | |
804 | ||
805 | lights[j].LightType = int (LightType); | |
806 | lights[j].Active = 1; | |
807 | lights[j].LightId = | |
808 | int ((MyContext.ActivatedLight (j+1))->Identification ()); | |
809 | lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0; | |
810 | ||
811 | switch (LightType) { | |
812 | ||
813 | case Visual3d_TOLS_AMBIENT : | |
814 | (MyContext.ActivatedLight (j+1))->Values ( | |
815 | LightColor | |
816 | ); | |
817 | break; | |
818 | ||
819 | case Visual3d_TOLS_POSITIONAL : | |
820 | (MyContext.ActivatedLight (j+1))->Values ( | |
821 | LightColor, | |
822 | LightPosition, | |
823 | LightAttenuation1, | |
824 | LightAttenuation2 | |
825 | ); | |
826 | break; | |
827 | ||
828 | case Visual3d_TOLS_DIRECTIONAL : | |
829 | (MyContext.ActivatedLight (j+1))->Values ( | |
830 | LightColor, | |
831 | LightDirection | |
832 | ); | |
833 | break; | |
834 | ||
835 | case Visual3d_TOLS_SPOT : | |
836 | (MyContext.ActivatedLight (j+1))->Values ( | |
837 | LightColor, | |
838 | LightPosition, | |
839 | LightDirection, | |
840 | LightConcentration, | |
841 | LightAttenuation1, | |
842 | LightAttenuation2, | |
843 | LightAngle | |
844 | ); | |
845 | break; | |
846 | ||
847 | } | |
848 | ||
849 | lights[j].Color.r = float (LightColor.Red ()); | |
850 | lights[j].Color.g = float (LightColor.Green ()); | |
851 | lights[j].Color.b = float (LightColor.Blue ()); | |
852 | ||
853 | if ( (LightType == Visual3d_TOLS_POSITIONAL) || | |
854 | (LightType == Visual3d_TOLS_SPOT) ) { | |
855 | LightPosition.Coord (X, Y, Z); | |
856 | lights[j].Position.x = float (X); | |
857 | lights[j].Position.y = float (Y); | |
858 | lights[j].Position.z = float (Z); | |
859 | } | |
860 | ||
861 | if ( (LightType == Visual3d_TOLS_DIRECTIONAL) || | |
862 | (LightType == Visual3d_TOLS_SPOT) ) { | |
863 | LightDirection.Coord (X, Y, Z); | |
864 | lights[j].Direction.x = float (X); | |
865 | lights[j].Direction.y = float (Y); | |
866 | lights[j].Direction.z = float (Z); | |
867 | } | |
868 | ||
869 | if ( (LightType == Visual3d_TOLS_POSITIONAL) || | |
870 | (LightType == Visual3d_TOLS_SPOT) ) { | |
871 | lights[j].Attenuation[0] = | |
872 | float (LightAttenuation1); | |
873 | lights[j].Attenuation[1] = | |
874 | float (LightAttenuation2); | |
875 | } | |
876 | ||
877 | if (LightType == Visual3d_TOLS_SPOT) { | |
878 | lights[j].Concentration = | |
879 | float (LightConcentration); | |
880 | lights[j].Angle = | |
881 | float (LightAngle); | |
882 | } | |
883 | } | |
884 | ||
885 | } | |
886 | #ifdef BUC60570 | |
887 | } | |
888 | #endif | |
81bba717 | 889 | // management of light sources |
7fd59977 | 890 | if (! IsDeleted ()) |
891 | if (IsDefined ()) | |
892 | MyGraphicDriver->SetLight (MyCView); | |
893 | ||
81bba717 | 894 | // Dynamic allocation |
7fd59977 | 895 | if (MyCView.Context.NbActiveLight > 0) delete [] lights; |
896 | ||
897 | } | |
898 | ||
899 | void Visual3d_View::UpdatePlanes () { | |
900 | ||
901 | Standard_Integer i, j; | |
902 | CALL_DEF_PLANE *planes=NULL; | |
903 | ||
904 | i = MyContext.NumberOfActivatedClipPlanes (); | |
905 | j = MyGraphicDriver->InquirePlaneLimit (); | |
906 | MyCView.Context.NbActivePlane = (i > j ? j : i); | |
907 | ||
908 | if (MyCView.Context.NbActivePlane > 0) { | |
909 | ||
81bba717 | 910 | // Dynamic Allocation |
7fd59977 | 911 | #ifdef GER61454 //Keep the plane address for the next Update ! |
912 | if( !MyCView.Context.ActivePlane ) | |
913 | MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j]; | |
914 | planes = MyCView.Context.ActivePlane; | |
915 | #else | |
916 | planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane]; | |
917 | ||
918 | MyCView.Context.ActivePlane = planes; | |
919 | #endif | |
920 | Standard_Real A, B, C, D; | |
921 | ||
81bba717 | 922 | // Parcing of clipping planes |
7fd59977 | 923 | for (j=0; j<MyCView.Context.NbActivePlane; j++) { |
924 | ||
925 | planes[j].WsId = MyCView.ViewId; | |
926 | planes[j].ViewId = MyCView.ViewId; | |
927 | ||
928 | planes[j].Active = 1; | |
929 | planes[j].PlaneId = | |
930 | int ((MyContext.ActivatedClipPlane (j+1))->Identification ()); | |
931 | ||
932 | (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D); | |
933 | planes[j].CoefA = float (A); | |
934 | planes[j].CoefB = float (B); | |
935 | planes[j].CoefC = float (C); | |
936 | planes[j].CoefD = float (D); | |
937 | } | |
938 | ||
939 | } | |
940 | ||
81bba717 | 941 | // Management of planes of clipping model |
7fd59977 | 942 | if (! IsDeleted ()) |
943 | if (IsDefined ()) | |
944 | MyGraphicDriver->SetPlane (MyCView); | |
945 | ||
81bba717 | 946 | // Dynamic allocation |
7fd59977 | 947 | #ifdef GER61454 |
948 | if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0) | |
949 | ) { | |
950 | delete [] MyCView.Context.ActivePlane; | |
951 | MyCView.Context.ActivePlane = NULL; | |
952 | } | |
953 | #else | |
954 | if (MyCView.Context.NbActivePlane > 0) delete [] planes; | |
955 | #endif | |
956 | ||
957 | } | |
958 | ||
959 | void Visual3d_View::SetBackground (const Aspect_Background& ABack) { | |
960 | ||
961 | if (IsDeleted ()) return; | |
962 | ||
963 | if (! IsDefined ()) | |
964 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
965 | ||
81bba717 | 966 | // At this level, only GL can update the background. |
967 | // It is not necessary to call MyWindow->SetBackground (ABack); as | |
968 | // this method starts update of window background by X | |
969 | // (if the windowing is X) | |
7fd59977 | 970 | |
971 | Standard_Real R, G, B; | |
972 | MyBackground = ABack; | |
973 | (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB); | |
974 | MyCView.DefWindow.Background.r = float (R); | |
975 | MyCView.DefWindow.Background.g = float (G); | |
976 | MyCView.DefWindow.Background.b = float (B); | |
977 | ||
978 | MyGraphicDriver->Background (MyCView); | |
979 | ||
980 | if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP) | |
981 | Update (); | |
982 | ||
983 | } | |
984 | ||
985 | void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update) | |
986 | { | |
987 | ||
988 | if (IsDeleted ()) return; | |
989 | ||
990 | if (! IsDefined ()) | |
991 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
992 | ||
993 | MyGradientBackground = ABack; | |
994 | Quantity_Color aCol1,aCol2; | |
995 | MyGradientBackground.Colors(aCol1,aCol2); | |
996 | MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod()); | |
997 | ||
998 | if ( update ) | |
999 | Update (); | |
1000 | else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP) | |
1001 | Update(); | |
1002 | } | |
1003 | ||
1004 | void Visual3d_View::SetBackgroundImage( const Standard_CString FileName, | |
1005 | const Aspect_FillMethod FillStyle, | |
1006 | const Standard_Boolean update ) | |
1007 | { | |
1008 | #ifdef OCC1188 | |
1009 | if ( IsDeleted() ) | |
1010 | return; | |
1011 | if ( !IsDefined() ) | |
1012 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
1013 | ||
1014 | MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle ); | |
1015 | ||
1016 | if ( update ) | |
1017 | Update(); | |
1018 | else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) | |
1019 | Update(); | |
1020 | #endif | |
1021 | } | |
1022 | ||
1023 | void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle, | |
1024 | const Standard_Boolean update ) | |
1025 | { | |
1026 | #ifdef OCC1188 | |
1027 | if ( IsDeleted() ) | |
1028 | return; | |
1029 | if ( !IsDefined() ) | |
1030 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
1031 | ||
1032 | MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle ); | |
1033 | ||
1034 | if ( update ) | |
1035 | Update(); | |
1036 | else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) | |
1037 | Update(); | |
1038 | #endif | |
1039 | } | |
1040 | ||
1041 | Aspect_Background Visual3d_View::Background () const { | |
1042 | ||
1043 | return (MyBackground); | |
1044 | ||
1045 | } | |
1046 | ||
1047 | void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle, | |
1048 | const Standard_Boolean update ) | |
1049 | { | |
1050 | if ( IsDeleted() ) | |
1051 | return; | |
1052 | if ( !IsDefined() ) | |
1053 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
1054 | ||
1055 | MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle ); | |
1056 | ||
1057 | if ( update ) | |
1058 | Update(); | |
1059 | else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) | |
1060 | Update(); | |
1061 | ||
1062 | } | |
1063 | ||
1064 | Aspect_GradientBackground Visual3d_View::GradientBackground () const { | |
1065 | ||
1066 | return MyGradientBackground; | |
1067 | ||
1068 | } | |
1069 | ||
1070 | void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) { | |
1071 | ||
1072 | if (IsDeleted ()) return; | |
1073 | ||
1074 | Standard_Integer lr, ur, lc, uc; | |
1075 | Standard_Integer i, j; | |
1076 | ||
1077 | // Assign the new transformation in an array [0..3][0..3] | |
81bba717 | 1078 | // Avoid problems if the has defined a matrice [1..4][1..4] |
7fd59977 | 1079 | // ou [3..6][-1..2] !! |
1080 | lr = AMatrix.LowerRow (); | |
1081 | ur = AMatrix.UpperRow (); | |
1082 | lc = AMatrix.LowerCol (); | |
1083 | uc = AMatrix.UpperCol (); | |
1084 | ||
1085 | if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) | |
1086 | Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix"); | |
1087 | ||
1088 | for (i=0; i<=3; i++) | |
1089 | for (j=0; j<=3; j++) | |
1090 | MyTransformation (i, j) = AMatrix (lr + i, lc + j); | |
1091 | ||
1092 | Graphic3d_Vector VPN; | |
1093 | Graphic3d_Vertex VRP; | |
1094 | Graphic3d_Vector VUP; | |
1095 | Standard_Real Sx, Sy, Sz; | |
1096 | ||
1097 | Visual3d_ViewOrientation NewViewOrientation; | |
1098 | ||
1099 | VPN = MyViewOrientation.ViewReferencePlane (); | |
1100 | VRP = MyViewOrientation.ViewReferencePoint (); | |
1101 | VUP = MyViewOrientation.ViewReferenceUp (); | |
1102 | MyViewOrientation.AxialScale(Sx, Sy, Sz); | |
1103 | ||
1104 | NewViewOrientation.SetViewReferencePlane | |
1105 | (Graphic3d_Structure::Transforms (Transform (), VPN)); | |
1106 | ||
1107 | NewViewOrientation.SetViewReferencePoint | |
1108 | (Graphic3d_Structure::Transforms (Transform (), VRP)); | |
1109 | ||
1110 | NewViewOrientation.SetViewReferenceUp | |
1111 | (Graphic3d_Structure::Transforms (Transform (), VUP)); | |
1112 | NewViewOrientation.SetAxialScale(Sx, Sy, Sz); | |
1113 | ||
1114 | SetViewOrientation (NewViewOrientation); | |
1115 | ||
1116 | MyMatOfOriIsModified = Standard_True; | |
1117 | MyMatOfOriIsEvaluated = Standard_False; | |
1118 | ||
1119 | } | |
1120 | ||
1121 | const TColStd_Array2OfReal& Visual3d_View::Transform () const { | |
1122 | ||
1123 | return (MyTransformation); | |
1124 | ||
1125 | } | |
1126 | ||
1127 | void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) { | |
1128 | ||
1129 | if (IsDeleted ()) return; | |
1130 | ||
1131 | MyViewOrientation = VO; | |
1132 | ||
1133 | Standard_Real X, Y, Z; | |
1134 | ||
81bba717 | 1135 | // Tests on modification of parameters. |
7fd59977 | 1136 | Standard_Boolean VUPIsModified = Standard_False; |
1137 | Standard_Boolean VRPIsModified = Standard_False; | |
1138 | Standard_Boolean VRUIsModified = Standard_False; | |
1139 | Standard_Boolean ScaleIsModified = Standard_False; | |
1140 | Standard_Boolean CustomIsModified = Standard_False; | |
1141 | ||
1142 | (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z); | |
1143 | VUPIsModified = | |
1144 | MyCView.Orientation.ViewReferencePoint.x != float (X) | |
1145 | || MyCView.Orientation.ViewReferencePoint.y != float (Y) | |
1146 | || MyCView.Orientation.ViewReferencePoint.z != float (Z); | |
1147 | MyCView.Orientation.ViewReferencePoint.x = float (X); | |
1148 | MyCView.Orientation.ViewReferencePoint.y = float (Y); | |
1149 | MyCView.Orientation.ViewReferencePoint.z = float (Z); | |
1150 | ||
1151 | (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z); | |
1152 | VRPIsModified = | |
1153 | MyCView.Orientation.ViewReferencePlane.x != float (X) | |
1154 | || MyCView.Orientation.ViewReferencePlane.y != float (Y) | |
1155 | || MyCView.Orientation.ViewReferencePlane.z != float (Z); | |
1156 | MyCView.Orientation.ViewReferencePlane.x = float (X); | |
1157 | MyCView.Orientation.ViewReferencePlane.y = float (Y); | |
1158 | MyCView.Orientation.ViewReferencePlane.z = float (Z); | |
1159 | ||
1160 | (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z); | |
1161 | VRUIsModified = | |
1162 | MyCView.Orientation.ViewReferenceUp.x != float (X) | |
1163 | || MyCView.Orientation.ViewReferenceUp.y != float (Y) | |
1164 | || MyCView.Orientation.ViewReferenceUp.z != float (Z); | |
1165 | MyCView.Orientation.ViewReferenceUp.x = float (X); | |
1166 | MyCView.Orientation.ViewReferenceUp.y = float (Y); | |
1167 | MyCView.Orientation.ViewReferenceUp.z = float (Z); | |
1168 | ||
1169 | Standard_Real Sx, Sy, Sz; | |
1170 | ||
1171 | MyViewOrientation.AxialScale(Sx, Sy, Sz); | |
1172 | ScaleIsModified = | |
1173 | MyCView.Orientation.ViewScaleX != float (X) | |
1174 | || MyCView.Orientation.ViewScaleY != float (Y) | |
1175 | || MyCView.Orientation.ViewScaleZ != float (Z); | |
1176 | MyCView.Orientation.ViewScaleX = float (Sx); | |
1177 | MyCView.Orientation.ViewScaleY = float (Sy); | |
1178 | MyCView.Orientation.ViewScaleZ = float (Sz); | |
1179 | ||
1180 | CustomIsModified = | |
1181 | MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix(); | |
1182 | MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix(); | |
1183 | if ( MyViewOrientation.IsCustomMatrix() ) { | |
1184 | Standard_Integer i, j; | |
1185 | for (i = 0; i < 4; i++) | |
1186 | for (j = 0; j < 4; j++) { | |
1187 | if (!CustomIsModified) CustomIsModified = | |
1188 | MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j); | |
1189 | MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j); | |
1190 | } | |
1191 | } | |
1192 | ||
1193 | #ifdef TRACE_TRSF | |
1194 | cout << "Visual3d_View::SetViewOrientation\n"; | |
1195 | if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) | |
1196 | cout << "VUPIsModified : " << VUPIsModified | |
1197 | << ", VRPIsModified : " << VRPIsModified | |
1198 | << ", VRUIsModified : " << VRUIsModified | |
1199 | << ", CustomIsModified : " << CustomIsModified << "\n" << flush; | |
1200 | else | |
1201 | cout << "no modification\n" << flush; | |
1202 | #endif | |
1203 | ||
81bba717 | 1204 | // restart if one of parameters is modified |
7fd59977 | 1205 | if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) { |
1206 | ||
1207 | if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) { | |
1208 | MyMatOfOriIsModified = Standard_True; | |
1209 | MyMatOfOriIsEvaluated = Standard_False; | |
1210 | } | |
1211 | ||
1212 | if (! IsDefined ()) return; | |
1213 | ||
81bba717 | 1214 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 1215 | MyGraphicDriver->ViewOrientation (MyCView, AWait); |
1216 | ||
1217 | Compute (); | |
1218 | ||
1219 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1220 | } | |
1221 | ||
1222 | } | |
1223 | ||
1224 | Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const { | |
1225 | ||
1226 | return (MyViewOrientation); | |
1227 | ||
1228 | } | |
1229 | ||
1230 | Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const { | |
1231 | ||
1232 | return (MyViewOrientationReset); | |
1233 | ||
1234 | } | |
1235 | ||
1236 | void Visual3d_View::SetViewOrientationDefault () { | |
1237 | ||
1238 | MyViewOrientationReset.Assign (MyViewOrientation); | |
1239 | ||
1240 | } | |
1241 | ||
1242 | void Visual3d_View::ViewOrientationReset () { | |
1243 | ||
1244 | if (IsDeleted ()) return; | |
1245 | ||
1246 | MyViewOrientation = MyViewOrientationReset; | |
1247 | ||
1248 | Standard_Real X, Y, Z; | |
1249 | ||
81bba717 | 1250 | // Tests on modification of parameters. |
7fd59977 | 1251 | Standard_Boolean VUPIsModified = Standard_False; |
1252 | Standard_Boolean VRPIsModified = Standard_False; | |
1253 | Standard_Boolean VRUIsModified = Standard_False; | |
1254 | Standard_Boolean ScaleIsModified = Standard_False; | |
1255 | Standard_Boolean CustomIsModified = Standard_False; | |
1256 | ||
1257 | (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z); | |
1258 | VUPIsModified = | |
1259 | MyCView.Orientation.ViewReferencePoint.x != float (X) | |
1260 | || MyCView.Orientation.ViewReferencePoint.y != float (Y) | |
9d21a648 | 1261 | || MyCView.Orientation.ViewReferencePoint.z != float (Z); |
7fd59977 | 1262 | MyCView.Orientation.ViewReferencePoint.x = float (X); |
1263 | MyCView.Orientation.ViewReferencePoint.y = float (Y); | |
1264 | MyCView.Orientation.ViewReferencePoint.z = float (Z); | |
1265 | ||
1266 | (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z); | |
1267 | VRPIsModified = | |
1268 | MyCView.Orientation.ViewReferencePlane.x != float (X) | |
1269 | || MyCView.Orientation.ViewReferencePlane.y != float (Y) | |
9d21a648 | 1270 | || MyCView.Orientation.ViewReferencePlane.z != float (Z); |
7fd59977 | 1271 | MyCView.Orientation.ViewReferencePlane.x = float (X); |
1272 | MyCView.Orientation.ViewReferencePlane.y = float (Y); | |
1273 | MyCView.Orientation.ViewReferencePlane.z = float (Z); | |
1274 | ||
1275 | (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z); | |
1276 | VRUIsModified = | |
1277 | MyCView.Orientation.ViewReferenceUp.x != float (X) | |
1278 | || MyCView.Orientation.ViewReferenceUp.y != float (Y) | |
9d21a648 | 1279 | || MyCView.Orientation.ViewReferenceUp.z != float (Z); |
7fd59977 | 1280 | MyCView.Orientation.ViewReferenceUp.x = float (X); |
1281 | MyCView.Orientation.ViewReferenceUp.y = float (Y); | |
1282 | MyCView.Orientation.ViewReferenceUp.z = float (Z); | |
1283 | ||
1284 | Standard_Real Sx, Sy, Sz; | |
1285 | ||
1286 | MyViewOrientation.AxialScale(Sx, Sy, Sz); | |
1287 | ScaleIsModified = | |
1288 | MyCView.Orientation.ViewScaleX != float (X) | |
1289 | || MyCView.Orientation.ViewScaleY != float (Y) | |
1290 | || MyCView.Orientation.ViewScaleZ != float (Z); | |
1291 | MyCView.Orientation.ViewScaleX = float (Sx); | |
1292 | MyCView.Orientation.ViewScaleY = float (Sy); | |
1293 | MyCView.Orientation.ViewScaleZ = float (Sz); | |
1294 | ||
1295 | CustomIsModified = | |
1296 | MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix(); | |
1297 | MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix(); | |
1298 | if ( MyViewOrientation.IsCustomMatrix() ) { | |
1299 | Standard_Integer i, j; | |
1300 | for (i = 0; i < 4; i++) | |
1301 | for (j = 0; j < 4; j++) { | |
1302 | if (!CustomIsModified) CustomIsModified = | |
1303 | MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j); | |
1304 | MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j); | |
1305 | } | |
1306 | } | |
1307 | ||
1308 | #ifdef TRACE_TRSF | |
1309 | cout << "Visual3d_View::ViewOrientationReset\n"; | |
1310 | if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) | |
1311 | cout << "VUPIsModified : " << VUPIsModified | |
1312 | << ", VRPIsModified : " << VRPIsModified | |
1313 | << ", VRUIsModified : " << VRUIsModified | |
1314 | << ", CustomIsModified : " << CustomIsModified << "\n" << flush; | |
1315 | else | |
1316 | cout << "no modification\n" << flush; | |
1317 | #endif | |
1318 | ||
81bba717 | 1319 | // Restart if one of parameters is modified |
7fd59977 | 1320 | if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) { |
1321 | ||
1322 | if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) { | |
1323 | MyMatOfOriIsModified = Standard_True; | |
1324 | MyMatOfOriIsEvaluated = Standard_False; | |
1325 | } | |
1326 | ||
1327 | if (! IsDefined ()) return; | |
1328 | ||
81bba717 | 1329 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 1330 | MyGraphicDriver->ViewOrientation (MyCView, AWait); |
1331 | ||
1332 | Compute (); | |
1333 | ||
1334 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1335 | } | |
1336 | ||
1337 | } | |
1338 | ||
1339 | void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) { | |
1340 | ||
1341 | if (IsDeleted ()) return; | |
1342 | ||
1343 | Visual3d_TypeOfProjection OldType = MyViewMapping.Projection (); | |
1344 | Visual3d_TypeOfProjection NewType = VM.Projection (); | |
1345 | ||
1346 | MyViewMapping = VM; | |
1347 | ||
1348 | Standard_Real X, Y, Z; | |
1349 | Standard_Real um, vm, uM, vM; | |
1350 | ||
1351 | MyCView.Mapping.Projection = int (MyViewMapping.Projection ()); | |
1352 | (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z); | |
1353 | MyCView.Mapping.ProjectionReferencePoint.x = float (X); | |
1354 | MyCView.Mapping.ProjectionReferencePoint.y = float (Y); | |
1355 | MyCView.Mapping.ProjectionReferencePoint.z = float (Z); | |
1356 | MyCView.Mapping.ViewPlaneDistance = | |
1357 | float (MyViewMapping.ViewPlaneDistance ()); | |
1358 | MyCView.Mapping.BackPlaneDistance = | |
1359 | float (MyViewMapping.BackPlaneDistance ()); | |
1360 | MyCView.Mapping.FrontPlaneDistance = | |
1361 | float (MyViewMapping.FrontPlaneDistance ()); | |
1362 | MyViewMapping.WindowLimit (um, vm, uM, vM); | |
1363 | MyCView.Mapping.WindowLimit.um = float (um); | |
1364 | MyCView.Mapping.WindowLimit.vm = float (vm); | |
1365 | MyCView.Mapping.WindowLimit.uM = float (uM); | |
1366 | MyCView.Mapping.WindowLimit.vM = float (vM); | |
1367 | ||
1368 | MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix(); | |
1369 | if (MyViewMapping.IsCustomMatrix()) { | |
1370 | Standard_Integer i, j; | |
1371 | for (i = 0; i < 4; i++) | |
1372 | for (j = 0; j < 4; j++) | |
1373 | MyCView.Mapping.ProjectionMatrix[i][j] = | |
1374 | MyViewMapping.MyProjectionMatrix->Value(i,j); | |
1375 | } | |
1376 | ||
1377 | MyMatOfMapIsModified = Standard_True; | |
1378 | MyMatOfMapIsEvaluated = Standard_False; | |
1379 | ||
1380 | if (! IsDefined ()) return; | |
1381 | ||
81bba717 | 1382 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 1383 | MyGraphicDriver->ViewMapping (MyCView, AWait); |
1384 | ||
1385 | // Passage Parallele/Perspective | |
1386 | if (OldType != NewType) | |
1387 | Compute (); | |
1388 | ||
1389 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1390 | ||
1391 | } | |
1392 | ||
1393 | Visual3d_ViewMapping Visual3d_View::ViewMapping () const { | |
1394 | ||
1395 | return (MyViewMapping); | |
1396 | ||
1397 | } | |
1398 | ||
1399 | Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const { | |
1400 | ||
1401 | return (MyViewMappingReset); | |
1402 | ||
1403 | } | |
1404 | ||
1405 | void Visual3d_View::SetViewMappingDefault () { | |
1406 | ||
1407 | MyViewMappingReset.Assign (MyViewMapping); | |
1408 | ||
1409 | } | |
1410 | ||
1411 | void Visual3d_View::ViewMappingReset () { | |
1412 | ||
1413 | if (IsDeleted ()) return; | |
1414 | ||
1415 | MyViewMapping = MyViewMappingReset; | |
1416 | ||
1417 | Standard_Real X, Y, Z; | |
1418 | Standard_Real um, vm, uM, vM; | |
1419 | ||
1420 | MyCView.Mapping.Projection = int (MyViewMapping.Projection ()); | |
1421 | (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z); | |
1422 | MyCView.Mapping.ProjectionReferencePoint.x = float (X); | |
1423 | MyCView.Mapping.ProjectionReferencePoint.y = float (Y); | |
1424 | MyCView.Mapping.ProjectionReferencePoint.z = float (Z); | |
1425 | MyCView.Mapping.ViewPlaneDistance = | |
1426 | float (MyViewMapping.ViewPlaneDistance ()); | |
1427 | MyCView.Mapping.BackPlaneDistance = | |
1428 | float (MyViewMapping.BackPlaneDistance ()); | |
1429 | MyCView.Mapping.FrontPlaneDistance = | |
1430 | float (MyViewMapping.FrontPlaneDistance ()); | |
1431 | MyViewMapping.WindowLimit (um, vm, uM, vM); | |
1432 | MyCView.Mapping.WindowLimit.um = float (um); | |
1433 | MyCView.Mapping.WindowLimit.vm = float (vm); | |
1434 | MyCView.Mapping.WindowLimit.uM = float (uM); | |
1435 | MyCView.Mapping.WindowLimit.vM = float (vM); | |
1436 | ||
1437 | MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix(); | |
1438 | if (MyViewMapping.IsCustomMatrix()) { | |
1439 | Standard_Integer i, j; | |
1440 | for (i = 0; i < 4; i++) | |
1441 | for (j = 0; j < 4; j++) | |
1442 | MyCView.Mapping.ProjectionMatrix[i][j] = | |
1443 | MyViewMapping.MyProjectionMatrix->Value(i,j); | |
1444 | } | |
1445 | ||
1446 | MyMatOfMapIsModified = Standard_True; | |
1447 | MyMatOfMapIsEvaluated = Standard_False; | |
1448 | ||
1449 | if (! IsDefined ()) return; | |
1450 | ||
81bba717 | 1451 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 1452 | MyGraphicDriver->ViewMapping (MyCView, AWait); |
1453 | ||
1454 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1455 | ||
1456 | } | |
1457 | ||
1458 | void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) { | |
1459 | ||
1460 | if (IsDeleted ()) return; | |
1461 | ||
1462 | Visual3d_TypeOfVisualization OldVisualMode; | |
1463 | Visual3d_TypeOfVisualization NewVisualMode; | |
1464 | ||
81bba717 | 1465 | // To manage display only in case of |
1466 | // change of visualisation mode. | |
7fd59977 | 1467 | OldVisualMode = MyContext.Visualization (); |
1468 | NewVisualMode = CTX.Visualization (); | |
1469 | ||
1470 | Visual3d_TypeOfModel OldModel; | |
1471 | Visual3d_TypeOfModel NewModel; | |
1472 | ||
81bba717 | 1473 | // To manage change of visualisation only in case |
1474 | // of change of mode of visualisation or of type of shading. | |
7fd59977 | 1475 | OldModel = MyContext.Model (); |
1476 | NewModel = CTX.Model (); | |
1477 | ||
1478 | Standard_Boolean OldAliasingMode; | |
1479 | Standard_Boolean NewAliasingMode; | |
1480 | ||
81bba717 | 1481 | // To manage antialiasing only in case of change. |
7fd59977 | 1482 | OldAliasingMode = MyContext.AliasingIsOn (); |
1483 | NewAliasingMode = CTX.AliasingIsOn (); | |
1484 | ||
1485 | Standard_Boolean OldDepthCueingMode; | |
1486 | Standard_Boolean NewDepthCueingMode; | |
1487 | ||
1488 | Standard_Real OldDepthCueingFrontPlane; | |
1489 | Standard_Real NewDepthCueingFrontPlane; | |
1490 | Standard_Real OldDepthCueingBackPlane; | |
1491 | Standard_Real NewDepthCueingBackPlane; | |
1492 | ||
81bba717 | 1493 | // To manage the depth cueing only in case of change. |
7fd59977 | 1494 | OldDepthCueingMode = MyContext.DepthCueingIsOn (); |
1495 | NewDepthCueingMode = CTX.DepthCueingIsOn (); | |
1496 | ||
1497 | OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane (); | |
1498 | NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane (); | |
1499 | OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane (); | |
1500 | NewDepthCueingBackPlane = CTX.DepthCueingBackPlane (); | |
1501 | ||
1502 | Standard_Boolean OldFrontZClippingMode; | |
1503 | Standard_Boolean NewFrontZClippingMode; | |
1504 | Standard_Boolean OldBackZClippingMode; | |
1505 | Standard_Boolean NewBackZClippingMode; | |
1506 | ||
1507 | Standard_Real OldZClippingFrontPlane; | |
1508 | Standard_Real NewZClippingFrontPlane; | |
1509 | Standard_Real OldZClippingBackPlane; | |
1510 | Standard_Real NewZClippingBackPlane; | |
1511 | ||
81bba717 | 1512 | // To manage the Zclipping only in case of change. |
7fd59977 | 1513 | OldFrontZClippingMode = MyContext.FrontZClippingIsOn (); |
1514 | NewFrontZClippingMode = CTX.FrontZClippingIsOn (); | |
1515 | OldBackZClippingMode = MyContext.BackZClippingIsOn (); | |
1516 | NewBackZClippingMode = CTX.BackZClippingIsOn (); | |
1517 | ||
1518 | OldZClippingFrontPlane = MyContext.ZClippingFrontPlane (); | |
1519 | NewZClippingFrontPlane = CTX.ZClippingFrontPlane (); | |
1520 | OldZClippingBackPlane = MyContext.ZClippingBackPlane (); | |
1521 | NewZClippingBackPlane = CTX.ZClippingBackPlane (); | |
1522 | ||
1523 | Standard_Integer OldTexEnvId; | |
1524 | Standard_Integer NewTexEnvId; | |
1525 | Visual3d_TypeOfSurfaceDetail OldSurfaceDetail; | |
1526 | Visual3d_TypeOfSurfaceDetail NewSurfaceDetail; | |
1527 | ||
1528 | Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv(); | |
1529 | if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId(); | |
1530 | else OldTexEnvId = -1; | |
1531 | ||
1532 | Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv(); | |
1533 | ||
1534 | if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId(); | |
1535 | else NewTexEnvId = -1; | |
1536 | ||
1537 | OldSurfaceDetail = MyContext.SurfaceDetail(); | |
1538 | NewSurfaceDetail = CTX.SurfaceDetail(); | |
1539 | ||
1540 | MyContext = CTX; | |
1541 | ||
1542 | UpdateView (); | |
1543 | ||
81bba717 | 1544 | Standard_Boolean AWait = Standard_False; // => immediate update |
7fd59977 | 1545 | if (IsDefined ()) { |
81bba717 | 1546 | // management of visualization modes and types of shading. |
7fd59977 | 1547 | if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel)) |
1548 | MyGraphicDriver->SetVisualisation (MyCView); | |
1549 | ||
81bba717 | 1550 | // management of antialiasing. |
7fd59977 | 1551 | if (OldAliasingMode != NewAliasingMode) |
1552 | MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode); | |
1553 | ||
81bba717 | 1554 | // management of depth_cueing. |
7fd59977 | 1555 | if ((OldDepthCueingMode != NewDepthCueingMode) || |
1556 | (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) || | |
1557 | (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) { | |
1558 | #ifdef BUC60572 | |
1559 | if( NewDepthCueingMode && | |
1560 | (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) ) | |
1561 | Visual3d_DepthCueingDefinitionError::Raise | |
1562 | ("Bad value for DepthCueingPlanes position"); | |
1563 | #endif | |
1564 | MyGraphicDriver->DepthCueing | |
1565 | (MyCView, NewDepthCueingMode); | |
1566 | } | |
1567 | ||
81bba717 | 1568 | // management of Zclipping |
7fd59977 | 1569 | if ((OldFrontZClippingMode != NewFrontZClippingMode) || |
1570 | (OldBackZClippingMode != NewBackZClippingMode) || | |
1571 | (OldZClippingFrontPlane != NewZClippingFrontPlane) || | |
1572 | (OldZClippingBackPlane != NewZClippingBackPlane)) { | |
1573 | #ifdef BUC60572 | |
1574 | if( NewBackZClippingMode && NewFrontZClippingMode && | |
1575 | (NewZClippingBackPlane >= NewZClippingFrontPlane) ) | |
1576 | Visual3d_ZClippingDefinitionError::Raise | |
1577 | ("Bad value for ZClippingPlanes position"); | |
1578 | #endif | |
1579 | MyGraphicDriver->ClipLimit (MyCView, AWait); | |
1580 | } | |
1581 | ||
81bba717 | 1582 | // management of textures |
7fd59977 | 1583 | if ( (OldTexEnvId != NewTexEnvId) || |
1584 | (OldSurfaceDetail != NewSurfaceDetail) ) | |
1585 | MyGraphicDriver->Environment(MyCView); | |
1586 | ||
81bba717 | 1587 | // Update of planes of model clipping |
7fd59977 | 1588 | UpdatePlanes (); |
1589 | ||
81bba717 | 1590 | // Update of light sources |
7fd59977 | 1591 | UpdateLights (); |
1592 | } | |
1593 | ||
1594 | if (OldVisualMode != NewVisualMode) { | |
1595 | ||
1596 | /* | |
81bba717 | 1597 | * Change of context => |
1598 | * Remove structures that cannot be displayed | |
1599 | * in the new visualisation mode. | |
1600 | * It is not necessary to warn ViewManager as | |
1601 | * this structure should not disappear from | |
1602 | * the list of structures displayed in it. | |
7fd59977 | 1603 | */ |
1604 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
1605 | Visual3d_TypeOfAnswer Answer; | |
1606 | ||
1607 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
1608 | ||
1609 | Graphic3d_SequenceOfStructure FooSequence; | |
1610 | ||
1611 | while (S1Iterator.More ()) { | |
1612 | Answer = AcceptDisplay (S1Iterator.Key ()); | |
81bba717 | 1613 | // If the structure can't be displayed in the |
1614 | // new context of the view, it is removed. | |
7fd59977 | 1615 | if ((Answer == Visual3d_TOA_NO) || |
1616 | (Answer == Visual3d_TOA_COMPUTE)) | |
1617 | //Erase (S1Iterator.Key (), Aspect_TOU_WAIT); | |
1618 | FooSequence.Append (S1Iterator.Key ()); | |
1619 | ||
81bba717 | 1620 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 1621 | S1Iterator.Next (); |
1622 | } | |
1623 | ||
1624 | Standard_Integer Length = FooSequence.Length (); | |
81bba717 | 1625 | // The stored structures are removed |
7fd59977 | 1626 | for (i=1; i<=Length; i++) |
1627 | Erase (FooSequence.Value (i), Aspect_TOU_WAIT); | |
1628 | if (Length != 0) FooSequence.Clear (); | |
1629 | ||
1630 | /* | |
81bba717 | 1631 | * Change of context => |
1632 | * Display structures that can be displayed | |
1633 | * with the new visualisation mode. | |
1634 | * All structures with status Displayed are removed from the ViewManager | |
1635 | * and displayed in the view directly, if the structure is not already | |
1636 | * displayed and if the view accepts it in its context. | |
7fd59977 | 1637 | */ |
1638 | ||
1639 | i = MyViewManager->NumberOfDisplayedStructures (); | |
1640 | Graphic3d_MapOfStructure Map; | |
1641 | MyViewManager->DisplayedStructures(Map); | |
1642 | Graphic3d_MapIteratorOfMapOfStructure it(Map); | |
1643 | ||
1644 | for (; it.More(); it.Next()) { | |
1645 | Handle(Graphic3d_Structure) SG = it.Key(); | |
1646 | if (! IsDisplayed (SG)) { | |
1647 | Answer = AcceptDisplay(SG); | |
81bba717 | 1648 | // If the structure can be displayed in the |
1649 | // new context of the view, it is displayed. | |
7fd59977 | 1650 | if ((Answer == Visual3d_TOA_YES) || |
1651 | (Answer == Visual3d_TOA_COMPUTE)) | |
1652 | //Display (MyViewManager->DisplayedStructure (j), | |
1653 | //Aspect_TOU_WAIT); | |
1654 | FooSequence.Append (SG); | |
1655 | } | |
1656 | } | |
1657 | ||
1658 | Length = FooSequence.Length (); | |
81bba717 | 1659 | // The stored structures are displayed |
7fd59977 | 1660 | for (i=1; i<=Length; i++) |
1661 | Display (FooSequence.Value (i), Aspect_TOU_WAIT); | |
1662 | if (Length != 0) FooSequence.Clear (); | |
1663 | } | |
1664 | ||
1665 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1666 | ||
1667 | } | |
1668 | ||
1669 | const Visual3d_ContextView& Visual3d_View::Context () const { | |
1670 | ||
1671 | return (MyContext); | |
1672 | ||
1673 | } | |
1674 | ||
1675 | void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const | |
1676 | { | |
1677 | ||
1678 | if (IsDeleted ()) return; | |
1679 | ||
1680 | Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure); | |
1681 | ||
1682 | while (Iterator.More ()) { | |
1683 | SG.Add (Iterator.Key ()); | |
1684 | ||
81bba717 | 1685 | // Iterator.Next () is located on the next structure |
7fd59977 | 1686 | Iterator.Next (); |
1687 | } | |
1688 | ||
1689 | } | |
1690 | ||
1691 | void Visual3d_View::Activate () { | |
1692 | ||
1693 | if (IsDeleted ()) return; | |
1694 | ||
1695 | if (! IsDefined ()) | |
1696 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
1697 | ||
1698 | if (! IsActive ()) { | |
1699 | ||
1700 | MyGraphicDriver->ActivateView (MyCView); | |
1701 | MyGraphicDriver->Background (MyCView); | |
1702 | MyGraphicDriver->Transparency | |
1703 | (MyCView, MyViewManager->Transparency ()); | |
1704 | ||
1705 | MyCView.Active = 1; | |
1706 | ||
1707 | /* | |
81bba717 | 1708 | * Activation of a new view => |
1709 | * Display structures that can be displayed in this new view. | |
1710 | * All structures with status | |
1711 | * Displayed in ViewManager are returned and displayed in | |
1712 | * the view directly, if the structure is not already | |
1713 | * displayed and if the view accepts it in its context. | |
7fd59977 | 1714 | */ |
1715 | ||
1716 | Visual3d_TypeOfAnswer Answer; | |
1717 | Graphic3d_MapOfStructure Map; | |
1718 | MyViewManager->DisplayedStructures(Map); | |
1719 | Graphic3d_MapIteratorOfMapOfStructure it(Map); | |
1720 | ||
1721 | for (; it.More(); it.Next()) { | |
1722 | Handle(Graphic3d_Structure) SG = it.Key(); | |
1723 | if (! IsDisplayed (SG)) { | |
1724 | Answer = AcceptDisplay(SG); | |
81bba717 | 1725 | // If the structure can be displayed in the |
1726 | // new context of the view, it is displayed. | |
7fd59977 | 1727 | if ((Answer == Visual3d_TOA_YES) || |
1728 | (Answer == Visual3d_TOA_COMPUTE)) | |
1729 | Display (SG,Aspect_TOU_WAIT); | |
1730 | } | |
1731 | } | |
1732 | ||
1733 | } | |
1734 | ||
81bba717 | 1735 | // If the activation/desactivation of ZBuffer should be automatic |
1736 | // depending on the presence or absence of facets. | |
7fd59977 | 1737 | if (MyViewManager->ZBufferAuto ()) { |
1738 | Standard_Boolean BContainsFacet = ContainsFacet (); | |
1739 | Standard_Boolean BZBuffer = ZBufferIsActivated (); | |
81bba717 | 1740 | // If the view contains facets |
1741 | // and if ZBuffer is not active | |
7fd59977 | 1742 | if (BContainsFacet && ! BZBuffer) |
1743 | SetZBufferActivity (1); | |
81bba717 | 1744 | // If the view does not contain facets |
1745 | // and if ZBuffer is active | |
7fd59977 | 1746 | if (! BContainsFacet && BZBuffer) |
1747 | SetZBufferActivity (0); | |
1748 | } | |
1749 | ||
1750 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1751 | ||
1752 | } | |
1753 | ||
1754 | Standard_Boolean Visual3d_View::IsActive () const { | |
1755 | ||
1756 | if (IsDeleted ()) return (Standard_False); | |
1757 | ||
1758 | if (MyCView.Active) | |
1759 | return (Standard_True); | |
1760 | else | |
1761 | return (Standard_False); | |
1762 | ||
1763 | } | |
1764 | ||
1765 | void Visual3d_View::Deactivate () { | |
1766 | ||
1767 | if (IsDeleted ()) return; | |
1768 | ||
1769 | if (! IsDefined ()) | |
1770 | Visual3d_ViewDefinitionError::Raise ("Window not defined"); | |
1771 | ||
1772 | if (IsActive ()) { | |
1773 | ||
1774 | MyGraphicDriver->DeactivateView (MyCView); | |
1775 | ||
1776 | /* | |
81bba717 | 1777 | * Deactivation of a view => |
1778 | * Removal of structures displayed in this view. | |
1779 | * All structures with status | |
1780 | * Displayed in ViewManager are returned and removed from | |
1781 | * the view directly, if the structure is not already | |
1782 | * displayed and if the view accepts it in its context. | |
1783 | */ | |
7fd59977 | 1784 | |
1785 | Visual3d_TypeOfAnswer Answer; | |
1786 | Graphic3d_MapOfStructure Map; | |
1787 | MyViewManager->DisplayedStructures(Map); | |
1788 | Graphic3d_MapIteratorOfMapOfStructure it(Map); | |
1789 | ||
1790 | for (; it.More(); it.Next()) { | |
1791 | Handle(Graphic3d_Structure) SG = it.Key(); | |
1792 | if (! IsDisplayed (SG)) { | |
1793 | Answer = AcceptDisplay(SG); | |
81bba717 | 1794 | // If the structure was displayed it is removed. |
7fd59977 | 1795 | if ((Answer == Visual3d_TOA_YES) || |
1796 | (Answer == Visual3d_TOA_COMPUTE)) | |
1797 | Erase (SG,Aspect_TOU_WAIT); | |
1798 | } | |
1799 | } | |
1800 | ||
1801 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
1802 | ||
81bba717 | 1803 | // No action currently possible in the view |
7fd59977 | 1804 | MyCView.Active = 0; |
1805 | } | |
1806 | ||
1807 | } | |
1808 | ||
1809 | void Visual3d_View::Redraw () { | |
1810 | ||
1811 | Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ()); | |
1812 | ||
1813 | } | |
1814 | ||
1815 | void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) { | |
1816 | ||
1817 | Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height); | |
1818 | } | |
1819 | ||
1820 | void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) { | |
1821 | ||
1822 | if (IsDeleted ()) return; | |
1823 | ||
1824 | if ((! IsDefined ()) || (! IsActive ())) return; | |
1825 | ||
1826 | if (! MyWindow->IsMapped ()) return; | |
1827 | ||
1828 | // san - 14/04/2004 - set up Z buffer state before redrawing | |
81bba717 | 1829 | // If the activation/desactivation of ZBuffer should be automatic |
1830 | // depending on the presence or absence of facets. | |
7fd59977 | 1831 | if (MyViewManager->ZBufferAuto ()) { |
1832 | Standard_Boolean BContainsFacet = ContainsFacet (); | |
1833 | Standard_Boolean BZBuffer = ZBufferIsActivated (); | |
81bba717 | 1834 | // If the view contains facets |
1835 | // and if ZBuffer is not active | |
7fd59977 | 1836 | if (BContainsFacet && ! BZBuffer) |
1837 | SetZBufferActivity (1); | |
81bba717 | 1838 | // If the view contains only facets |
1839 | // and if ZBuffer is active | |
7fd59977 | 1840 | if (! BContainsFacet && BZBuffer) |
1841 | SetZBufferActivity (0); | |
1842 | } | |
1843 | ||
1844 | Aspect_CLayer2d OverCLayer; | |
1845 | Aspect_CLayer2d UnderCLayer; | |
1846 | OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; | |
1847 | if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer (); | |
1848 | if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer (); | |
1849 | MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer); | |
1850 | ||
1851 | } | |
1852 | ||
1853 | void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) { | |
1854 | ||
1855 | if (IsDeleted ()) return; | |
1856 | ||
1857 | if ((! IsDefined ()) || (! IsActive ())) return; | |
1858 | ||
1859 | if (! MyWindow->IsMapped ()) return; | |
1860 | ||
1861 | // san - 14/04/2004 - set up Z buffer state before redrawing | |
81bba717 | 1862 | // If activation/desactivation of ZBuffer should be automatic |
1863 | // depending on the presence or absence of facets. | |
7fd59977 | 1864 | if (MyViewManager->ZBufferAuto ()) { |
1865 | Standard_Boolean BContainsFacet = ContainsFacet (); | |
1866 | Standard_Boolean BZBuffer = ZBufferIsActivated (); | |
81bba717 | 1867 | // If the view contains facets |
1868 | // and if ZBuffer is not active | |
7fd59977 | 1869 | if (BContainsFacet && ! BZBuffer) |
1870 | SetZBufferActivity (1); | |
81bba717 | 1871 | // If the view contains only facets |
1872 | // and if ZBuffer is active | |
7fd59977 | 1873 | if (! BContainsFacet && BZBuffer) |
1874 | SetZBufferActivity (0); | |
1875 | } | |
1876 | ||
1877 | Aspect_CLayer2d OverCLayer; | |
1878 | Aspect_CLayer2d UnderCLayer; | |
1879 | OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; | |
1880 | if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer (); | |
1881 | if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer (); | |
1882 | MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height); | |
1883 | ||
1884 | } | |
1885 | ||
1886 | void Visual3d_View::Update () { | |
1887 | ||
1888 | Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ()); | |
1889 | ||
1890 | } | |
1891 | ||
1892 | void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) { | |
1893 | ||
1894 | if (IsDeleted ()) return; | |
1895 | ||
1896 | if ((! IsDefined ()) || (! IsActive ())) return; | |
1897 | ||
1898 | if (! MyWindow->IsMapped ()) return; | |
1899 | ||
81bba717 | 1900 | // If activation/desactivation of ZBuffer should be automatic |
1901 | // depending on the presence or absence of facets. | |
7fd59977 | 1902 | if (MyViewManager->ZBufferAuto ()) { |
1903 | Standard_Boolean BContainsFacet = ContainsFacet (); | |
1904 | Standard_Boolean BZBuffer = ZBufferIsActivated (); | |
81bba717 | 1905 | // If the view contains facets |
1906 | // and if ZBuffer is not active | |
1907 | if (BContainsFacet && ! BZBuffer) | |
7fd59977 | 1908 | SetZBufferActivity (1); |
81bba717 | 1909 | // If the view does not contain facets |
1910 | // and if ZBuffer is active | |
7fd59977 | 1911 | if (! BContainsFacet && BZBuffer) |
1912 | SetZBufferActivity (0); | |
1913 | } | |
1914 | ||
1915 | Aspect_CLayer2d OverCLayer; | |
1916 | Aspect_CLayer2d UnderCLayer; | |
1917 | OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; | |
1918 | if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer (); | |
1919 | if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer (); | |
1920 | //OSD::SetSignal (Standard_False); | |
1921 | MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer); | |
1922 | //OSD::SetSignal (Standard_True); | |
1923 | ||
1924 | MyMatOfMapIsModified = Standard_False; | |
1925 | MyMatOfOriIsModified = Standard_False; | |
1926 | ||
1927 | } | |
1928 | ||
1929 | Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const { | |
1930 | ||
81bba717 | 1931 | // Return type of visualization of the view |
7fd59977 | 1932 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
1933 | ||
81bba717 | 1934 | // Return type of visualization of the structure |
7fd59977 | 1935 | Graphic3d_TypeOfStructure StructType = AStructure->Visual (); |
1936 | ||
1937 | Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO; | |
1938 | ||
1939 | if (StructType == Graphic3d_TOS_ALL) | |
81bba717 | 1940 | // The structure accepts any type of view |
7fd59977 | 1941 | Result = Visual3d_TOA_YES; |
1942 | else { | |
1943 | if ((StructType == Graphic3d_TOS_SHADING) | |
1944 | && (ViewType == Visual3d_TOV_SHADING)) | |
1945 | Result = Visual3d_TOA_YES; | |
1946 | if ((StructType == Graphic3d_TOS_WIREFRAME) | |
1947 | && (ViewType == Visual3d_TOV_WIREFRAME)) | |
1948 | Result = Visual3d_TOA_YES; | |
1949 | if ((StructType == Graphic3d_TOS_COMPUTED) | |
1950 | && (ViewType == Visual3d_TOV_WIREFRAME)) | |
1951 | Result = Visual3d_TOA_COMPUTE; | |
1952 | if ((StructType == Graphic3d_TOS_COMPUTED) | |
1953 | && (ViewType == Visual3d_TOV_SHADING)) | |
1954 | Result = Visual3d_TOA_COMPUTE; | |
1955 | } | |
1956 | ||
1957 | #ifdef TRACE_ACCEPT | |
1958 | if (Result == Visual3d_TOA_YES) | |
1959 | cout << "YES = Visual3d_View" << MyCView.ViewId | |
1960 | << "::AcceptDisplay (" << AStructure->Identification () << ")\n"; | |
1961 | if (Result == Visual3d_TOA_NO) | |
1962 | cout << "NO = Visual3d_View" << MyCView.ViewId | |
1963 | << "::AcceptDisplay (" << AStructure->Identification () << ")\n"; | |
1964 | if (Result == Visual3d_TOA_COMPUTE) | |
1965 | cout << "COMPUTE = Visual3d_View" << MyCView.ViewId | |
1966 | << "::AcceptDisplay (" << AStructure->Identification () << ")\n"; | |
1967 | cout << flush; | |
1968 | #endif | |
1969 | ||
1970 | return (Result); | |
1971 | ||
1972 | } | |
1973 | ||
1974 | void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) { | |
1975 | ||
1976 | if (IsDeleted ()) return; | |
1977 | if (! IsDefined ()) return; | |
1978 | if (! IsActive ()) return; | |
1979 | if (! IsDisplayed (AStructure)) return; | |
1980 | ||
1981 | Standard_Integer Index = IsComputed (AStructure); | |
1982 | #ifdef G003 | |
1983 | if ( Index != 0 && ComputedMode () && !DegenerateModeIsOn () ) | |
1984 | #else | |
1985 | if ((Index != 0) && (! DegenerateModeIsOn ())) | |
1986 | #endif // G003 | |
1987 | { | |
1988 | #ifdef TRACE | |
1989 | Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification (); | |
1990 | cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority (" | |
1991 | << AStructure->Identification () << "/" << StructId | |
1992 | << ", " << OldPriority << ", " << NewPriority << ")\n"; | |
1993 | cout << flush; | |
1994 | #endif | |
1995 | MyGraphicDriver->EraseStructure | |
1996 | (MyCView, | |
1997 | *(Graphic3d_CStructure *) | |
1998 | MyCOMPUTEDSequence.Value (Index)->CStructure ()); | |
1999 | MyGraphicDriver->DisplayStructure | |
2000 | (MyCView, | |
2001 | *(Graphic3d_CStructure *) | |
2002 | MyCOMPUTEDSequence.Value (Index)->CStructure (), | |
2003 | int (NewPriority)); | |
2004 | } | |
2005 | else { | |
2006 | #ifdef TRACE | |
2007 | Standard_Integer StructId = AStructure->Identification (); | |
2008 | cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority (" | |
2009 | << AStructure->Identification () << "/" << StructId | |
2010 | << ", " << OldPriority << ", " << NewPriority << ")\n"; | |
2011 | cout << flush; | |
2012 | #endif | |
2013 | MyGraphicDriver->EraseStructure | |
2014 | (MyCView, | |
2015 | *(Graphic3d_CStructure *)AStructure->CStructure ()); | |
2016 | MyGraphicDriver->DisplayStructure | |
2017 | (MyCView, | |
2018 | *(Graphic3d_CStructure *)AStructure->CStructure (), | |
2019 | int (NewPriority)); | |
2020 | } | |
2021 | ||
2022 | } | |
2023 | ||
2024 | void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) { | |
2025 | ||
2026 | #ifdef TRACE_CLEAR | |
2027 | cout << "Visual3d_View" << MyCView.ViewId << "::Clear (" | |
2028 | << AStructure->Identification () << ")\n"; | |
2029 | cout << flush; | |
2030 | #endif | |
2031 | ||
2032 | Standard_Integer Index = IsComputed (AStructure); | |
2033 | if (Index != 0) { | |
2034 | #ifdef TRACE_CLEAR | |
81bba717 | 2035 | cout << "Structure " << AStructure->Identification () |
2036 | << " calculated in the view " | |
2037 | << Identification () << ", by structure " | |
7fd59977 | 2038 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 2039 | << " is emptied.\n"; |
7fd59977 | 2040 | cout << flush; |
2041 | #endif | |
2042 | MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction); | |
2043 | MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False); | |
2044 | } | |
2045 | ||
2046 | } | |
2047 | ||
2048 | void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) { | |
2049 | ||
2050 | #ifdef TRACE_CONNECT | |
2051 | cout << "Visual3d_View" << MyCView.ViewId << "::Connect (" | |
2052 | << AMother->Identification () | |
2053 | << ADaughter->Identification () << ")\n"; | |
2054 | cout << flush; | |
2055 | #endif | |
2056 | ||
2057 | Standard_Integer IndexM = IsComputed (AMother); | |
2058 | Standard_Integer IndexD = IsComputed (ADaughter); | |
2059 | ||
2060 | if (IndexM != 0 && IndexD != 0) { | |
2061 | #ifdef TRACE_CONNECT | |
81bba717 | 2062 | cout << "Structure " << AMother->Identification () |
2063 | << " is connected to structure " | |
7fd59977 | 2064 | << ADaughter->Identification () << endl; |
81bba717 | 2065 | cout << "These structures are calculated.\n"; |
2066 | cout << "In the view " << Identification () | |
2067 | << "Structure " | |
7fd59977 | 2068 | << MyCOMPUTEDSequence.Value (IndexM)->Identification () |
81bba717 | 2069 | << " is connected to the structure " |
7fd59977 | 2070 | << MyCOMPUTEDSequence.Value (IndexD)->Identification () |
2071 | << endl; | |
2072 | #endif | |
2073 | MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD)); | |
2074 | } | |
2075 | ||
2076 | } | |
2077 | ||
2078 | void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) { | |
2079 | ||
2080 | #ifdef TRACE_CONNECT | |
2081 | cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect (" | |
2082 | << AMother->Identification () | |
2083 | << ADaughter->Identification () << ")\n"; | |
2084 | cout << flush; | |
2085 | #endif | |
2086 | ||
2087 | Standard_Integer IndexM = IsComputed (AMother); | |
2088 | Standard_Integer IndexD = IsComputed (ADaughter); | |
2089 | ||
2090 | if (IndexM != 0 && IndexD != 0) { | |
2091 | #ifdef TRACE_CONNECT | |
81bba717 | 2092 | cout << "Structure " << AMother->Identification () |
2093 | << " is disconnected from the structure " | |
7fd59977 | 2094 | << ADaughter->Identification () << endl; |
81bba717 | 2095 | cout << "These structures are calculated.\n"; |
2096 | cout << "In the view " << Identification () | |
2097 | << "Structure " | |
7fd59977 | 2098 | << MyCOMPUTEDSequence.Value (IndexM)->Identification () |
81bba717 | 2099 | << " is disconnected from the structure " |
7fd59977 | 2100 | << MyCOMPUTEDSequence.Value (IndexD)->Identification () |
2101 | << endl; | |
2102 | #endif | |
2103 | MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD)); | |
2104 | } | |
2105 | ||
2106 | } | |
2107 | ||
2108 | void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) { | |
2109 | ||
2110 | Display (AStructure, MyViewManager->UpdateMode ()); | |
2111 | ||
2112 | } | |
2113 | ||
2114 | void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) { | |
2115 | ||
2116 | if (IsDeleted ()) return; | |
2117 | if (! IsDefined ()) return; | |
2118 | if (! IsActive ()) return; | |
2119 | ||
81bba717 | 2120 | // If Display on a structure present in the list |
2121 | // of calculated structures while it is not | |
2122 | // or more, of calculated type => | |
2123 | // - removes it as well as the associated old computed | |
2124 | // THis happens when hlhsr becomes again of type e | |
2125 | // non computed after SetVisual. | |
7fd59977 | 2126 | Standard_Integer Index = IsComputed (AStructure); |
2127 | ||
2128 | if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) { | |
2129 | ||
2130 | #ifdef TRACE_LENGTH | |
2131 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
2132 | cout << "In Visual3d_View::Display, "; | |
2133 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2134 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2135 | << "\n" << flush; | |
2136 | } | |
2137 | #endif | |
2138 | MyTOCOMPUTESequence.Remove (Index); | |
2139 | MyCOMPUTEDSequence.Remove (Index); | |
2140 | ||
2141 | #ifdef TRACE_LENGTH | |
2142 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
2143 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2144 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2145 | << "\n" << flush; | |
2146 | #endif | |
2147 | Index = 0; | |
2148 | } | |
2149 | ||
2150 | Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure); | |
2151 | ||
2152 | #ifdef TRACE_DISPLAY | |
2153 | Standard_Integer StructId = AStructure->Identification (); | |
2154 | cout << "Visual3d_View" << MyCView.ViewId << "::Display (" | |
2155 | << StructId << ");\n"; | |
2156 | cout << flush; | |
2157 | #endif | |
2158 | ||
2159 | if (Answer == Visual3d_TOA_NO) { | |
2160 | #ifdef TRACE_DISPLAY | |
2161 | cout << "Answer : Visual3d_TOA_NO\n"; | |
2162 | cout << flush; | |
2163 | #endif | |
2164 | return; | |
2165 | } | |
2166 | ||
81bba717 | 2167 | // Mode degenerated active |
7fd59977 | 2168 | #ifdef G003 |
2169 | if ( !ComputedMode () || DegenerateModeIsOn () ) | |
2170 | Answer = Visual3d_TOA_YES; | |
2171 | #else | |
2172 | if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES; | |
2173 | ; | |
2174 | #endif // G003 | |
2175 | ||
2176 | if (Answer == Visual3d_TOA_YES ) { | |
2177 | #ifdef TRACE_DISPLAY | |
2178 | cout << "Answer : Visual3d_TOA_YES\n"; | |
2179 | cout << flush; | |
2180 | #endif | |
2181 | if (IsDisplayed (AStructure)) return; | |
2182 | MyGraphicDriver->DisplayStructure ( | |
2183 | MyCView, | |
2184 | *(Graphic3d_CStructure *)AStructure->CStructure (), | |
2185 | int (AStructure->DisplayPriority ()) | |
2186 | ); | |
2187 | MyDisplayedStructure.Add (AStructure); | |
2188 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
2189 | } | |
2190 | ||
2191 | if (Answer == Visual3d_TOA_COMPUTE) { | |
2192 | #ifdef TRACE_DISPLAY | |
2193 | cout << "Answer : Visual3d_TOA_COMPUTE\n"; | |
2194 | cout << "Index : " << Index << "\n" << flush; | |
2195 | #endif | |
2196 | if (Index != 0) { | |
81bba717 | 2197 | // Already computed, is COMPUTED still valid? |
7fd59977 | 2198 | #ifdef TRACE_DISPLAY |
2199 | if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) { | |
81bba717 | 2200 | cout << "Structure " |
7fd59977 | 2201 | << MyTOCOMPUTESequence.Value (Index)->Identification () |
81bba717 | 2202 | << "already calculated, in the view " |
7fd59977 | 2203 | << Identification () << ", par la structure " |
2204 | << MyCOMPUTEDSequence.Value (Index)->Identification () | |
81bba717 | 2205 | << "\n was not recalculated as HLR is valid\n"; |
7fd59977 | 2206 | cout << flush; |
2207 | } | |
2208 | else { | |
81bba717 | 2209 | cout << "Structure " |
7fd59977 | 2210 | << MyTOCOMPUTESequence.Value (Index)->Identification () |
81bba717 | 2211 | << " already calculated, in the view " |
2212 | << Identification () << ", by the structure " | |
7fd59977 | 2213 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 2214 | << "\n should be recalculated as HLR is invalid\n"; |
7fd59977 | 2215 | cout << flush; |
2216 | } | |
2217 | #endif | |
2218 | Standard_Integer OldStructId = | |
2219 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
2220 | ||
81bba717 | 2221 | // Case COMPUTED valide |
7fd59977 | 2222 | if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) { |
81bba717 | 2223 | // to be displayed |
7fd59977 | 2224 | if (! IsDisplayed (AStructure)) { |
2225 | MyDisplayedStructure.Add (AStructure); | |
2226 | MyGraphicDriver->DisplayStructure ( | |
2227 | MyCView, | |
2228 | *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (), | |
2229 | int (AStructure->DisplayPriority ()) | |
2230 | ); | |
2231 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
2232 | } | |
2233 | return; | |
2234 | } | |
2235 | ||
81bba717 | 2236 | // Case COMPUTED invalid |
7fd59977 | 2237 | else { |
81bba717 | 2238 | // Is there another valid representation ? |
2239 | // Find in the sequence of already calculated structures | |
2240 | // 1/ Structure having the same Owner as <AStructure> | |
2241 | // 2/ That is not <AStructure> | |
2242 | // 3/ The COMPUTED which of is valid | |
7fd59977 | 2243 | Standard_Integer NewIndex = HaveTheSameOwner (AStructure); |
2244 | ||
81bba717 | 2245 | // Case of COMPUTED invalid, WITH a valid of replacement |
7fd59977 | 2246 | if (NewIndex != 0) { |
81bba717 | 2247 | // to be displayed |
7fd59977 | 2248 | if (! IsDisplayed (AStructure)) { |
2249 | MyCOMPUTEDSequence.SetValue | |
2250 | (Index, MyCOMPUTEDSequence.Value (NewIndex)); | |
2251 | OldStructId = MyCOMPUTEDSequence.Value (NewIndex)-> | |
2252 | Identification (); | |
2253 | MyDisplayedStructure.Add (AStructure); | |
2254 | MyGraphicDriver->DisplayStructure ( | |
2255 | MyCView, | |
2256 | *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (), | |
2257 | int (AStructure->DisplayPriority ()) | |
2258 | ); | |
2259 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
2260 | } | |
2261 | return; | |
2262 | } | |
2263 | ||
81bba717 | 2264 | // Cas COMPUTED invalid, WITHOUT a valid of replacement |
7fd59977 | 2265 | else { |
81bba717 | 2266 | // COMPUTED is removed if displayed |
7fd59977 | 2267 | if (IsDisplayed (AStructure)) |
2268 | MyGraphicDriver->EraseStructure ( | |
2269 | MyCView, | |
2270 | *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure () | |
2271 | ); | |
2272 | } | |
2273 | } | |
2274 | } // if (Index != 0) | |
2275 | ||
2276 | // Compute + Validation | |
2277 | #ifdef OLD | |
2278 | Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this); | |
2279 | #else | |
2280 | Handle(Graphic3d_Structure) TheStructure; | |
2281 | TColStd_Array2OfReal ATrsf (0, 3, 0, 3); | |
2282 | AStructure->Transform (ATrsf); | |
2283 | if (Index != 0) { | |
2284 | TColStd_Array2OfReal Ident (0, 3, 0, 3); | |
2285 | Standard_Integer ii, jj; | |
2286 | for (ii=0; ii<=3; ii++) | |
2287 | for (jj=0; jj<=3; jj++) | |
2288 | Ident (ii, jj) = (ii == jj ? 1.0 : 0.0); | |
2289 | TheStructure = MyCOMPUTEDSequence.Value (Index); | |
2290 | TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE); | |
2291 | if (AStructure->IsTransformed ()) { | |
2292 | AStructure->Compute (this, ATrsf, TheStructure); | |
2293 | } | |
2294 | else { | |
2295 | AStructure->Compute (this, TheStructure); | |
2296 | } | |
2297 | } | |
2298 | else { | |
2299 | if (AStructure->IsTransformed ()) { | |
2300 | TheStructure = AStructure->Compute (this, ATrsf); | |
2301 | } | |
2302 | else { | |
2303 | TheStructure = AStructure->Compute (this); | |
2304 | } | |
2305 | } | |
2306 | #endif | |
2307 | TheStructure->SetHLRValidation (Standard_True); | |
2308 | ||
2309 | #ifdef TRACE_LENGTH | |
2310 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
2311 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2312 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2313 | << "\n" << flush; | |
2314 | #endif | |
2315 | ||
81bba717 | 2316 | // TOCOMPUTE and COMPUTED associated to sequences are added |
7fd59977 | 2317 | MyTOCOMPUTESequence.Append (AStructure); |
2318 | MyCOMPUTEDSequence.Append (TheStructure); | |
2319 | ||
2320 | #ifdef TRACE_LENGTH | |
2321 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
2322 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2323 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2324 | << "\n" << flush; | |
2325 | #endif | |
2326 | ||
81bba717 | 2327 | // The previous are removed if necessary |
7fd59977 | 2328 | if (Index != 0) { |
2329 | MyTOCOMPUTESequence.Remove (Index); | |
2330 | MyCOMPUTEDSequence.Remove (Index); | |
2331 | } | |
2332 | ||
2333 | #ifdef TRACE_LENGTH | |
2334 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
2335 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2336 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2337 | << "\n" << flush; | |
2338 | #endif | |
2339 | ||
81bba717 | 2340 | // Return type of visualisation of the view |
7fd59977 | 2341 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
2342 | ||
81bba717 | 2343 | // Of which type will be the computed ? |
7fd59977 | 2344 | Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) && |
2345 | (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING)); | |
2346 | ||
2347 | Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) && | |
2348 | (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME)); | |
2349 | ||
2350 | if (ComputeWireframe) | |
2351 | TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME); | |
2352 | if (ComputeShading) | |
2353 | TheStructure->SetVisual (Graphic3d_TOS_SHADING); | |
2354 | ||
2355 | if (! ComputeShading && ! ComputeWireframe) | |
2356 | Answer = Visual3d_TOA_NO; | |
2357 | else | |
2358 | Answer = AcceptDisplay (TheStructure); | |
2359 | ||
2360 | if (AStructure->IsHighlighted()) { | |
2361 | TheStructure->SetHighlightColor (AStructure->HighlightColor ()); | |
2362 | TheStructure->GraphicHighlight (Aspect_TOHM_COLOR); | |
2363 | } | |
2364 | ||
2365 | #ifdef TRACE_DISPLAY | |
81bba717 | 2366 | cout << "Structure " << StructId |
2367 | << " in the view " << Identification () | |
2368 | << " is calculated by the structure " | |
7fd59977 | 2369 | << TheStructure->Identification (); |
2370 | if (Answer == Visual3d_TOA_YES) | |
81bba717 | 2371 | cout << " and displayed\n"; |
7fd59977 | 2372 | else |
81bba717 | 2373 | cout << " but not displayed\n"; |
7fd59977 | 2374 | cout << flush; |
2375 | #endif | |
2376 | ||
81bba717 | 2377 | // It is displayed only if the calculated structure |
2378 | // has a proper type corresponding to the one of the view. | |
7fd59977 | 2379 | if (Answer != Visual3d_TOA_NO) { |
2380 | if (! IsDisplayed (AStructure)) | |
2381 | MyDisplayedStructure.Add (AStructure); | |
2382 | MyGraphicDriver->DisplayStructure ( | |
2383 | MyCView, | |
2384 | *(Graphic3d_CStructure *)TheStructure->CStructure (), | |
2385 | int (AStructure->DisplayPriority ()) | |
2386 | ); | |
2387 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
2388 | } | |
2389 | } // Visual3d_TOA_COMPUTE | |
2390 | } | |
2391 | ||
2392 | void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) { | |
2393 | ||
2394 | if (IsDeleted ()) return; | |
2395 | ||
2396 | Erase (AStructure, MyViewManager->UpdateMode ()); | |
2397 | ||
2398 | } | |
2399 | ||
2400 | void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) { | |
2401 | ||
2402 | Standard_Integer StructId; | |
2403 | ||
2404 | if (IsDeleted ()) return; | |
2405 | ||
81bba717 | 2406 | // No test on window as the structure is displayed only if |
2407 | // the window exists, so only one test is enough. | |
7fd59977 | 2408 | if (IsDisplayed (AStructure)) { |
2409 | Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure); | |
2410 | ||
81bba717 | 2411 | // Degenerated mode is active |
7fd59977 | 2412 | #ifdef G003 |
2413 | if ( !ComputedMode () || DegenerateModeIsOn () ) | |
2414 | Answer = Visual3d_TOA_YES; | |
2415 | #else | |
2416 | if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES; | |
2417 | #endif // G003 | |
2418 | ||
2419 | if (Answer != Visual3d_TOA_COMPUTE) { | |
2420 | MyGraphicDriver->EraseStructure ( | |
2421 | MyCView, | |
2422 | *(Graphic3d_CStructure *)AStructure->CStructure () | |
2423 | ); | |
2424 | } | |
2425 | ||
2426 | if (Answer == Visual3d_TOA_COMPUTE) { | |
2427 | Standard_Integer Index = IsComputed (AStructure); | |
2428 | #ifdef TRACE_COMP | |
2429 | cout << "Visual3d_View" << MyCView.ViewId << "::Erase (" | |
2430 | << AStructure->Identification () << ");\n"; | |
2431 | cout << "Index : " << Index << "\n"; | |
2432 | cout << flush; | |
2433 | #endif | |
2434 | #ifdef G003 | |
2435 | if ( Index != 0 && ComputedMode () && | |
2436 | !DegenerateModeIsOn () ) | |
2437 | #else | |
2438 | if ((Index != 0) && (! DegenerateModeIsOn ())) | |
2439 | #endif // G003 | |
2440 | { | |
2441 | StructId = | |
2442 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
2443 | #ifdef TRACE_COMP | |
2444 | cout << "Structure " << AStructure->Identification () | |
81bba717 | 2445 | << " calculated, in the view " |
2446 | << Identification () << ", by the structure " | |
2447 | << StructId << " is removed. \n"; | |
7fd59977 | 2448 | cout << flush; |
2449 | #endif | |
2450 | MyGraphicDriver->EraseStructure | |
2451 | (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()); | |
2452 | } | |
81bba717 | 2453 | // else is impossible |
7fd59977 | 2454 | } |
2455 | MyDisplayedStructure.Remove (AStructure); | |
2456 | if (AnUpdateMode == Aspect_TOU_ASAP) Update (); | |
2457 | } | |
2458 | ||
2459 | } | |
2460 | ||
2461 | void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) { | |
2462 | ||
2463 | #ifdef TRACE_HIGH | |
2464 | cout << "Visual3d_View" << MyCView.ViewId << "::Highlight (" | |
2465 | << AStructure->Identification () << ")\n"; | |
2466 | cout << flush; | |
2467 | #endif | |
2468 | ||
2469 | Standard_Integer Index = IsComputed (AStructure); | |
2470 | if (Index != 0) { | |
2471 | #ifdef TRACE_HIGH | |
81bba717 | 2472 | cout << "Structure " << AStructure->Identification () |
2473 | << " calculated, in the view " | |
2474 | << Identification () << ", by the structure " | |
7fd59977 | 2475 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 2476 | << " passes in highlight mode.\n"; |
7fd59977 | 2477 | cout << flush; |
2478 | #endif | |
2479 | (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor | |
2480 | (AStructure->HighlightColor ()); | |
2481 | (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod); | |
2482 | } | |
2483 | ||
2484 | } | |
2485 | ||
2486 | void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) { | |
2487 | ||
2488 | #ifdef TRACE_TRSF | |
2489 | cout << "Visual3d_View" << MyCView.ViewId << "::Transform (" | |
2490 | << AStructure->Identification () << ")\n"; | |
2491 | cout << flush; | |
2492 | #endif | |
2493 | ||
2494 | Standard_Integer Index = IsComputed (AStructure); | |
2495 | if (Index != 0) { | |
2496 | #ifdef TRACE_TRSF | |
81bba717 | 2497 | cout << "The structure " << AStructure->Identification () |
2498 | << " calculated, in the view " | |
2499 | << Identification () << ", by the structure " | |
7fd59977 | 2500 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 2501 | << " is transformed.\n"; |
7fd59977 | 2502 | cout << flush; |
2503 | #endif | |
81bba717 | 2504 | // Test is somewhat light ! |
2505 | // trsf is transferred only if it is : | |
2506 | // a translation | |
2507 | // a scale | |
7fd59977 | 2508 | if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0. |
2509 | || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0. | |
2510 | || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.) | |
2511 | ReCompute (AStructure); | |
2512 | else | |
2513 | MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf); | |
2514 | } | |
2515 | ||
2516 | } | |
2517 | ||
2518 | void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) { | |
2519 | ||
2520 | #ifdef TRACE_HIGH | |
2521 | cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight (" | |
2522 | << AStructure->Identification () << ")\n"; | |
2523 | cout << flush; | |
2524 | #endif | |
2525 | ||
2526 | Standard_Integer Index = IsComputed (AStructure); | |
2527 | if (Index != 0) { | |
2528 | #ifdef TRACE_HIGH | |
81bba717 | 2529 | cout << "Structure " << AStructure->Identification () |
2530 | << " calculated, in the view " | |
2531 | << Identification () << ", by the structure " | |
7fd59977 | 2532 | << MyCOMPUTEDSequence.Value (Index)->Identification () |
81bba717 | 2533 | << " passes in unhighlight mode.\n"; |
7fd59977 | 2534 | cout << flush; |
2535 | #endif | |
2536 | MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight (); | |
2537 | } | |
2538 | ||
2539 | ||
2540 | } | |
2541 | ||
2542 | Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const { | |
2543 | ||
2544 | Standard_Integer StrId = AStructure->Identification (); | |
2545 | ||
2546 | Standard_Integer Result = 0; | |
2547 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
2548 | ||
2549 | // Recherche de la structure <AStructure> dans la | |
2550 | // sequence des structures deja calculees | |
2551 | for (Standard_Integer i=1; i<=Length && Result==0; i++) | |
2552 | if ((MyTOCOMPUTESequence.Value (i))->Identification () | |
2553 | == StrId) Result = i; | |
2554 | #ifdef TRACE_ISCOMP | |
81bba717 | 2555 | cout << "\n In the view " << Identification () << " the structure "; |
7fd59977 | 2556 | if (Result != 0) |
81bba717 | 2557 | cout << StrId << " is calculated by " |
7fd59977 | 2558 | << MyCOMPUTEDSequence.Value (Result)->Identification () |
2559 | << "\n" << flush; | |
2560 | else | |
81bba717 | 2561 | cout << StrId << " is not calculated\n" << flush; |
7fd59977 | 2562 | #endif |
2563 | ||
2564 | #ifdef TRACE_LENGTH | |
2565 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
2566 | cout << "In Visual3d_View::IsComputed, "; | |
2567 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
2568 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
2569 | << "\n" << flush; | |
2570 | } | |
2571 | #endif | |
2572 | ||
2573 | return (Result); | |
2574 | ||
2575 | } | |
2576 | ||
2577 | Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const { | |
2578 | ||
2579 | Standard_Boolean Result = Standard_False; | |
2580 | ||
2581 | if (IsDeleted ()) return Result; | |
2582 | ||
2583 | Result = MyDisplayedStructure.Contains (AStructure); | |
2584 | ||
2585 | return Result; | |
2586 | ||
2587 | } | |
2588 | ||
2589 | #ifdef IMPLEMENTED | |
2590 | Standard_Boolean Visual3d_View::ContainsComputedStructure () const { | |
2591 | ||
2592 | Standard_Boolean Result = Standard_False; | |
2593 | ||
2594 | if (MyDisplayedStructure.IsEmpty ()) return Result; | |
2595 | ||
2596 | Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure); | |
2597 | ||
2598 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
2599 | ||
81bba717 | 2600 | // Stop at the first structure of type TOS_COMPUTED |
7fd59977 | 2601 | while (! Result && Iterator.More ()) { |
2602 | Result = | |
2603 | (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED); | |
2604 | ||
81bba717 | 2605 | // Iterator.Next () is located on the |
2606 | // next structure | |
7fd59977 | 2607 | Iterator.Next (); |
2608 | } | |
2609 | ||
2610 | return Result; | |
2611 | ||
2612 | } | |
2613 | #endif | |
2614 | ||
2615 | Standard_Boolean Visual3d_View::ContainsFacet () const { | |
2616 | ||
2617 | return ContainsFacet (MyDisplayedStructure); | |
2618 | ||
2619 | } | |
2620 | ||
2621 | Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const { | |
2622 | ||
2623 | Standard_Boolean Result = Standard_False; | |
2624 | ||
2625 | if (ASet.IsEmpty ()) return Result; | |
2626 | ||
2627 | Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet); | |
2628 | ||
81bba717 | 2629 | // Stop at the first structure containing a facet |
7fd59977 | 2630 | for ( Iterator.Initialize (ASet); |
2631 | Iterator.More () && ! Result; | |
2632 | Iterator.Next ()) | |
2633 | Result = (Iterator.Key ())->ContainsFacet (); | |
2634 | ||
2635 | return Result; | |
2636 | ||
2637 | } | |
2638 | ||
2639 | void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const { | |
2640 | ||
2641 | MinMaxValues | |
2642 | (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax); | |
2643 | ||
2644 | } | |
2645 | ||
2646 | void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const { | |
2647 | ||
2648 | if (ASet.IsEmpty ()) { | |
2649 | XMin = RealFirst (); | |
2650 | YMin = RealFirst (); | |
2651 | ZMin = RealFirst (); | |
2652 | ||
2653 | XMax = RealLast (); | |
2654 | YMax = RealLast (); | |
2655 | ZMax = RealLast (); | |
2656 | } | |
2657 | else { | |
2658 | ||
2659 | Standard_Real Xm, Ym, Zm, XM, YM, ZM; | |
2660 | Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet); | |
2661 | ||
2662 | XMin = RealLast (); | |
2663 | YMin = RealLast (); | |
2664 | ZMin = RealLast (); | |
2665 | ||
2666 | XMax = RealFirst (); | |
2667 | YMax = RealFirst (); | |
2668 | ZMax = RealFirst (); | |
2669 | ||
2670 | for ( Iterator.Initialize (ASet); | |
2671 | Iterator.More (); | |
2672 | Iterator.Next ()) { | |
2673 | ||
2674 | if ( (Iterator.Key ())->IsInfinite ()){ | |
2675 | //XMin, YMin .... ZMax are initialized by means of infinite line data | |
2676 | (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM); | |
2677 | if ( Xm != RealFirst() && Xm < XMin ) | |
2678 | XMin = Xm ; | |
2679 | if ( Ym != RealFirst() && Ym < YMin ) | |
2680 | YMin = Ym ; | |
2681 | if ( Zm != RealFirst() && Zm < ZMin ) | |
2682 | ZMin = Zm ; | |
2683 | if ( XM != RealLast() && XM > XMax ) | |
2684 | XMax = XM ; | |
2685 | if ( YM != RealLast() && YM > YMax ) | |
2686 | YMax = YM ; | |
2687 | if ( ZM != RealLast() && ZM > ZMax ) | |
2688 | ZMax = ZM ; | |
2689 | } | |
81bba717 | 2690 | // Only non-empty and non-infinite structures |
2691 | // are taken into account for calculation of MinMax | |
7fd59977 | 2692 | if (! (Iterator.Key ())->IsInfinite () && |
2693 | ! (Iterator.Key ())->IsEmpty ()) { | |
2694 | (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM); | |
2695 | /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */ | |
2696 | //"FitAll" operation ignores object with transform persitence parameter | |
2697 | if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None ) | |
2698 | { | |
2699 | if (Xm < XMin) XMin = Xm; | |
2700 | if (Ym < YMin) YMin = Ym; | |
2701 | if (Zm < ZMin) ZMin = Zm; | |
2702 | if (XM > XMax) XMax = XM; | |
2703 | if (YM > YMax) YMax = YM; | |
2704 | if (ZM > ZMax) ZMax = ZM; | |
2705 | } | |
2706 | } | |
2707 | } | |
2708 | ||
81bba717 | 2709 | // The following cases are relevant |
2710 | // For exemple if all structures are empty or infinite | |
7fd59977 | 2711 | if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; } |
2712 | if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; } | |
2713 | if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; } | |
2714 | } | |
2715 | Standard_Real Sx, Sy, Sz; | |
2716 | MyViewOrientation.AxialScale(Sx, Sy, Sz); | |
2717 | XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx; | |
2718 | XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx; | |
2719 | YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy; | |
2720 | YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy; | |
2721 | ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz; | |
2722 | ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz; | |
2723 | } | |
2724 | ||
2725 | void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) { | |
2726 | ||
2727 | MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax); | |
2728 | ||
2729 | } | |
2730 | ||
2731 | void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) { | |
2732 | ||
2733 | Standard_Real Xm, Ym, Zm, XM, YM, ZM; | |
2734 | Standard_Real Xp, Yp, Zp; | |
2735 | ||
2736 | MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM); | |
2737 | ||
2738 | Projects (Xm, Ym, Zm, Xp, Yp, Zp); | |
2739 | XMin = Xp; | |
2740 | YMin = Yp; | |
2741 | ||
2742 | Projects (XM, YM, ZM, Xp, Yp, Zp); | |
2743 | XMax = Xp; | |
2744 | YMax = Yp; | |
2745 | ||
2746 | if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; } | |
2747 | if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; } | |
2748 | } | |
2749 | ||
2750 | const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () { | |
2751 | ||
2752 | if (! MyMatOfOriIsEvaluated) { | |
2753 | MyGraphicDriver->InquireMat | |
2754 | (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping); | |
2755 | MyMatOfMapIsEvaluated = Standard_True; | |
2756 | MyMatOfOriIsEvaluated = Standard_True; | |
2757 | } | |
2758 | ||
2759 | return (MyMatrixOfOrientation); | |
2760 | ||
2761 | } | |
2762 | ||
2763 | const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () { | |
2764 | ||
2765 | if (! MyMatOfMapIsEvaluated) { | |
2766 | MyGraphicDriver->InquireMat | |
2767 | (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping); | |
2768 | MyMatOfMapIsEvaluated = Standard_True; | |
2769 | MyMatOfOriIsEvaluated = Standard_True; | |
2770 | } | |
2771 | ||
2772 | return (MyMatrixOfMapping); | |
2773 | ||
2774 | } | |
2775 | ||
2776 | Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const { | |
2777 | ||
2778 | Standard_Integer Result = MyDisplayedStructure.Extent (); | |
2779 | ||
2780 | return (Result); | |
2781 | ||
2782 | } | |
2783 | ||
2784 | #ifdef OLD_METHOD | |
2785 | void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) const { | |
2786 | ||
2787 | math_Vector PtDC (0,3), PtWC (0,3); | |
2788 | ||
2789 | // RLE method: | |
81bba717 | 2790 | // Otherwise use new on Visual3d_View (constructor+destructor) |
2791 | // as Projects is a const method or MatrixOfOrientation and | |
2792 | // MatrixOfMapping is not. | |
7fd59977 | 2793 | Visual3d_View * const newthis = (Visual3d_View * const) this; |
2794 | newthis->MatrixOfOrientation (); | |
2795 | newthis->MatrixOfMapping (); | |
2796 | ||
2797 | // World Coordinate Space | |
2798 | PtWC (0) = AX; | |
2799 | PtWC (1) = AY; | |
2800 | PtWC (2) = AZ; | |
2801 | PtWC (3) = 1.0; | |
2802 | ||
2803 | // WCS -> View Reference Coordinate Space | |
2804 | math_Vector PtVRC(0,3); | |
2805 | PtVRC = MyMatrixOfOrientation.Multiplied (PtWC); | |
2806 | ||
2807 | // VRCS -> Normalized Projection Coordinate Space | |
2808 | math_Vector PtNPC(0,3); | |
2809 | PtNPC = MyMatrixOfMapping.Multiplied (PtVRC); | |
2810 | for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3); | |
2811 | ||
2812 | #ifdef DEBUG | |
2813 | printf("Display coordinates PtNPC: %f,%f,%f,%f\n", | |
2814 | PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3)); | |
2815 | #endif // DEBUG | |
2816 | ||
2817 | Standard_Real Ratio; | |
2818 | #ifdef DEBUG | |
2819 | // NPCS -> Device Coordinate Space | |
2820 | Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx); | |
2821 | Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy); | |
2822 | ||
2823 | Ratio = Dx / Dy; | |
2824 | PtDC (0) = PtNPC (0) * Dx; | |
2825 | PtDC (1) = Dy - PtNPC (1) * Dy * Ratio; | |
2826 | ||
2827 | printf("Display coordinates : %f,%f,%f,%f\n", | |
2828 | PtDC(0),PtDC(1),PtDC(2),PtDC(3)); | |
2829 | #endif // DEBUG | |
2830 | ||
2831 | // NPCS -> Window Space | |
2832 | Standard_Real um, vm, uM, vM; | |
2833 | MyViewMapping.WindowLimit (um, vm, uM, vM); | |
2834 | ||
2835 | Ratio = (uM - um) / (vM - vm); | |
2836 | if (Ratio >= 1.0) | |
2837 | PtNPC (1) = PtNPC (1) * Ratio; | |
2838 | else | |
2839 | PtNPC (0) = PtNPC (0) / Ratio; | |
2840 | ||
2841 | #ifdef DEBUG | |
2842 | printf("Display coordinates PtNPC: %f,%f,%f,%f\n", | |
2843 | PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3)); | |
2844 | #endif // DEBUG | |
2845 | ||
2846 | Standard_Real fpd = MyViewMapping.FrontPlaneDistance (); | |
2847 | Standard_Real bpd = MyViewMapping.BackPlaneDistance (); | |
2848 | ||
2849 | /* | |
81bba717 | 2850 | * Coordinates of PtNPC are described in the space |
7fd59977 | 2851 | * [0-1]x[0-1]x[0-1]. |
81bba717 | 2852 | * It is necessary to transform x and y in the window space. |
2853 | * It is necessary to transform z in the space of back and front | |
2854 | * plane, taking into account clipping planes. | |
2855 | * Z clipping planes are defined between 0 and 1. | |
7fd59977 | 2856 | */ |
2857 | ||
2858 | APX = PtNPC (0) * (uM - um) + um; | |
2859 | APY = PtNPC (1) * (vM - vm) + vm; | |
2860 | APZ = PtNPC (2) * (fpd - bpd) + bpd; | |
2861 | ||
2862 | #ifdef DEBUG | |
2863 | Standard_Integer l,c; | |
2864 | printf("OrientationMatrix :"); | |
2865 | for( l=0 ; l<4 ; l++ ) { | |
2866 | printf("\n %d->",l); | |
2867 | for( c=0 ; c<4 ; c++ ) { | |
2868 | printf(" %f ,",MyMatrixOfOrientation(c,l)); | |
2869 | } | |
2870 | } | |
2871 | printf("\n\n"); | |
2872 | printf("MappingMatrix :"); | |
2873 | for( l=0 ; l<4 ; l++ ) { | |
2874 | printf("\n %d->",l); | |
2875 | for( c=0 ; c<4 ; c++ ) { | |
2876 | printf(" %f ,",MyMatrixOfMapping(c,l)); | |
2877 | } | |
2878 | } | |
2879 | printf("\n\n"); | |
2880 | printf("World coordinates : %f,%f,%f,%f\n", | |
2881 | PtWC(0),PtWC(1),PtWC(2),PtWC(3)); | |
2882 | printf("View coordinates : %f,%f,%f,%f\n", | |
2883 | PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3)); | |
2884 | printf("Display coordinates : %f,%f,%f,%f\n", | |
2885 | PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3)); | |
2886 | printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM); | |
2887 | printf("Ratio : %f\n",Ratio); | |
2888 | printf("Front-plane : %f back-plane : %f\n",fpd,bpd); | |
2889 | printf("Projection : %f,%f,%f\n \n",APX,APY,APZ); | |
2890 | #endif | |
2891 | ||
2892 | } | |
2893 | #endif /* OLD_METHOD */ | |
2894 | ||
2895 | // OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one, | |
2896 | // therefore it is necessary to consider merging the two methods or making them call the same | |
2897 | // graphic driver's method after OCCT 6.3. | |
2898 | void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) { | |
2899 | ||
2900 | Standard_Real PtX, PtY, PtZ, PtT; | |
2901 | Standard_Real APT; | |
2902 | static Standard_Real Ratio, um, vm, uM, vM; | |
2903 | static Standard_Real fpd, bpd; | |
2904 | ||
2905 | if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) { | |
2906 | MyGraphicDriver->InquireMat | |
2907 | (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping); | |
2908 | MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True; | |
2909 | } | |
2910 | ||
2911 | // WCS -> View Reference Coordinate Space | |
2912 | PtX = MyMatrixOfOrientation (0, 0) * AX | |
2913 | + MyMatrixOfOrientation (0, 1) * AY | |
2914 | + MyMatrixOfOrientation (0, 2) * AZ | |
2915 | + MyMatrixOfOrientation (0, 3); | |
2916 | PtY = MyMatrixOfOrientation (1, 0) * AX | |
2917 | + MyMatrixOfOrientation (1, 1) * AY | |
2918 | + MyMatrixOfOrientation (1, 2) * AZ | |
2919 | + MyMatrixOfOrientation (1, 3); | |
2920 | PtZ = MyMatrixOfOrientation (2, 0) * AX | |
2921 | + MyMatrixOfOrientation (2, 1) * AY | |
2922 | + MyMatrixOfOrientation (2, 2) * AZ | |
2923 | + MyMatrixOfOrientation (2, 3); | |
2924 | PtT = MyMatrixOfOrientation (3, 0) * AX | |
2925 | + MyMatrixOfOrientation (3, 1) * AY | |
2926 | + MyMatrixOfOrientation (3, 2) * AZ | |
2927 | + MyMatrixOfOrientation (3, 3); | |
2928 | ||
2929 | // VRCS -> Normalized Projection Coordinate Space | |
2930 | APX = MyMatrixOfMapping (0, 0) * PtX | |
2931 | + MyMatrixOfMapping (0, 1) * PtY | |
2932 | + MyMatrixOfMapping (0, 2) * PtZ | |
2933 | + MyMatrixOfMapping (0, 3) * PtT; | |
2934 | APY = MyMatrixOfMapping (1, 0) * PtX | |
2935 | + MyMatrixOfMapping (1, 1) * PtY | |
2936 | + MyMatrixOfMapping (1, 2) * PtZ | |
2937 | + MyMatrixOfMapping (1, 3) * PtT; | |
2938 | APZ = MyMatrixOfMapping (2, 0) * PtX | |
2939 | + MyMatrixOfMapping (2, 1) * PtY | |
2940 | + MyMatrixOfMapping (2, 2) * PtZ | |
2941 | + MyMatrixOfMapping (2, 3) * PtT; | |
2942 | APT = MyMatrixOfMapping (3, 0) * PtX | |
2943 | + MyMatrixOfMapping (3, 1) * PtY | |
2944 | + MyMatrixOfMapping (3, 2) * PtZ | |
2945 | + MyMatrixOfMapping (3, 3) * PtT; | |
2946 | ||
2947 | APX /= APT; | |
2948 | APY /= APT; | |
2949 | APZ /= APT; | |
2950 | ||
2951 | // NPCS -> Window Space | |
2952 | MyViewMapping.WindowLimit (um, vm, uM, vM); | |
2953 | fpd = MyViewMapping.FrontPlaneDistance (); | |
2954 | bpd = MyViewMapping.BackPlaneDistance (); | |
2955 | ||
2956 | if(MyCView.Mapping.IsCustomMatrix) { | |
2957 | // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL | |
2958 | // visualization, then X, Y and Z coordinates normally vary between -1 and 1 | |
2959 | APX = ( APX + 1 ) * 0.5 * (uM - um) + um; | |
2960 | APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm; | |
2961 | } else { | |
2962 | Ratio = (uM - um) / (vM - vm); | |
2963 | if (Ratio >= 1.0) | |
2964 | APY *= Ratio; | |
2965 | else | |
2966 | APX /= Ratio; | |
2967 | ||
2968 | /* | |
81bba717 | 2969 | * Coordinates of APX, APY, APZ are described in the space |
2970 | * [0-1]x[0-1]x[0-1]. | |
2971 | * It is necessary to transform x and y in the window space. | |
2972 | * It is necessary to transform z in the space of back and front | |
2973 | * plane, taking into account clipping planes. | |
2974 | * Z clipping planes are defined between 0 and 1. | |
2975 | */ | |
7fd59977 | 2976 | APX = APX * (uM - um) + um; |
2977 | APY = APY * (vM - vm) + vm; | |
2978 | } | |
2979 | APZ = APZ * (fpd - bpd) + bpd; | |
2980 | } | |
2981 | ||
2982 | Standard_Integer Visual3d_View::Identification () const { | |
2983 | ||
2984 | return (Standard_Integer (MyCView.ViewId)); | |
2985 | ||
2986 | } | |
2987 | ||
7fd59977 | 2988 | |
2989 | Standard_Boolean Visual3d_View::ZBufferIsActivated () const { | |
2990 | ||
2991 | if (IsDeleted ()) return (Standard_False); | |
2992 | ||
2993 | if ((! IsDefined ()) || (! IsActive ())) return (Standard_False); | |
2994 | ||
81bba717 | 2995 | // -1 => not forced by the programmer => depends on the type of visualisation |
2996 | // 0 ou 1 => forced by the programmer | |
7fd59977 | 2997 | |
2998 | if (MyCView.Context.ZBufferActivity == -1) | |
2999 | if (MyContext.Visualization () == Visual3d_TOV_SHADING) | |
3000 | return (Standard_True); | |
3001 | else | |
3002 | return (Standard_False); | |
3003 | else | |
3004 | if (MyCView.Context.ZBufferActivity) | |
3005 | return (Standard_True); | |
3006 | else | |
3007 | return (Standard_False); | |
3008 | ||
3009 | } | |
3010 | ||
3011 | void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) { | |
3012 | ||
3013 | if (IsDeleted ()) return; | |
3014 | ||
3015 | if ((! IsDefined ()) || (! IsActive ())) return; | |
3016 | ||
3017 | MyGraphicDriver->Transparency (MyCView, AnActivity); | |
3018 | ||
3019 | } | |
3020 | ||
3021 | void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) { | |
3022 | ||
3023 | if (MyCView.Context.ZBufferActivity == AnActivity) return; | |
3024 | ||
3025 | if (IsDeleted ()) return; | |
3026 | ||
3027 | if ((! IsDefined ()) || (! IsActive ())) return; | |
3028 | ||
3029 | MyCView.Context.ZBufferActivity = AnActivity; | |
3030 | MyGraphicDriver->SetVisualisation (MyCView); | |
3031 | ||
3032 | } | |
3033 | ||
3034 | void Visual3d_View::UpdateView () { | |
3035 | ||
3036 | MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0); | |
3037 | MyCView.Context.BackZClipping = | |
3038 | (MyContext.BackZClippingIsOn () ? 1:0); | |
3039 | MyCView.Context.FrontZClipping = | |
3040 | (MyContext.FrontZClippingIsOn() ? 1:0); | |
3041 | MyCView.Context.DepthCueing = | |
3042 | (MyContext.DepthCueingIsOn () ? 1:0); | |
3043 | ||
3044 | MyCView.Context.ZClipFrontPlane = | |
3045 | float (MyContext.ZClippingFrontPlane ()); | |
3046 | MyCView.Context.ZClipBackPlane = | |
3047 | float (MyContext.ZClippingBackPlane ()); | |
3048 | MyCView.Context.DepthFrontPlane = | |
3049 | float (MyContext.DepthCueingFrontPlane ()); | |
3050 | MyCView.Context.DepthBackPlane = | |
3051 | float (MyContext.DepthCueingBackPlane ()); | |
3052 | ||
3053 | MyCView.Context.Model = int (MyContext.Model ()); | |
3054 | MyCView.Context.Visualization = int (MyContext.Visualization ()); | |
3055 | ||
3056 | Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv(); | |
3057 | if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId(); | |
3058 | else MyCView.Context.TexEnvId = -1; | |
3059 | MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail(); | |
3060 | ||
3061 | } | |
3062 | ||
3063 | void Visual3d_View::Compute () { | |
3064 | ||
3065 | Standard_Integer i; | |
3066 | Standard_Integer Length = MyCOMPUTEDSequence.Length (); | |
3067 | for (i=1; i<=Length; i++) | |
3068 | (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False); | |
3069 | ||
81bba717 | 3070 | // if the degenerated node is active, nothing is recomputed |
7fd59977 | 3071 | #ifdef G003 |
3072 | if ( DegenerateModeIsOn () || !ComputedMode () ) return; | |
3073 | #else | |
3074 | if (DegenerateModeIsOn ()) return; | |
3075 | #endif // G003 | |
3076 | ||
3077 | /* | |
81bba717 | 3078 | * Force HLRValidation to False on all structures |
3079 | * calculated in the view. | |
7fd59977 | 3080 | */ |
3081 | #ifdef TRACE_LENGTH | |
3082 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
3083 | cout << "In Visual3d_View::Compute, "; | |
3084 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
3085 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
3086 | << "\n" << flush; | |
3087 | } | |
3088 | #endif | |
3089 | ||
3090 | /* | |
81bba717 | 3091 | * Change of orientation or of projection type => |
3092 | * Remove structures that were calculated for the | |
3093 | * previous orientation. | |
3094 | * Recalculation of new structures. | |
3095 | * Passage of the degenerated mode ON to OFF => | |
3096 | * Remove structures that were calculated before | |
3097 | * the degenerated mode passed to ON. | |
3098 | * Recalculate new structures. | |
7fd59977 | 3099 | */ |
3100 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
3101 | Visual3d_TypeOfAnswer Answer; | |
3102 | ||
3103 | i = MyDisplayedStructure.Extent (); | |
3104 | ||
3105 | Graphic3d_SequenceOfStructure FooSequence; | |
3106 | ||
3107 | while (S1Iterator.More ()) { | |
3108 | Answer = AcceptDisplay (S1Iterator.Key ()); | |
81bba717 | 3109 | // If the structure was calculated, it is recalculated. |
7fd59977 | 3110 | if (Answer == Visual3d_TOA_COMPUTE) { |
3111 | #ifdef TRACE | |
3112 | cout << "AcceptDisplay (" | |
3113 | << (S1Iterator.Key ())->Identification () | |
3114 | << ") == Visual3d_TOA_COMPUTE;\n"; | |
3115 | cout << flush; | |
3116 | #endif | |
3117 | //Display (S1Iterator.Key (), Aspect_TOU_WAIT); | |
3118 | FooSequence.Append (S1Iterator.Key ()); | |
3119 | } | |
3120 | ||
81bba717 | 3121 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 3122 | S1Iterator.Next (); |
3123 | } | |
3124 | ||
3125 | Length = FooSequence.Length (); | |
81bba717 | 3126 | // All stored structures are displayed |
7fd59977 | 3127 | for (i=1; i<=Length; i++) |
3128 | Display (FooSequence.Value (i), Aspect_TOU_WAIT); | |
3129 | if (Length != 0) FooSequence.Clear (); | |
3130 | ||
3131 | } | |
3132 | ||
3133 | void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) { | |
3134 | #ifdef G003 | |
3135 | if ( DegenerateModeIsOn () || !ComputedMode () ) return; | |
3136 | #else | |
3137 | if (DegenerateModeIsOn()) return; | |
3138 | #endif // G003 | |
3139 | ||
3140 | if (IsDeleted ()) return; | |
3141 | ||
3142 | if ((! IsDefined ()) || (! IsActive ())) return; | |
3143 | ||
3144 | if (! MyWindow->IsMapped ()) return; | |
3145 | ||
3146 | if (! AStructure->IsDisplayed ()) return; | |
3147 | ||
3148 | Visual3d_TypeOfAnswer Answer; | |
3149 | ||
3150 | Answer = AcceptDisplay (AStructure); | |
3151 | ||
3152 | if (Answer == Visual3d_TOA_COMPUTE) { | |
3153 | Standard_Integer Index = IsComputed (AStructure); | |
3154 | if (Index == 0) { | |
3155 | #ifdef TRACE_COMP | |
81bba717 | 3156 | cout << "Structure " << AStructure->Identification () |
3157 | << " is not calculated in the view " | |
7fd59977 | 3158 | << Identification () << "\n"; |
3159 | cout << flush; | |
3160 | #endif | |
3161 | } | |
3162 | else { | |
3163 | Standard_Integer OldStructId, NewStructId; | |
3164 | OldStructId = | |
3165 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
3166 | #ifdef TRACE_COMP | |
3167 | Standard_Integer StructId = AStructure->Identification (); | |
81bba717 | 3168 | cout << "Structure " << StructId |
3169 | << " calculated, in the view " | |
3170 | << Identification () << ", by the structure " | |
3171 | << OldStructId << " is recalculated.\n"; | |
7fd59977 | 3172 | cout << flush; |
3173 | #endif | |
3174 | ||
3175 | // Compute + Validation | |
3176 | #ifdef OLD | |
3177 | Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this); | |
3178 | #else | |
3179 | Handle(Graphic3d_Structure) TheStructure; | |
3180 | TColStd_Array2OfReal ATrsf (0, 3, 0, 3); | |
3181 | AStructure->Transform (ATrsf); | |
3182 | if (Index != 0) { | |
3183 | TColStd_Array2OfReal Ident (0, 3, 0, 3); | |
3184 | Standard_Integer ii, jj; | |
3185 | for (ii=0; ii<=3; ii++) | |
3186 | for (jj=0; jj<=3; jj++) | |
3187 | Ident (ii, jj) = (ii == jj ? 1.0 : 0.0); | |
3188 | TheStructure = MyCOMPUTEDSequence.Value (Index); | |
3189 | TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE); | |
3190 | if (AStructure->IsTransformed ()) { | |
3191 | AStructure->Compute (this, ATrsf, TheStructure); | |
3192 | } | |
3193 | else { | |
3194 | AStructure->Compute (this, TheStructure); | |
3195 | } | |
3196 | } | |
3197 | else { | |
3198 | if (AStructure->IsTransformed ()) { | |
3199 | TheStructure = AStructure->Compute (this, ATrsf); | |
3200 | } | |
3201 | else { | |
3202 | TheStructure = AStructure->Compute (this); | |
3203 | } | |
3204 | } | |
3205 | #endif | |
3206 | TheStructure->SetHLRValidation (Standard_True); | |
3207 | ||
81bba717 | 3208 | // Return type of visualisation of the view |
7fd59977 | 3209 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
3210 | ||
81bba717 | 3211 | // Of which type will be the computed ? |
7fd59977 | 3212 | Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) && |
3213 | (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING)); | |
3214 | ||
3215 | Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) && | |
3216 | (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME)); | |
3217 | ||
3218 | if (ComputeWireframe) | |
3219 | TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME); | |
3220 | if (ComputeShading) | |
3221 | TheStructure->SetVisual (Graphic3d_TOS_SHADING); | |
3222 | ||
3223 | if (AStructure->IsHighlighted ()) { | |
3224 | TheStructure->SetHighlightColor | |
3225 | (AStructure->HighlightColor ()); | |
3226 | TheStructure->GraphicHighlight (Aspect_TOHM_COLOR); | |
3227 | } | |
3228 | ||
81bba717 | 3229 | // Ot is ranged |
3230 | // Find structure <AStructure> | |
3231 | // in the sequence of structures to be calculated. | |
7fd59977 | 3232 | NewStructId = TheStructure->Identification (); |
3233 | ||
81bba717 | 3234 | // The previous calculation is removed and the new one is dislayed |
7fd59977 | 3235 | MyGraphicDriver->EraseStructure ( |
3236 | MyCView, | |
3237 | *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()); | |
3238 | MyGraphicDriver->DisplayStructure ( | |
3239 | MyCView, | |
3240 | *(Graphic3d_CStructure *)TheStructure->CStructure (), | |
3241 | int (AStructure->DisplayPriority ()) | |
3242 | ); | |
3243 | ||
3244 | #ifdef TRACE_LENGTH | |
3245 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
3246 | cout << "In Visual3d_View::ReCompute, "; | |
3247 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
3248 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
3249 | << "\n" << flush; | |
3250 | } | |
3251 | #endif | |
3252 | ||
81bba717 | 3253 | // hlhsr and the new associated compute are added |
7fd59977 | 3254 | MyTOCOMPUTESequence.Append (AStructure); |
3255 | MyCOMPUTEDSequence.Append (TheStructure); | |
3256 | ||
3257 | #ifdef TRACE_LENGTH | |
3258 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
3259 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
3260 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
3261 | << "\n" << flush; | |
3262 | #endif | |
3263 | ||
81bba717 | 3264 | // hlhsr and the new associated compute are removed |
7fd59977 | 3265 | |
3266 | MyTOCOMPUTESequence.Remove (Index); | |
3267 | MyCOMPUTEDSequence.Remove (Index); | |
3268 | ||
3269 | #ifdef TRACE_LENGTH | |
3270 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
3271 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
3272 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
3273 | << "\n" << flush; | |
3274 | #endif | |
3275 | } | |
3276 | } | |
3277 | ||
3278 | } | |
3279 | ||
3280 | void | |
3281 | #ifdef G003 | |
3282 | Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) { | |
3283 | #else | |
3284 | Visual3d_View::SetAnimationModeOn () { | |
3285 | #endif | |
3286 | ||
3287 | if (AnimationModeIsOn ()) return; | |
3288 | ||
3289 | AnimationModeIsActive = Standard_True; | |
3290 | #ifdef G003 | |
3291 | if ( degenerate ) | |
3292 | SetDegenerateModeOn (); | |
3293 | else | |
3294 | SetDegenerateModeOff (); | |
3295 | #endif // G003 | |
3296 | MyGraphicDriver->BeginAnimation (MyCView); | |
3297 | ||
3298 | } | |
3299 | ||
3300 | void Visual3d_View::SetAnimationModeOff () { | |
3301 | ||
3302 | if (! AnimationModeIsOn ()) return; | |
3303 | ||
3304 | AnimationModeIsActive = Standard_False; | |
3305 | #ifdef G003 | |
3306 | SetDegenerateModeOff (); | |
3307 | #endif // G003 | |
3308 | MyGraphicDriver->EndAnimation (MyCView); | |
3309 | ||
3310 | } | |
3311 | ||
3312 | Standard_Boolean Visual3d_View::AnimationModeIsOn () const { | |
3313 | ||
3314 | return AnimationModeIsActive; | |
3315 | ||
3316 | } | |
3317 | ||
3318 | void Visual3d_View::SetDegenerateModeOn () { | |
3319 | ||
3320 | #ifdef TRACE | |
3321 | cout << "Visual3d_View" << MyCView.ViewId | |
3322 | << "::SetDegenerateModeOn ();\n"; | |
3323 | cout << flush; | |
3324 | #endif | |
3325 | ||
81bba717 | 3326 | // If the degenerated mode is already active, nothing is recalculated |
7fd59977 | 3327 | if (DegenerateModeIsOn ()) return; |
3328 | DegenerateModeIsActive = Standard_True; | |
3329 | ||
3330 | #ifdef G003 | |
3331 | MyCView.IsDegenerates = 1; | |
3332 | #else | |
3333 | /* | |
81bba717 | 3334 | * Change of activity of the degenerated mode |
3335 | * Remove structures that were calculated | |
3336 | * and displayed when the mode was off. | |
3337 | * Display of non-calculated structures. | |
7fd59977 | 3338 | */ |
3339 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
3340 | Visual3d_TypeOfAnswer Answer; | |
3341 | Standard_Integer StructId; | |
3342 | ||
3343 | while (S1Iterator.More ()) { | |
3344 | ||
3345 | Answer = AcceptDisplay (S1Iterator.Key ()); | |
81bba717 | 3346 | // If the structure was calculated, the previous one is |
3347 | // removed and the new one is displayed | |
3348 | // (This is the role of passage into degenerated mode) | |
7fd59977 | 3349 | |
3350 | if (Answer == Visual3d_TOA_COMPUTE) { | |
3351 | Standard_Integer Index = IsComputed (S1Iterator.Key ()); | |
3352 | if (Index != 0) { | |
3353 | StructId = | |
3354 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
3355 | #ifdef TRACE_COMP | |
81bba717 | 3356 | cout << "Structure " << S1Iterator.Key ()->Identification () |
3357 | << " calculated, in the view " | |
3358 | << Identification () << ", by structure " | |
3359 | << StructId << " passes in degenerated mode.\n"; | |
3360 | cout << "Remove" << StructId << " then display " | |
7fd59977 | 3361 | << S1Iterator.Key ()->Identification () << "\n"; |
3362 | cout << flush; | |
3363 | #endif | |
3364 | MyGraphicDriver->EraseStructure | |
3365 | (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()); | |
3366 | MyGraphicDriver->DisplayStructure ( | |
3367 | MyCView, | |
3368 | *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (), | |
3369 | int (S1Iterator.Key ()->DisplayPriority ()) | |
3370 | ); | |
3371 | } | |
3372 | else { | |
81bba717 | 3373 | // Else is impossible) |
3374 | // If the mode was not degenerated previously, the | |
3375 | // calculated structure associated to S1Iterator.Key () | |
3376 | // really exists and Index != 0 | |
7fd59977 | 3377 | } |
3378 | } | |
3379 | ||
81bba717 | 3380 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 3381 | S1Iterator.Next (); |
3382 | } | |
3383 | #endif //G003 | |
3384 | } | |
3385 | ||
3386 | void Visual3d_View::SetDegenerateModeOff () { | |
3387 | ||
3388 | #ifdef TRACE | |
3389 | cout << "Visual3d_View" << MyCView.ViewId | |
3390 | << "::SetDegenerateModeOff ();\n"; | |
3391 | cout << flush; | |
3392 | #endif | |
3393 | ||
81bba717 | 3394 | // If the degenerated mode is already inactive, nothing is recalculated |
7fd59977 | 3395 | if (! DegenerateModeIsOn ()) return; |
3396 | ||
3397 | DegenerateModeIsActive = Standard_False; | |
3398 | ||
3399 | #ifdef G003 | |
3400 | MyCView.IsDegenerates = 0; | |
3401 | #else | |
3402 | /* | |
81bba717 | 3403 | * Change of activity of degenerated mode |
3404 | * Remove structures that were displayed | |
3405 | * when the mode was on. | |
3406 | * Calculation of structures. | |
7fd59977 | 3407 | */ |
3408 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
3409 | Visual3d_TypeOfAnswer Answer; | |
3410 | Standard_Integer StructId; | |
3411 | ||
3412 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
3413 | ||
3414 | while (S1Iterator.More ()) { | |
3415 | ||
3416 | Answer = AcceptDisplay (S1Iterator.Key ()); | |
81bba717 | 3417 | // If the structure was calculated, the previous one is |
3418 | // removed and the new one is displayed | |
3419 | // (This is the role of passage into degenerated mode) | |
3420 | ||
7fd59977 | 3421 | if (Answer == Visual3d_TOA_COMPUTE) { |
3422 | Standard_Integer Index = IsComputed (S1Iterator.Key ()); | |
3423 | if (Index != 0) { | |
3424 | StructId = | |
3425 | MyCOMPUTEDSequence.Value (Index)->Identification (); | |
3426 | #ifdef TRACE_COMP | |
81bba717 | 3427 | cout << "Structure " << S1Iterator.Key ()->Identification () |
3428 | << " calculated, in the view " | |
3429 | << Identification () << ", by the structure " | |
3430 | << StructId << " passes into normal mode.\n"; | |
3431 | cout << "Remove " << S1Iterator.Key ()->Identification () | |
3432 | << " then display " << StructId << "\n"; | |
7fd59977 | 3433 | cout << flush; |
3434 | #endif | |
3435 | MyGraphicDriver->EraseStructure | |
3436 | (MyCView, | |
3437 | *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ()); | |
3438 | MyGraphicDriver->DisplayStructure ( | |
3439 | MyCView, | |
3440 | *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (), | |
3441 | int (S1Iterator.Key ()->DisplayPriority ()) | |
3442 | ); | |
3443 | ||
3444 | Display (S1Iterator.Key (), Aspect_TOU_WAIT); | |
3445 | ||
3446 | if ((S1Iterator.Key ())->IsHighlighted()) { | |
3447 | if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) { | |
3448 | (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor | |
3449 | ((S1Iterator.Key ())->HighlightColor ()); | |
3450 | (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR); | |
3451 | } | |
3452 | } | |
3453 | } | |
3454 | else { | |
81bba717 | 3455 | // Else is impossible |
3456 | // Degenerated mode was activated before display of the | |
3457 | // structure. So the structure was displayed in the | |
3458 | // degenerated mode, but the calculated structure didn't exist. | |
3459 | // It is calculated. | |
7fd59977 | 3460 | |
3461 | // Compute + Validation | |
3462 | Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ()); | |
3463 | #ifdef OLD | |
3464 | Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this); | |
3465 | #else | |
3466 | Handle(Graphic3d_Structure) TheStructure; | |
3467 | TColStd_Array2OfReal ATrsf (0, 3, 0, 3); | |
3468 | AStructure->Transform (ATrsf); | |
3469 | if (Index != 0) { | |
3470 | TColStd_Array2OfReal Ident (0, 3, 0, 3); | |
3471 | Standard_Integer ii, jj; | |
3472 | for (ii=0; ii<=3; ii++) | |
3473 | for (jj=0; jj<=3; jj++) | |
3474 | Ident (ii, jj) = (ii == jj ? 1.0 : 0.0); | |
3475 | TheStructure = MyCOMPUTEDSequence.Value (Index); | |
3476 | TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE); | |
3477 | if (AStructure->IsTransformed ()) { | |
3478 | AStructure->Compute (this, ATrsf, TheStructure); | |
3479 | } | |
3480 | else { | |
3481 | AStructure->Compute (this, TheStructure); | |
3482 | } | |
3483 | } | |
3484 | else { | |
3485 | if (AStructure->IsTransformed ()) { | |
3486 | TheStructure = AStructure->Compute (this, ATrsf); | |
3487 | } | |
3488 | else { | |
3489 | TheStructure = AStructure->Compute (this); | |
3490 | } | |
3491 | } | |
3492 | #endif | |
3493 | TheStructure->SetHLRValidation (Standard_True); | |
3494 | ||
81bba717 | 3495 | // Return type of visualisation of the view |
7fd59977 | 3496 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); |
3497 | ||
81bba717 | 3498 | // Of which type will be the computed ? |
7fd59977 | 3499 | Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) && |
3500 | ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING)); | |
3501 | ||
3502 | Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) && | |
3503 | ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME)); | |
3504 | ||
3505 | if (ComputeWireframe) | |
3506 | TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME); | |
3507 | if (ComputeShading) | |
3508 | TheStructure->SetVisual (Graphic3d_TOS_SHADING); | |
3509 | ||
3510 | if ((S1Iterator.Key ())->IsHighlighted()) { | |
3511 | TheStructure->SetHighlightColor | |
3512 | ((S1Iterator.Key ())->HighlightColor ()); | |
3513 | TheStructure->GraphicHighlight (Aspect_TOHM_COLOR); | |
3514 | } | |
3515 | ||
81bba717 | 3516 | // Make range |
7fd59977 | 3517 | Standard_Integer Result = 0; |
3518 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
81bba717 | 3519 | // Find structure <S1Iterator.Key ()> |
3520 | // in the sequence of structures to be calculated | |
7fd59977 | 3521 | StructId = (S1Iterator.Key ())->Identification (); |
3522 | for (i=1; i<=Length && Result==0; i++) | |
3523 | if ((MyTOCOMPUTESequence.Value (i))->Identification () == | |
3524 | StructId) Result = i; | |
3525 | if (Result != 0) | |
3526 | MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure; | |
3527 | else { | |
81bba717 | 3528 | // hlhsr and the associated new compute are added |
7fd59977 | 3529 | #ifdef TRACE_LENGTH |
3530 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) { | |
3531 | cout << "In Visual3d_View::SetDegenerateModeOff, "; | |
3532 | cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
3533 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
3534 | << "\n" << flush; | |
3535 | } | |
3536 | #endif | |
3537 | MyTOCOMPUTESequence.Append (S1Iterator.Key ()); | |
3538 | MyCOMPUTEDSequence.Append (TheStructure); | |
3539 | #ifdef TRACE_LENGTH | |
3540 | if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) | |
3541 | cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length () | |
3542 | << " != COMPUTED " << MyCOMPUTEDSequence.Length () | |
3543 | << "\n" << flush; | |
3544 | #endif | |
3545 | } | |
3546 | ||
81bba717 | 3547 | // The degenerated is removed and the calculated is displayed |
7fd59977 | 3548 | MyGraphicDriver->EraseStructure |
3549 | (MyCView, | |
3550 | *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ())); | |
3551 | MyGraphicDriver->DisplayStructure ( | |
3552 | MyCView, | |
3553 | *(Graphic3d_CStructure *)TheStructure->CStructure (), | |
3554 | int (S1Iterator.Key ()->DisplayPriority ()) | |
3555 | ); | |
3556 | } | |
3557 | } | |
3558 | ||
81bba717 | 3559 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 3560 | S1Iterator.Next (); |
3561 | } | |
3562 | ||
3563 | if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update (); | |
3564 | #endif //G003 | |
3565 | } | |
3566 | ||
3567 | Standard_Boolean Visual3d_View::DegenerateModeIsOn () const { | |
3568 | ||
3569 | return DegenerateModeIsActive; | |
3570 | ||
3571 | } | |
3572 | ||
3573 | Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const { | |
3574 | ||
3575 | return MyGraphicDriver; | |
3576 | ||
3577 | } | |
3578 | ||
3579 | void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const { | |
3580 | ||
3581 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); | |
3582 | ||
3583 | while (S1Iterator.More ()) { | |
3584 | ||
3585 | if (DegenerateModeIsOn ()) | |
81bba717 | 3586 | // As the mode is degenerated the displayed structure |
3587 | // is plotted without taking into account if it is calculated or not | |
7fd59977 | 3588 | (S1Iterator.Key ())->Plot (APlotter); |
3589 | else { | |
3590 | Standard_Integer Index = IsComputed (S1Iterator.Key ()); | |
81bba717 | 3591 | // As the mode is not degenerated the displayed structure |
3592 | // is plotted as if it was not calculated, otherwise the | |
3593 | // associated calculated structure is plotted. | |
7fd59977 | 3594 | if (Index == 0) |
3595 | (S1Iterator.Key ())->Plot (APlotter); | |
3596 | else | |
3597 | (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter); | |
3598 | } | |
3599 | ||
81bba717 | 3600 | // S1Iterator.Next () is located on the next structure |
7fd59977 | 3601 | S1Iterator.Next (); |
3602 | } | |
3603 | ||
3604 | } | |
3605 | ||
3606 | Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const { | |
3607 | ||
3608 | Standard_Integer Result = 0; | |
3609 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
3610 | ||
81bba717 | 3611 | // Find in the sequence of already calculated structures |
3612 | // 1/ Structure with the same Owner as <AStructure> | |
3613 | // 2/ Which is not <AStructure> | |
3614 | // 3/ COMPUTED which of is valid | |
7fd59977 | 3615 | for (Standard_Integer i=1; i<=Length && Result==0; i++) |
3616 | if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ()) | |
3617 | && (MyTOCOMPUTESequence.Value (i)->Identification () != | |
3618 | AStructure->Identification ()) | |
3619 | && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i; | |
3620 | ||
3621 | return (Result); | |
3622 | ||
3623 | } | |
3624 | ||
3625 | Standard_Address Visual3d_View::CView () const { | |
3626 | ||
3627 | return Standard_Address (&MyCView); | |
3628 | ||
3629 | } | |
3630 | ||
3631 | ||
3632 | // Triedron methods : the Triedron is a non-zoomable object. | |
3633 | ||
3634 | void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor, | |
3635 | const Quantity_NameOfColor YColor, | |
3636 | const Quantity_NameOfColor ZColor, | |
3637 | const Standard_Real SizeRatio, | |
3638 | const Standard_Real AxisDiametr, | |
3639 | const Standard_Integer NbFacettes) { | |
3640 | MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor, | |
3641 | SizeRatio, AxisDiametr, NbFacettes); | |
3642 | } | |
3643 | ||
3644 | ||
3645 | ||
3646 | void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, | |
3647 | const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) { | |
3648 | ||
3649 | MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe); | |
3650 | ||
3651 | } | |
3652 | ||
3653 | void Visual3d_View::TriedronErase () { | |
3654 | ||
3655 | MyGraphicDriver->TriedronErase (MyCView); | |
3656 | ||
3657 | ||
3658 | } | |
3659 | ||
3660 | void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) { | |
3661 | ||
3662 | MyGraphicDriver->TriedronEcho (MyCView,AType); | |
3663 | ||
3664 | } | |
3665 | ||
3666 | Standard_Boolean checkFloat(const Standard_Real value) | |
3667 | { | |
3668 | return value > -FLT_MAX && value < FLT_MAX; | |
3669 | } | |
3670 | ||
3671 | void SetMinMaxValuesCallback(void* Visual3dView) | |
3672 | { | |
3673 | Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; | |
3674 | ||
3675 | Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView; | |
3676 | view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax); | |
3677 | ||
3678 | if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) && | |
3679 | checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax)) | |
3680 | { | |
3681 | Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver()); | |
3682 | driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin, | |
3683 | (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax); | |
3684 | } | |
3685 | } | |
3686 | ||
13a22457 S |
3687 | Standard_Boolean Visual3d_View::GetGraduatedTrihedron |
3688 | (/* Names of axes */ | |
3689 | TCollection_ExtendedString& xname, | |
3690 | TCollection_ExtendedString& yname, | |
3691 | TCollection_ExtendedString& zname, | |
3692 | /* Draw names */ | |
3693 | Standard_Boolean& xdrawname, | |
3694 | Standard_Boolean& ydrawname, | |
3695 | Standard_Boolean& zdrawname, | |
3696 | /* Draw values */ | |
3697 | Standard_Boolean& xdrawvalues, | |
3698 | Standard_Boolean& ydrawvalues, | |
3699 | Standard_Boolean& zdrawvalues, | |
3700 | /* Draw grid */ | |
3701 | Standard_Boolean& drawgrid, | |
3702 | /* Draw axes */ | |
3703 | Standard_Boolean& drawaxes, | |
3704 | /* Number of splits along axes */ | |
3705 | Standard_Integer& nbx, | |
3706 | Standard_Integer& nby, | |
3707 | Standard_Integer& nbz, | |
3708 | /* Offset for drawing values */ | |
3709 | Standard_Integer& xoffset, | |
3710 | Standard_Integer& yoffset, | |
3711 | Standard_Integer& zoffset, | |
3712 | /* Offset for drawing names of axes */ | |
3713 | Standard_Integer& xaxisoffset, | |
3714 | Standard_Integer& yaxisoffset, | |
3715 | Standard_Integer& zaxisoffset, | |
3716 | /* Draw tickmarks */ | |
3717 | Standard_Boolean& xdrawtickmarks, | |
3718 | Standard_Boolean& ydrawtickmarks, | |
3719 | Standard_Boolean& zdrawtickmarks, | |
3720 | /* Length of tickmarks */ | |
3721 | Standard_Integer& xtickmarklength, | |
3722 | Standard_Integer& ytickmarklength, | |
3723 | Standard_Integer& ztickmarklength, | |
3724 | /* Grid color */ | |
3725 | Quantity_Color& gridcolor, | |
3726 | /* Colors of axis names */ | |
3727 | Quantity_Color& xnamecolor, | |
3728 | Quantity_Color& ynamecolor, | |
3729 | Quantity_Color& znamecolor, | |
3730 | /* Colors of axis and values */ | |
3731 | Quantity_Color& xcolor, | |
3732 | Quantity_Color& ycolor, | |
3733 | Quantity_Color& zcolor, | |
3734 | /* Name of font for names of axes */ | |
3735 | TCollection_AsciiString& fontOfNames, | |
3736 | /* Style of names of axes */ | |
3737 | OSD_FontAspect& styleOfNames, | |
3738 | /* Size of names of axes */ | |
3739 | Standard_Integer& sizeOfNames, | |
3740 | /* Name of font for values */ | |
3741 | TCollection_AsciiString& fontOfValues, | |
3742 | /* Style of values */ | |
3743 | OSD_FontAspect& styleOfValues, | |
3744 | /* Size of values */ | |
3745 | Standard_Integer& sizeOfValues) const | |
7fd59977 | 3746 | { |
13a22457 S |
3747 | if (!MyGTrihedron.ptrVisual3dView) |
3748 | return Standard_False; | |
3749 | ||
3750 | /* Names of axes */ | |
3751 | xname = MyGTrihedron.xname; | |
3752 | yname = MyGTrihedron.yname; | |
3753 | zname = MyGTrihedron.zname; | |
3754 | /* Draw names */ | |
3755 | xdrawname = MyGTrihedron.xdrawname; | |
3756 | ydrawname = MyGTrihedron.ydrawname; | |
3757 | zdrawname = MyGTrihedron.zdrawname; | |
3758 | /* Draw values */ | |
3759 | xdrawvalues = MyGTrihedron.xdrawvalues; | |
3760 | ydrawvalues = MyGTrihedron.ydrawvalues; | |
3761 | zdrawvalues = MyGTrihedron.zdrawvalues; | |
3762 | /* Draw grid */ | |
3763 | drawgrid = MyGTrihedron.drawgrid; | |
3764 | /* Draw axes */ | |
3765 | drawaxes = MyGTrihedron.drawaxes; | |
3766 | /* Number of splits along axes */ | |
3767 | nbx = MyGTrihedron.nbx; | |
3768 | nby = MyGTrihedron.nby; | |
3769 | nbz = MyGTrihedron.nbz; | |
3770 | /* Offset for drawing values */ | |
3771 | xoffset = MyGTrihedron.xoffset; | |
3772 | yoffset = MyGTrihedron.yoffset; | |
3773 | zoffset = MyGTrihedron.zoffset; | |
3774 | /* Offset for drawing names of axes */ | |
3775 | xaxisoffset = MyGTrihedron.xaxisoffset; | |
3776 | yaxisoffset = MyGTrihedron.yaxisoffset; | |
3777 | zaxisoffset = MyGTrihedron.zaxisoffset; | |
3778 | /* Draw tickmarks */ | |
3779 | xdrawtickmarks = MyGTrihedron.xdrawtickmarks; | |
3780 | ydrawtickmarks = MyGTrihedron.ydrawtickmarks; | |
3781 | zdrawtickmarks = MyGTrihedron.zdrawtickmarks; | |
3782 | /* Length of tickmarks */ | |
3783 | xtickmarklength = MyGTrihedron.xtickmarklength; | |
3784 | ytickmarklength = MyGTrihedron.ytickmarklength; | |
3785 | ztickmarklength = MyGTrihedron.ztickmarklength; | |
3786 | /* Grid color */ | |
3787 | gridcolor = MyGTrihedron.gridcolor; | |
3788 | /* Colors of axis names */ | |
3789 | xnamecolor = MyGTrihedron.xnamecolor; | |
3790 | ynamecolor = MyGTrihedron.ynamecolor; | |
3791 | znamecolor = MyGTrihedron.znamecolor; | |
3792 | /* Colors of axis and values */ | |
3793 | xcolor = MyGTrihedron.xcolor; | |
3794 | ycolor = MyGTrihedron.ycolor; | |
3795 | zcolor = MyGTrihedron.zcolor; | |
3796 | /* Name of font for names of axes */ | |
3797 | fontOfNames = MyGTrihedron.fontOfNames; | |
3798 | /* Style of names of axes */ | |
3799 | styleOfNames = MyGTrihedron.styleOfNames; | |
3800 | /* Size of names of axes */ | |
3801 | sizeOfNames = MyGTrihedron.sizeOfNames; | |
3802 | /* Name of font for values */ | |
3803 | fontOfValues = MyGTrihedron.fontOfValues; | |
3804 | /* Style of values */ | |
3805 | styleOfValues = MyGTrihedron.styleOfValues; | |
3806 | /* Size of values */ | |
3807 | sizeOfValues = MyGTrihedron.sizeOfValues; | |
3808 | ||
3809 | return Standard_True; | |
3810 | } | |
3811 | ||
3812 | void Visual3d_View::GraduatedTrihedronDisplay | |
3813 | (/* Names of axes */ | |
3814 | const TCollection_ExtendedString &xname, | |
3815 | const TCollection_ExtendedString &yname, | |
3816 | const TCollection_ExtendedString &zname, | |
3817 | /* Draw names */ | |
3818 | const Standard_Boolean xdrawname, | |
3819 | const Standard_Boolean ydrawname, | |
3820 | const Standard_Boolean zdrawname, | |
3821 | /* Draw values */ | |
3822 | const Standard_Boolean xdrawvalues, | |
3823 | const Standard_Boolean ydrawvalues, | |
3824 | const Standard_Boolean zdrawvalues, | |
3825 | /* Draw grid */ | |
3826 | const Standard_Boolean drawgrid, | |
3827 | /* Draw axes */ | |
3828 | const Standard_Boolean drawaxes, | |
3829 | /* Number of splits along axes */ | |
3830 | const Standard_Integer nbx, | |
3831 | const Standard_Integer nby, | |
3832 | const Standard_Integer nbz, | |
3833 | /* Offset for drawing values */ | |
3834 | const Standard_Integer xoffset, | |
3835 | const Standard_Integer yoffset, | |
3836 | const Standard_Integer zoffset, | |
3837 | /* Offset for drawing names of axes */ | |
3838 | const Standard_Integer xaxisoffset, | |
3839 | const Standard_Integer yaxisoffset, | |
3840 | const Standard_Integer zaxisoffset, | |
3841 | /* Draw tickmarks */ | |
3842 | const Standard_Boolean xdrawtickmarks, | |
3843 | const Standard_Boolean ydrawtickmarks, | |
3844 | const Standard_Boolean zdrawtickmarks, | |
3845 | /* Length of tickmarks */ | |
3846 | const Standard_Integer xtickmarklength, | |
3847 | const Standard_Integer ytickmarklength, | |
3848 | const Standard_Integer ztickmarklength, | |
3849 | /* Grid color */ | |
3850 | const Quantity_Color& gridcolor, | |
3851 | /* Colors of axis names */ | |
3852 | const Quantity_Color& xnamecolor, | |
3853 | const Quantity_Color& ynamecolor, | |
3854 | const Quantity_Color& znamecolor, | |
3855 | /* Colors of axis and values */ | |
3856 | const Quantity_Color& xcolor, | |
3857 | const Quantity_Color& ycolor, | |
3858 | const Quantity_Color& zcolor, | |
3859 | /* Name of font for names of axes */ | |
3860 | const TCollection_AsciiString &fontOfNames, | |
3861 | /* Style of names of axes */ | |
3862 | const OSD_FontAspect styleOfNames, | |
3863 | /* Size of names of axes */ | |
3864 | const Standard_Integer sizeOfNames, | |
3865 | /* Name of font for values */ | |
3866 | const TCollection_AsciiString &fontOfValues, | |
3867 | /* Style of values */ | |
3868 | const OSD_FontAspect styleOfValues, | |
3869 | /* Size of values */ | |
3870 | const Standard_Integer sizeOfValues) | |
7fd59977 | 3871 | { |
13a22457 S |
3872 | /* Names of axes */ |
3873 | MyGTrihedron.xname = xname; | |
3874 | MyGTrihedron.yname = yname; | |
3875 | MyGTrihedron.zname = zname; | |
3876 | /* Draw names */ | |
3877 | MyGTrihedron.xdrawname = xdrawname; | |
3878 | MyGTrihedron.ydrawname = ydrawname; | |
3879 | MyGTrihedron.zdrawname = zdrawname; | |
3880 | /* Draw values */ | |
3881 | MyGTrihedron.xdrawvalues = xdrawvalues; | |
3882 | MyGTrihedron.ydrawvalues = ydrawvalues; | |
3883 | MyGTrihedron.zdrawvalues = zdrawvalues; | |
3884 | /* Draw grid */ | |
3885 | MyGTrihedron.drawgrid = drawgrid; | |
3886 | /* Draw axes */ | |
3887 | MyGTrihedron.drawaxes = drawaxes; | |
3888 | /* Number of splits along axes */ | |
3889 | MyGTrihedron.nbx = nbx; | |
3890 | MyGTrihedron.nby = nby; | |
3891 | MyGTrihedron.nbz = nbz; | |
3892 | /* Offset for drawing values */ | |
3893 | MyGTrihedron.xoffset = xoffset; | |
3894 | MyGTrihedron.yoffset = yoffset; | |
3895 | MyGTrihedron.zoffset = zoffset; | |
3896 | /* Offset for drawing names of axes */ | |
3897 | MyGTrihedron.xaxisoffset = xaxisoffset; | |
3898 | MyGTrihedron.yaxisoffset = yaxisoffset; | |
3899 | MyGTrihedron.zaxisoffset = zaxisoffset; | |
3900 | /* Draw tickmarks */ | |
3901 | MyGTrihedron.xdrawtickmarks = xdrawtickmarks; | |
3902 | MyGTrihedron.ydrawtickmarks = ydrawtickmarks; | |
3903 | MyGTrihedron.zdrawtickmarks = zdrawtickmarks; | |
3904 | /* Length of tickmarks */ | |
3905 | MyGTrihedron.xtickmarklength = xtickmarklength; | |
3906 | MyGTrihedron.ytickmarklength = ytickmarklength; | |
3907 | MyGTrihedron.ztickmarklength = ztickmarklength; | |
3908 | /* Grid color */ | |
3909 | MyGTrihedron.gridcolor = gridcolor; | |
3910 | /* Colors of axis names */ | |
3911 | MyGTrihedron.xnamecolor = xnamecolor; | |
3912 | MyGTrihedron.ynamecolor = ynamecolor; | |
3913 | MyGTrihedron.znamecolor = znamecolor; | |
3914 | /* Colors of axis and values */ | |
3915 | MyGTrihedron.xcolor = xcolor; | |
3916 | MyGTrihedron.ycolor = ycolor; | |
3917 | MyGTrihedron.zcolor = zcolor; | |
3918 | /* Name of font for names of axes */ | |
3919 | MyGTrihedron.fontOfNames = fontOfNames; | |
3920 | /* Style of names of axes */ | |
3921 | MyGTrihedron.styleOfNames = styleOfNames; | |
3922 | /* Size of names of axes */ | |
3923 | MyGTrihedron.sizeOfNames = sizeOfNames; | |
3924 | /* Name of font for values */ | |
3925 | MyGTrihedron.fontOfValues = fontOfValues; | |
3926 | /* Style of values */ | |
3927 | MyGTrihedron.styleOfValues = styleOfValues; | |
3928 | /* Size of values */ | |
3929 | MyGTrihedron.sizeOfValues = sizeOfValues; | |
3930 | ||
3931 | MyGTrihedron.ptrVisual3dView = this; | |
3932 | MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback; | |
3933 | MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron); | |
7fd59977 | 3934 | } |
3935 | ||
3936 | void Visual3d_View::GraduatedTrihedronErase() | |
3937 | { | |
13a22457 | 3938 | MyGTrihedron.ptrVisual3dView = NULL; |
7fd59977 | 3939 | MyGraphicDriver->GraduatedTrihedronErase(MyCView); |
3940 | } | |
3941 | ||
3942 | const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const { | |
3943 | ||
3944 | return (MyViewManager->UnderLayer ()); | |
3945 | ||
3946 | } | |
3947 | ||
3948 | const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const { | |
3949 | ||
3950 | return (MyViewManager->OverLayer ()); | |
3951 | ||
3952 | } | |
3953 | ||
3954 | Standard_Integer Visual3d_View::LightLimit() const { | |
3955 | ||
3956 | Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit (); | |
3957 | // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight); | |
3958 | return maxlight; | |
3959 | } | |
3960 | ||
3961 | Standard_Integer Visual3d_View::PlaneLimit() const { | |
3962 | ||
3963 | Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit (); | |
3964 | // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane); | |
3965 | return maxplane; | |
3966 | } | |
3967 | ||
3968 | #ifdef IMP140100 | |
3969 | Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const { | |
3970 | ||
3971 | return MyPtrViewManager; | |
3972 | } | |
3973 | #endif | |
3974 | ||
3975 | #ifdef G003 | |
3976 | void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) { | |
3977 | ||
3978 | if ( ( (aMode && ComputedModeIsActive) || | |
3979 | (!aMode && !ComputedModeIsActive) | |
3980 | ) || DegenerateModeIsOn () | |
3981 | ) return; | |
3982 | ||
3983 | Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure ); | |
3984 | Visual3d_TypeOfAnswer Answer; | |
3985 | Standard_Integer StructId; | |
3986 | Standard_Integer i = MyDisplayedStructure.Extent (); | |
3987 | ||
3988 | if ( !( ComputedModeIsActive = aMode ) ) { | |
3989 | ||
3990 | while ( S1Iterator.More () ) { | |
3991 | ||
3992 | Answer = AcceptDisplay ( S1Iterator.Key () ); | |
3993 | ||
3994 | if ( Answer == Visual3d_TOA_COMPUTE ) { | |
3995 | ||
3996 | Standard_Integer Index = IsComputed ( S1Iterator.Key () ); | |
3997 | ||
3998 | if ( Index != 0 ) { | |
3999 | ||
4000 | StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification (); | |
4001 | ||
4002 | MyGraphicDriver -> EraseStructure ( | |
4003 | MyCView, | |
4004 | *( Graphic3d_CStructure* ) | |
4005 | MyCOMPUTEDSequence.Value ( Index ) -> CStructure () | |
4006 | ); | |
4007 | MyGraphicDriver -> DisplayStructure ( | |
4008 | MyCView, | |
4009 | *( Graphic3d_CStructure* ) | |
4010 | S1Iterator.Key () -> CStructure (), | |
4011 | int ( S1Iterator.Key () -> DisplayPriority () ) | |
4012 | ); | |
4013 | } // end if ( Index != 0 ) . . . | |
4014 | ||
4015 | } // end if ( Answer . . . ) | |
4016 | ||
4017 | S1Iterator.Next (); | |
4018 | ||
4019 | } // end while | |
4020 | ||
4021 | } else { | |
4022 | ||
4023 | while ( S1Iterator.More () ) { | |
4024 | ||
4025 | Answer = AcceptDisplay ( S1Iterator.Key () ); | |
4026 | ||
4027 | if ( Answer == Visual3d_TOA_COMPUTE ) { | |
4028 | ||
4029 | Standard_Integer Index = IsComputed ( S1Iterator.Key () ); | |
4030 | ||
4031 | if ( Index != 0 ) { | |
4032 | ||
4033 | StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification (); | |
4034 | ||
4035 | MyGraphicDriver -> EraseStructure ( | |
4036 | MyCView, | |
4037 | *( Graphic3d_CStructure* ) | |
4038 | S1Iterator.Key () -> CStructure () | |
4039 | ); | |
4040 | MyGraphicDriver -> DisplayStructure ( | |
4041 | MyCView, | |
4042 | *( Graphic3d_CStructure* ) | |
4043 | MyCOMPUTEDSequence.Value ( Index ) -> CStructure (), | |
4044 | int ( S1Iterator.Key () -> DisplayPriority () ) | |
4045 | ); | |
4046 | ||
4047 | Display ( S1Iterator.Key (), Aspect_TOU_WAIT ); | |
4048 | ||
4049 | if ( S1Iterator.Key () -> IsHighlighted () ) { | |
4050 | ||
4051 | if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) { | |
4052 | ||
4053 | MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor ( | |
4054 | S1Iterator.Key () -> | |
4055 | HighlightColor () | |
4056 | ); | |
4057 | MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight ( | |
4058 | Aspect_TOHM_COLOR | |
4059 | ); | |
4060 | } // end if | |
4061 | ||
4062 | } // end if | |
4063 | ||
4064 | } else { | |
4065 | ||
4066 | Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key (); | |
4067 | #ifdef OLD | |
4068 | Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this ); | |
4069 | #else | |
4070 | Handle( Graphic3d_Structure ) TheStructure; | |
4071 | TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 ); | |
4072 | ||
4073 | AStructure -> Transform ( ATrsf ); | |
4074 | ||
4075 | if ( Index != 0 ) { | |
4076 | ||
4077 | TColStd_Array2OfReal Ident ( 0, 3, 0, 3 ); | |
4078 | Standard_Integer ii, jj; | |
4079 | ||
4080 | for ( ii = 0; ii <= 3; ++ii ) | |
4081 | ||
4082 | for ( jj = 0; jj <= 3; ++jj ) | |
4083 | ||
4084 | Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 ); | |
4085 | ||
4086 | TheStructure = MyCOMPUTEDSequence.Value ( Index ); | |
4087 | ||
4088 | TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE ); | |
4089 | ||
4090 | if ( AStructure->IsTransformed () ) | |
4091 | ||
4092 | AStructure -> Compute ( this, ATrsf, TheStructure ); | |
4093 | ||
4094 | else | |
4095 | ||
4096 | AStructure -> Compute ( this, TheStructure ); | |
4097 | ||
4098 | } else { | |
4099 | ||
4100 | if ( AStructure -> IsTransformed () ) | |
4101 | ||
4102 | TheStructure = AStructure -> Compute ( this, ATrsf ); | |
4103 | ||
4104 | else | |
4105 | ||
4106 | TheStructure = AStructure -> Compute ( this ); | |
4107 | ||
4108 | } // end else | |
4109 | #endif // OLD | |
4110 | TheStructure -> SetHLRValidation ( Standard_True ); | |
4111 | ||
4112 | Visual3d_TypeOfVisualization ViewType = MyContext.Visualization (); | |
4113 | ||
4114 | Standard_Boolean ComputeWireframe = | |
4115 | ( ( ViewType == Visual3d_TOV_WIREFRAME ) && | |
4116 | ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING ) | |
4117 | ); | |
4118 | ||
4119 | Standard_Boolean ComputeShading = | |
4120 | ( ( ViewType == Visual3d_TOV_SHADING ) && | |
4121 | ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME ) | |
4122 | ); | |
4123 | ||
4124 | if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME ); | |
4125 | if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING ); | |
4126 | ||
4127 | if ( S1Iterator.Key () -> IsHighlighted () ) { | |
4128 | ||
4129 | TheStructure -> SetHighlightColor ( | |
4130 | S1Iterator.Key () -> HighlightColor () | |
4131 | ); | |
4132 | TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR ); | |
4133 | ||
4134 | } // end if | |
4135 | ||
4136 | Standard_Integer Result = 0; | |
4137 | Standard_Integer Length = MyTOCOMPUTESequence.Length (); | |
4138 | StructId = S1Iterator.Key () -> Identification (); | |
4139 | ||
4140 | for ( i = 1; i <= Length && Result == 0; ++i ) | |
4141 | ||
4142 | if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId ) | |
4143 | ||
4144 | Result = i; | |
4145 | ||
4146 | if ( Result ) | |
4147 | ||
4148 | MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure; | |
4149 | ||
4150 | else { | |
4151 | ||
4152 | MyTOCOMPUTESequence.Append ( S1Iterator.Key () ); | |
4153 | MyCOMPUTEDSequence.Append ( TheStructure ); | |
4154 | ||
4155 | } // end else | |
4156 | ||
4157 | MyGraphicDriver -> EraseStructure ( | |
4158 | MyCView, | |
4159 | *( Graphic3d_CStructure* ) | |
4160 | S1Iterator.Key () -> CStructure () | |
4161 | ); | |
4162 | MyGraphicDriver -> DisplayStructure ( | |
4163 | MyCView, | |
4164 | *( Graphic3d_CStructure* )TheStructure -> CStructure (), | |
4165 | int ( S1Iterator.Key () -> DisplayPriority () ) | |
4166 | ); | |
4167 | } // end else | |
4168 | ||
4169 | } // end if | |
4170 | ||
4171 | S1Iterator.Next (); | |
4172 | ||
4173 | } // end while | |
4174 | ||
4175 | if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update (); | |
4176 | ||
4177 | } // end else | |
4178 | ||
4179 | } // end Visual3d_View :: SetComputedMode | |
4180 | ||
4181 | Standard_Boolean Visual3d_View :: ComputedMode () const { | |
4182 | ||
4183 | return ComputedModeIsActive; | |
4184 | ||
4185 | } // end Visual3d_View :: ComputedMode | |
4186 | ||
4187 | void Visual3d_View :: SetBackFacingModel ( | |
4188 | const Visual3d_TypeOfBackfacingModel aModel | |
4189 | ) { | |
4190 | switch ( aModel ) { | |
4191 | ||
4192 | default: | |
4193 | case Visual3d_TOBM_AUTOMATIC: | |
4194 | MyCView.Backfacing = 0; | |
4195 | break; | |
4196 | ||
4197 | case Visual3d_TOBM_FORCE: | |
4198 | MyCView.Backfacing = 1; | |
4199 | break; | |
4200 | ||
4201 | case Visual3d_TOBM_DISABLE: | |
4202 | MyCView.Backfacing = -1; | |
4203 | break; | |
4204 | ||
4205 | } // end switch | |
4206 | ||
4207 | MyGraphicDriver -> SetBackFacingModel ( MyCView ); | |
4208 | ||
4209 | } // end Visual3d_View :: SetBackFacingModel | |
4210 | ||
4211 | Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const { | |
4212 | ||
4213 | switch ( MyCView.Backfacing ) { | |
4214 | ||
4215 | case 0: | |
4216 | return Visual3d_TOBM_AUTOMATIC; | |
4217 | ||
4218 | case 1: | |
4219 | return Visual3d_TOBM_FORCE; | |
4220 | ||
4221 | } // end switch | |
4222 | ||
4223 | return Visual3d_TOBM_DISABLE; | |
4224 | ||
4225 | } // end Visual3d_View :: BackFacingModel | |
4226 | #endif // G003 | |
4227 | ||
4228 | void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const | |
4229 | { | |
4230 | #ifdef BUC61044 | |
4231 | MyGraphicDriver->SetDepthTestEnabled( MyCView, enable ); | |
4232 | #endif | |
4233 | } | |
4234 | ||
4235 | Standard_Boolean Visual3d_View::IsDepthTestEnabled() const | |
4236 | { | |
4237 | #ifdef BUC61044 | |
4238 | return MyGraphicDriver->IsDepthTestEnabled( MyCView ); | |
4239 | #else | |
4240 | return Standard_True; | |
4241 | #endif | |
4242 | } | |
4243 | ||
4244 | void Visual3d_View::ReadDepths(const Standard_Integer x, | |
4245 | const Standard_Integer y, | |
4246 | const Standard_Integer width, | |
4247 | const Standard_Integer height, | |
4248 | const Standard_Address buffer) const | |
4249 | { | |
4250 | MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer ); | |
4251 | } | |
4252 | ||
4253 | Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth, | |
4254 | const Standard_Integer theHeight) | |
4255 | { | |
4256 | return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight ); | |
4257 | } | |
4258 | ||
4259 | void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr) | |
4260 | { | |
4261 | MyGraphicDriver->FBORelease( MyCView, theFBOPtr ); | |
4262 | } | |
4263 | ||
4264 | void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr, | |
4265 | Standard_Integer& theWidth, Standard_Integer& theHeight, | |
4266 | Standard_Integer& theWidthMax, Standard_Integer& theHeightMax) | |
4267 | { | |
4268 | MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr, | |
4269 | theWidth, theHeight, | |
4270 | theWidthMax, theHeightMax ); | |
4271 | } | |
4272 | ||
4273 | void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr, | |
4274 | const Standard_Integer theWidth, const Standard_Integer theHeight) | |
4275 | { | |
4276 | MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr, | |
4277 | theWidth, theHeight ); | |
4278 | } | |
4279 | ||
692613e5 | 4280 | Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage, |
4281 | const Graphic3d_BufferType& theBufferType) | |
7fd59977 | 4282 | { |
692613e5 | 4283 | return MyGraphicDriver->BufferDump (MyCView, theImage, theBufferType); |
7fd59977 | 4284 | } |
4285 | ||
4286 | void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const | |
4287 | { | |
4288 | #ifdef BUC61045 | |
4289 | MyGraphicDriver->SetGLLightEnabled( MyCView, enable ); | |
4290 | #endif | |
4291 | } | |
4292 | ||
4293 | ||
4294 | Standard_Boolean Visual3d_View::IsGLLightEnabled() const | |
4295 | { | |
4296 | #ifdef BUC61045 | |
4297 | return MyGraphicDriver->IsGLLightEnabled( MyCView ); | |
4298 | #else | |
4299 | return Standard_True; | |
4300 | #endif | |
4301 | } | |
4302 | ||
5cedc27f K |
4303 | Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName, |
4304 | const Graphic3d_ExportFormat theFormat, | |
4305 | const Graphic3d_SortType theSortType, | |
4306 | const Standard_Real thePrecision, | |
4307 | const Standard_Address theProgressBarFunc, | |
4308 | const Standard_Address theProgressObject) const | |
7fd59977 | 4309 | { |
5cedc27f K |
4310 | Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer(); |
4311 | Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer(); | |
7fd59977 | 4312 | |
5cedc27f K |
4313 | Aspect_CLayer2d anOverCLayer; |
4314 | Aspect_CLayer2d anUnderCLayer; | |
4315 | anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL; | |
7fd59977 | 4316 | |
5cedc27f K |
4317 | if (!anOverLayer.IsNull()) |
4318 | anOverCLayer = anOverLayer->CLayer(); | |
4319 | if (!anUnderLayer.IsNull()) | |
4320 | anUnderCLayer = anUnderLayer->CLayer(); | |
7fd59977 | 4321 | |
5cedc27f K |
4322 | Standard_Integer aWidth, aHeight; |
4323 | Window()->Size (aWidth, aHeight); | |
7fd59977 | 4324 | |
5cedc27f K |
4325 | return MyGraphicDriver->Export (theFileName, theFormat, theSortType, |
4326 | aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer, | |
4327 | thePrecision, theProgressBarFunc, theProgressObject); | |
7fd59977 | 4328 | } |
59f45b7c | 4329 | |
4330 | //======================================================================= | |
4331 | //function : AddZLayer | |
4332 | //purpose : | |
4333 | //======================================================================= | |
4334 | ||
4335 | void Visual3d_View::AddZLayer (const Standard_Integer theLayerId) | |
4336 | { | |
4337 | MyGraphicDriver->AddZLayer (MyCView, theLayerId); | |
4338 | } | |
4339 | ||
4340 | //======================================================================= | |
4341 | //function : RemoveZLayer | |
4342 | //purpose : | |
4343 | //======================================================================= | |
4344 | ||
4345 | void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId) | |
4346 | { | |
4347 | MyGraphicDriver->RemoveZLayer (MyCView, theLayerId); | |
4348 | } | |
4349 | ||
4350 | //======================================================================= | |
4351 | //function : ChangeZLayer | |
4352 | //purpose : | |
4353 | //======================================================================= | |
4354 | ||
4355 | void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, | |
4356 | const Standard_Integer theLayerId) | |
4357 | { | |
4358 | MyGraphicDriver->ChangeZLayer ( | |
4359 | (*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId); | |
4360 | } |