Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/senum is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_senum
0005 #define tools_sg_senum
0006 
0007 #include "enums"
0008 #include "lpat"
0009 
0010 #include <string>
0011 #include <vector>
0012 
0013 namespace tools {
0014 namespace sg {
0015 
0016 typedef struct {char string[32];hjust value;} hjust_rec;
0017 inline const hjust_rec* hjust_recs(unsigned int& a_num){
0018   static const hjust_rec list[] = { //read only static, then ok.
0019     {"left",     left},
0020     {"center",   center},
0021     {"right",    right}
0022   };
0023   a_num = sizeof(list)/sizeof(list[0]);
0024   return list;
0025 }
0026 inline bool shjust(const std::string& a_s,hjust& a_v){
0027   unsigned int number;
0028   const hjust_rec* list = hjust_recs(number);
0029   for(unsigned int count=0;count<number;count++) {
0030     if(a_s==list[count].string) {
0031       a_v = list[count].value;
0032       return true;
0033     }
0034   }
0035   a_v = left;
0036   return false;
0037 }
0038 inline const char* shjust(hjust a_v){
0039   unsigned int number;
0040   const hjust_rec* list = hjust_recs(number);
0041   for(unsigned int count=0;count<number;count++) {
0042     if(a_v==list[count].value) return list[count].string;
0043   }
0044   return 0;
0045 }
0046 
0047 typedef struct {char string[32];vjust value;} vjust_rec;
0048 inline const vjust_rec* vjust_recs(unsigned int& a_num){
0049   static const vjust_rec list[] = { //read only static, then ok.
0050     {"bottom",   bottom},
0051     {"middle",   middle},
0052     {"top",      top}
0053   };
0054   a_num = sizeof(list)/sizeof(list[0]);
0055   return list;
0056 }
0057 inline bool svjust(const std::string& a_s,vjust& a_v){
0058   unsigned int number;
0059   const vjust_rec* list = vjust_recs(number);
0060   for(unsigned int count=0;count<number;count++) {
0061     if(a_s==list[count].string) {
0062       a_v = list[count].value;
0063       return true;
0064     }
0065   }
0066   a_v = bottom;
0067   return false;
0068 }
0069 inline const char* svjust(vjust a_v){
0070   unsigned int number;
0071   const vjust_rec* list = vjust_recs(number);
0072   for(unsigned int count=0;count<number;count++) {
0073     if(a_v==list[count].value) return list[count].string;
0074   }
0075   return 0;
0076 }
0077 
0078 typedef struct {char string[32];marker_style value;} marker_style_rec;
0079 inline const marker_style_rec* marker_style_recs(unsigned int& a_num){
0080   static const marker_style_rec list[] = { //read only static, then ok.
0081     {"dot",         marker_dot},
0082     {"plus",        marker_plus},
0083     {"asterisk",    marker_asterisk},
0084     {"cross",       marker_cross},
0085     {"star",        marker_star},
0086     {"circle_line",         marker_circle_line},
0087     {"circle_filled",       marker_circle_filled},
0088     {"triangle_up_line",    marker_triangle_up_line},
0089     {"triangle_up_filled",  marker_triangle_up_filled},
0090     {"triangle_down_line",  marker_triangle_down_line},
0091     {"triangle_down_filled",marker_triangle_down_filled},
0092     {"david_star_line",     marker_david_star_line},
0093     {"david_star_filled",   marker_david_star_filled},
0094     {"swiss_cross_line",    marker_swiss_cross_line},
0095     {"swiss_cross_filled",  marker_swiss_cross_filled},
0096     {"diamond_line",        marker_diamond_line},
0097     {"diamond_filled",      marker_diamond_filled},
0098     {"square_line",         marker_square_line},
0099     {"square_filled",       marker_square_filled},
0100     {"penta_star_line",     marker_penta_star_line},
0101     {"penta_star_filled",   marker_penta_star_filled},
0102     {"minus",               marker_minus}
0103   };
0104   a_num = sizeof(list)/sizeof(list[0]);
0105   return list;
0106 }
0107 inline bool smarker_style(const std::string& a_s,marker_style& a_v){
0108   unsigned int number;
0109   const marker_style_rec* list = marker_style_recs(number);
0110   for(unsigned int count=0;count<number;count++) {
0111     if(a_s==list[count].string) {
0112       a_v = list[count].value;
0113       return true;
0114     }
0115   }
0116   a_v = marker_dot;
0117   return false;
0118 }
0119 inline const char* smarker_style(marker_style a_v){
0120   unsigned int number;
0121   const marker_style_rec* list = marker_style_recs(number);
0122   for(unsigned int count=0;count<number;count++) {
0123     if(a_v==list[count].value) return list[count].string;
0124   }
0125   return 0;
0126 }
0127 inline void smarker_styles(std::vector<std::string>& a_v){
0128   a_v.clear();
0129   unsigned int number;
0130   const marker_style_rec* list = marker_style_recs(number);
0131   for(unsigned int count=0;count<number;count++) {
0132     a_v.push_back(list[count].string);
0133   }
0134 }
0135 
0136 typedef struct {char string[16];area_style value;} area_style_rec;
0137 inline const area_style_rec* area_style_recsList(unsigned int& a_num){
0138   static const area_style_rec list[] = { //read only static, then ok.
0139     {"solid",         area_solid},
0140     {"hatched",       area_hatched},
0141     {"checker",       area_checker},
0142     {"edged",         area_edged}
0143   };
0144   a_num = sizeof(list)/sizeof(list[0]);
0145   return list;
0146 }
0147 inline bool sarea_style(const std::string& a_s,area_style& a_v){
0148   unsigned int number;
0149   const area_style_rec* list = area_style_recsList(number);
0150   for(unsigned int count=0;count<number;count++) {
0151     if(a_s==list[count].string) {
0152       a_v = list[count].value;
0153       return true;
0154     }
0155   }
0156   a_v = area_solid;
0157   return false;
0158 }
0159 inline const char* sarea_style(area_style a_v){
0160   unsigned int number;
0161   const area_style_rec* list = area_style_recsList(number);
0162   for(unsigned int count=0;count<number;count++) {
0163     if(a_v==list[count].value) return list[count].string;
0164   }
0165   return 0;
0166 }
0167 
0168 typedef struct {char string[20];painting_policy value;} painting_policy_rec;
0169 inline const painting_policy_rec* painting_policy_recsList(unsigned int& a_num){
0170   static const painting_policy_rec list[] = { //read only static, then ok.
0171     {"uniform",      painting_uniform},
0172     {"by_value",     painting_by_value},
0173     {"by_level",     painting_by_level},
0174     {"grey_scale",   painting_grey_scale},
0175     {"violet_to_red",painting_violet_to_red},
0176     {"grey_scale_inverse",painting_grey_scale_inverse}
0177   };
0178   a_num = sizeof(list)/sizeof(list[0]);
0179   return list;
0180 }
0181 inline void spainting_policies(std::vector<std::string>& a_v){
0182   a_v.clear();
0183   unsigned int number;
0184   const painting_policy_rec* list = painting_policy_recsList(number);
0185   for(unsigned int count=0;count<number;count++) {
0186     a_v.push_back(list[count].string);
0187   }
0188 }
0189 inline bool spainting_policy(const std::string& a_s,painting_policy& a_v){
0190   unsigned int number;
0191   const painting_policy_rec* list = painting_policy_recsList(number);
0192   for(unsigned int count=0;count<number;count++) {
0193     if(a_s==list[count].string) {
0194       a_v = list[count].value;
0195       return true;
0196     }
0197   }
0198   a_v = painting_uniform;
0199   return false;
0200 }
0201 inline const char* spainting_policy(painting_policy a_v){
0202   unsigned int number;
0203   const painting_policy_rec* list = painting_policy_recsList(number);
0204   for(unsigned int count=0;count<number;count++) {
0205     if(a_v==list[count].value) return list[count].string;
0206   }
0207   return 0;
0208 }
0209 
0210 
0211 typedef struct {char string[16];hatching_policy value;} hatching_policy_rec;
0212 inline const hatching_policy_rec* hatching_policy_recsList(unsigned int& a_num){
0213   static const hatching_policy_rec list[] = { //read only static, then ok.
0214     {"none",           hatching_none},
0215     {"right",          hatching_right},
0216     {"left",           hatching_left},
0217     {"left_and_right", hatching_left_and_right}
0218   };
0219   a_num = sizeof(list)/sizeof(list[0]);
0220   return list;
0221 }
0222 inline bool shatching_policy(const std::string& a_s,hatching_policy& a_v){
0223   unsigned int number;
0224   const hatching_policy_rec* list = hatching_policy_recsList(number);
0225   for(unsigned int count=0;count<number;count++) {
0226     if(a_s==list[count].string) {
0227       a_v = list[count].value;
0228       return true;
0229     }
0230   }
0231   a_v = hatching_none;
0232   return false;
0233 }
0234 inline const char* shatching_policy(hatching_policy a_v){
0235   unsigned int number;
0236   const hatching_policy_rec* list = hatching_policy_recsList(number);
0237   for(unsigned int count=0;count<number;count++) {
0238     if(a_v==list[count].value) return list[count].string;
0239   }
0240   return 0;
0241 }
0242 
0243 typedef struct {char string[16];projection_type value;} projection_type_rec;
0244 inline const projection_type_rec* projection_type_recsList(unsigned int& a_num){
0245   static const projection_type_rec list[] = { //read only static, then ok.
0246     {"none",     projection_none},
0247     {"rz",       projection_rz},
0248     {"phiz",     projection_phiz},
0249     {"zr",       projection_zr},
0250     {"zphi",     projection_zphi}
0251   };
0252   a_num = sizeof(list)/sizeof(list[0]);
0253   return list;
0254 }
0255 inline bool sprojection_type(const std::string& a_s,projection_type& a_v){
0256   unsigned int number;
0257   const projection_type_rec* list = projection_type_recsList(number);
0258   for(unsigned int count=0;count<number;count++) {
0259     if(a_s==list[count].string) {
0260       a_v = list[count].value;
0261       return true;
0262     }
0263   }
0264   a_v = projection_none;
0265   return false;
0266 }
0267 inline const char* sprojection_type(projection_type a_v){
0268   unsigned int number;
0269   const projection_type_rec* list = projection_type_recsList(number);
0270   for(unsigned int count=0;count<number;count++) {
0271     if(a_v==list[count].value) return list[count].string;
0272   }
0273   return 0;
0274 }
0275 
0276 inline bool sline_pattern(const std::string& a_s,lpat& aPattern){
0277   if(a_s=="solid") {
0278     aPattern = line_solid;
0279   } else if(a_s=="dashed") {
0280     aPattern = line_dashed;
0281   } else if(a_s=="dotted") {
0282     aPattern = line_dotted;
0283   } else if(a_s=="dash_dotted") {
0284     aPattern = line_dash_dotted;
0285   } else {
0286     aPattern = line_solid;
0287     return false;
0288   }
0289   return true;
0290 }
0291 
0292 ///////////////////////////////////////////////////////////////
0293 ///////////////////////////////////////////////////////////////
0294 ///////////////////////////////////////////////////////////////
0295 inline bool smove_type(const std::string& a_s,move_type& a_move) {
0296   if(a_s=="move_rotate_right") {a_move = move_rotate_right;return true;}
0297   if(a_s=="move_rotate_left") {a_move = move_rotate_left;return true;}
0298   if(a_s=="move_rotate_up") {a_move = move_rotate_up;return true;}
0299   if(a_s=="move_rotate_down") {a_move = move_rotate_down;return true;}
0300   if(a_s=="move_roll_plus") {a_move = move_roll_plus;return true;}
0301   if(a_s=="move_roll_minus") {a_move = move_roll_minus;return true;}
0302   if(a_s=="move_translate_right") {a_move = move_translate_right;return true;}
0303   if(a_s=="move_translate_left") {a_move = move_translate_left;return true;}
0304   if(a_s=="move_up") {a_move = move_up;return true;}
0305   if(a_s=="move_down") {a_move = move_down;return true;}
0306   if(a_s=="move_forward") {a_move = move_forward;return true;}
0307   if(a_s=="move_backward") {a_move = move_backward;return true;}
0308   if(a_s=="move_zoom_in") {a_move = move_zoom_in;return true;}
0309   if(a_s=="move_zoom_out") {a_move = move_zoom_out;return true;}
0310   if(a_s=="move_rotate_around_focal_right") {a_move = move_rotate_around_focal_right;return true;}
0311   if(a_s=="move_rotate_around_focal_left") {a_move = move_rotate_around_focal_left;return true;}
0312   if(a_s=="move_rotate_around_focal_up") {a_move = move_rotate_around_focal_up;return true;}
0313   if(a_s=="move_rotate_around_focal_down") {a_move = move_rotate_around_focal_down;return true;}
0314   if(a_s=="move_roll_around_focal_plus") {a_move = move_roll_around_focal_plus;return true;}
0315   if(a_s=="move_roll_around_focal_minus") {a_move = move_roll_around_focal_minus;return true;}
0316   if(a_s=="move_zoom_in_out") {a_move = move_zoom_in_out;return true;}
0317   if(a_s=="move_zoom_in_out_rot") {a_move = move_zoom_in_out_rot;return true;}
0318   if(a_s=="move_curve") {a_move = move_curve;return true;}
0319   a_move = move_rotate_left;
0320   return false;
0321 }
0322 
0323 }}
0324 /*
0325 #include "../snpf"
0326 #include "../colorf"
0327 
0328 namespace tools {
0329 namespace sg {
0330 
0331 inline bool scolor(const colorf& a_col,std::string& a_s){
0332   char _s[256];
0333   snpf(_s,sizeof(_s),"%g %g %g",a_col[0],a_col[1],a_col[2]);
0334   a_s = _s;
0335   return true;
0336 }
0337 
0338 }}
0339 */
0340 
0341 #endif