0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_lightstate.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5File OpenGl_qstrip :
6
7
8REMARQUES:
9----------
10
11
12HISTORIQUE DES MODIFICATIONS :
13--------------------------------
14xx-xx-xx : xxx ; Creation.
1530-06-97 : FMN ; Appel de la toolkit OpenGl_LightBox.
16
17************************************************************************/
18
19/*----------------------------------------------------------------------*/
20/*
21* Includes
22*/
23
24
25#include <OpenGl_tgl_all.hxx>
26
27#include <stddef.h>
28#include <stdio.h>
29#include <GL/gl.h>
30#include <GL/glu.h>
31
32#include <OpenGl_cmn_varargs.hxx>
33#include <OpenGl_telem_attri.hxx>
34#include <OpenGl_tsm.hxx>
35#include <OpenGl_telem.hxx>
36#include <OpenGl_LightBox.hxx>
37#include <OpenGl_telem_inquire.hxx>
38
39static TStatus LightSrcStateDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
40static TStatus LightSrcStateAdd( TSM_ELEM_DATA, Tint, cmn_key* );
41static TStatus LightSrcStateDelete( TSM_ELEM_DATA, Tint, cmn_key* );
42static TStatus LightSrcStatePrint( TSM_ELEM_DATA, Tint, cmn_key* );
43static TStatus LightSrcStateInquire( TSM_ELEM_DATA, Tint, cmn_key* );
44
45static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
46{
47 0, /* PickTraverse */
48 LightSrcStateDisplay,
49 LightSrcStateAdd,
50 LightSrcStateDelete,
51 LightSrcStatePrint,
52 LightSrcStateInquire
53};
54
55#define NO_TRACE_LIGHT
56
57MtblPtr
58TelLightSrcStateInitClass( TelType* el )
59{
60 *el = TelLightSrcState;
61 return MtdTbl;
62}
63
64static TStatus
65LightSrcStateAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
66{
67 Tint i, num, *ptr;
68 tel_tint_data data;
69
70 num = k[0]->id;
71 data = new TEL_TINT_DATA();
72 if( !data )
73 return TFailure;
74 data->data = new int[num];
75 if( !data->data )
76 return TFailure;
77
78 for( i=0, ptr=(Tint*)(k[0]->data.pdata); i<num; i++ )
79 {
80 data->data[i] = ptr[i];
81 }
82 data->num = num;
83
84 ((tsm_elem_data)(d.pdata))->pdata = data;
85
86 return TSuccess;
87}
88
89
90static TStatus
91LightSrcStateDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
92{
93 tel_tint_data d = (tel_tint_data)data.pdata;
94
95#ifdef TRACE_LIGHT
96 printf("OpenGl_lightstate::LightSrcStateDisplay:UpdateLight(%d)\n", TglActiveWs);
97#endif
98 UpdateLight( TglActiveWs);
99 return TSuccess;
100}
101
102static TStatus
103LightSrcStateDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
104{
105 delete [] data.pdata;
106 return TSuccess;
107}
108
109
110
111
112static TStatus
113LightSrcStatePrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
114{
115 Tint i;
116 tel_tint_data p;
117
118 p = (tel_tint_data)data.pdata;
119
120 fprintf( stdout, "TelLightSrcState. Number: %d\n", p->num );
121 for( i = 0; i < p->num; i++ )
122 {
123 fprintf( stdout, "\n\t\t v[%d] = %d", i, p->data[i] );
124 }
125 fprintf( stdout, "\n" );
126
127 return TSuccess;
128}
129
130
131static TStatus
132LightSrcStateInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
133{
134 Tint i;
135 tel_tint_data d;
136 Tint size_reqd=0;
137 TStatus status = TSuccess;
138
139 d = (tel_tint_data)data.pdata;
140
141 size_reqd = d->num * sizeof( Tint );
142
143 for( i = 0; i < n; i++ )
144 {
145 switch( k[i]->id )
146 {
147 case INQ_GET_SIZE_ID:
148 {
149 k[i]->data.ldata = size_reqd;
150 break;
151 }
152
153 case INQ_GET_CONTENT_ID:
154 {
155 TEL_INQ_CONTENT *c;
156 Teldata *w;
157
158 c = (tel_inq_content)k[i]->data.pdata;
159 c->act_size = size_reqd;
160 w = c->data;
161
162 if( c->size >= size_reqd )
163 {
164 w->light_source_state.on.number = d->num;
165 w->light_source_state.off.number = 0;
166 w->light_source_state.on.integers = (Tint *)(c->buf);
167 w->light_source_state.off.integers = 0;
168
169 memcpy( w->light_source_state.on.integers, d->data, d->num*sizeof(Tint) );
170 }
171
172 break;
173 }
174 }
175 }
176 return status;
177}