OCC22391 Polylines arrays not drawn for mesh with VBO flag enabled
[occt.git] / src / OpenGl / OpenGl_togl_contextstructure.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5File OpenGl_contextstructure.c :
6
7
8REMARQUES:
9----------
10
11
12HISTORIQUE DES MODIFICATIONS :
13--------------------------------
1405-08-97 : PCT ; Support texture mapping
1523-12-97 : FMN ; Suppression TelBackInteriorStyle, TelBackInteriorStyleIndex
1630-12-97 : FMN ; CTS18312: Correction back material
1715-01-98 : FMN ; Ajout Hidden line
1803-03-98 : CAL ; Modification des structures CALL_DEF_GROUP et STRUCTURE
1908-04-98 : FGU ; Ajout Emission
2030-11-98 : FMN ; S4069 : Textes toujours visibles
2102.14.100 : JR : Warnings on WNT #include ,stdio.h>
2222-03-04 : SAN ; OCC4895 High-level interface for controlling polygon offsets
23
24************************************************************************/
25
26#define OCC1174 /* SAV 08/01/03 : Added back face interior color management*/
27
28
29/*----------------------------------------------------------------------*/
30/*
31* Includes
32*/
33
34#include <stdio.h>
35
36#include <OpenGl_tgl_all.hxx>
37
38#include <InterfaceGraphic_Labels.hxx>
39#include <InterfaceGraphic_Graphic3d.hxx>
40
41#include <OpenGl_tgl.hxx>
42#include <OpenGl_tgl_funcs.hxx>
43#include <OpenGl_tgl_subrs.hxx>
44
45#include <OSD_FontAspect.hxx>
46
47
48void EXPORT
49call_togl_contextstructure
50(
51 CALL_DEF_STRUCTURE * astructure
52 )
53{
54 Tfloat liner, lineg, lineb;
55 Tfloat fillr, fillg, fillb;
56#ifdef OCC1174
57 Tfloat fillBackr, fillBackg, fillBackb;
58#endif
59 Tint linetype=0;
60 Tint intstyle=0;
61 Tfloat linewidth;
62 Tint hatch=0;
63 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
64 Tint polyOffsetMode;
65 Tfloat polyOffsetFactor, polyOffsetUnits;
66 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
67
68 Tfloat markr, markg, markb;
69 Tint markertype=0;
70 Tfloat markerscale;
71
72 Tchar *fontid=NULL;
73 Tfloat textr, textg, textb;
74 Tfloat textrs, textgs, textbs;
75 Tfloat textspace;
76 Tfloat textexpan;
77 int textstyle, textdisplaytype;
78 Tint textzoomable;
79 Tfloat textangle;
80 OSD_FontAspect textfontaspect;
81 /* Flag de mise a jour des composants materiel */
82 Tint lightbool = 0x0;
83 CALL_DEF_TRANSFORM_PERSISTENCE transPers = astructure->TransformPersistence;
84
85 /* Destruction */
86 if( astructure->ContextLine.IsDef == -1 )
87 {
88 }
89 if( astructure->ContextFillArea.IsDef == -1 )
90 {
91 }
92 if( astructure->ContextMarker.IsDef == -1 )
93 {
94 }
95 if( astructure->ContextText.IsDef == -1 )
96 {
97 }
98 call_func_open_struct( astructure->Id );
99 call_func_set_elem_ptr( 0 );
100 call_func_set_elem_ptr_label( Structure_LABTransPersistence );
101 if( astructure->TransformPersistence.IsSet == 1 )
102 {
103 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
104 call_func_offset_elem_ptr( 1 );
105 }
106 else
107 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
108 /*call_func_set_transform_persistence( transPersFlag );*/
109 call_func_set_transform_persistence( transPers.Flag, transPers.Point.x, transPers.Point.y, transPers.Point.z );
110 call_func_close_struct();
111 /* }*/
112 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
113 if( astructure->ContextLine.IsDef == 1 )
114 {
115 liner = astructure->ContextLine.Color.r;
116 lineg = astructure->ContextLine.Color.g;
117 lineb = astructure->ContextLine.Color.b;
118
119 switch( astructure->ContextLine.LineType )
120 {
121 case 0 : /* Aspect_TOL_SOLID */
122 linetype = CALL_PHIGS_LINE_SOLID;
123 break;
124 case 1 : /* Aspect_TOL_DASH */
125 linetype = CALL_PHIGS_LINE_DASH;
126 break;
127 case 2 : /* Aspect_TOL_DOT */
128 linetype = CALL_PHIGS_LINE_DOT;
129 break;
130 case 3 : /* Aspect_TOL_DOTDASH */
131 linetype = CALL_PHIGS_LINE_DASH_DOT;
132 break;
133 default :
134 break;
135 }
136
137 linewidth = (Tfloat)astructure->ContextLine.Width;
138
139 if( astructure->ContextLine.IsSet )
140 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
141 else
142 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
143 call_func_open_struct( astructure->Id );
144 call_func_set_elem_ptr( 0 );
145 call_func_set_elem_ptr_label( Structure_LABContextLine );
146
147 if( astructure->ContextLine.IsSet )
148 call_func_offset_elem_ptr( 1 );
149 call_subr_set_line_colr( liner, lineg, lineb );
150 if( astructure->ContextLine.IsSet )
151 call_func_offset_elem_ptr( 1 );
152 call_func_set_linetype( linetype );
153 if( astructure->ContextLine.IsSet )
154 call_func_offset_elem_ptr( 1 );
155 call_func_set_linewidth( linewidth );
156 call_func_close_struct();
157 }
158
159 if( astructure->ContextFillArea.IsDef == 1 )
160 {
161 switch( astructure->ContextFillArea.Style )
162 {
163 case 0 : /* Aspect_IS_EMPTY */
164 intstyle = CALL_PHIGS_STYLE_EMPTY;
165 break;
166 case 1 : /* Aspect_IS_HOLLOW */
167 intstyle = CALL_PHIGS_STYLE_HOLLOW;
168 break;
169 case 2 : /* Aspect_IS_HATCH */
170 intstyle = CALL_PHIGS_STYLE_HATCH;
171 break;
172 case 3 : /* Aspect_IS_SOLID */
173 intstyle = CALL_PHIGS_STYLE_SOLID;
174 break;
175 case 4 : /* Aspect_IS_HIDDENLINE */
176 intstyle = CALL_PHIGS_STYLE_HIDDENLINE;
177 break;
178 default :
179 break;
180 }
181
182 switch( astructure->ContextFillArea.Hatch )
183 {
184 case 0 : /* Aspect_HS_HORIZONTAL */
185 hatch = CALL_PHIGS_HATCH_HORIZ;
186 break;
187 case 1 : /* Aspect_HS_HORIZONTAL_WIDE */
188 hatch = CALL_PHIGS_HATCH_HORIZ_DBL;
189 break;
190 case 2 : /* Aspect_HS_VERTICAL */
191 hatch = CALL_PHIGS_HATCH_VERT;
192 break;
193 case 3 : /* Aspect_HS_VERTICAL_WIDE */
194 hatch = CALL_PHIGS_HATCH_VERT_DBL;
195 break;
196 case 4 : /* Aspect_HS_DIAGONAL_45 */
197 hatch = CALL_PHIGS_HATCH_DIAG_45;
198 break;
199 case 5 : /* Aspect_HS_DIAGONAL_45_WIDE */
200 hatch = CALL_PHIGS_HATCH_DIAG_45_DBL;
201 break;
202 case 6 : /* Aspect_HS_DIAGONAL_135 */
203 hatch = CALL_PHIGS_HATCH_DIAG_135;
204 break;
205 case 7 : /* Aspect_HS_DIAGONAL_135_WIDE */
206 hatch = CALL_PHIGS_HATCH_DIAG_135_DBL;
207 break;
208 case 8 : /* Aspect_HS_GRID */
209 hatch = CALL_PHIGS_HATCH_GRID_R;
210 break;
211 case 9 : /* Aspect_HS_GRID_WIDE */
212 hatch = CALL_PHIGS_HATCH_GRID_R_DBL;
213 break;
214 case 10 : /* Aspect_HS_GRID_DIAGONAL */
215 hatch = CALL_PHIGS_HATCH_GRID_D;
216 break;
217 case 11 : /* Aspect_HS_GRID_DIAGONAL_WIDE */
218 hatch = CALL_PHIGS_HATCH_GRID_D_DBL;
219 break;
220 default :
221 break;
222 }
223
224 fillr = astructure->ContextFillArea.IntColor.r;
225 fillg = astructure->ContextFillArea.IntColor.g;
226 fillb = astructure->ContextFillArea.IntColor.b;
227
228#ifdef OCC1174
229 fillBackr = astructure->ContextFillArea.BackIntColor.r;
230 fillBackg = astructure->ContextFillArea.BackIntColor.g;
231 fillBackb = astructure->ContextFillArea.BackIntColor.b;
232#endif
233
234 liner = astructure->ContextFillArea.EdgeColor.r;
235 lineg = astructure->ContextFillArea.EdgeColor.g;
236 lineb = astructure->ContextFillArea.EdgeColor.b;
237
238 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
239 polyOffsetMode = astructure->ContextFillArea.PolygonOffsetMode;
240 polyOffsetFactor = astructure->ContextFillArea.PolygonOffsetFactor;
241 polyOffsetUnits = astructure->ContextFillArea.PolygonOffsetUnits;
242 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
243
244 switch( astructure->ContextFillArea.LineType )
245 {
246 case 0 : /* Aspect_TOL_SOLID */
247 linetype = CALL_PHIGS_LINE_SOLID;
248 break;
249 case 1 : /* Aspect_TOL_DASH */
250 linetype = CALL_PHIGS_LINE_DASH;
251 break;
252 case 2 : /* Aspect_TOL_DOT */
253 linetype = CALL_PHIGS_LINE_DOT;
254 break;
255 case 3 : /* Aspect_TOL_DOTDASH */
256 linetype = CALL_PHIGS_LINE_DASH_DOT;
257 break;
258 default :
259 break;
260 }
261
262 linewidth = (Tfloat)astructure->ContextFillArea.Width;
263
264 if( astructure->ContextFillArea.IsSet )
265 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
266 else
267 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
268 call_func_open_struct( astructure->Id );
269 call_func_set_elem_ptr( 0 );
270 call_func_set_elem_ptr_label( Structure_LABContextFillArea );
271
272 /* interior */
273 if( astructure->ContextFillArea.IsSet )
274 call_func_offset_elem_ptr( 1 );
275 call_func_set_int_style( intstyle );
276 if( astructure->ContextFillArea.IsSet )
277 call_func_offset_elem_ptr( 1 );
278 call_subr_set_int_colr( fillr, fillg, fillb, ( float )1.0 );
279 if( astructure->ContextFillArea.IsSet )
280 call_func_offset_elem_ptr( 1 );
281#ifdef OCC1174
282 call_subr_set_back_int_colr( fillBackr, fillBackg, fillBackb, ( float )1.0 );
283#else
284 call_subr_set_back_int_colr( fillr, fillg, fillb, ( float )1.0 );
285#endif
286 /* edge */
287 if( astructure->ContextFillArea.IsSet )
288 call_func_offset_elem_ptr( 1 );
289 if( astructure->ContextFillArea.Edge )
290 call_func_set_edge_flag( CALL_PHIGS_EDGE_ON );
291 else
292 call_func_set_edge_flag( CALL_PHIGS_EDGE_OFF );
293 if( astructure->ContextFillArea.IsSet )
294 call_func_offset_elem_ptr( 1 );
295 call_subr_set_edge_colr( liner, lineg, lineb );
296 if( astructure->ContextFillArea.IsSet )
297 call_func_offset_elem_ptr( 1 );
298 call_func_set_edge_type( linetype );
299 if( astructure->ContextFillArea.IsSet )
300 call_func_offset_elem_ptr( 1 );
301 call_func_set_edgewidth( linewidth );
302 /* hatch */
303 if( astructure->ContextFillArea.IsSet )
304 call_func_offset_elem_ptr( 1 );
305 if( intstyle == CALL_PHIGS_STYLE_HATCH )
306 call_func_set_int_style_ind( hatch );
307 else
308 call_func_appl_data( 0 );
309 /* front and back face */
310 if( astructure->ContextFillArea.IsSet )
311 call_func_offset_elem_ptr( 1 );
312 if( astructure->ContextFillArea.Distinguish )
313 call_func_set_face_disting_mode(CALL_PHIGS_DISTING_YES);
314 else
315 call_func_set_face_disting_mode(CALL_PHIGS_DISTING_NO);
316 if( astructure->ContextFillArea.IsSet )
317 call_func_offset_elem_ptr( 1 );
318 if( astructure->ContextFillArea.BackFace )
319 call_func_set_face_cull_mode(CALL_PHIGS_CULL_BACKFACE);
320 else
321 call_func_set_face_cull_mode( CALL_PHIGS_CULL_NONE );
322 /* front face */
323 if( astructure->ContextFillArea.IsSet )
324 call_func_offset_elem_ptr( 1 );
325
326 /* Front face */
327 /* Gestion Lumiere */
328 if( astructure->ContextFillArea.Front.IsAmbient )
329 lightbool = lightbool | AMBIENT_MASK;
330
331 if( astructure->ContextFillArea.Front.IsDiffuse )
332 lightbool = lightbool | DIFFUSE_MASK;
333
334 if( astructure->ContextFillArea.Front.IsSpecular )
335 lightbool = lightbool | SPECULAR_MASK;
336
337 if( astructure->ContextFillArea.Front.IsEmission )
338 lightbool = lightbool | EMISSIVE_MASK;
339
340 if( !lightbool )
341 call_func_set_refl_eqn( CALL_PHIGS_REFL_NONE );
342 else
343 call_func_set_refl_eqn( lightbool );
344
345 if( astructure->ContextFillArea.IsSet )
346 call_func_offset_elem_ptr( 1 );
347 call_subr_set_refl_props( &astructure->ContextFillArea.Front, 0 );
348
349 /* back face */
350 /* Gestion lumiere */
351 if( astructure->ContextFillArea.IsSet )
352 call_func_offset_elem_ptr( 1 );
353
354 if( astructure->ContextFillArea.Back.IsAmbient )
355 lightbool = lightbool | AMBIENT_MASK;
356
357 if( astructure->ContextFillArea.Back.IsDiffuse )
358 lightbool = lightbool | DIFFUSE_MASK;
359
360 if( astructure->ContextFillArea.Back.IsSpecular )
361 lightbool = lightbool | SPECULAR_MASK;
362
363 if( astructure->ContextFillArea.Back.IsEmission )
364 lightbool = lightbool | EMISSIVE_MASK;
365
366 if( !lightbool )
367 call_func_set_back_refl_eqn( CALL_PHIGS_REFL_NONE );
368 else
369 call_func_set_back_refl_eqn( lightbool );
370
371 if( astructure->ContextFillArea.IsSet )
372 call_func_offset_elem_ptr( 1 );
373 call_subr_set_refl_props( &astructure->ContextFillArea.Back, 1 );
374
375 if( astructure->ContextFillArea.IsSet )
376 call_func_offset_elem_ptr( 1 );
377 call_func_set_do_texturemap(astructure->ContextFillArea.Texture.doTextureMap);
378
379 if( astructure->ContextFillArea.IsSet )
380 call_func_offset_elem_ptr( 1 );
381 call_func_set_texture_id(astructure->ContextFillArea.Texture.TexId);
382
383 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
384 if( astructure->ContextFillArea.IsSet )
385 call_func_offset_elem_ptr( 1 );
386 call_func_set_polygon_offset_params( polyOffsetMode, polyOffsetFactor, polyOffsetUnits );
387 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
388 call_func_close_struct();
389 }
390
391 if( astructure->ContextMarker.IsDef == 1 )
392 {
393 markr = astructure->ContextMarker.Color.r;
394 markg = astructure->ContextMarker.Color.g;
395 markb = astructure->ContextMarker.Color.b;
396
397 switch( astructure->ContextMarker.MarkerType )
398 {
399 case 0 : /* Aspect_TOM_POINT */
400 markertype = CALL_PHIGS_MARKER_DOT;
401 break;
402 case 1 : /* Aspect_TOM_PLUS */
403 markertype = CALL_PHIGS_MARKER_PLUS;
404 break;
405 case 2 : /* Aspect_TOM_STAR */
406 markertype = CALL_PHIGS_MARKER_ASTERISK;
407 break;
408 case 3 : /* Aspect_TOM_O */
409 markertype = CALL_PHIGS_MARKER_CIRCLE;
410 break;
411 case 4 : /* Aspect_TOM_X */
412 markertype = CALL_PHIGS_MARKER_CROSS;
413 break;
414 case 5 : /* Aspect_TOM_USERDEFINED*/
415 markertype = CALL_PHIGS_MARKER_USER_DEFINED;
416 break;
417 default :
418 printf( "\n\tINVALID MARKER TYPE %d",
419 astructure->ContextMarker.MarkerType );
420 break;
421 }
422
423 markerscale = (Tfloat)astructure->ContextMarker.Scale;
424
425 if( astructure->ContextMarker.IsSet )
426 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
427 else
428 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
429 call_func_open_struct( astructure->Id );
430 call_func_set_elem_ptr( 0 );
431 call_func_set_elem_ptr_label( Structure_LABContextMarker );
432 if( astructure->ContextMarker.IsSet )
433 call_func_offset_elem_ptr( 1 );
434 call_subr_set_marker_colr( markr, markg, markb );
435 if( astructure->ContextMarker.IsSet )
436 call_func_offset_elem_ptr( 1 );
437 call_func_set_marker_type( markertype );
438 if( astructure->ContextMarker.IsSet )
439 call_func_offset_elem_ptr( 1 );
440 call_func_set_marker_size( markerscale );
441 call_func_close_struct();
442 }
443
444#ifdef TRACE
445 cout << "TKOpenGl::OpenGl_togl_contextstructure"
446 << "\t is defined : " << astructure->ContextText.IsDef << endl;
447#endif
448 if( astructure->ContextText.IsDef == 1 )
449 {
450 textr = astructure->ContextText.Color.r;
451 textg = astructure->ContextText.Color.g;
452 textb = astructure->ContextText.Color.b;
453
454 textrs = astructure->ContextText.ColorSubTitle.r;
455 textgs = astructure->ContextText.ColorSubTitle.g;
456 textbs = astructure->ContextText.ColorSubTitle.b;
457
458 fontid = new Tchar[strlen((char*)astructure->ContextText.Font)+1];
459 strcpy((char*)fontid,(char*)astructure->ContextText.Font);
460
461 textspace = (Tfloat)astructure->ContextText.Space;
462 textexpan = (Tfloat)astructure->ContextText.Expan;
463 textstyle = (int) astructure->ContextText.Style;
464 textdisplaytype = (int) astructure->ContextText.DisplayType;
465 textzoomable = (int) astructure->ContextText.TextZoomable;
466 textangle = (float) astructure->ContextText.TextAngle;
467 textfontaspect = (OSD_FontAspect)astructure->ContextText.TextFontAspect;
468
469 if( astructure->ContextText.IsSet )
470 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
471 else
472 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
473 call_func_open_struct( astructure->Id );
474 call_func_set_elem_ptr( 0 );
475 call_func_set_elem_ptr_label( Structure_LABContextText );
476 if( astructure->ContextText.IsSet )
477 call_func_offset_elem_ptr( 1 );
478 call_func_set_text_zoomable( textzoomable );
479 call_func_set_text_angle( textangle );
480 call_func_set_text_fontaspect( textfontaspect );
481
482 if( astructure->ContextText.IsSet )
483 call_func_offset_elem_ptr( 1 );
484 call_func_set_text_font( fontid );
485 if( astructure->ContextText.IsSet )
486 call_func_offset_elem_ptr( 1 );
487 call_func_set_char_space( textspace );
488 if( astructure->ContextText.IsSet )
489 call_func_offset_elem_ptr( 1 );
490 call_func_set_char_expan( textexpan );
491 if( astructure->ContextText.IsSet )
492 call_func_offset_elem_ptr( 1 );
493 call_subr_set_text_colr( textr, textg, textb );
494 if( astructure->ContextText.IsSet )
495 call_func_offset_elem_ptr( 1 );
496 call_func_set_text_style( textstyle );
497 if( astructure->ContextText.IsSet )
498 call_func_offset_elem_ptr( 1 );
499 call_func_set_text_display_type( textdisplaytype );
500 if( astructure->ContextText.IsSet )
501 call_func_offset_elem_ptr( 1 );
502 call_subr_set_text_colr_subtitle( textrs, textgs, textbs );
503
504 call_func_close_struct();
505 }
506 return;
507}