0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_mrkrset.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5File OpenGl_mrkrset :
6
7
8REMARQUES:
9----------
10
11
12HISTORIQUE DES MODIFICATIONS :
13--------------------------------
14xx-xx-xx : xxx ; Creation.
1511-03-96 : FMN ; Correction warning compilation
1601-04-96 : CAL ; Integration MINSK portage WNT
1708-07-96 : BGN ; (PRO4768) suppression du cas particulier TEL_PM_DOT.
1821-10-96 : FMN ; Suppression LMC_COLOR fait dans OpenGl_execstruct.c
1919-10-96 : CAL ; Restauration du cas particulier TEL_PM_DOT mais
20avec la correction sur la mise a jour du pointSize.
21
22************************************************************************/
23
24/*----------------------------------------------------------------------*/
25/*
26* Includes
27*/
28
29
30#include <OpenGl_tgl_all.hxx>
31
32#include <stddef.h>
33#include <stdio.h>
34#include <string.h>
35
36#include <GL/gl.h>
37#include <GL/glu.h>
38
39#include <OpenGl_cmn_varargs.hxx>
40#include <OpenGl_telem_attri.hxx>
41#include <OpenGl_tsm.hxx>
42#include <OpenGl_telem.hxx>
43#include <OpenGl_telem_highlight.hxx>
44#include <OpenGl_telem_inquire.hxx>
45
46static TStatus MarkerSetDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
47static TStatus MarkerSetAdd( TSM_ELEM_DATA, Tint, cmn_key* );
48static TStatus MarkerSetDelete( TSM_ELEM_DATA, Tint, cmn_key* );
49static TStatus MarkerSetPrint( TSM_ELEM_DATA, Tint, cmn_key* );
50static TStatus MarkerSetInquire( TSM_ELEM_DATA, Tint, cmn_key* );
51
52
53extern GLuint GetListIndex(int);
54
55static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
56{
57 MarkerSetDisplay, /* PickTraverse */
58 MarkerSetDisplay,
59 MarkerSetAdd,
60 MarkerSetDelete,
61 MarkerSetPrint,
62 MarkerSetInquire
63};
64
65
66MtblPtr
67TelMarkerSetInitClass( TelType* el )
68{
69 *el = TelMarkerSet;
70 return MtdTbl;
71}
72
73extern GLuint markerBase;
74static TStatus
75MarkerSetAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
76{
77 Tint i, num;
78 tel_point_data data;
79 tel_point ptr;
80
81 num = k[0]->id;
82 data = new TEL_POINT_DATA();
83 if( !data )
84 return TFailure;
85
86 data->data = new TEL_POINT[num];
87 if( !data->data )
88 return TFailure;
89
90 for( i=0, ptr=(tel_point)(k[0]->data.pdata); i<num; i++ )
91 {
92 data->data[i] = ptr[i];
93 }
94 data->num = num;
95
96 ((tsm_elem_data)(d.pdata))->pdata = data;
97
98 return TSuccess;
99}
100
101
102static TStatus
103MarkerSetDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
104{
105 tel_point_data d;
106 tel_point ptr;
107 Tint i;
108 CMN_KEY key1, key2, key3;
109 TEL_COLOUR colour;
110 Tchar *str;
111
112 key1.id = TelPolymarkerColour;
113 key1.data.pdata = &colour;
114
115 key2.id = TelPolymarkerType;
116 key3.id = TelPolymarkerSize;
117 TsmGetAttri( 3, &key1, &key2, &key3 );
118
119 if( k[0]->id == TOn )
120 { /* Use highlight colours */
121 TEL_HIGHLIGHT hrep;
122
123 key1.id = TelHighlightIndex;
124 TsmGetAttri( 1, &key1 );
125 if( TelGetHighlightRep( TglActiveWs, key1.data.ldata, &hrep )
126 == TSuccess )
127 colour = hrep.col;
128 else
129 {
130 TelGetHighlightRep( TglActiveWs, 0, &hrep );
131 colour = hrep.col;
132 }
133 }
134
135 glColor3fv( colour.rgb );
136 d = (tel_point_data)data.pdata;
137 ptr = d->data;
138
139 if( key2.data.ldata == TEL_PM_DOT )
140 {
141 glPointSize( key3.data.fdata );
142 glBegin( GL_POINTS );
143 for( i=0; i<d->num; i++, ptr++ )
144 glVertex3f( ptr->xyz[0], ptr->xyz[1], ptr->xyz[2] );
145 glEnd();
146 }
147 else
148 {
149 GLint mode;
150 glGetIntegerv( GL_RENDER_MODE, &mode );
151
152 if( key2.data.ldata == TEL_PM_USERDEFINED )
153 {
154 for( i=0; i<d->num; i++, ptr++ )
155 {
156 glRasterPos3f( ptr->xyz[0], ptr->xyz[1], ptr->xyz[2] );
157 glCallList( GetListIndex( (int)key3.data.fdata ) );
158 if( mode==GL_FEEDBACK )
159 {
160 glBegin( GL_POINTS );
161 glVertex3f( ptr->xyz[0], ptr->xyz[1], ptr->xyz[2] );
162 glEnd();
163 /* it is necessary to indicate end of marker information */
164 }
165 }
166 }
167 else
168 {
169 str = TelGetStringForPM( key2.data.ldata, key3.data.fdata );
170 glListBase(markerBase);
171 for( i=0; i<d->num; i++, ptr++ )
172 {
173 glRasterPos3f( ptr->xyz[0], ptr->xyz[1], ptr->xyz[2] );
174 glCallLists(strlen( (char*)str ), GL_UNSIGNED_BYTE, (GLubyte *) str );
175
176 if( mode==GL_FEEDBACK )
177 {
178 glBegin( GL_POINTS );
179 glVertex3f( ptr->xyz[0], ptr->xyz[1], ptr->xyz[2] );
180 glEnd();
181 }
182 }
183 }
184 }
185
186 return TSuccess;
187}
188
189
190static TStatus
191MarkerSetDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
192{
193 if (data.pdata)
194 delete data.pdata;
195 return TSuccess;
196}
197
198
199
200
201static TStatus
202MarkerSetPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
203{
204 Tint i;
205 tel_point_data p;
206
207 p = (tel_point_data)data.pdata;
208
209 fprintf( stdout, "TelMarkerSet. Number of points: %d\n", p->num );
210 for( i = 0; i < p->num; i++ )
211 {
212 fprintf( stdout, "\n\t\t v[%d] = %g %g %g", i, p->data[i].xyz[0],
213 p->data[i].xyz[1], p->data[i].xyz[2] );
214 }
215 fprintf( stdout, "\n" );
216
217 return TSuccess;
218}
219
220
221static TStatus
222MarkerSetInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
223{
224 Tint i, j;
225 tel_point_data d;
226 Tint size_reqd=0;
227 TStatus status = TSuccess;
228
229 d = (tel_point_data)data.pdata;
230
231 size_reqd = d->num * sizeof( TEL_POINT );
232
233 for( i = 0; i < n; i++ )
234 {
235 switch( k[i]->id )
236 {
237 case INQ_GET_SIZE_ID:
238 {
239 k[i]->data.ldata = size_reqd;
240 break;
241 }
242
243 case INQ_GET_CONTENT_ID:
244 {
245 TEL_INQ_CONTENT *c;
246 Teldata *w;
247
248 c = (tel_inq_content)k[i]->data.pdata;
249 c->act_size = size_reqd;
250 w = c->data;
251
252 if( c->size >= size_reqd )
253 {
254 w->pts3 = (tel_point)(c->buf);
255
256 for( j = 0; j < d->num; j++ )
257 w->pts3[j] = d->data[j];
258
259 status = TSuccess;
260 }
261 else
262 status = TFailure;
263 break;
264 }
265 }
266 }
267 return status;
268}