g4tools  5.4.0
line_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_line_style
5 #define tools_sg_line_style
6 
7 #include "../lina/vec3f"
8 
9 #include "sf_vec"
10 #include "node"
11 #include "enums"
12 #include "style_parser"
13 
14 namespace tools {
15 namespace sg {
16 
17 class line_style : public node {
19 public:
24 public:
25  virtual const desc_fields& node_desc_fields() const {
27  static const desc_fields s_v(parent::node_desc_fields(),4, //WARNING : take care of count.
32  );
33  return s_v;
34  }
35 private:
36  void add_fields(){
38  add_field(&color);
39  add_field(&width);
41  }
42 public:
44  :parent()
45  ,visible(true)
46  ,color(colorf_black())
47  ,width(1)
49  {
50  add_fields();
51  }
52  virtual ~line_style(){}
53 public:
54  line_style(const line_style& a_from)
55  :parent(a_from)
56  ,visible(a_from.visible)
57  ,color(a_from.color)
58  ,width(a_from.width)
59  ,pattern(a_from.pattern)
60  {
61  add_fields();
62  }
63  line_style& operator=(const line_style& a_from){
64  parent::operator=(a_from);
65 
66  visible = a_from.visible;
67  color = a_from.color;
68  width = a_from.width;
69  pattern = a_from.pattern;
70  return *this;
71  }
72 public:
73  bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s){
74  style_parser sp;
75 
76  sp.visible(visible.value());
77  sp.color(color.value());
78  //sp.transparency(transparency.value());
79  sp.width(width.value());
80  sp.pattern(pattern.value());
81 
82  if(!sp.parse(a_out,a_cmaps,a_s)) {
83  a_out << "tools::sg::line_style::from_string :"
84  << " parse failed."
85  << std::endl;
86  return false;
87  }
88 
89  visible.value(sp.visible());
90  color.value(sp.color());
91  //transparency.value(sp.transparency());
92  width.value(sp.width());
93  pattern.value(sp.pattern());
94 
95  return true;
96  }
97 
98 };
99 
100 }}
101 
102 #endif
tools::sg::line_style
Definition: line_style:17
node
tools::sg::line_style::line_style
line_style()
Definition: line_style:43
style_parser
tools::sg::line_style::pattern
sf< lpat > pattern
Definition: line_style:23
tools::sg::line_style::color
sf_vec< colorf, float > color
Definition: line_style:21
tools::sg::line_style::width
sf< float > width
Definition: line_style:22
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::node
Definition: node:28
TOOLS_NODE
#define TOOLS_NODE(a__class, a__sclass, a__parent)
Definition: node:324
tools::sg::style_parser::color
void color(const colorf &a_v)
Definition: style_parser:479
tools::sg::desc_fields
Definition: field_desc:148
tools::sg::color
Definition: color:16
tools::sg::line_style::visible
sf< bool > visible
Definition: line_style:20
tools::sg::sf_vec
Definition: sf_vec:15
tools::sg::cmaps_t
std::map< std::string, style_colormap > cmaps_t
Definition: style_colormap:536
tools::sg::style_parser
Definition: style_parser:20
tools::sg::line_style::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: line_style:25
sf_vec
tools::sg::line_style::~line_style
virtual ~line_style()
Definition: line_style:52
tools::sg::line_style::from_string
bool from_string(std::ostream &a_out, const cmaps_t &a_cmaps, const std::string &a_s)
Definition: line_style:73
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::style_parser::pattern
void pattern(lpat a_v)
Definition: style_parser:542
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
enums
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::line_style::operator=
line_style & operator=(const line_style &a_from)
Definition: line_style:63
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::style_parser::width
void width(float a_v)
Definition: style_parser:488
tools::sg::line_style::line_style
line_style(const line_style &a_from)
Definition: line_style:54
tools::sg::sf< bool >
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71