inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/sg/line_style
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_sg_line_style
00005 #define inlib_sg_line_style
00006 
00007 #include "../vec3f"
00008 
00009 #include "sfs"
00010 #include "node"
00011 #include "styles"
00012 #include "enums"
00013 #include "style_parser"
00014 
00015 namespace inlib {
00016 namespace sg {
00017 
00018 class line_style : public node {
00019   static const std::string& s_class() {
00020     static const std::string s_v("inlib::sg::line_style");
00021     return s_v;
00022   }
00023 public:
00024   sf<bool> visible;
00025   sf_vec<colorf,float> color;
00026   sf<float> transparency;
00027   sf<float> width;
00028   sf<lpat> pattern;
00029 private:
00030   void add_fields(){
00031     add_field(&visible);
00032     add_field(&color);
00033     add_field(&transparency);
00034     add_field(&width);
00035     add_field(&pattern);
00036   }
00037 public: //actions
00038   virtual node* copy() const {return new line_style(*this);}
00039   virtual const std::string& s_cls() const {return s_class();}
00040 public:
00041   line_style()
00042   :node()
00043   ,visible(true)
00044   ,color(colorf::black())
00045   ,transparency(0)
00046   ,width(1)
00047   ,pattern(line_solid)
00048   {
00049     add_fields();
00050   }
00051   virtual ~line_style(){}
00052 public:
00053   line_style(const line_style& a_from)
00054   :node(a_from)
00055   ,visible(a_from.visible)
00056   ,color(a_from.color)
00057   ,transparency(a_from.transparency)
00058   ,width(a_from.width)
00059   ,pattern(a_from.pattern)
00060   {
00061     add_fields();
00062   }
00063   line_style& operator=(const line_style& a_from){
00064     node::operator=(a_from);
00065 
00066     visible = a_from.visible;
00067     color = a_from.color;
00068     transparency = a_from.transparency;
00069     width = a_from.width;
00070     pattern = a_from.pattern;
00071     return *this;
00072   }
00073 public:
00074   bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,
00075                           const std::string& a_s){
00076     style_parser sp;
00077 
00078     sp.visible(visible.value());
00079     sp.color(color.value());
00080     sp.transparency(transparency.value());
00081     sp.line_width(width.value());
00082     sp.line_pattern(pattern.value());
00083 
00084     if(!sp.parse(a_out,a_cmaps,a_s)) {
00085       a_out << "inlib::sg::line_style::from_string :"
00086             << " parse failed."
00087             << std::endl;
00088       return false;    
00089     }
00090 
00091     visible.value(sp.visible());
00092     color.value(sp.color());
00093     transparency.value(sp.transparency());
00094     width.value(sp.line_width());
00095     pattern.value(sp.line_pattern());
00096 
00097     return true;
00098   }
00099 
00100 };
00101 
00102 }}
00103 
00104 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines