0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_remnames.cxx
CommitLineData
7fd59977 1
2#include <OpenGl_tgl_all.hxx>
3
4#include <stddef.h>
5#include <stdio.h>
6#include <GL/gl.h>
7#include <GL/glu.h>
8
9#include <OpenGl_cmn_varargs.hxx>
10#include <OpenGl_telem_attri.hxx>
11#include <OpenGl_telem_filters.hxx>
12#include <OpenGl_tsm.hxx>
13#include <OpenGl_telem.hxx>
14#include <OpenGl_telem_inquire.hxx>
15#include <OpenGl_Memory.hxx>
16
17static TStatus RemoveNamesetDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
18static TStatus RemoveNamesetAdd( TSM_ELEM_DATA, Tint, cmn_key* );
19static TStatus RemoveNamesetDelete( TSM_ELEM_DATA, Tint, cmn_key* );
20static TStatus RemoveNamesetPrint( TSM_ELEM_DATA, Tint, cmn_key* );
21static TStatus RemoveNamesetInquire( TSM_ELEM_DATA, Tint, cmn_key* );
22
23static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
24{
25 RemoveNamesetDisplay, /* PickTraverse */
26 RemoveNamesetDisplay,
27 RemoveNamesetAdd,
28 RemoveNamesetDelete,
29 RemoveNamesetPrint,
30 RemoveNamesetInquire
31};
32
33
34MtblPtr
35TelRemoveNamesetInitClass( TelType* el )
36{
37 *el = TelRemoveNameset;
38 return MtdTbl;
39}
40
41static TStatus
42RemoveNamesetAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
43{
44 Tint i, num, *ptr;
45 tel_tint_data data;
46
47 num = k[0]->id;
48 data = new TEL_TINT_DATA();
49 if( !data )
50 return TFailure;
51 data->data = new Tint[num];
52 if( !data->data )
53 return TFailure;
54
55 for( i=0, ptr=(Tint*)(k[0]->data.pdata); i<num; i++ )
56 {
57 data->data[i] = ptr[i];
58 }
59 data->num = num;
60
61 ((tsm_elem_data)(d.pdata))->pdata = data;
62
63 return TSuccess;
64}
65
66
67static TStatus
68RemoveNamesetDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
69{
70 tel_tint_data d = (tel_tint_data)data.pdata;
71 TglNamesetRemove( d->num, d->data );
72
73 return TSuccess;
74}
75
76static TStatus
77RemoveNamesetDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
78{
79 if (data.pdata)
80 delete data.pdata;
81 return TSuccess;
82}
83
84
85
86
87static TStatus
88RemoveNamesetPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
89{
90 Tint i;
91 tel_tint_data p;
92
93 p = (tel_tint_data)data.pdata;
94
95 fprintf( stdout, "TelRemoveNameset. Number: %d\n", p->num );
96 for( i = 0; i < p->num; i++ )
97 {
98 fprintf( stdout, "\n\t\t v[%d] = %d", i, p->data[i] );
99 }
100 fprintf( stdout, "\n" );
101
102 return TSuccess;
103}
104
105static TStatus
106RemoveNamesetInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
107{
108 Tint i;
109 tel_tint_data d;
110 Tint size_reqd=0;
111 TStatus status = TSuccess;
112
113 d = (tel_tint_data)data.pdata;
114
115 size_reqd = d->num * sizeof( Tint );
116
117 for( i = 0; i < n; i++ )
118 {
119 switch( k[i]->id )
120 {
121 case INQ_GET_SIZE_ID:
122 {
123 k[i]->data.ldata = size_reqd;
124 break;
125 }
126
127 case INQ_GET_CONTENT_ID:
128 {
129 TEL_INQ_CONTENT *c;
130 Teldata *w;
131
132 c = (tel_inq_content)k[i]->data.pdata;
133 c->act_size = size_reqd;
134 w = c->data;
135
136 w->name_set.number = d->num;
137 if( c->size >= size_reqd )
138 {
139 w->name_set.integers = (Tint *)(c->buf);
140 memcpy(w->name_set.integers, d->data, d->num*sizeof(Tint));
141 status = TSuccess;
142 }
143 else
144 status = TFailure;
145 break;
146 }
147 }
148 }
149 return status;
150}