g4tools  5.4.0
senum
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_sg_senum
5 #define tools_sg_senum
6 
7 #include "enums"
8 #include "lpat"
9 
10 #include <string>
11 #include <vector>
12 
13 namespace tools {
14 namespace sg {
15 
16 typedef struct {char string[32];hjust value;} hjust_rec;
17 inline const hjust_rec* hjust_recs(unsigned int& a_num){
18  static const hjust_rec list[] = { //read only static, then ok.
19  {"left", left},
20  {"center", center},
21  {"right", right}
22  };
23  a_num = sizeof(list)/sizeof(list[0]);
24  return list;
25 }
26 inline bool shjust(const std::string& a_s,hjust& a_v){
27  unsigned int number;
28  const hjust_rec* list = hjust_recs(number);
29  for(unsigned int count=0;count<number;count++) {
30  if(a_s==list[count].string) {
31  a_v = list[count].value;
32  return true;
33  }
34  }
35  a_v = left;
36  return false;
37 }
38 inline const char* shjust(hjust a_v){
39  unsigned int number;
40  const hjust_rec* list = hjust_recs(number);
41  for(unsigned int count=0;count<number;count++) {
42  if(a_v==list[count].value) return list[count].string;
43  }
44  return 0;
45 }
46 
47 typedef struct {char string[32];vjust value;} vjust_rec;
48 inline const vjust_rec* vjust_recs(unsigned int& a_num){
49  static const vjust_rec list[] = { //read only static, then ok.
50  {"bottom", bottom},
51  {"middle", middle},
52  {"top", top}
53  };
54  a_num = sizeof(list)/sizeof(list[0]);
55  return list;
56 }
57 inline bool svjust(const std::string& a_s,vjust& a_v){
58  unsigned int number;
59  const vjust_rec* list = vjust_recs(number);
60  for(unsigned int count=0;count<number;count++) {
61  if(a_s==list[count].string) {
62  a_v = list[count].value;
63  return true;
64  }
65  }
66  a_v = bottom;
67  return false;
68 }
69 inline const char* svjust(vjust a_v){
70  unsigned int number;
71  const vjust_rec* list = vjust_recs(number);
72  for(unsigned int count=0;count<number;count++) {
73  if(a_v==list[count].value) return list[count].string;
74  }
75  return 0;
76 }
77 
78 typedef struct {char string[32];marker_style value;} marker_style_rec;
79 inline const marker_style_rec* marker_style_recs(unsigned int& a_num){
80  static const marker_style_rec list[] = { //read only static, then ok.
81  {"dot", marker_dot},
82  {"plus", marker_plus},
83  {"asterisk", marker_asterisk},
84  {"cross", marker_cross},
85  {"star", marker_star},
86  {"circle_line", marker_circle_line},
87  {"circle_filled", marker_circle_filled},
88  {"triangle_up_line", marker_triangle_up_line},
89  {"triangle_up_filled", marker_triangle_up_filled},
90  {"triangle_down_line", marker_triangle_down_line},
91  {"triangle_down_filled",marker_triangle_down_filled},
92  {"david_star_line", marker_david_star_line},
93  {"david_star_filled", marker_david_star_filled},
94  {"swiss_cross_line", marker_swiss_cross_line},
95  {"swiss_cross_filled", marker_swiss_cross_filled},
96  {"diamond_line", marker_diamond_line},
97  {"diamond_filled", marker_diamond_filled},
98  {"square_line", marker_square_line},
99  {"square_filled", marker_square_filled},
100  {"penta_star_line", marker_penta_star_line},
101  {"penta_star_filled", marker_penta_star_filled},
102  {"minus", marker_minus}
103  };
104  a_num = sizeof(list)/sizeof(list[0]);
105  return list;
106 }
107 inline bool smarker_style(const std::string& a_s,marker_style& a_v){
108  unsigned int number;
109  const marker_style_rec* list = marker_style_recs(number);
110  for(unsigned int count=0;count<number;count++) {
111  if(a_s==list[count].string) {
112  a_v = list[count].value;
113  return true;
114  }
115  }
116  a_v = marker_dot;
117  return false;
118 }
119 inline const char* smarker_style(marker_style a_v){
120  unsigned int number;
121  const marker_style_rec* list = marker_style_recs(number);
122  for(unsigned int count=0;count<number;count++) {
123  if(a_v==list[count].value) return list[count].string;
124  }
125  return 0;
126 }
127 inline void smarker_styles(std::vector<std::string>& a_v){
128  a_v.clear();
129  unsigned int number;
130  const marker_style_rec* list = marker_style_recs(number);
131  for(unsigned int count=0;count<number;count++) {
132  a_v.push_back(list[count].string);
133  }
134 }
135 
136 typedef struct {char string[16];area_style value;} area_style_rec;
137 inline const area_style_rec* area_style_recsList(unsigned int& a_num){
138  static const area_style_rec list[] = { //read only static, then ok.
139  {"solid", area_solid},
140  {"hatched", area_hatched},
141  {"checker", area_checker},
142  {"edged", area_edged}
143  };
144  a_num = sizeof(list)/sizeof(list[0]);
145  return list;
146 }
147 inline bool sarea_style(const std::string& a_s,area_style& a_v){
148  unsigned int number;
149  const area_style_rec* list = area_style_recsList(number);
150  for(unsigned int count=0;count<number;count++) {
151  if(a_s==list[count].string) {
152  a_v = list[count].value;
153  return true;
154  }
155  }
156  a_v = area_solid;
157  return false;
158 }
159 inline const char* sarea_style(area_style a_v){
160  unsigned int number;
161  const area_style_rec* list = area_style_recsList(number);
162  for(unsigned int count=0;count<number;count++) {
163  if(a_v==list[count].value) return list[count].string;
164  }
165  return 0;
166 }
167 
168 typedef struct {char string[20];painting_policy value;} painting_policy_rec;
169 inline const painting_policy_rec* painting_policy_recsList(unsigned int& a_num){
170  static const painting_policy_rec list[] = { //read only static, then ok.
171  {"uniform", painting_uniform},
172  {"by_value", painting_by_value},
173  {"by_level", painting_by_level},
174  {"grey_scale", painting_grey_scale},
175  {"violet_to_red",painting_violet_to_red},
176  {"grey_scale_inverse",painting_grey_scale_inverse}
177  };
178  a_num = sizeof(list)/sizeof(list[0]);
179  return list;
180 }
181 inline void spainting_policies(std::vector<std::string>& a_v){
182  a_v.clear();
183  unsigned int number;
184  const painting_policy_rec* list = painting_policy_recsList(number);
185  for(unsigned int count=0;count<number;count++) {
186  a_v.push_back(list[count].string);
187  }
188 }
189 inline bool spainting_policy(const std::string& a_s,painting_policy& a_v){
190  unsigned int number;
191  const painting_policy_rec* list = painting_policy_recsList(number);
192  for(unsigned int count=0;count<number;count++) {
193  if(a_s==list[count].string) {
194  a_v = list[count].value;
195  return true;
196  }
197  }
198  a_v = painting_uniform;
199  return false;
200 }
201 inline const char* spainting_policy(painting_policy a_v){
202  unsigned int number;
203  const painting_policy_rec* list = painting_policy_recsList(number);
204  for(unsigned int count=0;count<number;count++) {
205  if(a_v==list[count].value) return list[count].string;
206  }
207  return 0;
208 }
209 
210 
211 typedef struct {char string[16];hatching_policy value;} hatching_policy_rec;
212 inline const hatching_policy_rec* hatching_policy_recsList(unsigned int& a_num){
213  static const hatching_policy_rec list[] = { //read only static, then ok.
214  {"none", hatching_none},
215  {"right", hatching_right},
216  {"left", hatching_left},
217  {"left_and_right", hatching_left_and_right}
218  };
219  a_num = sizeof(list)/sizeof(list[0]);
220  return list;
221 }
222 inline bool shatching_policy(const std::string& a_s,hatching_policy& a_v){
223  unsigned int number;
224  const hatching_policy_rec* list = hatching_policy_recsList(number);
225  for(unsigned int count=0;count<number;count++) {
226  if(a_s==list[count].string) {
227  a_v = list[count].value;
228  return true;
229  }
230  }
231  a_v = hatching_none;
232  return false;
233 }
234 inline const char* shatching_policy(hatching_policy a_v){
235  unsigned int number;
236  const hatching_policy_rec* list = hatching_policy_recsList(number);
237  for(unsigned int count=0;count<number;count++) {
238  if(a_v==list[count].value) return list[count].string;
239  }
240  return 0;
241 }
242 
243 typedef struct {char string[16];projection_type value;} projection_type_rec;
244 inline const projection_type_rec* projection_type_recsList(unsigned int& a_num){
245  static const projection_type_rec list[] = { //read only static, then ok.
246  {"none", projection_none},
247  {"rz", projection_rz},
248  {"phiz", projection_phiz},
249  {"zr", projection_zr},
250  {"zphi", projection_zphi}
251  };
252  a_num = sizeof(list)/sizeof(list[0]);
253  return list;
254 }
255 inline bool sprojection_type(const std::string& a_s,projection_type& a_v){
256  unsigned int number;
257  const projection_type_rec* list = projection_type_recsList(number);
258  for(unsigned int count=0;count<number;count++) {
259  if(a_s==list[count].string) {
260  a_v = list[count].value;
261  return true;
262  }
263  }
264  a_v = projection_none;
265  return false;
266 }
267 inline const char* sprojection_type(projection_type a_v){
268  unsigned int number;
269  const projection_type_rec* list = projection_type_recsList(number);
270  for(unsigned int count=0;count<number;count++) {
271  if(a_v==list[count].value) return list[count].string;
272  }
273  return 0;
274 }
275 
276 inline bool sline_pattern(const std::string& a_s,lpat& aPattern){
277  if(a_s=="solid") {
278  aPattern = line_solid;
279  } else if(a_s=="dashed") {
280  aPattern = line_dashed;
281  } else if(a_s=="dotted") {
282  aPattern = line_dotted;
283  } else if(a_s=="dash_dotted") {
284  aPattern = line_dash_dotted;
285  } else {
286  aPattern = line_solid;
287  return false;
288  }
289  return true;
290 }
291 
295 inline bool smove_type(const std::string& a_s,move_type& a_move) {
296  if(a_s=="move_rotate_right") {a_move = move_rotate_right;return true;}
297  if(a_s=="move_rotate_left") {a_move = move_rotate_left;return true;}
298  if(a_s=="move_rotate_up") {a_move = move_rotate_up;return true;}
299  if(a_s=="move_rotate_down") {a_move = move_rotate_down;return true;}
300  if(a_s=="move_roll_plus") {a_move = move_roll_plus;return true;}
301  if(a_s=="move_roll_minus") {a_move = move_roll_minus;return true;}
302  if(a_s=="move_translate_right") {a_move = move_translate_right;return true;}
303  if(a_s=="move_translate_left") {a_move = move_translate_left;return true;}
304  if(a_s=="move_up") {a_move = move_up;return true;}
305  if(a_s=="move_down") {a_move = move_down;return true;}
306  if(a_s=="move_forward") {a_move = move_forward;return true;}
307  if(a_s=="move_backward") {a_move = move_backward;return true;}
308  if(a_s=="move_zoom_in") {a_move = move_zoom_in;return true;}
309  if(a_s=="move_zoom_out") {a_move = move_zoom_out;return true;}
310  if(a_s=="move_rotate_around_focal_right") {a_move = move_rotate_around_focal_right;return true;}
311  if(a_s=="move_rotate_around_focal_left") {a_move = move_rotate_around_focal_left;return true;}
312  if(a_s=="move_rotate_around_focal_up") {a_move = move_rotate_around_focal_up;return true;}
313  if(a_s=="move_rotate_around_focal_down") {a_move = move_rotate_around_focal_down;return true;}
314  if(a_s=="move_roll_around_focal_plus") {a_move = move_roll_around_focal_plus;return true;}
315  if(a_s=="move_roll_around_focal_minus") {a_move = move_roll_around_focal_minus;return true;}
316  if(a_s=="move_zoom_in_out") {a_move = move_zoom_in_out;return true;}
317  if(a_s=="move_zoom_in_out_rot") {a_move = move_zoom_in_out_rot;return true;}
318  if(a_s=="move_curve") {a_move = move_curve;return true;}
319  a_move = move_rotate_left;
320  return false;
321 }
322 
323 }}
324 /*
325 #include "../snpf"
326 #include "../colorf"
327 
328 namespace tools {
329 namespace sg {
330 
331 inline bool scolor(const colorf& a_col,std::string& a_s){
332  char s[256];
333  snpf(s,sizeof(s),"%g %g %g",a_col[0],a_col[1],a_col[2]);
334  a_s = s;
335  return true;
336 }
337 
338 }}
339 */
340 
341 #endif
lpat
tools::sg::marker_swiss_cross_filled
@ marker_swiss_cross_filled
Definition: enums:32
tools::sg::projection_zr
@ projection_zr
Definition: enums:53
tools::sg::area_style
area_style
Definition: enums:42
tools::sg::marker_plus
@ marker_plus
Definition: enums:19
tools::sg::vjust_recs
const vjust_rec * vjust_recs(unsigned int &a_num)
Definition: senum:48
tools::sg::move_rotate_around_focal_down
@ move_rotate_around_focal_down
Definition: enums:129
tools::sg::line_dash_dotted
@ line_dash_dotted
Definition: enums:14
tools::sg::marker_david_star_filled
@ marker_david_star_filled
Definition: enums:30
tools::sg::projection_phiz
@ projection_phiz
Definition: enums:52
tools::sg::move_roll_minus
@ move_roll_minus
Definition: enums:116
tools::value
Definition: value:18
tools::sg::marker_circle_line
@ marker_circle_line
Definition: enums:23
tools::sg::projection_type_recsList
const projection_type_rec * projection_type_recsList(unsigned int &a_num)
Definition: senum:244
tools::sg::marker_minus
@ marker_minus
Definition: enums:39
tools::sg::sarea_style
bool sarea_style(const std::string &a_s, area_style &a_v)
Definition: senum:147
tools::sg::painting_policy
painting_policy
Definition: enums:57
tools::sg::painting_by_level
@ painting_by_level
Definition: enums:60
tools::sg::move_type
move_type
Definition: enums:109
tools::sg::line_dotted
@ line_dotted
Definition: enums:13
tools::sg::move_roll_around_focal_minus
@ move_roll_around_focal_minus
Definition: enums:131
tools::sg::projection_none
@ projection_none
Definition: enums:50
tools::sg::marker_triangle_up_filled
@ marker_triangle_up_filled
Definition: enums:26
tools::sg::painting_policy_recsList
const painting_policy_rec * painting_policy_recsList(unsigned int &a_num)
Definition: senum:169
tools::sg::hjust
hjust
Definition: enums:73
tools::sg::marker_style
marker_style
Definition: enums:17
tools::sg::painting_by_value
@ painting_by_value
Definition: enums:59
tools::sg::marker_penta_star_filled
@ marker_penta_star_filled
Definition: enums:38
tools::sg::hatching_policy_rec::value
hatching_policy value
Definition: senum:211
tools::sg::move_rotate_around_focal_left
@ move_rotate_around_focal_left
Definition: enums:127
tools::sg::marker_triangle_down_line
@ marker_triangle_down_line
Definition: enums:27
tools::sg::move_curve
@ move_curve
Definition: enums:134
tools::sg::marker_cross
@ marker_cross
Definition: enums:21
tools::sg::projection_type_rec::value
projection_type value
Definition: senum:243
tools::sg::shjust
bool shjust(const std::string &a_s, hjust &a_v)
Definition: senum:26
tools::sg::marker_swiss_cross_line
@ marker_swiss_cross_line
Definition: enums:31
tools::sg::right
@ right
Definition: enums:76
tools::sg::painting_grey_scale
@ painting_grey_scale
Definition: enums:61
tools::sg::spainting_policy
bool spainting_policy(const std::string &a_s, painting_policy &a_v)
Definition: senum:189
tools::sg::marker_star
@ marker_star
Definition: enums:22
tools::sg::marker_triangle_down_filled
@ marker_triangle_down_filled
Definition: enums:28
tools::sg::marker_dot
@ marker_dot
Definition: enums:18
tools::sg::area_style_rec::value
area_style value
Definition: senum:136
tools::sg::marker_penta_star_line
@ marker_penta_star_line
Definition: enums:37
tools::sg::move_roll_plus
@ move_roll_plus
Definition: enums:115
tools::sg::move_backward
@ move_backward
Definition: enums:123
tools::sg::top
@ top
Definition: enums:82
tools::sg::marker_style_rec::string
char string[32]
Definition: senum:78
tools::sg::hatching_left
@ hatching_left
Definition: enums:69
tools::sg::vjust_rec
Definition: senum:47
tools::sg::move_translate_right
@ move_translate_right
Definition: enums:118
tools::sg::area_checker
@ area_checker
Definition: enums:45
tools::sg::projection_type_rec
Definition: senum:243
tools::sg::painting_policy_rec::value
painting_policy value
Definition: senum:168
tools::sg::left
@ left
Definition: enums:74
tools::sg::hjust_rec
Definition: senum:16
tools::sg::area_edged
@ area_edged
Definition: enums:46
tools::sg::move_zoom_in_out_rot
@ move_zoom_in_out_rot
Definition: enums:133
tools::sg::hatching_policy_recsList
const hatching_policy_rec * hatching_policy_recsList(unsigned int &a_num)
Definition: senum:212
tools::sg::sline_pattern
bool sline_pattern(const std::string &a_s, lpat &aPattern)
Definition: senum:276
tools::sg::vjust_rec::value
vjust value
Definition: senum:47
tools::sg::lpat
unsigned short lpat
Definition: lpat:10
tools::sg::projection_type_rec::string
char string[16]
Definition: senum:243
tools::sg::painting_violet_to_red
@ painting_violet_to_red
Definition: enums:62
tools::sg::move_rotate_down
@ move_rotate_down
Definition: enums:114
tools::sg::marker_circle_filled
@ marker_circle_filled
Definition: enums:24
tools::sg::hatching_policy_rec
Definition: senum:211
tools::sg::move_roll_around_focal_plus
@ move_roll_around_focal_plus
Definition: enums:130
tools::sg::marker_square_line
@ marker_square_line
Definition: enums:35
tools::sg::area_style_rec::string
char string[16]
Definition: senum:136
tools::sg::marker_style_rec::value
marker_style value
Definition: senum:78
tools::sg::vjust
vjust
Definition: enums:79
tools::sg::move_zoom_in_out
@ move_zoom_in_out
Definition: enums:132
tools::sg::area_hatched
@ area_hatched
Definition: enums:44
tools::sg::bottom
@ bottom
Definition: enums:80
tools::sg::marker_david_star_line
@ marker_david_star_line
Definition: enums:29
tools::sg::hjust_rec::value
hjust value
Definition: senum:16
tools::sg::middle
@ middle
Definition: enums:81
tools::sg::smarker_style
bool smarker_style(const std::string &a_s, marker_style &a_v)
Definition: senum:107
tools::sg::move_translate_left
@ move_translate_left
Definition: enums:119
tools::sg::hatching_none
@ hatching_none
Definition: enums:67
tools::sg::painting_policy_rec::string
char string[20]
Definition: senum:168
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::marker_diamond_filled
@ marker_diamond_filled
Definition: enums:34
tools::sg::painting_uniform
@ painting_uniform
Definition: enums:58
tools::sg::area_style_rec
Definition: senum:136
tools::sg::hatching_left_and_right
@ hatching_left_and_right
Definition: enums:70
tools::sg::hjust_rec::string
char string[32]
Definition: senum:16
tools::sg::projection_type
projection_type
Definition: enums:49
tools::sg::shatching_policy
bool shatching_policy(const std::string &a_s, hatching_policy &a_v)
Definition: senum:222
tools::sg::move_forward
@ move_forward
Definition: enums:122
tools::sg::painting_policy_rec
Definition: senum:168
tools::sg::move_up
@ move_up
Definition: enums:120
tools::sg::spainting_policies
void spainting_policies(std::vector< std::string > &a_v)
Definition: senum:181
tools::sg::move_zoom_out
@ move_zoom_out
Definition: enums:125
enums
tools::sg::area_solid
@ area_solid
Definition: enums:43
tools::sg::line_dashed
@ line_dashed
Definition: enums:12
tools::sg::vjust_rec::string
char string[32]
Definition: senum:47
tools::sg::hatching_right
@ hatching_right
Definition: enums:68
tools::sg::marker_style_recs
const marker_style_rec * marker_style_recs(unsigned int &a_num)
Definition: senum:79
tools::sg::line_solid
@ line_solid
Definition: enums:11
tools::sg::move_rotate_around_focal_right
@ move_rotate_around_focal_right
Definition: enums:126
tools::sg::move_rotate_left
@ move_rotate_left
Definition: enums:112
tools::sg::marker_triangle_up_line
@ marker_triangle_up_line
Definition: enums:25
tools::sg::move_rotate_right
@ move_rotate_right
Definition: enums:111
tools::sg::projection_zphi
@ projection_zphi
Definition: enums:54
tools::sg::area_style_recsList
const area_style_rec * area_style_recsList(unsigned int &a_num)
Definition: senum:137
tools::sg::move_rotate_around_focal_up
@ move_rotate_around_focal_up
Definition: enums:128
tools::sg::hatching_policy_rec::string
char string[16]
Definition: senum:211
tools::sg::center
@ center
Definition: enums:75
tools::sg::hatching_policy
hatching_policy
Definition: enums:66
tools::sg::marker_diamond_line
@ marker_diamond_line
Definition: enums:33
tools::sg::marker_style_rec
Definition: senum:78
tools::sg::projection_rz
@ projection_rz
Definition: enums:51
tools::sg::marker_asterisk
@ marker_asterisk
Definition: enums:20
tools::sg::smove_type
bool smove_type(const std::string &a_s, move_type &a_move)
Definition: senum:295
tools::sg::move_rotate_up
@ move_rotate_up
Definition: enums:113
tools::sg::painting_grey_scale_inverse
@ painting_grey_scale_inverse
Definition: enums:63
tools::sg::marker_square_filled
@ marker_square_filled
Definition: enums:36
tools::sg::hjust_recs
const hjust_rec * hjust_recs(unsigned int &a_num)
Definition: senum:17
tools::sg::move_down
@ move_down
Definition: enums:121
tools::sg::move_zoom_in
@ move_zoom_in
Definition: enums:124
tools::sg::svjust
bool svjust(const std::string &a_s, vjust &a_v)
Definition: senum:57
tools::sg::smarker_styles
void smarker_styles(std::vector< std::string > &a_v)
Definition: senum:127
tools::sg::sprojection_type
bool sprojection_type(const std::string &a_s, projection_type &a_v)
Definition: senum:255