OCC22377 Patch for visualization component
[occt.git] / src / OpenGl / OpenGl_subrvis.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5File OpenGl_subrvis :
6
7TEST :
8------
9
10Le main TestOfDesktop.c permet de tester cette classe.
11
12
13REMARQUES:
14----------
15
16
17HISTORIQUE DES MODIFICATIONS :
18--------------------------------
19xx-xx-xx : xxx ; Creation.
2007-02-96 : FMN ; Suppression code inutile:
21- TxglLink() et TxglUnlink()
2219-03-96 : CAL ; Ajout de la fonction subr_resize.
23appele par togl_ratio_window
2421-03-96 : CAL ; Dans subr_doublebuffer et subr_open_ws
25retrait des lignes qui donnaient un background
26noir a la fenetre.
2701-04-96 : CAL ; Integration MINSK portage WNT
2802-07-96 : FMN ; Suppression WSWSHeight, WSWSWidth et WSType
2917-07-96 : FMN ; Modification de call_subr_hlhsr().
3018-07-96 : FMN ; Ajout appel TxglWinset() pour le Resize.
3101-08-96 : FMN ; Ajout appel reaffichage dans le resize.
3225-11-96 : FMN ; PRO6577: Ajout WSUpdateState pour call_subr_set_background.
3329-01-97 : FMN ; Suppression de call_subr_doublebuffer().
3405-02-97 : FMN ; Suppression variables inutiles.
3512-02-97 : FMN ; Suppression de call_facilities_list.DepthCueing
3614-02-97 : FMN ; Ajout WSUpdateState pour call_subr_transparency.
3730-06-97 : FMN ; Appel de la toolkit OpenGl_LightBox.
3802-07-97 : FMN ; Ajout init generale par contexte.
39(GL_POLYGON_OFFSET_EXT, glLightModelf, glHint).
4003-07-97 : FMN ; Test Headlight.
4108-09-97 : CAL ; subr_open_ws retourne 0 si pb. (gere par togl_view)
4207-10-97 : FMN ; Simplification WNT
4303-10-97 : FMN ; Meilleure gestion des EXT, ajout QueryExtension
4417-11-97 : FMN ; Suppression redraw sur le resize.
4505-12-97 : FMN ; Double gestion du glPolygonOffsetEXT
4617-12-97 : FMN ; Probleme compilation SGI
4703-03-98 : FMN ; Simplification gestion du glPolygonOffsetEXT
4815-03-98 : FMN ; Suppression variable WSNeedsClear
4917-03-98 : FMN ; Ajout mode animation
5008-07-98 : FMN ; Changement du nom de la primitive call_togl_erase_immediat_mode()
51-> call_togl_erase_animation_mode.
5222-10-98 : FMN ; Amelioration des perfs: glHint utilise GL_FASTEST.
5314-12-98 : BGN; Developpement (S3989, Phase "triedre")
5429-03-01 : GG; glPolygonOffsetEXT is no more available
55since OGL 1.2
5620-08-01 : GG ; Add functions call_subr_enable_polygon_offset ()
57and call_subr_disable_polygon_offset ()
58
59************************************************************************/
60
61#ifdef WNT
62#define BUC60579 /*GG_240999 Under WNT,resets the ws attributes for each
63// created view-manager and not only for the first
64*/
65#endif
66
67#define IMP190100 /*GG Reverse the front & back depth cueing planes
68// position.
69*/
70
71#define RIC120302 /*GG Use TxglSetWindow instead TxglCreateWindow
72// when a GLXContext is given
73// Add call_subr_displayCB function
74*/
75
76#define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing
77from higher API */
78#define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting
79from higher API */
80
81#define OCC1188 /*SAV added control of the background image*/
82
83/*----------------------------------------------------------------------*/
84/*
85* Includes
86*/
87
88#include <stdio.h>
89
90#include <OpenGl_tgl_all.hxx>
91
92
93#include <InterfaceGraphic.hxx>
94#include <InterfaceGraphic_Labels.hxx>
95#include <InterfaceGraphic_Graphic3d.hxx>
96#include <InterfaceGraphic_Visual3d.hxx>
97
98#include <OpenGl_inquire.hxx>
99
100#include <OpenGl_Extension.hxx>
101
102#include <OpenGl_cmn_varargs.hxx>
103#include <OpenGl_tsm.hxx>
104#include <OpenGl_tsm_ws.hxx>
105#include <OpenGl_telem_view.hxx>
106#include <OpenGl_telem_util.hxx>
107#include <OpenGl_telem_pick.hxx>
108#include <OpenGl_LightBox.hxx>
109#include <OpenGl_telem_highlight.hxx>
110#include <OpenGl_telem_depthcue.hxx>
111#include <OpenGl_txgl.hxx>
112#include <OpenGl_tgl_subrvis.hxx>
113#include <OpenGl_tgl_pick.hxx>
114#include <OpenGl_tgl_funcs.hxx>
115#include <OpenGl_telem_filters.hxx>
116#include <OpenGl_tgl_tox.hxx>
117#include <OpenGl_tgl.hxx>
118#include <OpenGl_animation.hxx>
119#include <OpenGl_triedron.hxx>
120#include <OpenGl_tgl_util.hxx>
121#include <OpenGl_Memory.hxx>
122#include <OpenGl_graduatedtrihedron.hxx>
47d31ec6
A
123#include <OpenGl_ResourceCleaner.hxx>
124#include <OpenGl_ResourceTexture.hxx>
7fd59977 125
126/*----------------------------------------------------------------------*/
127/*
128* Constantes
129*/
130
131static Tint attri_init = 0;
132
133/*----------------------------------------------------------------------*/
134
135#ifndef WNT
136static Bool WaitForNotify(Display *d, XEvent *e, char *arg) {
137 return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
138}
139#endif
140
141/*----------------------------------------------------------------------*/
142
143static int offsetStatus=0;
144#ifdef GL_EXT_polygon_offset
145static GLfloat offsetFactor=1.0,offsetUnits=0.0;
146#elif GL_POLYGON_OFFSET_EXT
147static GLfloat offsetFactor=0.5,offsetUnits=0.0005;
148#endif
149void call_subr_enable_polygon_offset( )
150{
151 if( offsetStatus < 0 ) return;
152
153#ifdef GL_EXT_polygon_offset
154 if( offsetStatus == 0 ) {
155 if (QueryExtension("GL_EXT_polygon_offset")) {
156 char svalue[64];
157 if( call_util_osd_getenv ("CALL_OPENGL_POLYGON_OFFSET",
158 svalue,sizeof(svalue)) ) {
159 float v1,v2;
160 int n = sscanf(svalue,"%f %f",&v1,&v2);
161 if( n > 0 ) offsetFactor = v1;
162 if( n > 1 ) offsetUnits = v2;
163 printf(" $$$ CALL_OPENGL_POLYGON_OFFSET %f %f\n",
164 offsetFactor,offsetUnits);
165 }
166 offsetStatus = 1;
167 } else {
168 offsetStatus = -1;
169 }
170 }
171
172 if( offsetStatus > 0 ) {
173#ifdef GL_POLYGON_OFFSET_FILL
174 glPolygonOffset(offsetFactor,offsetUnits);
175 glEnable(GL_POLYGON_OFFSET_FILL);
176#elif GL_POLYGON_OFFSET_EXT
177 glPolygonOffsetEXT(offsetFactor,offsetUnits);
178 glEnable(GL_POLYGON_OFFSET_EXT);
179#endif
180 }
181#else
182 offsetStatus = -1;
183#endif /* GL_EXT_polygon_offset */
184}
185
186void
187call_subr_disable_polygon_offset( )
188{
189 if( offsetStatus > 0 ) {
190#ifdef GL_POLYGON_OFFSET_FILL
191 glDisable(GL_POLYGON_OFFSET_FILL);
192#elif GL_POLYGON_OFFSET_EXT
193 glDisable(GL_POLYGON_OFFSET_EXT);
194#endif
195 }
196}
197
198/*----------------------------------------------------------------------*/
199
200int
201call_subr_open_ws( CALL_DEF_VIEW * aview )
202{
203 CMN_KEY_DATA data;
204 WINDOW win;
205 TEL_HIGHLIGHT hrep = { TelHLForcedColour, {{ ( float )1.0, ( float )1.0, ( float )1.0 }} };
206 TEL_DEPTHCUE dcrep = { TelDCSuppressed, {( float )0.0, ( float )1.0}, {( float )1.0, ( float )0.0}, {{( float )0.0, ( float )0.0, ( float )0.0}} };
207 Tint width, height;
208 Tfloat bgcolr, bgcolg, bgcolb; /* background color */
209#ifdef OCC1188
210 TSM_BG_TEXTURE bgTexture;
211#endif
212
213#ifndef WNT
214 XEvent event;
215 Window root;
216 int newx, newy;
217 unsigned int newwidth, newheight, newbw, newdepth;
218#else
219 RECT cr;
220#endif /* WNT */
221
222 width = ( Tint )aview->DefWindow.dx;
223 height = ( Tint )aview->DefWindow.dy;
224
225 /* background color */
226 bgcolr = aview->DefWindow.Background.r,
227 bgcolg = aview->DefWindow.Background.g,
228 bgcolb = aview->DefWindow.Background.b;
229
230#ifdef RIC120302
231 if( aview->GContext )
232 win = TxglSetWindow( call_thedisplay, /*(HWND)*/(WINDOW)aview->DefWindow.XWindow,
233 /*(HGLRC)*/(GLCONTEXT)aview->GContext );
234 else
235#endif /*RIC120302*/
236 win = TxglCreateWindow( call_thedisplay, /*(HWND)*/(WINDOW)aview->DefWindow.XWindow,
237 0, 0, width, height, 0, bgcolr, bgcolg, bgcolb );
238#ifndef WNT
239 if( win != aview->DefWindow.XWindow ) {
240 XMapWindow( call_thedisplay, win );
241 XIfEvent(call_thedisplay, &event, WaitForNotify, (char *) win);
242 }
243#endif /* WNT */
244
245 if( TxglWinset( call_thedisplay, (WINDOW) win ) == TFailure )
246 return 0;
247 else {
248 TsmRegisterWsid( aview->WsId );
249 data.ldata = (Tint) win;
250 TsmSetWSAttri( aview->WsId, WSWindow, &data );
251#ifndef WNT
252 XGetGeometry (
253 call_thedisplay, win, &root,
254 &newx, &newy,&newwidth, &newheight, &newbw, &newdepth
255 );
256 width = newwidth;
257 height = newheight;
258#else
259 GetClientRect ( win, &cr );
260 width = cr.right;
261 height = cr.bottom;
262#endif /* WNT */
263#ifdef OCC1188
264 bgTexture.texId = 0;
265 data.pdata = &bgTexture;
266 TsmSetWSAttri( aview->WsId, WSBgTexture, &data );
267#endif
268 data.ldata = width;
269 TsmSetWSAttri( aview->WsId, WSWidth, &data );
270 data.ldata = height;
271 TsmSetWSAttri( aview->WsId, WSHeight, &data );
272 data.ldata = -1;
273 TsmSetWSAttri( aview->WsId, WSViewStid, &data );
274 data.ldata = TOn;
275 TsmSetWSAttri( aview->WsId, WSDbuff, &data );
276 data.ldata = TNotDone;
277 TsmSetWSAttri( aview->WsId, WSUpdateState, &data );
278 data.ldata = TOff;
279 TsmSetWSAttri( aview->WsId, WSTransparency, &data );
280 TelSetHighlightRep( aview->WsId, 0, &hrep );
281 TelSetDepthCueRep( aview->WsId, 0, &dcrep );
282 TelInitWS( aview->WsId, width, height, bgcolr, bgcolg, bgcolb );
283
284#ifdef BUC61044
285 /* 24/10/01 : SAV ; setting OGL depth testing enabled by default */
286 data.ldata = TOn;
287 TsmSetWSAttri( aview->WsId, WSDepthTest, &data );
288#endif
289#ifdef BUC61045
290 /* 24/10/01 : SAV ; setting flag to control GL_LIGHTING (used in triedron) */
291 data.ldata = TOn;
292 TsmSetWSAttri( aview->WsId, WSGLLight, &data );
293#endif
294
295#ifdef BUC60579
296 TsmInitAttributes();
297#else
298 if( !attri_init ) {
299 TsmInitAttributes();
300 attri_init = 1;
301 }
302#endif
303
304 /*
305 * Init generale du contexte
306 */
307
308 /* Eviter d'avoir les faces mal orientees en noir. */
309 /* Pourrait etre utiliser pour detecter les problemes d'orientation */
310 glLightModeli((GLenum)GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
311
312 /* Optimisation pour le Fog et l'antialiasing */
313 glHint( GL_FOG_HINT, GL_FASTEST );
314 glHint( GL_POINT_SMOOTH_HINT, GL_FASTEST );
315 glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST );
316 glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST );
317
318 /* Polygon Offset */
319 call_subr_enable_polygon_offset();
320
321 return 1;
322
323 } /* TxglWinset */
324}
325
326/*----------------------------------------------------------------------*/
327
328void
329call_subr_resize (CALL_DEF_VIEW * aview)
330{
331 CMN_KEY_DATA data;
332 WINDOW win;
333 Tint width, height;
334 Tfloat bgcolr, bgcolg, bgcolb;
335 Tint wswidth, wsheight;
336 Tint wsviewstid;
337 /* Tint swap = 1;*/ /* swap buffers ? yes */
338
339#ifndef WNT
340 /* XEvent event;*/
341 Window root;
342 int newx, newy;
343 unsigned int newwidth, newheight, newbw, newdepth;
344#else
345 RECT cr;
346#endif /* WNT */
347
348#ifdef TRACE
349 printf("call_subr_resize \n");
350#endif
351 /* Recuperation de la definition precedente de la ws */
352 TsmGetWSAttri (aview->WsId, WSWidth, &data);
353 wswidth = data.ldata;
354 TsmGetWSAttri (aview->WsId, WSHeight, &data);
355 wsheight = data.ldata;
356 TsmGetWSAttri (aview->WsId, WSViewStid, &data);
357 wsviewstid = data.ldata;
358
359 /* S'il s'agit du togl_ratio_window initial alors on ne fait rien */
360 if (wsviewstid == -1) return;
361
362 /*
363 * Si l'on resize une fenetre qui a la meme taille que la taille
364 * precedente alors on ne fait rien
365 */
366 if ((wswidth == (Tint) aview->DefWindow.dx) &&
367 (wsheight == (Tint) aview->DefWindow.dy)) return;
368
369#ifndef WNT
370 TsmGetWSAttri (aview->WsId, WSWindow, &data);
371 win = data.ldata;
372
373 XResizeWindow (call_thedisplay, win,
374 (unsigned int) aview->DefWindow.dx,
375 (unsigned int) aview->DefWindow.dy);
376
377 XSync (call_thedisplay, False);
378
379 /* Mettre a jour ses attributs */
380 XGetGeometry (call_thedisplay, win, &root,
381 &newx, &newy,&newwidth, &newheight, &newbw, &newdepth);
382 width = newwidth;
383 height = newheight;
384
385 /* background color */
386 bgcolr = aview->DefWindow.Background.r,
387 bgcolg = aview->DefWindow.Background.g,
388 bgcolb = aview->DefWindow.Background.b;
389
390 /* Rendre courant le Drawable et le Context */
391 if (TxglWinset (call_thedisplay, (Window) win) == TSuccess) {
392
393 data.ldata = width;
394 TsmSetWSAttri (aview->WsId, WSWidth, &data);
395 data.ldata = height;
396 TsmSetWSAttri (aview->WsId, WSHeight, &data);
397 TelInitWS (aview->WsId, width, height, bgcolr, bgcolg, bgcolb);
398 }
399
400#else
401
402 /* On detruit l'ancienne sous-fenetre de la window graphique */
403 TsmGetWSAttri (aview->WsId, WSWindow, &data);
404 win = (WINDOW) data.ldata;
405 /*
406 * On recree une nouvelle sous-fenetre de la window graphique
407 * avec la nouvelle dimension
408 */
409 /* background color */
410 bgcolr = aview->DefWindow.Background.r,
411 bgcolg = aview->DefWindow.Background.g,
412 bgcolb = aview->DefWindow.Background.b;
413 /* Rendre courant le Drawable et le Context */
414 if (TxglWinset (call_thedisplay, win) == TSuccess) {
415 //if (TxglWinset (call_thedisplay, GET_GL_CONTEXT()) == TSuccess) {
416 /* Mettre a jour la sous-fenetre associee */
417 /* Mettre a jour ses attributs */
418 GetClientRect ( win, &cr );
419 width = cr.right;
420 height = cr.bottom;
421 data.ldata = width;
422 TsmSetWSAttri (aview->WsId, WSWidth, &data);
423 data.ldata = height;
424 TsmSetWSAttri (aview->WsId, WSHeight, &data);
425 TelInitWS (aview->WsId, width, height, bgcolr, bgcolg, bgcolb);
426 }
427#endif /* WNT */
428
429 return;
430}
431
432/*----------------------------------------------------------------------*/
433
434void
435call_subr_antialiasing( CALL_DEF_VIEW * aview, Tint tag )
436{
437 CMN_KEY k;
438 Tint fl = tag ? TOn : TOff;
439
440 call_func_set_edit_mode( TEditReplace );
441 call_func_open_struct( aview->ViewId );
442 call_func_set_elem_ptr(0);
443 call_func_set_elem_ptr_label(View_LABAliasing);
444 call_func_offset_elem_ptr(1);
445 k.data.ldata = fl;
446 TsmAddToStructure( TelAntiAliasing, 1, &k );
447 call_func_close_struct();
448 return;
449}
450
451/*----------------------------------------------------------------------*/
452
453void
454call_subr_hlhsr( CALL_DEF_VIEW * aview, int tag )
455{
456 CMN_KEY_DATA data;
457
458 data.ldata = (tag ? TOn : TOff);
459 TsmSetWSAttri( aview->WsId, WSZbuffer, &data );
460 return;
461}
462
463
464/*----------------------------------------------------------------------*/
465
466void
467call_subr_depthcueing( CALL_DEF_VIEW * aview, Tint tag )
468{
469 TEL_DEPTHCUE rep;
470# define CALL_DEF_DEPTH_CUEING_INDEX 1
471
472 if( !tag )
473 {
474 call_func_set_edit_mode(CALL_PHIGS_EDIT_REPLACE);
475 call_func_open_struct(aview->ViewId);
476 call_func_set_elem_ptr(0);
477 call_func_set_elem_ptr_label(View_LABDepthCueing);
478 call_func_offset_elem_ptr(1);
479 call_func_appl_data(0);
480 call_func_close_struct();
481 }
482 else
483 {
484 rep.mode = CALL_PHIGS_ALLOWED;
485 rep.planes[0] = aview->Context.DepthBackPlane;
486 rep.planes[1] = aview->Context.DepthFrontPlane;
487#ifdef TRACE
488 printf(" $$$ DepthFrontPlane %f DepthBackPlane %f FrontPlaneDistance %f BackPlaneDistance %f\n",aview->Context.DepthFrontPlane,aview->Context.DepthBackPlane,aview->Mapping.FrontPlaneDistance,aview->Mapping.BackPlaneDistance);
489#endif
490 rep.planes[0] =
491#ifdef IMP190100
492 (aview->Context.DepthFrontPlane -
493 aview->Mapping.BackPlaneDistance) /
494#else
495 (aview->Mapping.FrontPlaneDistance -
496 aview->Context.DepthFrontPlane) /
497#endif
498 (aview->Mapping.FrontPlaneDistance -
499 aview->Mapping.BackPlaneDistance);
500
501 rep.planes[1] =
502#ifdef IMP190100
503 (aview->Context.DepthBackPlane -
504 aview->Mapping.BackPlaneDistance) /
505#else
506 (aview->Mapping.FrontPlaneDistance -
507 aview->Context.DepthBackPlane) /
508#endif
509 (aview->Mapping.FrontPlaneDistance -
510 aview->Mapping.BackPlaneDistance);
511
512 if(rep.planes[0] < 0.)
513 rep.planes[0] = ( float )0.0;
514 else if(rep.planes[0] > 1.)
515 rep.planes[0] = ( float )1.0;
516 if(rep.planes[1] < 0.)
517 rep.planes[1] = ( float )0.0;
518 else if(rep.planes[1] > 1.)
519 rep.planes[1] = ( float )1.0;
520#ifdef IMP190100
521 if(rep.planes[1] > rep.planes[0])
522 {
523 rep.planes[1] = ( float )0.0;
524 rep.planes[0] = ( float )1.0;
525 }
526#else
527 if(rep.planes[0] > rep.planes[1])
528 {
529 rep.planes[0] = ( float )0.0;
530 rep.planes[1] = ( float )1.0;
531 }
532#endif
533
534#ifdef TRACE
535 printf(" plane[0] %f plane[1] %f\n",rep.planes[0],rep.planes[1]);
536#endif
537 rep.scales[0] = ( float )1.;
538 rep.scales[1] = ( float )0.;
539 rep.col.rgb[0] = aview->DefWindow.Background.r;
540 rep.col.rgb[1] = aview->DefWindow.Background.g;
541 rep.col.rgb[2] = aview->DefWindow.Background.b;
542 TelSetDepthCueRep(aview->WsId, CALL_DEF_DEPTH_CUEING_INDEX, &rep);
543
544 call_func_set_edit_mode(CALL_PHIGS_EDIT_REPLACE);
545 call_func_open_struct(aview->ViewId);
546 call_func_set_elem_ptr(0);
547 call_func_set_elem_ptr_label(View_LABDepthCueing);
548 call_func_offset_elem_ptr(1);
549 call_func_dcue_ind(CALL_DEF_DEPTH_CUEING_INDEX);
550 call_func_close_struct();
551 }
552 return;
553}
554
555/*----------------------------------------------------------------------*/
556
557TStatus
558call_subr_get_view_index( Tint stid, Tint *ind )
559{
560 tsm_node node;
561 Tint i, num;
562
563 if( TsmGetStructure( stid, &num, &node ) == TSuccess )
564 {
565 for( i = 0; i < num; i++ )
566 {
567 if( node->elem.el == TelViewIndex )
568 {
569 *ind = node->elem.data.ldata;
570 return TSuccess;
571 }
572 }
573 }
574 return TFailure;
575}
576
577/*----------------------------------------------------------------------*/
578
579void
580call_subr_pick( CALL_DEF_PICK *apick )
581{
582 Tint depth;
583 TPickOrder order;
584 TStatus stat;
585
586 static int *listid, *listelem, *listpickid;
587
588 TEL_PICK_PATH path_list[CALL_MAX_DEPTH_LENGTH];
589 TEL_PICK_REPORT rep;
590
591 Tint i;
592
593 if( listid )
594 {
595 //cmn_freemem( listid );
596 delete[] listid;
597 //cmn_freemem( listelem );
598 delete[] listelem;
599 //cmn_freemem( listpickid );
600 delete[] listpickid;
601 listid = listelem = listpickid = 0;
602 }
603
604 order = apick->Context.order == 0 ? PTOP_FIRST : PBOTTOM_FIRST;
605
606 depth = apick->Context.depth < CALL_MAX_DEPTH_LENGTH ?
607 apick->Context.depth : CALL_MAX_DEPTH_LENGTH ;
608
609 rep.pick_path = path_list;
610
611 stat = TPick( apick->WsId, apick->x, apick->y, apick->Context.aperture,
612 apick->Context.aperture, order, depth, &rep );
613
614 if( stat == TSuccess )
615 {
616 apick->Pick.depth = rep.depth;
617
618#ifdef TRACE
619 printf( "\n\n\tPICK REPORT FOLLOWS" );
620 printf( "\n\t*******************\n" );
621 printf( "\ndepth = %d\torder = %s\n", rep.depth,
622 order == PTOP_FIRST ? "TopFirst" : "BottomFirst" );
623#endif
624
625 //cmn_memreserve( listid, rep.depth, 0 );
626 listid = new int[rep.depth];
627 //cmn_memreserve( listelem, rep.depth, 0 );
628 listelem = new int[rep.depth];
629 //cmn_memreserve( listpickid, rep.depth, 0 );
630 listpickid = new int[rep.depth];
631 if( !listid || !listelem || !listpickid )
632 return;
633 apick->Pick.listid = listid;
634 apick->Pick.listelem = listelem;
635 apick->Pick.listpickid = listpickid;
636
637 for( i = 0; i < rep.depth; i++ )
638 {
639 listelem[i] = path_list[i].el_num;
640 listpickid[i] = path_list[i].pick_id;
641 listid[i] = path_list[i].struct_id;
642#ifdef TRACE
643 printf( "\n\tSTRUCTURE ID [%d] = %ld", i, listid[i] );
644 printf( "\n\tPICK ID [%d] = %ld", i, listpickid[i] );
645 printf( "\n\tELEMENT ID [%d] = %ld", i, listelem[i] );
646#endif
647 }
648#ifdef TRACE
649 printf("\n");
650#endif
651 }
652
653 return;
654}
655
656
657/*----------------------------------------------------------------------*/
658
659void
660call_subr_set_light_src_rep( CALL_DEF_LIGHT * alight )
661{
662 TEL_LIGHT rep;
663
664 switch( alight->LightType )
665 {
666 case 0 : /* TOLS_AMBIENT */
667 rep.type = CALL_PHIGS_LIGHT_AMBIENT;
668 rep.col.rgb[0] = alight->Color.r;
669 rep.col.rgb[1] = alight->Color.g;
670 rep.col.rgb[2] = alight->Color.b;
671 break;
672
673 case 1 : /* TOLS_DIRECTIONAL */
674 rep.type = CALL_PHIGS_LIGHT_DIRECTIONAL;
675 rep.col.rgb[0] = alight->Color.r;
676 rep.col.rgb[1] = alight->Color.g;
677 rep.col.rgb[2] = alight->Color.b;
678 rep.dir[0] = alight->Direction.x;
679 rep.dir[1] = alight->Direction.y;
680 rep.dir[2] = alight->Direction.z;
681 break;
682
683 case 2 : /* TOLS_POSITIONAL */
684 rep.type = CALL_PHIGS_LIGHT_POSITIONAL;
685 rep.col.rgb[0] = alight->Color.r;
686 rep.col.rgb[1] = alight->Color.g;
687 rep.col.rgb[2] = alight->Color.b;
688 rep.pos[0] = alight->Position.x;
689 rep.pos[1] = alight->Position.y;
690 rep.pos[2] = alight->Position.z;
691 rep.atten[0] = alight->Attenuation[0];
692 rep.atten[1] = alight->Attenuation[1];
693 break;
694
695 case 3 : /* TOLS_SPOT */
696 rep.type = CALL_PHIGS_LIGHT_SPOT;
697 rep.col.rgb[0] = alight->Color.r;
698 rep.col.rgb[1] = alight->Color.g;
699 rep.col.rgb[2] = alight->Color.b;
700 rep.pos[0] = alight->Position.x;
701 rep.pos[1] = alight->Position.y;
702 rep.pos[2] = alight->Position.z;
703 rep.dir[0] = alight->Direction.x;
704 rep.dir[1] = alight->Direction.y;
705 rep.dir[2] = alight->Direction.z;
706 rep.shine = alight->Concentration;
707 rep.atten[0] = alight->Attenuation[0];
708 rep.atten[1] = alight->Attenuation[1];
709 rep.angle = alight->Angle;
710 break;
711 }
712
713 rep.HeadLight = alight->Headlight;
714 AddLight( alight->WsId, alight->LightId, &rep );
715
716 return;
717}
718
719/*----------------------------------------------------------------------*/
720
721void
722call_subr_set_background( Tint ws, tel_colour rgb )
723{
724 CMN_KEY_DATA data;
725 CMN_KEY_DATA key;
726
727 /* Mise a jour de l'update_mode */
728 key.ldata = TNotDone;
729 TsmSetWSAttri( ws, WSUpdateState, &key );
730
731 data.pdata = rgb->rgb;
732 TsmSetWSAttri( ws, WSBackground, &data );
733 return;
734}
735
736/*----------------------------------------------------------------------*/
737
738void
739call_subr_set_gradient_background( Tint ws, Tint type, tel_colour color1, tel_colour color2 )
740{
741 CMN_KEY_DATA data;
742 CMN_KEY_DATA key;
743 TSM_BG_GRADIENT bgGradient;
744
745 /* Mise a jour de l'update_mode */
746 key.ldata = TNotDone;
747 TsmSetWSAttri( ws, WSUpdateState, &key );
748
749 bgGradient.type = (TSM_GradientType)type;
750 bgGradient.color1 = *color1;
751 bgGradient.color2 = *color2;
752 data.pdata = &bgGradient;
753 TsmSetWSAttri( ws, WSBgGradient, &data );
754 return;
755}
756
757
758/*----------------------------------------------------------------------*/
759
760void
761call_subr_close_ws( CALL_DEF_VIEW * aview )
762{
763 CMN_KEY_DATA key;
47d31ec6
A
764 CMN_KEY_DATA textureKey;
765
766 TsmGetWSAttri( aview->WsId, WSWindow, &key );
767
7fd59977 768#ifdef OCC1188
769 tsm_bg_texture texture;
47d31ec6 770 WINDOW aWnd = (WINDOW) key.ldata;
7fd59977 771
47d31ec6
A
772 TsmGetWSAttri( aview->WsId, WSBgTexture, &textureKey );
773 texture = (tsm_bg_texture)textureKey.pdata;
7fd59977 774
47d31ec6
A
775 if ( texture != 0 && texture->texId != 0 )
776 {
777 OpenGl_ResourceCleaner* anCleaner = OpenGl_ResourceCleaner::GetInstance();
778
779 // Delete the texture with ResourceCleaner; if it is not possible
780 // do this directly with proper context selected
781 if ( !anCleaner->AddResource( TxglGetContext(aWnd),
782 new OpenGl_ResourceTexture(texture->texId) ) )
783 {
784 GLCONTEXT cur_context = GET_GL_CONTEXT();
785 GLDRAWABLE cur_drawable = GET_GLDEV_CONTEXT();
786
787 if ( TxglWinset( call_thedisplay, aWnd ) == TSuccess )
788 glDeleteTextures( 1,(GLuint *)&(texture->texId) );
789
790 // activate the previous context for this thread
791 GL_MAKE_CURRENT( call_thedisplay, cur_drawable, cur_context );
792 }
793 }
794
7fd59977 795#endif
796
7fd59977 797#ifdef RIC120302
798 if( !aview->GContext )
799#endif
800 TxglDestroyWindow( call_thedisplay, (WINDOW) key.ldata );
801
802 TglDeleteFiltersForWS( aview->WsId );
803 RemoveWksLight( aview->WsId );
804 call_triedron_erase (aview); /* BGN 09-12-98 */
805 call_graduatedtrihedron_erase( aview->WsId );
806 TelDeleteViewsForWS( aview->WsId );
807 TelDeleteHighlightsForWS( aview->WsId );
808 TelDeleteDepthCuesForWS( aview->WsId );
809
810 TsmUnregisterWsid( aview->WsId );
811 return;
812}
813
814/*----------------------------------------------------------------------*/
815
816void
817call_subr_transparency (int wsid, int viewid, int tag)
818{
819 CMN_KEY_DATA data;
820 CMN_KEY_DATA key;
821
822 /* Est-il necessaire de faire de la transparence ? */
823 TsmGetWSAttri( wsid, WSTransparency, &data );
824 if (data.ldata != tag)
825 {
826 data.ldata = (tag ? TOn : TOff);
827 TsmSetWSAttri( wsid, WSTransparency, &data );
828
829 /* Mise a jour de l'update_mode */
830 key.ldata = TNotDone;
831 TsmSetWSAttri( wsid, WSUpdateState, &key );
832 (void) call_togl_erase_animation_mode();
833 }
834}
835
836#ifdef RIC120302
837/*----------------------------------------------------------------------*/
838int
839call_subr_displayCB( CALL_DEF_VIEW * aview, int reason )
840{
841 int status = 0;
842 if( aview->GDisplayCB ) {
843 Aspect_GraphicCallbackStruct callData;
844 CMN_KEY_DATA data;
845 WINDOW win;
846
847 TsmGetWSAttri (aview->WsId, WSWindow, &data);
848 win = (WINDOW) data.ldata;
849
850 callData.reason = reason;
851 callData.display = call_thedisplay;
852 callData.window = win;
853 callData.wsID = aview->WsId;
854 callData.viewID = aview->ViewId;
855 callData.gcontext = TxglGetContext(win);
856
857 status = (*aview->GDisplayCB)
858 ( aview->DefWindow.XWindow, aview->GClientData, &callData );
859 }
860
861 return status;
862}
863#endif