0022962: Invalid realization of reading and writing material in STEP.
[occt.git] / src / OpenGl / OpenGl_intcol.cxx
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_tsm.hxx>
12 #include <OpenGl_telem.hxx>
13 #include <OpenGl_telem_inquire.hxx>
14
15 static  TStatus  InteriorColourDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
16 static  TStatus  InteriorColourAdd( TSM_ELEM_DATA, Tint, cmn_key* );
17 static  TStatus  InteriorColourDelete( TSM_ELEM_DATA, Tint, cmn_key* );
18 static  TStatus  InteriorColourPrint( TSM_ELEM_DATA, Tint, cmn_key* );
19 static  TStatus  InteriorColourInquire( TSM_ELEM_DATA, Tint, cmn_key* );
20
21 static  TStatus  (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
22 {
23   0,             /* PickTraverse */
24   InteriorColourDisplay,
25   InteriorColourAdd,
26   InteriorColourDelete,
27   InteriorColourPrint,
28   InteriorColourInquire
29 };
30
31
32 MtblPtr
33 TelInteriorColourInitClass( TelType *el )
34 {
35   *el = TelInteriorColour;
36   return MtdTbl;
37 }
38
39 static  TStatus
40 InteriorColourAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
41 {
42   tel_colour data = new TEL_COLOUR();
43
44   //cmn_memreserve( data, 1, 0 );
45   if( !data )
46     return TFailure;
47
48   *data = *(tel_colour)(k[0]->data.pdata);
49
50   ((tsm_elem_data)(d.pdata))->pdata = data;
51
52   return TSuccess;
53 }
54
55
56 static  TStatus
57 InteriorColourDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
58 {
59   tel_colour      d;
60   CMN_KEY         key;
61
62   d = (tel_colour)data.pdata;
63
64   key.id = TelInteriorColour;
65   key.data.pdata = d;
66   TsmSetAttri( 1, &key );
67
68   return TSuccess;
69 }
70
71
72 static  TStatus
73 InteriorColourDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
74 {
75   //cmn_freemem( data.pdata );
76   if (data.pdata)
77     delete data.pdata;
78   return TSuccess;
79 }
80
81
82
83
84 static  TStatus
85 InteriorColourPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
86 {
87   tel_colour p;
88
89   p = (tel_colour)data.pdata;
90
91   fprintf( stdout, "TelInteriorColour. R = %g, G = %g, B = %g\n",
92     p->rgb[0], p->rgb[1], p->rgb[2] );
93   fprintf( stdout, "\n" );
94
95   return TSuccess;
96 }
97
98
99 static TStatus
100 InteriorColourInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
101 {
102   Tint i;
103   tel_colour col;
104
105   col = (tel_colour)data.pdata;
106
107   for( i = 0; i < n; i++ )
108   {
109     switch( k[i]->id )
110     {
111     case INQ_GET_SIZE_ID:
112       {
113         k[i]->data.ldata = sizeof( Tint );
114         break;
115       }
116     case INQ_GET_CONTENT_ID:
117       {
118         TEL_INQ_CONTENT *c;
119         Teldata         *w;
120
121         c = (tel_inq_content)k[i]->data.pdata;
122         w = c->data;
123         c->act_size = 0;
124         w->gnl_colour = *col;
125         break;
126       }
127     }
128   }
129
130   return TSuccess;
131 }