0012121: Optimization of existing selection classes
[occt.git] / src / OpenGl / OpenGl_charexpan.cxx
CommitLineData
7fd59977 1
2#include <OpenGl_tgl_all.hxx>
3
4#include <stddef.h>
5#include <stdio.h>
6
7#include <OpenGl_cmn_varargs.hxx>
8#include <OpenGl_telem_attri.hxx>
9#include <OpenGl_tsm.hxx>
10#include <OpenGl_telem.hxx>
11#include <OpenGl_telem_inquire.hxx>
12
13static TStatus CharacterExpansionFactorDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
14static TStatus CharacterExpansionFactorAdd( TSM_ELEM_DATA, Tint, cmn_key* );
15static TStatus CharacterExpansionFactorDelete( TSM_ELEM_DATA, Tint, cmn_key* );
16static TStatus CharacterExpansionFactorPrint( TSM_ELEM_DATA, Tint, cmn_key* );
17static TStatus CharacterExpansionFactorInquire( TSM_ELEM_DATA, Tint, cmn_key* );
18
19static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
20{
21 CharacterExpansionFactorDisplay, /* PickTraverse */
22 CharacterExpansionFactorDisplay,
23 CharacterExpansionFactorAdd,
24 CharacterExpansionFactorDelete,
25 CharacterExpansionFactorPrint,
26 CharacterExpansionFactorInquire
27};
28
29
30MtblPtr
31TelCharacterExpansionFactorInitClass( TelType *el )
32{
33 *el = TelCharacterExpansionFactor;
34 return MtdTbl;
35}
36
37static TStatus
38CharacterExpansionFactorAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
39{
40 Tfloat *data = new Tfloat();
41 if( !data )
42 return TFailure;
43
44 *data = k[0]->data.fdata;
45
46 ((tsm_elem_data)(d.pdata))->pdata = data;
47
48 return TSuccess;
49}
50
51
52static TStatus
53CharacterExpansionFactorDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
54{
55 CMN_KEY key;
56
57 key.id = TelCharacterExpansionFactor;
58 key.data.fdata = *(Tfloat*)(data.pdata);
59 TsmSetAttri( 1, &key );
60
61 return TSuccess;
62}
63
64
65static TStatus
66CharacterExpansionFactorDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
67{
68 if (data.pdata)
69 delete data.pdata;
70 return TSuccess;
71}
72
73
74static TStatus
75CharacterExpansionFactorPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
76{
77 fprintf( stdout, "TelCharacterExpansionFactor. Value = %g\n", *(Tfloat *)(data.pdata));
78 fprintf( stdout, "\n" );
79
80 return TSuccess;
81}
82
83
84static TStatus
85CharacterExpansionFactorInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
86{
87 Tint i;
88 Tfloat *f = (Tfloat*)data.pdata;
89
90 for( i = 0; i < n; i++ )
91 {
92 switch( k[i]->id )
93 {
94 case INQ_GET_SIZE_ID:
95 {
96 k[i]->data.ldata = sizeof( Tint );
97 break;
98 }
99 case INQ_GET_CONTENT_ID:
100 {
101 TEL_INQ_CONTENT *c;
102 Teldata *w;
103
104 c = (tel_inq_content)k[i]->data.pdata;
105 w = c->data;
106 c->act_size = 0;
107 w->fdata = *f;
108 break;
109 }
110 }
111 }
112
113 return TSuccess;
114}