0012121: Optimization of existing selection classes
[occt.git] / src / OpenGl / OpenGl_charspace.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 CharacterSpacingDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
14static TStatus CharacterSpacingAdd( TSM_ELEM_DATA, Tint, cmn_key* );
15static TStatus CharacterSpacingDelete( TSM_ELEM_DATA, Tint, cmn_key* );
16static TStatus CharacterSpacingPrint( TSM_ELEM_DATA, Tint, cmn_key* );
17static TStatus CharacterSpacingInquire( TSM_ELEM_DATA, Tint, cmn_key* );
18
19static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
20{
21 CharacterSpacingDisplay, /* PickTraverse */
22 CharacterSpacingDisplay,
23 CharacterSpacingAdd,
24 CharacterSpacingDelete,
25 CharacterSpacingPrint,
26 CharacterSpacingInquire
27};
28
29
30MtblPtr
31TelCharacterSpacingInitClass( TelType *el )
32{
33 *el = TelCharacterSpacing;
34 return MtdTbl;
35}
36
37static TStatus
38CharacterSpacingAdd( 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
53CharacterSpacingDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
54{
55 CMN_KEY key;
56
57 key.id = TelCharacterSpacing;
58 key.data.fdata = *(Tfloat*)(data.pdata);
59 TsmSetAttri( 1, &key );
60
61 return TSuccess;
62}
63
64
65static TStatus
66CharacterSpacingDelete( 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
75CharacterSpacingPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
76{
77 fprintf( stdout, "TelCharacterSpacing. Value = %g\n", *(Tfloat *)(data.pdata));
78 fprintf( stdout, "\n" );
79 return TSuccess;
80}
81
82
83static TStatus
84CharacterSpacingInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
85{
86 Tint i;
87 Tfloat *f = (Tfloat*)data.pdata;
88
89 for( i = 0; i < n; i++ )
90 {
91 switch( k[i]->id )
92 {
93 case INQ_GET_SIZE_ID:
94 {
95 k[i]->data.ldata = sizeof( Tint );
96 break;
97 }
98 case INQ_GET_CONTENT_ID:
99 {
100 TEL_INQ_CONTENT *c;
101 Teldata *w;
102
103 c = (tel_inq_content)k[i]->data.pdata;
104 w = c->data;
105 c->act_size = 0;
106 w->fdata = *f;
107 break;
108 }
109 }
110 }
111
112 return TSuccess;
113}