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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 
292 ///////////////////////////////////////////////////////////////
293 ///////////////////////////////////////////////////////////////
294 ///////////////////////////////////////////////////////////////
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