Warning, /include/Geant4/tools/sg/text_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_text_style
0005 #define tools_sg_text_style
0006
0007 #include "../lina/vec3f"
0008
0009 #include "sf_vec3f"
0010 #include "sf_string"
0011 #include "sf_enum"
0012 #include "node"
0013 #include "enums"
0014 #include "style_parser"
0015
0016 namespace tools {
0017 namespace sg {
0018
0019 class text_style : public node {
0020 TOOLS_NODE(text_style,tools::sg::text_style,node)
0021 public:
0022 sf<bool> visible;
0023 sf_vec<colorf,float> color;
0024 sf_vec<colorf,float> back_color;
0025 sf<float> back_shadow;
0026
0027 sf_string modeling;
0028 sf_string font;
0029 sf<float> font_size;
0030 sf_enum<sg::font_modeling> font_modeling;
0031 sf_string encoding;
0032 sf<bool> smoothing;
0033 sf<bool> hinting;
0034 sf_enum<sg::hjust> hjust;
0035 sf_enum<sg::vjust> vjust;
0036 sf<float> scale;
0037 // For 3D text :
0038 sf_vec3f x_orientation;
0039 sf_vec3f y_orientation;
0040 // For bitmap text :
0041 sf<bool> rotated;
0042
0043 // for text_hershey :
0044 sf<float> line_width;
0045 sf<lpat> line_pattern;
0046 sf<bool> enforced;
0047 sf_vec3f translation;
0048
0049 // for text_freetype tessellation :
0050 sf_enum<winding_type> front_face;
0051
0052 sf_string options; //for gopaw.
0053 public:
0054 virtual const desc_fields& node_desc_fields() const {
0055 TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::text_style)
0056 static const desc_fields s_v(parent::node_desc_fields(),21, //WARNING : take care of count.
0057 TOOLS_ARG_FIELD_DESC(visible),
0058 TOOLS_ARG_FIELD_DESC(color),
0059
0060 TOOLS_ARG_FIELD_DESC(modeling),
0061 TOOLS_ARG_FIELD_DESC(font),
0062 TOOLS_ARG_FIELD_DESC(font_size),
0063 TOOLS_ARG_FIELD_DESC(font_modeling),
0064 TOOLS_ARG_FIELD_DESC(encoding),
0065 TOOLS_ARG_FIELD_DESC(smoothing),
0066 TOOLS_ARG_FIELD_DESC(hinting),
0067 TOOLS_ARG_FIELD_DESC(hjust),
0068 TOOLS_ARG_FIELD_DESC(vjust),
0069 TOOLS_ARG_FIELD_DESC(scale),
0070 TOOLS_ARG_FIELD_DESC(x_orientation),
0071 TOOLS_ARG_FIELD_DESC(y_orientation),
0072 TOOLS_ARG_FIELD_DESC(rotated),
0073
0074 TOOLS_ARG_FIELD_DESC(line_width),
0075 TOOLS_ARG_FIELD_DESC(line_pattern),
0076 TOOLS_ARG_FIELD_DESC(enforced),
0077 TOOLS_ARG_FIELD_DESC(translation),
0078
0079 TOOLS_ARG_FIELD_DESC(front_face),
0080 TOOLS_ARG_FIELD_DESC(options)
0081 );
0082 return s_v;
0083 }
0084 private:
0085 void add_fields(){
0086 add_field(&visible);
0087 add_field(&color);
0088
0089 add_field(&modeling);
0090 add_field(&font);
0091 add_field(&font_size);
0092 add_field(&font_modeling);
0093 add_field(&encoding);
0094 add_field(&smoothing);
0095 add_field(&hinting);
0096 add_field(&hjust);
0097 add_field(&vjust);
0098 add_field(&scale);
0099 add_field(&x_orientation);
0100 add_field(&y_orientation);
0101 add_field(&rotated);
0102
0103 add_field(&line_width);
0104 add_field(&line_pattern);
0105 add_field(&enforced);
0106 add_field(&translation);
0107
0108 add_field(&front_face);
0109 add_field(&options);
0110 }
0111 public:
0112 text_style()
0113 :parent()
0114 ,visible(true)
0115 ,color(colorf_black())
0116 ,back_color(colorf_white())
0117 ,back_shadow(0)
0118 ,modeling()
0119 ,font(font_hershey())
0120 ,font_size(10)
0121 ,font_modeling(font_filled)
0122 ,encoding(encoding_none())
0123 ,smoothing(false)
0124 ,hinting(false)
0125 ,hjust(left)
0126 ,vjust(bottom)
0127 ,scale(1)
0128 ,x_orientation(vec3f(1,0,0))
0129 ,y_orientation(vec3f(0,1,0))
0130 ,rotated(false)
0131 ,line_width(1)
0132 ,line_pattern(line_solid)
0133 ,enforced(false)
0134 ,translation(vec3f(0,0,0))
0135 ,front_face(winding_ccw)
0136 ,options("")
0137 {
0138 add_fields();
0139 }
0140 virtual ~text_style(){}
0141 public:
0142 text_style(const text_style& a_from)
0143 :parent(a_from),visible(a_from.visible)
0144 ,color(a_from.color)
0145 ,back_color(a_from.back_color)
0146 ,back_shadow(a_from.back_shadow)
0147 ,modeling(a_from.modeling)
0148 ,font(a_from.font)
0149 ,font_size(a_from.font_size)
0150 ,font_modeling(a_from.font_modeling)
0151 ,encoding(a_from.encoding)
0152 ,smoothing(a_from.smoothing)
0153 ,hinting(a_from.hinting)
0154 ,hjust(a_from.hjust)
0155 ,vjust(a_from.vjust)
0156 ,scale(a_from.scale)
0157 ,x_orientation(a_from.x_orientation)
0158 ,y_orientation(a_from.y_orientation)
0159 ,rotated(a_from.rotated)
0160 ,line_width(a_from.line_width)
0161 ,line_pattern(a_from.line_pattern)
0162 ,enforced(a_from.enforced)
0163 ,translation(a_from.translation)
0164 ,front_face(a_from.front_face)
0165 ,options(a_from.options)
0166 {
0167 add_fields();
0168 }
0169 text_style& operator=(const text_style& a_from){
0170 parent::operator=(a_from);
0171 visible = a_from.visible;
0172 color = a_from.color;
0173 back_color = a_from.back_color;
0174 back_shadow = a_from.back_shadow;
0175 modeling = a_from.modeling;
0176 font = a_from.font;
0177 font_size = a_from.font_size;
0178 font_modeling = a_from.font_modeling;
0179 encoding = a_from.encoding;
0180 smoothing = a_from.smoothing;
0181 hinting = a_from.hinting;
0182 hjust = a_from.hjust;
0183 vjust = a_from.vjust;
0184 scale = a_from.scale;
0185 x_orientation = a_from.x_orientation;
0186 y_orientation = a_from.y_orientation;
0187 rotated = a_from.rotated;
0188 line_width = a_from.line_width;
0189 line_pattern = a_from.line_pattern;
0190 enforced = a_from.enforced;
0191 translation = a_from.translation;
0192 front_face = a_from.front_face;
0193 options = a_from.options;
0194 return *this;
0195 }
0196 public:
0197 bool from_string(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s){
0198 style_parser sp;
0199
0200 sp.visible(visible.value());
0201 sp.color(color.value());
0202 //sp.transparency(transparency.value());
0203 sp.back_color(back_color.value());
0204 //sp.back_transparency(back_transparency.value());
0205 sp.back_shadow(back_shadow.value());
0206 sp.modeling(modeling.value());
0207 sp.font(font.value());
0208 sp.font_size(font_size.value());
0209 sp.font_modeling(font_modeling.value());
0210 sp.encoding(encoding.value());
0211 sp.smoothing(smoothing.value());
0212 sp.hinting(hinting.value());
0213 sp.scale(scale.value());
0214 //sp.angle(angle.value());
0215 //sp.x_orientation(x_orientation.value());
0216 //sp.y_orientation(y_orientation.value());
0217 //sp.rotated(rotated.value());
0218 sp.line_width(line_width.value());
0219 sp.line_pattern(line_pattern.value());
0220 sp.enforced(enforced.value());
0221 sp.translation(translation.value());
0222 sp.front_face(front_face.value());
0223 sp.options(options.value());
0224
0225 if(!sp.parse(a_out,a_cmaps,a_s)) {
0226 a_out << "tools::sg::text_style::from_string :"
0227 << " parse failed."
0228 << std::endl;
0229 return false;
0230 }
0231
0232 visible.value(sp.visible());
0233 color.value(sp.color());
0234 //transparency.value(sp.transparency());
0235 back_color.value(sp.back_color());
0236 //back_transparency.value(sp.back_transparency());
0237 back_shadow.value(sp.back_shadow());
0238 modeling.value(sp.modeling());
0239 font.value(sp.font());
0240 font_size.value(sp.font_size());
0241 font_modeling.value(sp.font_modeling());
0242 encoding.value(sp.encoding());
0243 smoothing.value(sp.smoothing());
0244 hinting.value(sp.hinting());
0245 scale.value(sp.scale());
0246 //angle.value(sp.angle());
0247 //x_orientation.value(sp.x_orientation());
0248 //y_orientation.value(sp.y_orientation());
0249 //rotated.value(sp.rotated());
0250 line_width.value(sp.line_width());
0251 line_pattern.value(sp.line_pattern());
0252 enforced.value(sp.enforced());
0253 translation.value(sp.translation());
0254 front_face = sp.front_face();
0255 options = sp.options();
0256
0257 return true;
0258 }
0259 };
0260
0261 }}
0262
0263 #endif