inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/sg/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_style
00005 #define inlib_sg_style
00006 
00007 // fields of style_parser but put as sf on a node.
00008 
00009 // inheritance :
00010 #include "node"
00011 
00012 #include "style_parser"
00013 #include "sfs"
00014 
00015 namespace inlib {
00016 namespace sg {
00017 
00018 class style : public node {
00019   static const std::string& s_class() {
00020     static const std::string s_v("inlib::sg::style");
00021     return s_v;
00022   }
00023 public:
00024   sf_vec<colorf,float> color;
00025   sf_vec<colorf,float> highlight_color;
00026   sf_vec<colorf,float> back_color;
00027   sf<float> line_width;
00028   sf<float> marker_size;
00029   sf<float> font_size;
00030   sf<lpat> line_pattern;
00031   sf_enum<sg::marker_style> marker_style;
00032   sf_enum<sg::area_style> area_style;
00033   sf_string modeling; 
00034   sf_string light_model; 
00035   sf_string tick_modeling; 
00036   sf_string encoding; 
00037   sf<bool> smoothing;
00038   sf<bool> hinting;
00039   sf_string cut;
00040   sf_enum<sg::painting_policy> painting;
00041   sf_enum<sg::hatching_policy> hatching;
00042   sf_enum<sg::projection_type> projection;
00043   sf_string font;
00044   sf<int> multi_node_limit;
00045   sf<int> divisions;
00046   sf<unsigned int> rotation_steps;
00047   sf<float> transparency;
00048   sf<float> back_transparency;
00049   sf<float> spacing;
00050   sf<float> angle;
00051   sf<float> scale;
00052   sf<float> offset;
00053   sf<float> strip_width;
00054   sf<bool> visible;
00055   sf<float> bar_offset;
00056   sf<float> bar_width;
00057   sf<bool> editable;
00058   sf<bool> automated;
00059   sf_string options;
00060   sf_string color_mapping;
00061   sf<bool> enforced;
00062   sf_vec<vec3f,float> translation;
00063 private:
00064   void add_fields(){
00065     add_field(&color);
00066     add_field(&highlight_color);
00067     add_field(&back_color);
00068     add_field(&line_width);
00069     add_field(&marker_size);
00070     add_field(&font_size);
00071     add_field(&line_pattern);
00072     add_field(&marker_style);
00073     add_field(&area_style);
00074     add_field(&modeling);
00075     add_field(&light_model); 
00076     add_field(&tick_modeling); 
00077     add_field(&encoding);
00078     add_field(&smoothing);
00079     add_field(&hinting);
00080     add_field(&cut);
00081     add_field(&painting);
00082     add_field(&hatching);
00083     add_field(&projection);
00084     add_field(&font);
00085     add_field(&multi_node_limit);
00086     add_field(&divisions);
00087     add_field(&rotation_steps);
00088     add_field(&transparency);
00089     add_field(&back_transparency);
00090     add_field(&spacing);
00091     add_field(&angle);
00092     add_field(&scale);
00093     add_field(&offset);
00094     add_field(&strip_width);
00095     add_field(&visible);
00096     add_field(&bar_offset);
00097     add_field(&bar_width);
00098     add_field(&editable);
00099     add_field(&automated);
00100     add_field(&options);
00101     add_field(&color_mapping);
00102     add_field(&enforced);
00103     add_field(&translation);
00104   }
00105 public: //actions
00106   virtual node* copy() const {return new style(*this);}
00107   virtual const std::string& s_cls() const {return s_class();}
00108 public:
00109   style()
00110   :node()
00111   ,color(colorf::black())
00112   ,highlight_color(colorf::black())
00113   ,back_color(colorf::white())
00114   ,line_width(1)
00115   ,marker_size(1)
00116   ,font_size(10)
00117   ,line_pattern(line_solid)
00118   ,marker_style(marker_dot)
00119   ,area_style(area_solid)
00120   ,modeling(modeling_boxes())
00121   ,light_model(light_model_phong())
00122   ,tick_modeling(tick_modeling_hippo())
00123   ,encoding(encoding_none())
00124   ,smoothing(false)
00125   ,hinting(false)
00126   ,cut("")
00127   ,painting(painting_uniform)
00128   ,hatching(hatching_none)
00129   ,projection(projection_none)
00130   ,font(font_hershey())
00131   ,multi_node_limit(style_parser::no_limit())
00132   ,divisions(510) //Same as ROOT/TAttAxis
00133   ,rotation_steps(24) //Same as SbPolyhedron default.
00134   ,transparency(0)
00135   ,back_transparency(0)
00136   ,spacing(0.05F)
00137   ,angle(fpi()/4.0F)
00138   ,scale(1)
00139   ,offset(0)
00140   ,strip_width(0)
00141   ,visible(true)
00142   ,bar_offset(0.25F)
00143   ,bar_width(0.5F)
00144   ,editable(false)
00145   ,automated(true)
00146   ,options("")
00147   ,color_mapping("")
00148   ,enforced(false)
00149   ,translation(vec3f(0,0,0))
00150   {
00151     add_fields();
00152   }
00153   virtual ~style(){}
00154 public:
00155   style(const style& a_from)
00156   :node(a_from)
00157   ,color(a_from.color)
00158   ,highlight_color(a_from.highlight_color)
00159   ,back_color(a_from.back_color)
00160   ,line_width(a_from.line_width)
00161   ,marker_size(a_from.marker_size)
00162   ,font_size(a_from.font_size)
00163   ,line_pattern(a_from.line_pattern)
00164   ,marker_style(a_from.marker_style)
00165   ,area_style(a_from.area_style)
00166   ,modeling (a_from.modeling )
00167   ,light_model(a_from.light_model)
00168   ,tick_modeling(a_from.tick_modeling)
00169   ,encoding(a_from.encoding)
00170   ,smoothing(a_from.smoothing)
00171   ,hinting(a_from.hinting)
00172   ,cut(a_from.cut)
00173   ,painting(a_from.painting)
00174   ,hatching(a_from.hatching)
00175   ,projection(a_from.projection)
00176   ,font(a_from.font)
00177   ,multi_node_limit(a_from.multi_node_limit)
00178   ,divisions(a_from.divisions)
00179   ,rotation_steps(a_from.rotation_steps)
00180   ,transparency(a_from.transparency)
00181   ,back_transparency(a_from.back_transparency)
00182   ,spacing(a_from.spacing)
00183   ,angle(a_from.angle)
00184   ,scale(a_from.scale)
00185   ,offset(a_from.offset)
00186   ,strip_width(a_from.strip_width)
00187   ,visible(a_from.visible)
00188   ,bar_offset(a_from.bar_offset)
00189   ,bar_width(a_from.bar_width)
00190   ,editable(a_from.editable)
00191   ,automated(a_from.automated)
00192   ,options(a_from.options)
00193   ,color_mapping(a_from.color_mapping)
00194   ,enforced(a_from.enforced)
00195   ,translation(a_from.translation)
00196   {
00197     add_fields();
00198   }
00199   style& operator=(const style& a_from){
00200     node::operator=(a_from);
00201 
00202     color = a_from.color;
00203     highlight_color = a_from.highlight_color;
00204     back_color = a_from.back_color;
00205     line_width = a_from.line_width;
00206     marker_size = a_from.marker_size;
00207     font_size = a_from.font_size;
00208     line_pattern = a_from.line_pattern;
00209     marker_style = a_from.marker_style;
00210     area_style = a_from.area_style;
00211     modeling  = a_from.modeling ;
00212     light_model = a_from.light_model;
00213     tick_modeling = a_from.tick_modeling;
00214     encoding = a_from.encoding;
00215     smoothing = a_from.smoothing;
00216     hinting = a_from.hinting;
00217     cut = a_from.cut;
00218     painting = a_from.painting;
00219     hatching = a_from.hatching;
00220     projection = a_from.projection;
00221     font = a_from.font;
00222     multi_node_limit = a_from.multi_node_limit;
00223     divisions = a_from.divisions;
00224     rotation_steps = a_from.rotation_steps;
00225     transparency = a_from.transparency;
00226     back_transparency = a_from.back_transparency;
00227     spacing = a_from.spacing;
00228     angle = a_from.angle;
00229     scale = a_from.scale;
00230     offset = a_from.offset;
00231     strip_width = a_from.strip_width;
00232     visible = a_from.visible;
00233     bar_offset = a_from.bar_offset;
00234     bar_width = a_from.bar_width;
00235     editable = a_from.editable;
00236     automated = a_from.automated;
00237     options = a_from.options;
00238     color_mapping = a_from.color_mapping;
00239     enforced = a_from.enforced;
00240     translation = a_from.translation;
00241 
00242     return *this;
00243   }
00244 public:
00245   bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,
00246                           const std::string& a_s){
00247     style_parser sp;
00248 
00249     sp.color(color.value());
00250     sp.highlight_color(highlight_color.value());
00251     sp.back_color(back_color.value());
00252     sp.line_width(line_width.value());
00253     sp.marker_size(marker_size.value());
00254     sp.font_size(font_size.value());
00255     sp.line_pattern(line_pattern.value());
00256     sp.marker_style(marker_style.value());
00257     sp.area_style(area_style.value());
00258     sp.modeling(modeling.value());
00259     sp.light_model(light_model.value());
00260     sp.tick_modeling(tick_modeling.value());
00261     sp.encoding(encoding.value());
00262     sp.smoothing(smoothing.value());
00263     sp.hinting(hinting.value());
00264     sp.cut(cut.value());
00265     sp.painting(painting.value());
00266     sp.hatching(hatching.value());
00267     sp.projection(projection.value());
00268     sp.font(font.value());
00269     sp.multi_node_limit(multi_node_limit.value());
00270     sp.divisions(divisions.value());
00271     sp.rotation_steps(rotation_steps.value());
00272     sp.transparency(transparency.value());
00273     sp.back_transparency(back_transparency.value());
00274     sp.spacing(spacing.value());
00275     sp.angle(angle.value());
00276     sp.scale(scale.value());
00277     sp.offset(offset.value());
00278     sp.strip_width(strip_width.value());
00279     sp.visible(visible.value());
00280     sp.bar_offset(bar_offset.value());
00281     sp.bar_width(bar_width.value());
00282     sp.editable(editable.value());
00283     sp.automated(automated.value());
00284     sp.options(options.value());
00285     sp.color_mapping(color_mapping.value());
00286     sp.enforced(enforced.value());
00287     sp.translation(translation.value());
00288 
00289     //if(!sp.parse(a_s,inlib::sg::style_parser::def_error_func)) 
00290     //  return false;
00291 
00292     if(!sp.parse(a_out,a_cmaps,a_s)) {
00293       a_out << "inlib::sg::style::from_string :"
00294             << " parse failed."
00295             << std::endl;
00296       return false;    
00297     }
00298 
00299     color.value(sp.color());
00300     highlight_color.value(sp.highlight_color());
00301     back_color.value(sp.back_color());
00302     line_width.value(sp.line_width());
00303     marker_size.value(sp.marker_size());
00304     font_size.value(sp.font_size());
00305     line_pattern.value(sp.line_pattern());
00306     marker_style.value(sp.marker_style());
00307     area_style.value(sp.area_style());
00308     modeling.value(sp.modeling());
00309     light_model.value(sp.light_model());
00310     tick_modeling.value(sp.tick_modeling());
00311     encoding.value(sp.encoding());
00312     smoothing.value(sp.smoothing());
00313     hinting.value(sp.hinting());
00314     cut.value(sp.cut());
00315     painting.value(sp.painting());
00316     hatching.value(sp.hatching());
00317     projection.value(sp.projection());
00318     font.value(sp.font());
00319     multi_node_limit.value(sp.multi_node_limit());
00320     divisions.value(sp.divisions());
00321     rotation_steps.value(sp.rotation_steps());
00322     transparency.value(sp.transparency());
00323     back_transparency.value(sp.back_transparency());
00324     spacing.value(sp.spacing());
00325     angle.value(sp.angle());
00326     scale.value(sp.scale());
00327     offset.value(sp.offset());
00328     strip_width.value(sp.strip_width());
00329     visible.value(sp.visible());
00330     bar_offset.value(sp.bar_offset());
00331     bar_width.value(sp.bar_width());
00332     editable.value(sp.editable());
00333     automated.value(sp.automated());
00334     options.value(sp.options());
00335     color_mapping.value(sp.color_mapping());
00336     enforced.value(sp.enforced());
00337     translation.value(sp.translation());
00338 
00339     return true;
00340   }
00341 
00342 };
00343 
00344 }}
00345 
00346 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines