Integration of OCCT 6.5.0 from SVN
[occt.git] / src / OpenGl / OpenGl_localtran3.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_telem_util.hxx>
12 #include <OpenGl_tsm.hxx>
13 #include <OpenGl_telem.hxx>
14 #include <OpenGl_telem_inquire.hxx>
15
16 static  TStatus  LocalTran3Display( TSM_ELEM_DATA, Tint, cmn_key* );
17 static  TStatus  LocalTran3Add( TSM_ELEM_DATA, Tint, cmn_key* );
18 static  TStatus  LocalTran3Delete( TSM_ELEM_DATA, Tint, cmn_key* );
19 static  TStatus  LocalTran3Print( TSM_ELEM_DATA, Tint, cmn_key* );
20 static  TStatus  LocalTran3Inquire( TSM_ELEM_DATA, Tint, cmn_key* );
21
22 static  TStatus  (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
23 {
24   LocalTran3Display,             /* PickTraverse */
25   LocalTran3Display,
26   LocalTran3Add,
27   LocalTran3Delete,
28   LocalTran3Print,
29   LocalTran3Inquire
30 };
31
32
33 MtblPtr
34 TelLocalTran3InitClass( TelType *el )
35 {
36   *el = TelLocalTran3;
37   return MtdTbl;
38 }
39
40 static  TStatus
41 LocalTran3Add( TSM_ELEM_DATA d, Tint n, cmn_key *k )
42 {
43   tel_matrix3_data data = new TEL_MATRIX3_DATA();
44
45   //cmn_memreserve( data, 1, 0 );
46
47   if( !data )
48     return TFailure;
49
50   data->mode = (TComposeType)(k[0]->id);
51   matcpy( data->mat, k[0]->data.pdata );
52
53   ((tsm_elem_data)(d.pdata))->pdata = data;
54
55   return TSuccess;
56 }
57
58
59 static  TStatus
60 LocalTran3Display( TSM_ELEM_DATA data, Tint n, cmn_key *k )
61 {
62   tel_matrix3_data d;
63   CMN_KEY          key;
64
65   d = (tel_matrix3_data)data.pdata;
66
67   key.id = TelLocalTran3;
68   key.data.pdata = d;
69   TsmSetAttri( 1, &key );
70
71   return TSuccess;
72 }
73
74
75 static  TStatus
76 LocalTran3Delete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
77 {
78   //cmn_freemem( data.pdata );
79   if (data.pdata)
80     delete data.pdata;
81   return TSuccess;
82 }
83
84
85
86
87 static  TStatus
88 LocalTran3Print( TSM_ELEM_DATA data, Tint n, cmn_key *k )
89 {
90   tel_matrix3_data  d;
91   Tint i;
92
93   d = (tel_matrix3_data)data.pdata;
94
95   fprintf( stdout, "TelLocalTran3. \n" );
96   for( i=0; i<4; i++ )
97     fprintf( stdout, "\t\t%12.7f  %12.7f  %12.7f  %12.7f\n", d->mat[i][0],
98     d->mat[i][1], d->mat[i][2], d->mat[i][3] );
99   fprintf( stdout, "\n" );
100
101   return TSuccess;
102 }
103
104
105 static TStatus
106 LocalTran3Inquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
107 {
108   Tint              i;
109   tel_matrix3_data d;
110
111   d = (tel_matrix3_data)data.pdata;
112
113   for( i = 0; i < n; i++ )
114   {
115     switch( k[i]->id )
116     {
117     case INQ_GET_SIZE_ID:
118       {
119         k[i]->data.ldata = 0;
120         break;
121       }
122
123     case INQ_GET_CONTENT_ID:
124       {
125         TEL_INQ_CONTENT *c;
126         Teldata         *w;
127
128         c = (tel_inq_content)k[i]->data.pdata;
129         c->act_size = 0;
130         w = c->data;
131
132         w->local_xform_3.compose_type = d->mode;
133         //cmn_memcpy( w->local_xform_3.mat3, d->mat, sizeof( Tmatrix3), 1 );
134         memcpy( w->local_xform_3.mat3, d->mat, sizeof( Tmatrix3) );
135       }
136     }
137   }
138   return TSuccess;
139 }