g4tools  5.4.0
style
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_style
5 #define tools_sg_style
6 
7 // fields of style_parser but put as sf on a node.
8 
9 #include "node"
10 
11 #include "style_parser"
12 #include "sf_string"
13 #include "sf_vec3f"
14 #include "sf_enum"
15 
16 namespace tools {
17 namespace sg {
18 
19 class style : public node {
21 public:
65 public:
66  virtual const desc_fields& node_desc_fields() const {
68  static const desc_fields s_v(parent::node_desc_fields(),43, //WARNING : take care of count.
79 
90 
101 
112 
116  );
117  return s_v;
118  }
119 private:
120  void add_fields(){
121  add_field(&color);
138  add_field(&hinting);
139  add_field(&cut);
143  add_field(&font);
147  add_field(&spacing);
148  add_field(&angle);
149  add_field(&scale);
150  add_field(&offset);
152  add_field(&visible);
158  add_field(&options);
163  add_field(&title);
164  }
165 public:
167  :parent()
168  ,color(colorf_black())
169  ,highlight_color(colorf_black())
170  ,back_color(colorf_white())
171  ,line_width(1)
172  ,marker_size(1)
173  ,point_size(1)
174  ,font_size(10)
184  ,smoothing(false)
185  ,hinting(false)
186  ,cut()
190  ,font(font_hershey())
191  ,multi_node_limit(style_parser::no_limit())
192  ,divisions(510) //Same as ROOT/TAttAxis
193  ,rotation_steps(24) //Same as SbPolyhedron default.
194  ,spacing(0.05F)
195  ,angle(fpi()/4.0F)
196  ,scale(1)
197  ,offset(0)
198  ,strip_width(0)
199  ,visible(true)
200  ,bar_offset(0.25F)
201  ,bar_width(0.5F)
202  ,editable(false)
203  ,pickable(false)
204  ,automated(true)
205  ,options()
206  ,color_mapping()
207  ,enforced(false)
208  ,translation(vec3f(0,0,0))
209  ,coloring()
210  ,title()
211  {
212  add_fields();
213  }
214  virtual ~style(){}
215 public:
216  style(const style& a_from)
217  :parent(a_from)
218  ,color(a_from.color)
220  ,back_color(a_from.back_color)
221  ,line_width(a_from.line_width)
222  ,marker_size(a_from.marker_size)
223  ,point_size(a_from.point_size)
224  ,font_size(a_from.font_size)
226  ,front_face(a_from.front_face)
227  ,line_pattern(a_from.line_pattern)
228  ,marker_style(a_from.marker_style)
229  ,area_style(a_from.area_style)
230  ,modeling (a_from.modeling )
231  ,light_model(a_from.light_model)
233  ,encoding(a_from.encoding)
234  ,smoothing(a_from.smoothing)
235  ,hinting(a_from.hinting)
236  ,cut(a_from.cut)
237  ,painting(a_from.painting)
238  ,hatching(a_from.hatching)
239  ,projection(a_from.projection)
240  ,font(a_from.font)
242  ,divisions(a_from.divisions)
244  ,spacing(a_from.spacing)
245  ,angle(a_from.angle)
246  ,scale(a_from.scale)
247  ,offset(a_from.offset)
248  ,strip_width(a_from.strip_width)
249  ,visible(a_from.visible)
250  ,bar_offset(a_from.bar_offset)
251  ,bar_width(a_from.bar_width)
252  ,editable(a_from.editable)
253  ,pickable(a_from.pickable)
254  ,automated(a_from.automated)
255  ,options(a_from.options)
257  ,enforced(a_from.enforced)
258  ,translation(a_from.translation)
259  ,coloring(a_from.coloring)
260  ,title(a_from.title)
261  {
262  add_fields();
263  }
264  style& operator=(const style& a_from){
265  parent::operator=(a_from);
266 
267  color = a_from.color;
269  back_color = a_from.back_color;
270  line_width = a_from.line_width;
271  marker_size = a_from.marker_size;
272  point_size = a_from.point_size;
273  font_size = a_from.font_size;
274  font_modeling = a_from.font_modeling;
275  front_face = a_from.front_face;
276  line_pattern = a_from.line_pattern;
277  marker_style = a_from.marker_style;
278  area_style = a_from.area_style;
279  modeling = a_from.modeling ;
280  light_model = a_from.light_model;
281  tick_modeling = a_from.tick_modeling;
282  encoding = a_from.encoding;
283  smoothing = a_from.smoothing;
284  hinting = a_from.hinting;
285  cut = a_from.cut;
286  painting = a_from.painting;
287  hatching = a_from.hatching;
288  projection = a_from.projection;
289  font = a_from.font;
291  divisions = a_from.divisions;
293  spacing = a_from.spacing;
294  angle = a_from.angle;
295  scale = a_from.scale;
296  offset = a_from.offset;
297  strip_width = a_from.strip_width;
298  visible = a_from.visible;
299  bar_offset = a_from.bar_offset;
300  bar_width = a_from.bar_width;
301  editable = a_from.editable;
302  pickable = a_from.pickable;
303  automated = a_from.automated;
304  options = a_from.options;
305  color_mapping = a_from.color_mapping;
306  enforced = a_from.enforced;
307  translation = a_from.translation;
308  coloring = a_from.coloring;
309  title = a_from.title;
310 
311  return *this;
312  }
313 public:
314  void reset() {
315  color = colorf_black();
316  highlight_color = colorf_black();
317  back_color = colorf_white();
318  line_width = 1;
319  marker_size = 1;
320  point_size = 1;
321  font_size = 10;
331  smoothing = false;
332  hinting = false;
333  cut = "";
337  font = font_hershey();
339  divisions = 510;
340  rotation_steps = 24;
341  spacing = 0.05F;
342  angle = fpi()/4.0F;
343  scale = 1;
344  offset = 0;
345  strip_width = 0;
346  visible = true;
347  bar_offset = 0.25F;
348  bar_width = 0.5F;
349  editable = false;
350  pickable = false;
351  automated = true;
352  options = "";
353  color_mapping = "";
354  enforced = false;
355  translation = vec3f(0,0,0);
356  coloring = "";
357  title = "";
358  }
359 
360  bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s) {
361  style_parser sp;
362 
363  sp.color(color.value());
364  sp.highlight_color(highlight_color.value());
365  sp.back_color(back_color.value());
369  sp.font_size(font_size.value());
370  sp.font_modeling(font_modeling.value());
372  sp.line_pattern(line_pattern.value());
373  sp.marker_style(marker_style.value());
374  sp.area_style(area_style.value());
375  sp.modeling(modeling.value());
378  sp.encoding(encoding.value());
379  sp.smoothing(smoothing.value());
380  sp.hinting(hinting.value());
381  sp.cut(cut.value());
382  sp.painting(painting.value());
383  sp.hatching(hatching.value());
385  sp.font(font.value());
387  sp.divisions(divisions.value());
389  //sp.transparency(transparency.value());
390  //sp.back_transparency(back_transparency.value());
391  sp.spacing(spacing.value());
392  sp.angle(angle.value());
393  sp.scale(scale.value());
394  sp.offset(offset.value());
396  sp.visible(visible.value());
398  sp.bar_width(bar_width.value());
399  sp.editable(editable.value());
400  sp.pickable(pickable.value());
401  sp.automated(automated.value());
402  sp.options(options.value());
404  sp.enforced(enforced.value());
406  sp.coloring(coloring.value());
407  sp.title(title.value());
408 
409  //if(!sp.parse(a_s,style_parser::def_error_func))
410  // return false;
411 
412  if(!sp.parse(a_out,a_cmaps,a_s)) {
413  a_out << "tools::sg::style::from_string :"
414  << " parse failed."
415  << std::endl;
416  return false;
417  }
418 
419  color.value(sp.color());
420  highlight_color.value(sp.highlight_color());
421  back_color.value(sp.back_color());
425  font_size.value(sp.font_size());
426  font_modeling.value(sp.font_modeling());
427  front_face = sp.front_face();
428  line_pattern.value(sp.line_pattern());
429  marker_style.value(sp.marker_style());
430  area_style.value(sp.area_style());
431  modeling.value(sp.modeling());
434  encoding.value(sp.encoding());
435  smoothing.value(sp.smoothing());
436  hinting.value(sp.hinting());
437  cut.value(sp.cut());
438  painting.value(sp.painting());
439  hatching.value(sp.hatching());
441  font.value(sp.font());
443  divisions.value(sp.divisions());
445  //transparency.value(sp.transparency());
446  //back_transparency.value(sp.back_transparency());
447  spacing.value(sp.spacing());
448  angle.value(sp.angle());
449  scale.value(sp.scale());
450  offset.value(sp.offset());
452  visible.value(sp.visible());
454  bar_width.value(sp.bar_width());
455  editable.value(sp.editable());
456  pickable.value(sp.pickable());
457  automated.value(sp.automated());
458  options.value(sp.options());
460  enforced.value(sp.enforced());
462  coloring.value(sp.coloring());
463  title.value(sp.title());
464 
465  return true;
466  }
467 
468 };
469 
470 }}
471 
472 #endif
tools::sg::style_parser::no_limit
static int no_limit()
Definition: style_parser:146
tools::sg::style_parser::marker_size
void marker_size(float a_v)
Definition: style_parser:500
tools::sg::area_style
area_style
Definition: enums:42
tools::sg::style::strip_width
sf< float > strip_width
Definition: style:52
tools::sg::style::visible
sf< bool > visible
Definition: style:53
tools::sg::style_parser::automated
void automated(bool a_v)
Definition: style_parser:587
node
tools::sg::style_parser::color_mapping
void color_mapping(const std::string &a_v)
Definition: style_parser:596
tools::sg::style_parser::point_size
void point_size(float a_v)
Definition: style_parser:503
tools::sg::style::smoothing
sf< bool > smoothing
Definition: style:38
tools::sg::light_model_phong
const std::string & light_model_phong()
Definition: strings:178
tools::sg::style_parser::cut
void cut(const std::string &a_v)
Definition: style_parser:590
tools::sg::modeling_boxes
const std::string & modeling_boxes()
Definition: strings:64
tools::sg::style_parser::scale
void scale(float a_v)
Definition: style_parser:566
tools::sg::style_parser::bar_offset
void bar_offset(float a_v)
Definition: style_parser:569
style_parser
tools::sg::style::painting
sf_enum< sg::painting_policy > painting
Definition: style:41
tools::sg::line_pattern
line_pattern
Definition: enums:10
tools::sg::style::light_model
sf_string light_model
Definition: style:35
tools::sg::winding_ccw
@ winding_ccw
Definition: enums:105
tools::sg::style::translation
sf_vec3f translation
Definition: style:62
tools::sg::style_parser::bar_width
void bar_width(float a_v)
Definition: style_parser:572
tools::sg::projection_none
@ projection_none
Definition: enums:50
tools::sg::style::color
sf_vec< colorf, float > color
Definition: style:22
tools::sg::style::automated
sf< bool > automated
Definition: style:58
tools::sg::style_parser::font
void font(const std::string &a_v)
Definition: style_parser:548
tools::sg::style::area_style
sf_enum< sg::area_style > area_style
Definition: style:33
tools::sg::style::highlight_color
sf_vec< colorf, float > highlight_color
Definition: style:23
tools::sg::style::projection
sf_enum< sg::projection_type > projection
Definition: style:43
tools::sg::style_parser::front_face
void front_face(winding_type a_v)
Definition: style_parser:605
tools::sg::style_parser::parse
bool parse(std::ostream &a_out, const cmaps_t &a_cmaps, const std::string &a_s)
Definition: style_parser:624
tools::sg::marker_style
marker_style
Definition: enums:17
tools::sg::style::style
style()
Definition: style:166
tools::sg::style::pickable
sf< bool > pickable
Definition: style:57
tools::sg::style::enforced
sf< bool > enforced
Definition: style:61
tools::sg::style::from_string
bool from_string(std::ostream &a_out, const cmaps_t &a_cmaps, const std::string &a_s)
Definition: style:360
tools::sg::style_parser::strip_width
void strip_width(float a_v)
Definition: style_parser:560
tools::sg::node
Definition: node:28
TOOLS_NODE
#define TOOLS_NODE(a__class, a__sclass, a__parent)
Definition: node:324
tools::sg::style_parser::marker_style
void marker_style(sg::marker_style a_v)
Definition: style_parser:497
tools::sg::style::multi_node_limit
sf< int > multi_node_limit
Definition: style:45
tools::sg::sf_vec3f
Definition: sf_vec3f:14
tools::sg::style::encoding
sf_string encoding
Definition: style:37
tools::sg::style_parser::color
void color(const colorf &a_v)
Definition: style_parser:479
tools::sg::style::style
style(const style &a_from)
Definition: style:216
tools::sg::style_parser::back_color
void back_color(const colorf &a_v)
Definition: style_parser:485
sf_string
tools::fpi
float fpi()
Definition: mathf:11
tools::sg::marker_dot
@ marker_dot
Definition: enums:18
tools::sg::style::font_size
sf< float > font_size
Definition: style:28
tools::sg::style_parser::offset
void offset(float a_v)
Definition: style_parser:557
tools::sg::style::offset
sf< float > offset
Definition: style:51
tools::sg::desc_fields
Definition: field_desc:148
tools::sg::style_parser::title
void title(const std::string &a_v)
Definition: style_parser:617
tools::sg::color
Definition: color:16
tools::sg::style_parser::rotation_steps
void rotation_steps(unsigned int a_v)
Definition: style_parser:554
tools::sg::style_parser::painting
sg::painting_policy painting() const
Definition: style_parser:533
tools::sg::style::bar_width
sf< float > bar_width
Definition: style:55
tools::sg::style::back_color
sf_vec< colorf, float > back_color
Definition: style:24
tools::sg::style::rotation_steps
sf< unsigned int > rotation_steps
Definition: style:47
tools::sg::tick_modeling_hippo
const std::string & tick_modeling_hippo()
Definition: strings:19
tools::sg::style::marker_size
sf< float > marker_size
Definition: style:26
tools::sg::sf_vec
Definition: sf_vec:15
sf_vec3f
tools::sg::style_parser::font_modeling
void font_modeling(sg::font_modeling a_v)
Definition: style_parser:509
tools::sg::style::line_pattern
sf< lpat > line_pattern
Definition: style:31
tools::sg::cmaps_t
std::map< std::string, style_colormap > cmaps_t
Definition: style_colormap:536
tools::sg::style
Definition: style:19
tools::sg::style_parser::highlight_color
void highlight_color(const colorf &a_v)
Definition: style_parser:482
tools::sg::sf_enum< sg::font_modeling >
tools::sg::style_parser::tick_modeling
void tick_modeling(const std::string &a_v)
Definition: style_parser:521
tools::sg::font_modeling
font_modeling
Definition: enums:91
tools::sg::style_parser
Definition: style_parser:20
tools::sg::style_parser::encoding
void encoding(const std::string &a_v)
Definition: style_parser:524
tools::sg::encoding_none
const std::string & encoding_none()
Definition: strings:38
tools::sg::style::hinting
sf< bool > hinting
Definition: style:39
tools::sg::style_parser::smoothing
void smoothing(bool a_v)
Definition: style_parser:527
tools::sg::style::operator=
style & operator=(const style &a_from)
Definition: style:264
tools::vec3f
Definition: vec3f:13
tools::sg::style::options
sf_string options
Definition: style:59
tools::sg::style_parser::hatching
sg::hatching_policy hatching() const
Definition: style_parser:536
tools::sg::style_parser::spacing
void spacing(float a_v)
Definition: style_parser:578
tools::sg::style::modeling
sf_string modeling
Definition: style:34
tools::sg::style::~style
virtual ~style()
Definition: style:214
tools::sg::style::marker_style
sf_enum< sg::marker_style > marker_style
Definition: style:32
tools::sg::hatching_none
@ hatching_none
Definition: enums:67
tools::sg::style_parser::font_size
void font_size(float a_v)
Definition: style_parser:506
sf_enum
tools::sg::style::editable
sf< bool > editable
Definition: style:56
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::style::color_mapping
sf_string color_mapping
Definition: style:60
tools::sg::painting_uniform
@ painting_uniform
Definition: enums:58
tools::sg::style::bar_offset
sf< float > bar_offset
Definition: style:54
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
tools::sg::style_parser::projection
sg::projection_type projection() const
Definition: style_parser:539
tools::sg::style::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: style:66
tools::sg::style::cut
sf_string cut
Definition: style:40
tools::sg::style::divisions
sf< int > divisions
Definition: style:46
tools::sg::style::front_face
sf_enum< winding_type > front_face
Definition: style:30
tools::sg::area_solid
@ area_solid
Definition: enums:43
tools::sg::style::angle
sf< float > angle
Definition: style:49
tools::sg::style_parser::line_width
void line_width(float a_v)
Definition: style_parser:491
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::line_solid
@ line_solid
Definition: enums:11
tools::sg::style_parser::visible
void visible(bool a_v)
Definition: style_parser:581
tools::sg::style_parser::angle
void angle(float a_v)
Definition: style_parser:563
tools::sg::sf_string
Definition: sf_string:15
tools::sg::style_parser::editable
void editable(bool a_v)
Definition: style_parser:584
tools::sg::style::line_width
sf< float > line_width
Definition: style:25
tools::sg::style_parser::light_model
void light_model(const std::string &a_v)
Definition: style_parser:518
tools::sg::style::scale
sf< float > scale
Definition: style:50
tools::sg::style_parser::translation
void translation(const vec3f &a_v)
Definition: style_parser:602
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::style::coloring
sf_string coloring
Definition: style:63
tools::sg::style::reset
void reset()
Definition: style:314
tools::sg::style::title
sf_string title
Definition: style:64
tools::sg::font_hershey
const std::string & font_hershey()
Definition: strings:186
tools::sg::style_parser::modeling
void modeling(const std::string &a_v)
Definition: style_parser:515
tools::sg::style_parser::multi_node_limit
void multi_node_limit(int a_v)
Definition: style_parser:575
tools::sg::font_filled
@ font_filled
Definition: enums:93
tools::sg::style_parser::enforced
void enforced(bool a_v)
Definition: style_parser:599
tools::sg::style::hatching
sf_enum< sg::hatching_policy > hatching
Definition: style:42
tools::sg::style_parser::options
void options(const std::string &a_v)
Definition: style_parser:593
tools::sg::style::font
sf_string font
Definition: style:44
tools::sg::style::point_size
sf< float > point_size
Definition: style:27
tools::sg::style::tick_modeling
sf_string tick_modeling
Definition: style:36
tools::sg::style_parser::line_pattern
void line_pattern(lpat a_v)
Definition: style_parser:545
tools::sg::style::font_modeling
sf_enum< sg::font_modeling > font_modeling
Definition: style:29
tools::sg::style_parser::pickable
void pickable(bool a_v)
Definition: style_parser:620
tools::sg::sf< float >
tools::sg::style_parser::area_style
void area_style(sg::area_style a_v)
Definition: style_parser:512
tools::sg::style_parser::coloring
void coloring(const std::string &a_v)
Definition: style_parser:614
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::style_parser::hinting
void hinting(bool a_v)
Definition: style_parser:530
tools::sg::style::spacing
sf< float > spacing
Definition: style:48
tools::sg::style_parser::divisions
void divisions(int a_v)
Definition: style_parser:551