Warning, /include/Geant4/tools/sg/style 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_style
0005 #define tools_sg_style
0006
0007 // fields of style_parser but put as sf on a node.
0008
0009 #include "node"
0010
0011 #include "style_parser"
0012 #include "sf_string"
0013 #include "sf_vec3f"
0014 #include "sf_enum"
0015
0016 namespace tools {
0017 namespace sg {
0018
0019 class style : public node {
0020 TOOLS_NODE(style,tools::sg::style,node)
0021 public:
0022 sf_vec<colorf,float> color;
0023 sf_vec<colorf,float> highlight_color;
0024 sf_vec<colorf,float> back_color;
0025 sf<float> line_width;
0026 sf<float> marker_size;
0027 sf<float> point_size;
0028 sf<float> font_size;
0029 sf_enum<sg::font_modeling> font_modeling;
0030 sf_enum<winding_type> front_face;
0031 sf<lpat> line_pattern;
0032 sf_enum<sg::marker_style> marker_style;
0033 sf_enum<sg::area_style> area_style;
0034 sf_string modeling;
0035 sf_string light_model;
0036 sf_string tick_modeling;
0037 sf_string encoding;
0038 sf<bool> smoothing;
0039 sf<bool> hinting;
0040 sf_string cut;
0041 sf_enum<sg::painting_policy> painting;
0042 sf_enum<sg::hatching_policy> hatching;
0043 sf_enum<sg::projection_type> projection;
0044 sf_string font;
0045 sf<int> multi_node_limit;
0046 sf<int> divisions;
0047 sf<unsigned int> rotation_steps;
0048 sf<float> spacing;
0049 sf<float> angle;
0050 sf<float> scale;
0051 sf<float> offset;
0052 sf<float> strip_width;
0053 sf<bool> visible;
0054 sf<float> bar_offset;
0055 sf<float> bar_width;
0056 sf<bool> editable;
0057 sf<bool> pickable;
0058 sf<bool> automated;
0059 sf_string options;
0060 sf_string color_mapping;
0061 sf<bool> enforced;
0062 sf_vec3f translation;
0063 sf_string coloring;
0064 sf_string title;
0065 public:
0066 virtual const desc_fields& node_desc_fields() const {
0067 TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::style)
0068 static const desc_fields s_v(parent::node_desc_fields(),43, //WARNING : take care of count.
0069 TOOLS_ARG_FIELD_DESC(color), //1
0070 TOOLS_ARG_FIELD_DESC(highlight_color),
0071 TOOLS_ARG_FIELD_DESC(back_color),
0072 TOOLS_ARG_FIELD_DESC(line_width),
0073 TOOLS_ARG_FIELD_DESC(marker_size),
0074 TOOLS_ARG_FIELD_DESC(point_size),
0075 TOOLS_ARG_FIELD_DESC(font_size),
0076 TOOLS_ARG_FIELD_DESC(font_modeling),
0077 TOOLS_ARG_FIELD_DESC(front_face),
0078 TOOLS_ARG_FIELD_DESC(line_pattern), //10
0079
0080 TOOLS_ARG_FIELD_DESC(marker_style),
0081 TOOLS_ARG_FIELD_DESC(area_style),
0082 TOOLS_ARG_FIELD_DESC(modeling),
0083 TOOLS_ARG_FIELD_DESC(light_model),
0084 TOOLS_ARG_FIELD_DESC(tick_modeling),
0085 TOOLS_ARG_FIELD_DESC(encoding),
0086 TOOLS_ARG_FIELD_DESC(smoothing),
0087 TOOLS_ARG_FIELD_DESC(hinting),
0088 TOOLS_ARG_FIELD_DESC(cut),
0089 TOOLS_ARG_FIELD_DESC(painting), //20
0090
0091 TOOLS_ARG_FIELD_DESC(hatching),
0092 TOOLS_ARG_FIELD_DESC(projection),
0093 TOOLS_ARG_FIELD_DESC(font),
0094 TOOLS_ARG_FIELD_DESC(multi_node_limit),
0095 TOOLS_ARG_FIELD_DESC(divisions),
0096 TOOLS_ARG_FIELD_DESC(rotation_steps),
0097 TOOLS_ARG_FIELD_DESC(spacing),
0098 TOOLS_ARG_FIELD_DESC(angle),
0099 TOOLS_ARG_FIELD_DESC(scale),
0100 TOOLS_ARG_FIELD_DESC(offset), //30
0101
0102 TOOLS_ARG_FIELD_DESC(strip_width),
0103 TOOLS_ARG_FIELD_DESC(visible),
0104 TOOLS_ARG_FIELD_DESC(bar_offset),
0105 TOOLS_ARG_FIELD_DESC(bar_width),
0106 TOOLS_ARG_FIELD_DESC(editable),
0107 TOOLS_ARG_FIELD_DESC(pickable),
0108 TOOLS_ARG_FIELD_DESC(automated),
0109 TOOLS_ARG_FIELD_DESC(options),
0110 TOOLS_ARG_FIELD_DESC(color_mapping),
0111 TOOLS_ARG_FIELD_DESC(enforced), //40
0112
0113 TOOLS_ARG_FIELD_DESC(translation),
0114 TOOLS_ARG_FIELD_DESC(coloring),
0115 TOOLS_ARG_FIELD_DESC(title)
0116 );
0117 return s_v;
0118 }
0119 private:
0120 void add_fields(){
0121 add_field(&color);
0122 add_field(&highlight_color);
0123 add_field(&back_color);
0124 add_field(&line_width);
0125 add_field(&marker_size);
0126 add_field(&point_size);
0127 add_field(&font_size);
0128 add_field(&font_modeling);
0129 add_field(&front_face);
0130 add_field(&line_pattern);
0131 add_field(&marker_style);
0132 add_field(&area_style);
0133 add_field(&modeling);
0134 add_field(&light_model);
0135 add_field(&tick_modeling);
0136 add_field(&encoding);
0137 add_field(&smoothing);
0138 add_field(&hinting);
0139 add_field(&cut);
0140 add_field(&painting);
0141 add_field(&hatching);
0142 add_field(&projection);
0143 add_field(&font);
0144 add_field(&multi_node_limit);
0145 add_field(&divisions);
0146 add_field(&rotation_steps);
0147 add_field(&spacing);
0148 add_field(&angle);
0149 add_field(&scale);
0150 add_field(&offset);
0151 add_field(&strip_width);
0152 add_field(&visible);
0153 add_field(&bar_offset);
0154 add_field(&bar_width);
0155 add_field(&editable);
0156 add_field(&pickable);
0157 add_field(&automated);
0158 add_field(&options);
0159 add_field(&color_mapping);
0160 add_field(&enforced);
0161 add_field(&translation);
0162 add_field(&coloring);
0163 add_field(&title);
0164 }
0165 public:
0166 style()
0167 :parent()
0168 ,color(colorf_black())
0169 ,highlight_color(colorf_black())
0170 ,back_color(colorf_white())
0171 ,line_width(1)
0172 ,marker_size(1)
0173 ,point_size(1)
0174 ,font_size(10)
0175 ,font_modeling(font_filled)
0176 ,front_face(winding_ccw)
0177 ,line_pattern(line_solid)
0178 ,marker_style(marker_dot)
0179 ,area_style(area_solid)
0180 ,modeling(modeling_boxes())
0181 ,light_model(light_model_phong())
0182 ,tick_modeling(tick_modeling_hippo())
0183 ,encoding(encoding_none())
0184 ,smoothing(false)
0185 ,hinting(false)
0186 ,cut()
0187 ,painting(painting_uniform)
0188 ,hatching(hatching_none)
0189 ,projection(projection_none)
0190 ,font(font_hershey())
0191 ,multi_node_limit(style_parser::no_limit())
0192 ,divisions(510) //Same as ROOT/TAttAxis
0193 ,rotation_steps(24) //Same as SbPolyhedron default.
0194 ,spacing(0.05F)
0195 ,angle(fpi()/4.0F)
0196 ,scale(1)
0197 ,offset(0)
0198 ,strip_width(0)
0199 ,visible(true)
0200 ,bar_offset(0.25F)
0201 ,bar_width(0.5F)
0202 ,editable(false)
0203 ,pickable(false)
0204 ,automated(true)
0205 ,options()
0206 ,color_mapping()
0207 ,enforced(false)
0208 ,translation(vec3f(0,0,0))
0209 ,coloring()
0210 ,title()
0211 {
0212 add_fields();
0213 }
0214 virtual ~style(){}
0215 public:
0216 style(const style& a_from)
0217 :parent(a_from)
0218 ,color(a_from.color)
0219 ,highlight_color(a_from.highlight_color)
0220 ,back_color(a_from.back_color)
0221 ,line_width(a_from.line_width)
0222 ,marker_size(a_from.marker_size)
0223 ,point_size(a_from.point_size)
0224 ,font_size(a_from.font_size)
0225 ,font_modeling(a_from.font_modeling)
0226 ,front_face(a_from.front_face)
0227 ,line_pattern(a_from.line_pattern)
0228 ,marker_style(a_from.marker_style)
0229 ,area_style(a_from.area_style)
0230 ,modeling (a_from.modeling )
0231 ,light_model(a_from.light_model)
0232 ,tick_modeling(a_from.tick_modeling)
0233 ,encoding(a_from.encoding)
0234 ,smoothing(a_from.smoothing)
0235 ,hinting(a_from.hinting)
0236 ,cut(a_from.cut)
0237 ,painting(a_from.painting)
0238 ,hatching(a_from.hatching)
0239 ,projection(a_from.projection)
0240 ,font(a_from.font)
0241 ,multi_node_limit(a_from.multi_node_limit)
0242 ,divisions(a_from.divisions)
0243 ,rotation_steps(a_from.rotation_steps)
0244 ,spacing(a_from.spacing)
0245 ,angle(a_from.angle)
0246 ,scale(a_from.scale)
0247 ,offset(a_from.offset)
0248 ,strip_width(a_from.strip_width)
0249 ,visible(a_from.visible)
0250 ,bar_offset(a_from.bar_offset)
0251 ,bar_width(a_from.bar_width)
0252 ,editable(a_from.editable)
0253 ,pickable(a_from.pickable)
0254 ,automated(a_from.automated)
0255 ,options(a_from.options)
0256 ,color_mapping(a_from.color_mapping)
0257 ,enforced(a_from.enforced)
0258 ,translation(a_from.translation)
0259 ,coloring(a_from.coloring)
0260 ,title(a_from.title)
0261 {
0262 add_fields();
0263 }
0264 style& operator=(const style& a_from){
0265 parent::operator=(a_from);
0266
0267 color = a_from.color;
0268 highlight_color = a_from.highlight_color;
0269 back_color = a_from.back_color;
0270 line_width = a_from.line_width;
0271 marker_size = a_from.marker_size;
0272 point_size = a_from.point_size;
0273 font_size = a_from.font_size;
0274 font_modeling = a_from.font_modeling;
0275 front_face = a_from.front_face;
0276 line_pattern = a_from.line_pattern;
0277 marker_style = a_from.marker_style;
0278 area_style = a_from.area_style;
0279 modeling = a_from.modeling ;
0280 light_model = a_from.light_model;
0281 tick_modeling = a_from.tick_modeling;
0282 encoding = a_from.encoding;
0283 smoothing = a_from.smoothing;
0284 hinting = a_from.hinting;
0285 cut = a_from.cut;
0286 painting = a_from.painting;
0287 hatching = a_from.hatching;
0288 projection = a_from.projection;
0289 font = a_from.font;
0290 multi_node_limit = a_from.multi_node_limit;
0291 divisions = a_from.divisions;
0292 rotation_steps = a_from.rotation_steps;
0293 spacing = a_from.spacing;
0294 angle = a_from.angle;
0295 scale = a_from.scale;
0296 offset = a_from.offset;
0297 strip_width = a_from.strip_width;
0298 visible = a_from.visible;
0299 bar_offset = a_from.bar_offset;
0300 bar_width = a_from.bar_width;
0301 editable = a_from.editable;
0302 pickable = a_from.pickable;
0303 automated = a_from.automated;
0304 options = a_from.options;
0305 color_mapping = a_from.color_mapping;
0306 enforced = a_from.enforced;
0307 translation = a_from.translation;
0308 coloring = a_from.coloring;
0309 title = a_from.title;
0310
0311 return *this;
0312 }
0313 public:
0314 void reset() {
0315 color = colorf_black();
0316 highlight_color = colorf_black();
0317 back_color = colorf_white();
0318 line_width = 1;
0319 marker_size = 1;
0320 point_size = 1;
0321 font_size = 10;
0322 font_modeling = font_filled;
0323 front_face = winding_ccw;
0324 line_pattern = line_solid;
0325 marker_style = marker_dot;
0326 area_style = area_solid;
0327 modeling = modeling_boxes();
0328 light_model = light_model_phong();
0329 tick_modeling = tick_modeling_hippo();
0330 encoding = encoding_none();
0331 smoothing = false;
0332 hinting = false;
0333 cut = "";
0334 painting = painting_uniform;
0335 hatching = hatching_none;
0336 projection = projection_none;
0337 font = font_hershey();
0338 multi_node_limit = style_parser::no_limit();
0339 divisions = 510;
0340 rotation_steps = 24;
0341 spacing = 0.05F;
0342 angle = fpi()/4.0F;
0343 scale = 1;
0344 offset = 0;
0345 strip_width = 0;
0346 visible = true;
0347 bar_offset = 0.25F;
0348 bar_width = 0.5F;
0349 editable = false;
0350 pickable = false;
0351 automated = true;
0352 options = "";
0353 color_mapping = "";
0354 enforced = false;
0355 translation = vec3f(0,0,0);
0356 coloring = "";
0357 title = "";
0358 }
0359
0360 bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s) {
0361 style_parser sp;
0362
0363 sp.color(color.value());
0364 sp.highlight_color(highlight_color.value());
0365 sp.back_color(back_color.value());
0366 sp.line_width(line_width.value());
0367 sp.marker_size(marker_size.value());
0368 sp.point_size(point_size.value());
0369 sp.font_size(font_size.value());
0370 sp.font_modeling(font_modeling.value());
0371 sp.front_face(front_face.value());
0372 sp.line_pattern(line_pattern.value());
0373 sp.marker_style(marker_style.value());
0374 sp.area_style(area_style.value());
0375 sp.modeling(modeling.value());
0376 sp.light_model(light_model.value());
0377 sp.tick_modeling(tick_modeling.value());
0378 sp.encoding(encoding.value());
0379 sp.smoothing(smoothing.value());
0380 sp.hinting(hinting.value());
0381 sp.cut(cut.value());
0382 sp.painting(painting.value());
0383 sp.hatching(hatching.value());
0384 sp.projection(projection.value());
0385 sp.font(font.value());
0386 sp.multi_node_limit(multi_node_limit.value());
0387 sp.divisions(divisions.value());
0388 sp.rotation_steps(rotation_steps.value());
0389 //sp.transparency(transparency.value());
0390 //sp.back_transparency(back_transparency.value());
0391 sp.spacing(spacing.value());
0392 sp.angle(angle.value());
0393 sp.scale(scale.value());
0394 sp.offset(offset.value());
0395 sp.strip_width(strip_width.value());
0396 sp.visible(visible.value());
0397 sp.bar_offset(bar_offset.value());
0398 sp.bar_width(bar_width.value());
0399 sp.editable(editable.value());
0400 sp.pickable(pickable.value());
0401 sp.automated(automated.value());
0402 sp.options(options.value());
0403 sp.color_mapping(color_mapping.value());
0404 sp.enforced(enforced.value());
0405 sp.translation(translation.value());
0406 sp.coloring(coloring.value());
0407 sp.title(title.value());
0408
0409 //if(!sp.parse(a_s,style_parser::def_error_func))
0410 // return false;
0411
0412 if(!sp.parse(a_out,a_cmaps,a_s)) {
0413 a_out << "tools::sg::style::from_string :"
0414 << " parse failed."
0415 << std::endl;
0416 return false;
0417 }
0418
0419 color.value(sp.color());
0420 highlight_color.value(sp.highlight_color());
0421 back_color.value(sp.back_color());
0422 line_width.value(sp.line_width());
0423 marker_size.value(sp.marker_size());
0424 point_size.value(sp.point_size());
0425 font_size.value(sp.font_size());
0426 font_modeling.value(sp.font_modeling());
0427 front_face = sp.front_face();
0428 line_pattern.value(sp.line_pattern());
0429 marker_style.value(sp.marker_style());
0430 area_style.value(sp.area_style());
0431 modeling.value(sp.modeling());
0432 light_model.value(sp.light_model());
0433 tick_modeling.value(sp.tick_modeling());
0434 encoding.value(sp.encoding());
0435 smoothing.value(sp.smoothing());
0436 hinting.value(sp.hinting());
0437 cut.value(sp.cut());
0438 painting.value(sp.painting());
0439 hatching.value(sp.hatching());
0440 projection.value(sp.projection());
0441 font.value(sp.font());
0442 multi_node_limit.value(sp.multi_node_limit());
0443 divisions.value(sp.divisions());
0444 rotation_steps.value(sp.rotation_steps());
0445 //transparency.value(sp.transparency());
0446 //back_transparency.value(sp.back_transparency());
0447 spacing.value(sp.spacing());
0448 angle.value(sp.angle());
0449 scale.value(sp.scale());
0450 offset.value(sp.offset());
0451 strip_width.value(sp.strip_width());
0452 visible.value(sp.visible());
0453 bar_offset.value(sp.bar_offset());
0454 bar_width.value(sp.bar_width());
0455 editable.value(sp.editable());
0456 pickable.value(sp.pickable());
0457 automated.value(sp.automated());
0458 options.value(sp.options());
0459 color_mapping.value(sp.color_mapping());
0460 enforced.value(sp.enforced());
0461 translation.value(sp.translation());
0462 coloring.value(sp.coloring());
0463 title.value(sp.title());
0464
0465 return true;
0466 }
0467
0468 };
0469
0470 }}
0471
0472 #endif