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