Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 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 { 18 TOOLS_NODE(line_style,tools::sg::line_style, 19 public: 20 sf<bool> visible; 21 sf_vec<colorf,float> color; 22 sf<float> width; 23 sf<lpat> pattern; 24 public: 25 virtual const desc_fields& node_desc_fields( 26 TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::lin 27 static const desc_fields s_v(parent::node_ 28 TOOLS_ARG_FIELD_DESC(visible), 29 TOOLS_ARG_FIELD_DESC(color), 30 TOOLS_ARG_FIELD_DESC(width), 31 TOOLS_ARG_FIELD_DESC(pattern) 32 ); 33 return s_v; 34 } 35 private: 36 void add_fields(){ 37 add_field(&visible); 38 add_field(&color); 39 add_field(&width); 40 add_field(&pattern); 41 } 42 public: 43 line_style() 44 :parent() 45 ,visible(true) 46 ,color(colorf_black()) 47 ,width(1) 48 ,pattern(line_solid) 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_fr 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 c 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_st 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