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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 {
 18   TOOLS_NODE(line_style,tools::sg::line_style,node)
 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() const {
 26     TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::line_style)
 27     static const desc_fields s_v(parent::node_desc_fields(),4, //WARNING : take care of count.
 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_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