Warning, /include/Geant4/tools/sg/line_style is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_line_style
0005 #define tools_sg_line_style
0006
0007 #include "../lina/vec3f"
0008
0009 #include "sf_vec"
0010 #include "node"
0011 #include "enums"
0012 #include "style_parser"
0013
0014 namespace tools {
0015 namespace sg {
0016
0017 class line_style : public node {
0018 TOOLS_NODE(line_style,tools::sg::line_style,node)
0019 public:
0020 sf<bool> visible;
0021 sf_vec<colorf,float> color;
0022 sf<float> width;
0023 sf<lpat> pattern;
0024 public:
0025 virtual const desc_fields& node_desc_fields() const {
0026 TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::line_style)
0027 static const desc_fields s_v(parent::node_desc_fields(),4, //WARNING : take care of count.
0028 TOOLS_ARG_FIELD_DESC(visible),
0029 TOOLS_ARG_FIELD_DESC(color),
0030 TOOLS_ARG_FIELD_DESC(width),
0031 TOOLS_ARG_FIELD_DESC(pattern)
0032 );
0033 return s_v;
0034 }
0035 private:
0036 void add_fields(){
0037 add_field(&visible);
0038 add_field(&color);
0039 add_field(&width);
0040 add_field(&pattern);
0041 }
0042 public:
0043 line_style()
0044 :parent()
0045 ,visible(true)
0046 ,color(colorf_black())
0047 ,width(1)
0048 ,pattern(line_solid)
0049 {
0050 add_fields();
0051 }
0052 virtual ~line_style(){}
0053 public:
0054 line_style(const line_style& a_from)
0055 :parent(a_from)
0056 ,visible(a_from.visible)
0057 ,color(a_from.color)
0058 ,width(a_from.width)
0059 ,pattern(a_from.pattern)
0060 {
0061 add_fields();
0062 }
0063 line_style& operator=(const line_style& a_from){
0064 parent::operator=(a_from);
0065
0066 visible = a_from.visible;
0067 color = a_from.color;
0068 width = a_from.width;
0069 pattern = a_from.pattern;
0070 return *this;
0071 }
0072 public:
0073 bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s){
0074 style_parser sp;
0075
0076 sp.visible(visible.value());
0077 sp.color(color.value());
0078 //sp.transparency(transparency.value());
0079 sp.width(width.value());
0080 sp.pattern(pattern.value());
0081
0082 if(!sp.parse(a_out,a_cmaps,a_s)) {
0083 a_out << "tools::sg::line_style::from_string :"
0084 << " parse failed."
0085 << std::endl;
0086 return false;
0087 }
0088
0089 visible.value(sp.visible());
0090 color.value(sp.color());
0091 //transparency.value(sp.transparency());
0092 width.value(sp.width());
0093 pattern.value(sp.pattern());
0094
0095 return true;
0096 }
0097
0098 };
0099
0100 }}
0101
0102 #endif