1 /***********************************************************************
5 File OpenGl_contextstructure.c :
12 HISTORIQUE DES MODIFICATIONS :
13 --------------------------------
14 05-08-97 : PCT ; Support texture mapping
15 23-12-97 : FMN ; Suppression TelBackInteriorStyle, TelBackInteriorStyleIndex
16 30-12-97 : FMN ; CTS18312: Correction back material
17 15-01-98 : FMN ; Ajout Hidden line
18 03-03-98 : CAL ; Modification des structures CALL_DEF_GROUP et STRUCTURE
19 08-04-98 : FGU ; Ajout Emission
20 30-11-98 : FMN ; S4069 : Textes toujours visibles
21 02.14.100 : JR : Warnings on WNT #include ,stdio.h>
22 22-03-04 : SAN ; OCC4895 High-level interface for controlling polygon offsets
24 ************************************************************************/
26 #define OCC1174 /* SAV 08/01/03 : Added back face interior color management*/
29 /*----------------------------------------------------------------------*/
36 #include <OpenGl_tgl_all.hxx>
38 #include <InterfaceGraphic_Labels.hxx>
39 #include <InterfaceGraphic_Graphic3d.hxx>
41 #include <OpenGl_tgl.hxx>
42 #include <OpenGl_tgl_funcs.hxx>
43 #include <OpenGl_tgl_subrs.hxx>
45 #include <OSD_FontAspect.hxx>
49 call_togl_contextstructure
51 CALL_DEF_STRUCTURE * astructure
54 Tfloat liner, lineg, lineb;
55 Tfloat fillr, fillg, fillb;
57 Tfloat fillBackr, fillBackg, fillBackb;
63 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
65 Tfloat polyOffsetFactor, polyOffsetUnits;
66 /* OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets */
68 Tfloat markr, markg, markb;
73 Tfloat textr, textg, textb;
74 Tfloat textrs, textgs, textbs;
77 int textstyle, textdisplaytype;
80 OSD_FontAspect textfontaspect;
81 /* Flag de mise a jour des composants materiel */
83 CALL_DEF_TRANSFORM_PERSISTENCE transPers = astructure->TransformPersistence;
86 if( astructure->ContextLine.IsDef == -1 )
89 if( astructure->ContextFillArea.IsDef == -1 )
92 if( astructure->ContextMarker.IsDef == -1 )
95 if( astructure->ContextText.IsDef == -1 )
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 )
103 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
104 call_func_offset_elem_ptr( 1 );
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();
112 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
113 if( astructure->ContextLine.IsDef == 1 )
115 liner = astructure->ContextLine.Color.r;
116 lineg = astructure->ContextLine.Color.g;
117 lineb = astructure->ContextLine.Color.b;
119 switch( astructure->ContextLine.LineType )
121 case 0 : /* Aspect_TOL_SOLID */
122 linetype = CALL_PHIGS_LINE_SOLID;
124 case 1 : /* Aspect_TOL_DASH */
125 linetype = CALL_PHIGS_LINE_DASH;
127 case 2 : /* Aspect_TOL_DOT */
128 linetype = CALL_PHIGS_LINE_DOT;
130 case 3 : /* Aspect_TOL_DOTDASH */
131 linetype = CALL_PHIGS_LINE_DASH_DOT;
137 linewidth = (Tfloat)astructure->ContextLine.Width;
139 if( astructure->ContextLine.IsSet )
140 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
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 );
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();
159 if( astructure->ContextFillArea.IsDef == 1 )
161 switch( astructure->ContextFillArea.Style )
163 case 0 : /* Aspect_IS_EMPTY */
164 intstyle = CALL_PHIGS_STYLE_EMPTY;
166 case 1 : /* Aspect_IS_HOLLOW */
167 intstyle = CALL_PHIGS_STYLE_HOLLOW;
169 case 2 : /* Aspect_IS_HATCH */
170 intstyle = CALL_PHIGS_STYLE_HATCH;
172 case 3 : /* Aspect_IS_SOLID */
173 intstyle = CALL_PHIGS_STYLE_SOLID;
175 case 4 : /* Aspect_IS_HIDDENLINE */
176 intstyle = CALL_PHIGS_STYLE_HIDDENLINE;
182 switch( astructure->ContextFillArea.Hatch )
184 case 0 : /* Aspect_HS_HORIZONTAL */
185 hatch = CALL_PHIGS_HATCH_HORIZ;
187 case 1 : /* Aspect_HS_HORIZONTAL_WIDE */
188 hatch = CALL_PHIGS_HATCH_HORIZ_DBL;
190 case 2 : /* Aspect_HS_VERTICAL */
191 hatch = CALL_PHIGS_HATCH_VERT;
193 case 3 : /* Aspect_HS_VERTICAL_WIDE */
194 hatch = CALL_PHIGS_HATCH_VERT_DBL;
196 case 4 : /* Aspect_HS_DIAGONAL_45 */
197 hatch = CALL_PHIGS_HATCH_DIAG_45;
199 case 5 : /* Aspect_HS_DIAGONAL_45_WIDE */
200 hatch = CALL_PHIGS_HATCH_DIAG_45_DBL;
202 case 6 : /* Aspect_HS_DIAGONAL_135 */
203 hatch = CALL_PHIGS_HATCH_DIAG_135;
205 case 7 : /* Aspect_HS_DIAGONAL_135_WIDE */
206 hatch = CALL_PHIGS_HATCH_DIAG_135_DBL;
208 case 8 : /* Aspect_HS_GRID */
209 hatch = CALL_PHIGS_HATCH_GRID_R;
211 case 9 : /* Aspect_HS_GRID_WIDE */
212 hatch = CALL_PHIGS_HATCH_GRID_R_DBL;
214 case 10 : /* Aspect_HS_GRID_DIAGONAL */
215 hatch = CALL_PHIGS_HATCH_GRID_D;
217 case 11 : /* Aspect_HS_GRID_DIAGONAL_WIDE */
218 hatch = CALL_PHIGS_HATCH_GRID_D_DBL;
224 fillr = astructure->ContextFillArea.IntColor.r;
225 fillg = astructure->ContextFillArea.IntColor.g;
226 fillb = astructure->ContextFillArea.IntColor.b;
229 fillBackr = astructure->ContextFillArea.BackIntColor.r;
230 fillBackg = astructure->ContextFillArea.BackIntColor.g;
231 fillBackb = astructure->ContextFillArea.BackIntColor.b;
234 liner = astructure->ContextFillArea.EdgeColor.r;
235 lineg = astructure->ContextFillArea.EdgeColor.g;
236 lineb = astructure->ContextFillArea.EdgeColor.b;
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 */
244 switch( astructure->ContextFillArea.LineType )
246 case 0 : /* Aspect_TOL_SOLID */
247 linetype = CALL_PHIGS_LINE_SOLID;
249 case 1 : /* Aspect_TOL_DASH */
250 linetype = CALL_PHIGS_LINE_DASH;
252 case 2 : /* Aspect_TOL_DOT */
253 linetype = CALL_PHIGS_LINE_DOT;
255 case 3 : /* Aspect_TOL_DOTDASH */
256 linetype = CALL_PHIGS_LINE_DASH_DOT;
262 linewidth = (Tfloat)astructure->ContextFillArea.Width;
264 if( astructure->ContextFillArea.IsSet )
265 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
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 );
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 );
282 call_subr_set_back_int_colr( fillBackr, fillBackg, fillBackb, ( float )1.0 );
284 call_subr_set_back_int_colr( fillr, fillg, fillb, ( float )1.0 );
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 );
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 );
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 );
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);
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);
321 call_func_set_face_cull_mode( CALL_PHIGS_CULL_NONE );
323 if( astructure->ContextFillArea.IsSet )
324 call_func_offset_elem_ptr( 1 );
327 /* Gestion Lumiere */
328 if( astructure->ContextFillArea.Front.IsAmbient )
329 lightbool = lightbool | AMBIENT_MASK;
331 if( astructure->ContextFillArea.Front.IsDiffuse )
332 lightbool = lightbool | DIFFUSE_MASK;
334 if( astructure->ContextFillArea.Front.IsSpecular )
335 lightbool = lightbool | SPECULAR_MASK;
337 if( astructure->ContextFillArea.Front.IsEmission )
338 lightbool = lightbool | EMISSIVE_MASK;
341 call_func_set_refl_eqn( CALL_PHIGS_REFL_NONE );
343 call_func_set_refl_eqn( lightbool );
345 if( astructure->ContextFillArea.IsSet )
346 call_func_offset_elem_ptr( 1 );
347 call_subr_set_refl_props( &astructure->ContextFillArea.Front, 0 );
350 /* Gestion lumiere */
351 if( astructure->ContextFillArea.IsSet )
352 call_func_offset_elem_ptr( 1 );
354 if( astructure->ContextFillArea.Back.IsAmbient )
355 lightbool = lightbool | AMBIENT_MASK;
357 if( astructure->ContextFillArea.Back.IsDiffuse )
358 lightbool = lightbool | DIFFUSE_MASK;
360 if( astructure->ContextFillArea.Back.IsSpecular )
361 lightbool = lightbool | SPECULAR_MASK;
363 if( astructure->ContextFillArea.Back.IsEmission )
364 lightbool = lightbool | EMISSIVE_MASK;
367 call_func_set_back_refl_eqn( CALL_PHIGS_REFL_NONE );
369 call_func_set_back_refl_eqn( lightbool );
371 if( astructure->ContextFillArea.IsSet )
372 call_func_offset_elem_ptr( 1 );
373 call_subr_set_refl_props( &astructure->ContextFillArea.Back, 1 );
375 if( astructure->ContextFillArea.IsSet )
376 call_func_offset_elem_ptr( 1 );
377 call_func_set_do_texturemap(astructure->ContextFillArea.Texture.doTextureMap);
379 if( astructure->ContextFillArea.IsSet )
380 call_func_offset_elem_ptr( 1 );
381 call_func_set_texture_id(astructure->ContextFillArea.Texture.TexId);
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();
391 if( astructure->ContextMarker.IsDef == 1 )
393 markr = astructure->ContextMarker.Color.r;
394 markg = astructure->ContextMarker.Color.g;
395 markb = astructure->ContextMarker.Color.b;
397 switch( astructure->ContextMarker.MarkerType )
399 case 0 : /* Aspect_TOM_POINT */
400 markertype = CALL_PHIGS_MARKER_DOT;
402 case 1 : /* Aspect_TOM_PLUS */
403 markertype = CALL_PHIGS_MARKER_PLUS;
405 case 2 : /* Aspect_TOM_STAR */
406 markertype = CALL_PHIGS_MARKER_ASTERISK;
408 case 3 : /* Aspect_TOM_O */
409 markertype = CALL_PHIGS_MARKER_CIRCLE;
411 case 4 : /* Aspect_TOM_X */
412 markertype = CALL_PHIGS_MARKER_CROSS;
414 case 5 : /* Aspect_TOM_USERDEFINED*/
415 markertype = CALL_PHIGS_MARKER_USER_DEFINED;
418 printf( "\n\tINVALID MARKER TYPE %d",
419 astructure->ContextMarker.MarkerType );
423 markerscale = (Tfloat)astructure->ContextMarker.Scale;
425 if( astructure->ContextMarker.IsSet )
426 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
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();
445 cout << "TKOpenGl::OpenGl_togl_contextstructure"
446 << "\t is defined : " << astructure->ContextText.IsDef << endl;
448 if( astructure->ContextText.IsDef == 1 )
450 textr = astructure->ContextText.Color.r;
451 textg = astructure->ContextText.Color.g;
452 textb = astructure->ContextText.Color.b;
454 textrs = astructure->ContextText.ColorSubTitle.r;
455 textgs = astructure->ContextText.ColorSubTitle.g;
456 textbs = astructure->ContextText.ColorSubTitle.b;
458 fontid = new Tchar[strlen((char*)astructure->ContextText.Font)+1];
459 strcpy((char*)fontid,(char*)astructure->ContextText.Font);
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;
469 if( astructure->ContextText.IsSet )
470 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
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 );
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 );
504 call_func_close_struct();