Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_sg_style_parser 4 #ifndef tools_sg_style_parser 5 #define tools_sg_style_parser 5 #define tools_sg_style_parser 6 6 7 #include "senum" 7 #include "senum" 8 #include "strings" 8 #include "strings" 9 #include "style_colormap" 9 #include "style_colormap" 10 10 11 #include "../mathf" 11 #include "../mathf" 12 #include "../lina/vec3f" 12 #include "../lina/vec3f" 13 #include "../sout" 13 #include "../sout" 14 #include "../colorfs" 14 #include "../colorfs" 15 #include "../get_lines" 15 #include "../get_lines" 16 16 17 namespace tools { 17 namespace tools { 18 namespace sg { 18 namespace sg { 19 19 20 class style_parser { 20 class style_parser { 21 #ifdef TOOLS_MEM 21 #ifdef TOOLS_MEM 22 TOOLS_SCLASS(tools::sg::style_parser) 22 TOOLS_SCLASS(tools::sg::style_parser) 23 #endif 23 #endif 24 public: 24 public: 25 style_parser() 25 style_parser() 26 :m_color(0,0,0) 26 :m_color(0,0,0) 27 ,m_highlight_color(0,0,0) 27 ,m_highlight_color(0,0,0) 28 ,m_back_color(1,1,1) 28 ,m_back_color(1,1,1) 29 ,m_width(1) 29 ,m_width(1) 30 ,m_line_width(1) 30 ,m_line_width(1) 31 ,m_marker_size(1) 31 ,m_marker_size(1) 32 ,m_point_size(1) 32 ,m_point_size(1) 33 ,m_font_size(10) 33 ,m_font_size(10) 34 ,m_font_modeling(font_filled) 34 ,m_font_modeling(font_filled) 35 ,m_pattern(line_solid) 35 ,m_pattern(line_solid) 36 ,m_line_pattern(line_solid) 36 ,m_line_pattern(line_solid) 37 ,m_marker_style(marker_dot) 37 ,m_marker_style(marker_dot) 38 ,m_area_style(area_solid) 38 ,m_area_style(area_solid) 39 ,m_modeling(modeling_boxes()) 39 ,m_modeling(modeling_boxes()) 40 ,m_light_model(light_model_phong()) 40 ,m_light_model(light_model_phong()) 41 ,m_tick_modeling(tick_modeling_hippo()) 41 ,m_tick_modeling(tick_modeling_hippo()) 42 ,m_encoding(encoding_none()) 42 ,m_encoding(encoding_none()) 43 ,m_smoothing(false) 43 ,m_smoothing(false) 44 ,m_hinting(false) 44 ,m_hinting(false) 45 ,m_cut() 45 ,m_cut() 46 ,m_painting(painting_uniform) 46 ,m_painting(painting_uniform) 47 ,m_hatching(hatching_none) 47 ,m_hatching(hatching_none) 48 ,m_projection(projection_none) 48 ,m_projection(projection_none) 49 ,m_font("default") 49 ,m_font("default") 50 ,m_multi_node_limit(no_limit()) 50 ,m_multi_node_limit(no_limit()) 51 ,m_divisions(510) //Same as CERN-ROOT/TAttAx 51 ,m_divisions(510) //Same as CERN-ROOT/TAttAxis 52 ,m_rotation_steps(24) //Same as SbPolyhedron 52 ,m_rotation_steps(24) //Same as SbPolyhedron default. 53 ,m_back_shadow(0) 53 ,m_back_shadow(0) 54 ,m_spacing(0.05F) 54 ,m_spacing(0.05F) 55 ,m_angle(fpi()/4.0F) 55 ,m_angle(fpi()/4.0F) 56 ,m_scale(1) 56 ,m_scale(1) 57 ,m_offset(0) 57 ,m_offset(0) 58 ,m_strip_width(0) 58 ,m_strip_width(0) 59 ,m_visible(true) 59 ,m_visible(true) 60 ,m_bar_offset(0.25F) 60 ,m_bar_offset(0.25F) 61 ,m_bar_width(0.5F) 61 ,m_bar_width(0.5F) 62 ,m_editable(false) 62 ,m_editable(false) 63 ,m_automated(true) 63 ,m_automated(true) 64 ,m_options() 64 ,m_options() 65 ,m_color_mapping() 65 ,m_color_mapping() 66 ,m_enforced(false) 66 ,m_enforced(false) 67 ,m_translation(0,0,0) 67 ,m_translation(0,0,0) 68 ,m_front_face(winding_ccw) 68 ,m_front_face(winding_ccw) 69 ,m_hjust(left) 69 ,m_hjust(left) 70 ,m_vjust(bottom) 70 ,m_vjust(bottom) 71 ,m_coloring() 71 ,m_coloring() 72 ,m_title() 72 ,m_title() 73 ,m_pickable(false) 73 ,m_pickable(false) 74 { 74 { 75 #ifdef TOOLS_MEM 75 #ifdef TOOLS_MEM 76 mem::increment(s_class().c_str()); 76 mem::increment(s_class().c_str()); 77 #endif 77 #endif 78 } 78 } 79 79 80 virtual ~style_parser(){ 80 virtual ~style_parser(){ 81 #ifdef TOOLS_MEM 81 #ifdef TOOLS_MEM 82 mem::decrement(s_class().c_str()); 82 mem::decrement(s_class().c_str()); 83 #endif 83 #endif 84 } 84 } 85 public: 85 public: 86 style_parser(const style_parser& a_from) 86 style_parser(const style_parser& a_from) 87 :m_color(a_from.m_color) 87 :m_color(a_from.m_color) 88 ,m_highlight_color(a_from.m_highlight_color) 88 ,m_highlight_color(a_from.m_highlight_color) 89 ,m_back_color(a_from.m_back_color) 89 ,m_back_color(a_from.m_back_color) 90 ,m_width(a_from.m_width) 90 ,m_width(a_from.m_width) 91 ,m_line_width(a_from.m_line_width) 91 ,m_line_width(a_from.m_line_width) 92 ,m_marker_size(a_from.m_marker_size) 92 ,m_marker_size(a_from.m_marker_size) 93 ,m_point_size(a_from.m_point_size) 93 ,m_point_size(a_from.m_point_size) 94 ,m_font_size(a_from.m_font_size) 94 ,m_font_size(a_from.m_font_size) 95 ,m_font_modeling(a_from.m_font_modeling) 95 ,m_font_modeling(a_from.m_font_modeling) 96 ,m_pattern(a_from.m_pattern) 96 ,m_pattern(a_from.m_pattern) 97 ,m_line_pattern(a_from.m_line_pattern) 97 ,m_line_pattern(a_from.m_line_pattern) 98 ,m_marker_style(a_from.m_marker_style) 98 ,m_marker_style(a_from.m_marker_style) 99 ,m_area_style(a_from.m_area_style) 99 ,m_area_style(a_from.m_area_style) 100 ,m_modeling (a_from.m_modeling ) 100 ,m_modeling (a_from.m_modeling ) 101 ,m_light_model(a_from.m_light_model) 101 ,m_light_model(a_from.m_light_model) 102 ,m_tick_modeling(a_from.m_tick_modeling) 102 ,m_tick_modeling(a_from.m_tick_modeling) 103 ,m_encoding(a_from.m_encoding) 103 ,m_encoding(a_from.m_encoding) 104 ,m_smoothing(a_from.m_smoothing) 104 ,m_smoothing(a_from.m_smoothing) 105 ,m_hinting(a_from.m_hinting) 105 ,m_hinting(a_from.m_hinting) 106 ,m_cut(a_from.m_cut) 106 ,m_cut(a_from.m_cut) 107 ,m_painting(a_from.m_painting) 107 ,m_painting(a_from.m_painting) 108 ,m_hatching(a_from.m_hatching) 108 ,m_hatching(a_from.m_hatching) 109 ,m_projection(a_from.m_projection) 109 ,m_projection(a_from.m_projection) 110 ,m_font(a_from.m_font) 110 ,m_font(a_from.m_font) 111 ,m_multi_node_limit(a_from.m_multi_node_limi 111 ,m_multi_node_limit(a_from.m_multi_node_limit) 112 ,m_divisions(a_from.m_divisions) 112 ,m_divisions(a_from.m_divisions) 113 ,m_rotation_steps(a_from.m_rotation_steps) 113 ,m_rotation_steps(a_from.m_rotation_steps) 114 ,m_back_shadow(a_from.m_back_shadow) 114 ,m_back_shadow(a_from.m_back_shadow) 115 ,m_spacing(a_from.m_spacing) 115 ,m_spacing(a_from.m_spacing) 116 ,m_angle(a_from.m_angle) 116 ,m_angle(a_from.m_angle) 117 ,m_scale(a_from.m_scale) 117 ,m_scale(a_from.m_scale) 118 ,m_offset(a_from.m_offset) 118 ,m_offset(a_from.m_offset) 119 ,m_strip_width(a_from.m_strip_width) 119 ,m_strip_width(a_from.m_strip_width) 120 ,m_visible(a_from.m_visible) 120 ,m_visible(a_from.m_visible) 121 ,m_bar_offset(a_from.m_bar_offset) 121 ,m_bar_offset(a_from.m_bar_offset) 122 ,m_bar_width(a_from.m_bar_width) 122 ,m_bar_width(a_from.m_bar_width) 123 ,m_editable(a_from.m_editable) 123 ,m_editable(a_from.m_editable) 124 ,m_automated(a_from.m_automated) 124 ,m_automated(a_from.m_automated) 125 ,m_options(a_from.m_options) 125 ,m_options(a_from.m_options) 126 ,m_color_mapping(a_from.m_color_mapping) 126 ,m_color_mapping(a_from.m_color_mapping) 127 ,m_enforced(a_from.m_enforced) 127 ,m_enforced(a_from.m_enforced) 128 ,m_translation(a_from.m_translation) 128 ,m_translation(a_from.m_translation) 129 ,m_front_face(a_from.m_front_face) 129 ,m_front_face(a_from.m_front_face) 130 ,m_hjust(a_from.m_hjust) 130 ,m_hjust(a_from.m_hjust) 131 ,m_vjust(a_from.m_vjust) 131 ,m_vjust(a_from.m_vjust) 132 ,m_coloring(a_from.m_coloring) 132 ,m_coloring(a_from.m_coloring) 133 ,m_title(a_from.m_title) 133 ,m_title(a_from.m_title) 134 ,m_pickable(a_from.m_pickable) 134 ,m_pickable(a_from.m_pickable) 135 { 135 { 136 #ifdef TOOLS_MEM 136 #ifdef TOOLS_MEM 137 mem::increment(s_class().c_str()); 137 mem::increment(s_class().c_str()); 138 #endif 138 #endif 139 } 139 } 140 140 141 style_parser& operator=(const style_parser& 141 style_parser& operator=(const style_parser& a_from){ 142 copy(a_from); 142 copy(a_from); 143 return *this; 143 return *this; 144 } 144 } 145 public: 145 public: 146 static int no_limit() {return (-1);} 146 static int no_limit() {return (-1);} 147 public: 147 public: 148 void copy(const style_parser& a_from){ 148 void copy(const style_parser& a_from){ 149 m_color = a_from.m_color; 149 m_color = a_from.m_color; 150 m_highlight_color = a_from.m_highlight_col 150 m_highlight_color = a_from.m_highlight_color; 151 m_back_color = a_from.m_back_color; 151 m_back_color = a_from.m_back_color; 152 m_width = a_from.m_width; 152 m_width = a_from.m_width; 153 m_line_width = a_from.m_line_width; 153 m_line_width = a_from.m_line_width; 154 m_marker_size = a_from.m_marker_size; 154 m_marker_size = a_from.m_marker_size; 155 m_point_size = a_from.m_point_size; 155 m_point_size = a_from.m_point_size; 156 m_font_size = a_from.m_font_size; 156 m_font_size = a_from.m_font_size; 157 m_font_modeling = a_from.m_font_modeling; 157 m_font_modeling = a_from.m_font_modeling; 158 m_pattern = a_from.m_pattern; 158 m_pattern = a_from.m_pattern; 159 m_line_pattern = a_from.m_line_pattern; 159 m_line_pattern = a_from.m_line_pattern; 160 m_marker_style = a_from.m_marker_style; 160 m_marker_style = a_from.m_marker_style; 161 m_area_style = a_from.m_area_style; 161 m_area_style = a_from.m_area_style; 162 m_modeling = a_from.m_modeling; 162 m_modeling = a_from.m_modeling; 163 m_light_model = a_from.m_light_model; 163 m_light_model = a_from.m_light_model; 164 m_tick_modeling = a_from.m_tick_modeling; 164 m_tick_modeling = a_from.m_tick_modeling; 165 m_encoding = a_from.m_encoding; 165 m_encoding = a_from.m_encoding; 166 m_smoothing = a_from.m_smoothing; 166 m_smoothing = a_from.m_smoothing; 167 m_hinting = a_from.m_hinting; 167 m_hinting = a_from.m_hinting; 168 m_cut = a_from.m_cut; 168 m_cut = a_from.m_cut; 169 m_painting = a_from.m_painting; 169 m_painting = a_from.m_painting; 170 m_hatching = a_from.m_hatching; 170 m_hatching = a_from.m_hatching; 171 m_projection = a_from.m_projection; 171 m_projection = a_from.m_projection; 172 m_font = a_from.m_font; 172 m_font = a_from.m_font; 173 m_multi_node_limit = a_from.m_multi_node_l 173 m_multi_node_limit = a_from.m_multi_node_limit; 174 m_divisions = a_from.m_divisions; 174 m_divisions = a_from.m_divisions; 175 m_rotation_steps = a_from.m_rotation_steps 175 m_rotation_steps = a_from.m_rotation_steps; 176 m_back_shadow = a_from.m_back_shadow; 176 m_back_shadow = a_from.m_back_shadow; 177 m_spacing = a_from.m_spacing; 177 m_spacing = a_from.m_spacing; 178 m_angle = a_from.m_angle; 178 m_angle = a_from.m_angle; 179 m_scale = a_from.m_scale; 179 m_scale = a_from.m_scale; 180 m_offset = a_from.m_offset; 180 m_offset = a_from.m_offset; 181 m_strip_width = a_from.m_strip_width; 181 m_strip_width = a_from.m_strip_width; 182 m_visible = a_from.m_visible; 182 m_visible = a_from.m_visible; 183 m_bar_offset = a_from.m_bar_offset; 183 m_bar_offset = a_from.m_bar_offset; 184 m_bar_width = a_from.m_bar_width; 184 m_bar_width = a_from.m_bar_width; 185 m_editable = a_from.m_editable; 185 m_editable = a_from.m_editable; 186 m_automated = a_from.m_automated; 186 m_automated = a_from.m_automated; 187 m_options = a_from.m_options; 187 m_options = a_from.m_options; 188 m_color_mapping = a_from.m_color_mapping; 188 m_color_mapping = a_from.m_color_mapping; 189 m_enforced = a_from.m_enforced; 189 m_enforced = a_from.m_enforced; 190 m_translation = a_from.m_translation; 190 m_translation = a_from.m_translation; 191 m_front_face = a_from.m_front_face; 191 m_front_face = a_from.m_front_face; 192 m_hjust = a_from.m_hjust; 192 m_hjust = a_from.m_hjust; 193 m_vjust = a_from.m_vjust; 193 m_vjust = a_from.m_vjust; 194 m_coloring = a_from.m_coloring; 194 m_coloring = a_from.m_coloring; 195 m_title = a_from.m_title; 195 m_title = a_from.m_title; 196 m_pickable = a_from.m_pickable; 196 m_pickable = a_from.m_pickable; 197 } 197 } 198 198 199 bool equal(const style_parser& a_from){ 199 bool equal(const style_parser& a_from){ 200 if(m_width!=a_from.m_width) return false; 200 if(m_width!=a_from.m_width) return false; 201 if(m_line_width!=a_from.m_line_width) retu 201 if(m_line_width!=a_from.m_line_width) return false; 202 if(m_marker_size!=a_from.m_marker_size) re 202 if(m_marker_size!=a_from.m_marker_size) return false; 203 if(m_point_size!=a_from.m_point_size) retu 203 if(m_point_size!=a_from.m_point_size) return false; 204 if(m_font_size!=a_from.m_font_size) return 204 if(m_font_size!=a_from.m_font_size) return false; 205 if(m_font_modeling!=a_from.m_font_modeling 205 if(m_font_modeling!=a_from.m_font_modeling) return false; 206 if(m_pattern!=a_from.m_pattern) return fal 206 if(m_pattern!=a_from.m_pattern) return false; 207 if(m_line_pattern!=a_from.m_line_pattern) 207 if(m_line_pattern!=a_from.m_line_pattern) return false; 208 if(m_marker_style!=a_from.m_marker_style) 208 if(m_marker_style!=a_from.m_marker_style) return false; 209 if(m_area_style!=a_from.m_area_style) retu 209 if(m_area_style!=a_from.m_area_style) return false; 210 if(m_smoothing!=a_from.m_smoothing) return 210 if(m_smoothing!=a_from.m_smoothing) return false; 211 if(m_hinting!=a_from.m_hinting) return fal 211 if(m_hinting!=a_from.m_hinting) return false; 212 if(m_painting!=a_from.m_painting) return f 212 if(m_painting!=a_from.m_painting) return false; 213 if(m_hatching!=a_from.m_hatching) return f 213 if(m_hatching!=a_from.m_hatching) return false; 214 if(m_projection!=a_from.m_projection) retu 214 if(m_projection!=a_from.m_projection) return false; 215 if(m_multi_node_limit!=a_from.m_multi_node 215 if(m_multi_node_limit!=a_from.m_multi_node_limit) return false; 216 if(m_divisions!=a_from.m_divisions) return 216 if(m_divisions!=a_from.m_divisions) return false; 217 if(m_rotation_steps!=a_from.m_rotation_ste 217 if(m_rotation_steps!=a_from.m_rotation_steps) return false; 218 if(m_back_shadow!=a_from.m_back_shadow) re 218 if(m_back_shadow!=a_from.m_back_shadow) return false; 219 if(m_spacing!=a_from.m_spacing) return fal 219 if(m_spacing!=a_from.m_spacing) return false; 220 if(m_angle!=a_from.m_angle) return false; 220 if(m_angle!=a_from.m_angle) return false; 221 if(m_scale!=a_from.m_scale) return false; 221 if(m_scale!=a_from.m_scale) return false; 222 if(m_offset!=a_from.m_offset) return false 222 if(m_offset!=a_from.m_offset) return false; 223 if(m_strip_width!=a_from.m_strip_width) re 223 if(m_strip_width!=a_from.m_strip_width) return false; 224 if(m_visible!=a_from.m_visible) return fal 224 if(m_visible!=a_from.m_visible) return false; 225 if(m_bar_offset!=a_from.m_bar_offset) retu 225 if(m_bar_offset!=a_from.m_bar_offset) return false; 226 if(m_bar_width!=a_from.m_bar_width) return 226 if(m_bar_width!=a_from.m_bar_width) return false; 227 if(m_editable!=a_from.m_editable) return f 227 if(m_editable!=a_from.m_editable) return false; 228 if(m_automated!=a_from.m_automated) return 228 if(m_automated!=a_from.m_automated) return false; 229 if(m_enforced!=a_from.m_enforced) return f 229 if(m_enforced!=a_from.m_enforced) return false; 230 230 231 //color 231 //color 232 if(m_color!=a_from.m_color) return false; 232 if(m_color!=a_from.m_color) return false; 233 if(m_highlight_color!=a_from.m_highlight_c 233 if(m_highlight_color!=a_from.m_highlight_color) return false; 234 if(m_back_color!=a_from.m_back_color) retu 234 if(m_back_color!=a_from.m_back_color) return false; 235 235 236 //std::string 236 //std::string 237 if(m_modeling!=a_from.m_modeling) return f 237 if(m_modeling!=a_from.m_modeling) return false; 238 if(m_light_model!=a_from.m_light_model) re 238 if(m_light_model!=a_from.m_light_model) return false; 239 if(m_tick_modeling!=a_from.m_tick_modeling 239 if(m_tick_modeling!=a_from.m_tick_modeling) return false; 240 if(m_encoding!=a_from.m_encoding) return f 240 if(m_encoding!=a_from.m_encoding) return false; 241 if(m_cut!=a_from.m_cut) return false; 241 if(m_cut!=a_from.m_cut) return false; 242 if(m_font!=a_from.m_font) return false; 242 if(m_font!=a_from.m_font) return false; 243 if(m_options!=a_from.m_options) return fal 243 if(m_options!=a_from.m_options) return false; 244 if(m_color_mapping!=a_from.m_color_mapping 244 if(m_color_mapping!=a_from.m_color_mapping) return false; 245 245 246 if(m_translation!=a_from.m_translation) re 246 if(m_translation!=a_from.m_translation) return false; 247 247 248 if(m_front_face!=a_from.m_front_face) retu 248 if(m_front_face!=a_from.m_front_face) return false; 249 249 250 if(m_hjust!=a_from.m_hjust) return false; 250 if(m_hjust!=a_from.m_hjust) return false; 251 if(m_vjust!=a_from.m_vjust) return false; 251 if(m_vjust!=a_from.m_vjust) return false; 252 252 253 if(m_coloring!=a_from.m_coloring) return f 253 if(m_coloring!=a_from.m_coloring) return false; 254 if(m_title!=a_from.m_title) return false; 254 if(m_title!=a_from.m_title) return false; 255 if(m_pickable!=a_from.m_pickable) return f 255 if(m_pickable!=a_from.m_pickable) return false; 256 256 257 return true; 257 return true; 258 } 258 } 259 259 260 virtual void reset(){ //virtual because of S 260 virtual void reset(){ //virtual because of SoGC 261 m_color = colorf_black(); 261 m_color = colorf_black(); 262 m_highlight_color = colorf_lightgrey(); 262 m_highlight_color = colorf_lightgrey(); 263 m_back_color = colorf_white(); 263 m_back_color = colorf_white(); 264 m_width = 1; 264 m_width = 1; 265 m_line_width = 1; 265 m_line_width = 1; 266 m_marker_size = 1; 266 m_marker_size = 1; 267 m_point_size = 1; 267 m_point_size = 1; 268 m_font_size = 10; 268 m_font_size = 10; 269 m_font_modeling = font_filled; 269 m_font_modeling = font_filled; 270 m_pattern = line_solid; 270 m_pattern = line_solid; 271 m_line_pattern = line_solid; 271 m_line_pattern = line_solid; 272 m_marker_style = marker_dot; 272 m_marker_style = marker_dot; 273 m_area_style = area_solid; 273 m_area_style = area_solid; 274 m_modeling = modeling_boxes(); 274 m_modeling = modeling_boxes(); 275 m_light_model = light_model_phong(); 275 m_light_model = light_model_phong(); 276 m_tick_modeling = tick_modeling_hippo(); 276 m_tick_modeling = tick_modeling_hippo(); 277 m_encoding = encoding_none(); 277 m_encoding = encoding_none(); 278 m_smoothing = false; 278 m_smoothing = false; 279 m_hinting = false; 279 m_hinting = false; 280 m_cut = ""; 280 m_cut = ""; 281 m_painting = painting_uniform; 281 m_painting = painting_uniform; 282 m_hatching = hatching_none; 282 m_hatching = hatching_none; 283 m_projection = projection_none; 283 m_projection = projection_none; 284 m_font = "default"; 284 m_font = "default"; 285 m_multi_node_limit = no_limit(); 285 m_multi_node_limit = no_limit(); 286 m_back_shadow = 0; 286 m_back_shadow = 0; 287 m_divisions = 510; 287 m_divisions = 510; 288 m_rotation_steps = 24; 288 m_rotation_steps = 24; 289 m_spacing = 0.05F; 289 m_spacing = 0.05F; 290 m_angle = fpi()/4; 290 m_angle = fpi()/4; 291 m_scale = 1; 291 m_scale = 1; 292 m_offset = 0; 292 m_offset = 0; 293 m_strip_width = 0; 293 m_strip_width = 0; 294 m_visible = true; 294 m_visible = true; 295 m_bar_offset = 0.25F; 295 m_bar_offset = 0.25F; 296 m_bar_width = 0.5F; 296 m_bar_width = 0.5F; 297 m_editable = false; 297 m_editable = false; 298 m_automated = true; 298 m_automated = true; 299 m_options = ""; 299 m_options = ""; 300 m_color_mapping = ""; 300 m_color_mapping = ""; 301 m_enforced = false; 301 m_enforced = false; 302 m_translation = vec3f(0,0,0); 302 m_translation = vec3f(0,0,0); 303 m_front_face = winding_ccw; 303 m_front_face = winding_ccw; 304 m_hjust = left; 304 m_hjust = left; 305 m_vjust = bottom; 305 m_vjust = bottom; 306 m_coloring = ""; 306 m_coloring = ""; 307 m_title = ""; 307 m_title = ""; 308 m_pickable = false; 308 m_pickable = false; 309 } 309 } 310 310 311 std::string tos() const{ 311 std::string tos() const{ 312 char ss[40 * 32]; 312 char ss[40 * 32]; 313 snpf(ss,sizeof(ss), 313 snpf(ss,sizeof(ss), 314 "color %g %g %g\n\ 314 "color %g %g %g\n\ 315 highlight_color %g %g %g\n\ 315 highlight_color %g %g %g\n\ 316 back_color %g %g %g\n\ 316 back_color %g %g %g\n\ 317 width %g\n\ 317 width %g\n\ 318 line_width %g\n\ 318 line_width %g\n\ 319 marker_size %g\n\ 319 marker_size %g\n\ 320 point_size %g\n\ 320 point_size %g\n\ 321 font_size %g\n\ 321 font_size %g\n\ 322 pattern %x\n\ 322 pattern %x\n\ 323 line_pattern %x\n\ 323 line_pattern %x\n\ 324 multi_node_limit %d\n\ 324 multi_node_limit %d\n\ 325 back_shadow %g\n\ 325 back_shadow %g\n\ 326 divisions %d\n\ 326 divisions %d\n\ 327 rotation_steps %d\n\ 327 rotation_steps %d\n\ 328 angle %g\n\ 328 angle %g\n\ 329 scale %g\n\ 329 scale %g\n\ 330 offset %g\n\ 330 offset %g\n\ 331 strip_width %g\n\ 331 strip_width %g\n\ 332 spacing %g\n\ 332 spacing %g\n\ 333 bar_offset %g\n\ 333 bar_offset %g\n\ 334 bar_width %g\n\ 334 bar_width %g\n\ 335 translation %g %g %g" 335 translation %g %g %g" 336 ,m_color[0],m_color[1],m_color[2] 336 ,m_color[0],m_color[1],m_color[2] 337 ,m_highlight_color[0],m_highlight_color[1] 337 ,m_highlight_color[0],m_highlight_color[1],m_highlight_color[2] 338 ,m_back_color[0],m_back_color[1],m_back_co 338 ,m_back_color[0],m_back_color[1],m_back_color[2] 339 ,m_width 339 ,m_width 340 ,m_line_width 340 ,m_line_width 341 ,m_marker_size 341 ,m_marker_size 342 ,m_point_size 342 ,m_point_size 343 ,m_font_size 343 ,m_font_size 344 ,m_pattern 344 ,m_pattern 345 ,m_line_pattern 345 ,m_line_pattern 346 ,m_multi_node_limit 346 ,m_multi_node_limit 347 ,m_back_shadow 347 ,m_back_shadow 348 ,m_divisions 348 ,m_divisions 349 ,m_rotation_steps 349 ,m_rotation_steps 350 ,m_angle 350 ,m_angle 351 ,m_scale 351 ,m_scale 352 ,m_offset 352 ,m_offset 353 ,m_strip_width 353 ,m_strip_width 354 ,m_spacing 354 ,m_spacing 355 ,m_bar_offset 355 ,m_bar_offset 356 ,m_bar_width 356 ,m_bar_width 357 ,m_translation[0],m_translation[1],m_trans 357 ,m_translation[0],m_translation[1],m_translation[2]); 358 358 359 std::string lf("\n"); 359 std::string lf("\n"); 360 std::string _s(ss); 360 std::string _s(ss); 361 361 362 _s += lf; 362 _s += lf; 363 _s += "smoothing "; 363 _s += "smoothing "; 364 _s += (m_smoothing?"true":"false"); 364 _s += (m_smoothing?"true":"false"); 365 365 366 _s += lf; 366 _s += lf; 367 _s += "hinting "; 367 _s += "hinting "; 368 _s += (m_hinting?"true":"false"); 368 _s += (m_hinting?"true":"false"); 369 369 370 _s += lf; 370 _s += lf; 371 _s += "enforced "; 371 _s += "enforced "; 372 _s += (m_enforced?"true":"false"); 372 _s += (m_enforced?"true":"false"); 373 373 374 _s += lf; 374 _s += lf; 375 _s += "visible "; 375 _s += "visible "; 376 _s += (m_visible?"true":"false"); 376 _s += (m_visible?"true":"false"); 377 377 378 _s += lf; 378 _s += lf; 379 _s += "editable "; 379 _s += "editable "; 380 _s += (m_editable?"true":"false"); 380 _s += (m_editable?"true":"false"); 381 381 382 _s += lf; 382 _s += lf; 383 _s += "automated "; 383 _s += "automated "; 384 _s += (m_automated?"true":"false"); 384 _s += (m_automated?"true":"false"); 385 385 386 _s += lf; 386 _s += lf; 387 _s += "pickable "; 387 _s += "pickable "; 388 _s += (m_pickable?"true":"false"); 388 _s += (m_pickable?"true":"false"); 389 389 390 _s += lf; 390 _s += lf; 391 _s += "marker_style "; 391 _s += "marker_style "; 392 _s += smarker_style(m_marker_style); 392 _s += smarker_style(m_marker_style); 393 393 394 _s += lf; 394 _s += lf; 395 _s += "area_style "; 395 _s += "area_style "; 396 _s += sarea_style(m_area_style); 396 _s += sarea_style(m_area_style); 397 397 398 _s += lf; 398 _s += lf; 399 _s += "modeling "; 399 _s += "modeling "; 400 _s += m_modeling; 400 _s += m_modeling; 401 401 402 _s += lf; 402 _s += lf; 403 _s += "coloring "; 403 _s += "coloring "; 404 _s += m_coloring; 404 _s += m_coloring; 405 405 406 _s += lf; 406 _s += lf; 407 _s += "title "; 407 _s += "title "; 408 _s += m_title; 408 _s += m_title; 409 409 410 _s += lf; 410 _s += lf; 411 _s += "light_model "; 411 _s += "light_model "; 412 _s += m_light_model; 412 _s += m_light_model; 413 413 414 _s += lf; 414 _s += lf; 415 _s += "tick_modeling "; 415 _s += "tick_modeling "; 416 _s += m_tick_modeling; 416 _s += m_tick_modeling; 417 417 418 _s += lf; 418 _s += lf; 419 _s += "encoding "; 419 _s += "encoding "; 420 _s += m_encoding; 420 _s += m_encoding; 421 421 422 _s += lf; 422 _s += lf; 423 _s += "cut "; 423 _s += "cut "; 424 _s += m_cut; 424 _s += m_cut; 425 425 426 _s += lf; 426 _s += lf; 427 _s += "painting "; 427 _s += "painting "; 428 _s += spainting_policy(m_painting); 428 _s += spainting_policy(m_painting); 429 429 430 _s += lf; 430 _s += lf; 431 _s += "hatching "; 431 _s += "hatching "; 432 _s += shatching_policy(m_hatching); 432 _s += shatching_policy(m_hatching); 433 433 434 _s += lf; 434 _s += lf; 435 _s += "projection "; 435 _s += "projection "; 436 _s += sprojection_type(m_projection); 436 _s += sprojection_type(m_projection); 437 437 438 _s += lf; 438 _s += lf; 439 _s += "font "; 439 _s += "font "; 440 _s += m_font; 440 _s += m_font; 441 441 442 if(m_font_modeling==font_outline) { 442 if(m_font_modeling==font_outline) { 443 _s += lf; 443 _s += lf; 444 _s += "font_modeling "; 444 _s += "font_modeling "; 445 _s += s_font_outline(); 445 _s += s_font_outline(); 446 } else if(m_font_modeling==font_filled) { 446 } else if(m_font_modeling==font_filled) { 447 _s += lf; 447 _s += lf; 448 _s += "font_modeling "; 448 _s += "font_modeling "; 449 _s += s_font_filled(); 449 _s += s_font_filled(); 450 } else if(m_font_modeling==font_pixmap) { 450 } else if(m_font_modeling==font_pixmap) { 451 _s += lf; 451 _s += lf; 452 _s += "font_modeling "; 452 _s += "font_modeling "; 453 _s += s_font_pixmap(); 453 _s += s_font_pixmap(); 454 } 454 } 455 455 456 _s += lf; 456 _s += lf; 457 _s += "options "; 457 _s += "options "; 458 _s += m_options; 458 _s += m_options; 459 459 460 _s += lf; 460 _s += lf; 461 _s += "color_mapping "; 461 _s += "color_mapping "; 462 _s += m_color_mapping; 462 _s += m_color_mapping; 463 463 464 _s += lf; 464 _s += lf; 465 _s += "front_face "; 465 _s += "front_face "; 466 _s += (m_front_face==winding_ccw?"ccw":"cw 466 _s += (m_front_face==winding_ccw?"ccw":"cw"); 467 467 468 _s += lf; 468 _s += lf; 469 _s += "hjust "; 469 _s += "hjust "; 470 _s += shjust(m_hjust); 470 _s += shjust(m_hjust); 471 471 472 _s += lf; 472 _s += lf; 473 _s += "vjust "; 473 _s += "vjust "; 474 _s += svjust(m_vjust); 474 _s += svjust(m_vjust); 475 475 476 return _s; 476 return _s; 477 } 477 } 478 478 479 void color(const colorf& a_v){m_color = a_v; 479 void color(const colorf& a_v){m_color = a_v;} 480 colorf color() const {return m_color;} 480 colorf color() const {return m_color;} 481 481 482 void highlight_color(const colorf& a_v){m_hi 482 void highlight_color(const colorf& a_v){m_highlight_color = a_v;} 483 colorf highlight_color() const {return m_hig 483 colorf highlight_color() const {return m_highlight_color;} 484 484 485 void back_color(const colorf& a_v){m_back_co 485 void back_color(const colorf& a_v){m_back_color = a_v;} 486 colorf back_color() const {return m_back_col 486 colorf back_color() const {return m_back_color;} 487 487 488 void width(float a_v){m_width = a_v;} 488 void width(float a_v){m_width = a_v;} 489 float width() const {return m_width;} 489 float width() const {return m_width;} 490 490 491 void line_width(float a_v){m_line_width = a_ 491 void line_width(float a_v){m_line_width = a_v;} 492 float line_width() const {return m_line_widt 492 float line_width() const {return m_line_width;} 493 493 494 float back_shadow() const {return m_back_sha 494 float back_shadow() const {return m_back_shadow;} 495 void back_shadow(float a_v) {m_back_shadow = 495 void back_shadow(float a_v) {m_back_shadow = a_v;} 496 496 497 void marker_style(sg::marker_style a_v){m_ma 497 void marker_style(sg::marker_style a_v){m_marker_style = a_v;} 498 sg::marker_style marker_style() const {retur 498 sg::marker_style marker_style() const {return m_marker_style;} 499 499 500 void marker_size(float a_v){m_marker_size = 500 void marker_size(float a_v){m_marker_size = a_v;} 501 float marker_size() const {return m_marker_s 501 float marker_size() const {return m_marker_size;} 502 502 503 void point_size(float a_v){m_point_size = a_ 503 void point_size(float a_v){m_point_size = a_v;} 504 float point_size() const {return m_point_siz 504 float point_size() const {return m_point_size;} 505 505 506 void font_size(float a_v){m_font_size = a_v; 506 void font_size(float a_v){m_font_size = a_v;} 507 float font_size() const {return m_font_size; 507 float font_size() const {return m_font_size;} 508 508 509 void font_modeling(sg::font_modeling a_v){m_ 509 void font_modeling(sg::font_modeling a_v){m_font_modeling = a_v;} 510 sg::font_modeling font_modeling() const {ret 510 sg::font_modeling font_modeling() const {return m_font_modeling;} 511 511 512 void area_style(sg::area_style a_v){m_area_s 512 void area_style(sg::area_style a_v){m_area_style = a_v;} 513 sg::area_style area_style() const {return m_ 513 sg::area_style area_style() const {return m_area_style;} 514 514 515 void modeling(const std::string& a_v){m_mode 515 void modeling(const std::string& a_v){m_modeling = a_v;} 516 const std::string& modeling() const {return 516 const std::string& modeling() const {return m_modeling ;} 517 517 518 void light_model(const std::string& a_v){m_l 518 void light_model(const std::string& a_v){m_light_model = a_v;} 519 const std::string& light_model() const {retu 519 const std::string& light_model() const {return m_light_model;} 520 520 521 void tick_modeling(const std::string& a_v){m 521 void tick_modeling(const std::string& a_v){m_tick_modeling = a_v;} 522 const std::string& tick_modeling() const {re 522 const std::string& tick_modeling() const {return m_tick_modeling;} 523 523 524 void encoding(const std::string& a_v){m_enco 524 void encoding(const std::string& a_v){m_encoding = a_v;} 525 const std::string& encoding() const {return 525 const std::string& encoding() const {return m_encoding;} 526 526 527 void smoothing(bool a_v){m_smoothing = a_v;} 527 void smoothing(bool a_v){m_smoothing = a_v;} 528 bool smoothing() const {return m_smoothing;} 528 bool smoothing() const {return m_smoothing;} 529 529 530 void hinting(bool a_v){m_hinting = a_v;} 530 void hinting(bool a_v){m_hinting = a_v;} 531 bool hinting() const {return m_hinting;} 531 bool hinting() const {return m_hinting;} 532 532 533 sg::painting_policy painting() const {return 533 sg::painting_policy painting() const {return m_painting;} 534 void painting(sg::painting_policy a_v){m_pai 534 void painting(sg::painting_policy a_v){m_painting = a_v;} 535 535 536 sg::hatching_policy hatching() const {return 536 sg::hatching_policy hatching() const {return m_hatching;} 537 void hatching(sg::hatching_policy a_v) {m_ha 537 void hatching(sg::hatching_policy a_v) {m_hatching = a_v;} 538 538 539 sg::projection_type projection() const {retu 539 sg::projection_type projection() const {return m_projection;} 540 void projection(sg::projection_type a_v){m_p 540 void projection(sg::projection_type a_v){m_projection = a_v;} 541 541 542 void pattern(lpat a_v){m_pattern = a_v;} 542 void pattern(lpat a_v){m_pattern = a_v;} 543 lpat pattern() const {return m_pattern;} 543 lpat pattern() const {return m_pattern;} 544 544 545 void line_pattern(lpat a_v){m_line_pattern = 545 void line_pattern(lpat a_v){m_line_pattern = a_v;} 546 lpat line_pattern() const {return m_line_pat 546 lpat line_pattern() const {return m_line_pattern;} 547 547 548 void font(const std::string& a_v){m_font = a 548 void font(const std::string& a_v){m_font = a_v;} 549 const std::string& font() const {return m_fo 549 const std::string& font() const {return m_font;} 550 550 551 void divisions(int a_v){m_divisions = a_v;} 551 void divisions(int a_v){m_divisions = a_v;} 552 int divisions() const {return m_divisions;} 552 int divisions() const {return m_divisions;} 553 553 554 void rotation_steps(unsigned int a_v){m_rota 554 void rotation_steps(unsigned int a_v){m_rotation_steps = a_v;} 555 unsigned int rotation_steps() const {return 555 unsigned int rotation_steps() const {return m_rotation_steps;} 556 556 557 void offset(float a_v){m_offset = a_v;} 557 void offset(float a_v){m_offset = a_v;} 558 float offset() const {return m_offset;} 558 float offset() const {return m_offset;} 559 559 560 void strip_width(float a_v){m_strip_width = 560 void strip_width(float a_v){m_strip_width = a_v;} 561 float strip_width() const {return m_strip_wi 561 float strip_width() const {return m_strip_width;} 562 562 563 void angle(float a_v){m_angle = a_v;} 563 void angle(float a_v){m_angle = a_v;} 564 float angle() const {return m_angle;} 564 float angle() const {return m_angle;} 565 565 566 void scale(float a_v){m_scale = a_v;} 566 void scale(float a_v){m_scale = a_v;} 567 float scale() const {return m_scale;} 567 float scale() const {return m_scale;} 568 568 569 void bar_offset(float a_v){m_bar_offset = a_ 569 void bar_offset(float a_v){m_bar_offset = a_v;} 570 float bar_offset() const {return m_bar_offse 570 float bar_offset() const {return m_bar_offset;} 571 571 572 void bar_width(float a_v){m_bar_width = a_v; 572 void bar_width(float a_v){m_bar_width = a_v;} 573 float bar_width() const {return m_bar_width; 573 float bar_width() const {return m_bar_width;} 574 574 575 void multi_node_limit(int a_v){m_multi_node_ 575 void multi_node_limit(int a_v){m_multi_node_limit = a_v;} 576 int multi_node_limit() const {return m_multi 576 int multi_node_limit() const {return m_multi_node_limit;} 577 577 578 void spacing(float a_v){m_spacing = a_v;} 578 void spacing(float a_v){m_spacing = a_v;} 579 float spacing() const {return m_spacing;} 579 float spacing() const {return m_spacing;} 580 580 581 void visible(bool a_v){m_visible = a_v;} 581 void visible(bool a_v){m_visible = a_v;} 582 bool visible() const{return m_visible;} 582 bool visible() const{return m_visible;} 583 583 584 void editable(bool a_v){m_editable = a_v;} 584 void editable(bool a_v){m_editable = a_v;} 585 bool editable() const{return m_editable;} 585 bool editable() const{return m_editable;} 586 586 587 void automated(bool a_v){m_automated = a_v;} 587 void automated(bool a_v){m_automated = a_v;} 588 bool automated() const{return m_automated;} 588 bool automated() const{return m_automated;} 589 589 590 void cut(const std::string& a_v){m_cut = a_v 590 void cut(const std::string& a_v){m_cut = a_v;} 591 const std::string& cut() const {return m_cut 591 const std::string& cut() const {return m_cut;} 592 592 593 void options(const std::string& a_v){m_optio 593 void options(const std::string& a_v){m_options = a_v;} 594 const std::string& options() const{return m_ 594 const std::string& options() const{return m_options;} 595 595 596 void color_mapping(const std::string& a_v){m 596 void color_mapping(const std::string& a_v){m_color_mapping = a_v;} 597 const std::string& color_mapping() const{ret 597 const std::string& color_mapping() const{return m_color_mapping;} 598 598 599 void enforced(bool a_v){m_enforced = a_v;} 599 void enforced(bool a_v){m_enforced = a_v;} 600 bool enforced() const{return m_enforced;} 600 bool enforced() const{return m_enforced;} 601 601 602 void translation(const vec3f& a_v){m_transla 602 void translation(const vec3f& a_v){m_translation = a_v;} 603 vec3f translation() const {return m_translat 603 vec3f translation() const {return m_translation;} 604 604 605 void front_face(winding_type a_v){m_front_fa 605 void front_face(winding_type a_v){m_front_face = a_v;} 606 winding_type front_face() const {return m_fr 606 winding_type front_face() const {return m_front_face;} 607 607 608 void hjust(sg::hjust a_v){m_hjust = a_v;} 608 void hjust(sg::hjust a_v){m_hjust = a_v;} 609 sg::hjust hjust() const {return m_hjust;} 609 sg::hjust hjust() const {return m_hjust;} 610 610 611 void vjust(sg::vjust a_v){m_vjust = a_v;} 611 void vjust(sg::vjust a_v){m_vjust = a_v;} 612 sg::vjust vjust() const {return m_vjust;} 612 sg::vjust vjust() const {return m_vjust;} 613 613 614 void coloring(const std::string& a_v){m_colo 614 void coloring(const std::string& a_v){m_coloring = a_v;} 615 const std::string& coloring() const {return 615 const std::string& coloring() const {return m_coloring;} 616 616 617 void title(const std::string& a_v){m_title 617 void title(const std::string& a_v){m_title = a_v;} 618 const std::string& title() const {return m_t 618 const std::string& title() const {return m_title;} 619 619 620 void pickable(bool a_v){m_pickable = a_v;} 620 void pickable(bool a_v){m_pickable = a_v;} 621 bool pickable() const {return m_pickable;} 621 bool pickable() const {return m_pickable;} 622 622 623 public: 623 public: 624 bool parse(std::ostream& a_out,const cmaps_t 624 bool parse(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s){ 625 // a_s = list of "name value" separated by 625 // a_s = list of "name value" separated by \n 626 //::printf("debug : style_parser::parse : 626 //::printf("debug : style_parser::parse : \"%s\"\n",a_s.c_str()); 627 std::vector<std::string> lines; 627 std::vector<std::string> lines; 628 get_lines(a_s,lines); 628 get_lines(a_s,lines); 629 629 630 tools_vforcit(std::string,lines,it) { 630 tools_vforcit(std::string,lines,it) { 631 const std::string& line = *it; 631 const std::string& line = *it; 632 if(line.empty()) continue; 632 if(line.empty()) continue; 633 if(line=="reset") { 633 if(line=="reset") { 634 reset(); 634 reset(); 635 continue; 635 continue; 636 } 636 } 637 std::vector<std::string> ws; 637 std::vector<std::string> ws; 638 words(line," ",false,ws); 638 words(line," ",false,ws); 639 size_t wordn = ws.size(); 639 size_t wordn = ws.size(); 640 if(!wordn) { 640 if(!wordn) { 641 a_out << "style_parser::parse :" 641 a_out << "style_parser::parse :" 642 << " in " << sout(a_s) 642 << " in " << sout(a_s) 643 << " : " << sout(line) 643 << " : " << sout(line) 644 << " has a bad word count (at le 644 << " has a bad word count (at least two expected)." 645 << std::endl; 645 << std::endl; 646 return false; 646 return false; 647 } 647 } 648 const std::string& word0 = ws[0]; 648 const std::string& word0 = ws[0]; 649 if(word0=="color") { 649 if(word0=="color") { 650 if(wordn==2) { 650 if(wordn==2) { 651 const std::string& word1 = ws[1]; 651 const std::string& word1 = ws[1]; 652 if(!find_color(a_cmaps,word1,m_color 652 if(!find_color(a_cmaps,word1,m_color)) { 653 a_out << "style_parser::parse :" 653 a_out << "style_parser::parse :" 654 << " in " << sout(a_s) 654 << " in " << sout(a_s) 655 << " : " << sout(word1) 655 << " : " << sout(word1) 656 << " not a color." 656 << " not a color." 657 << std::endl; 657 << std::endl; 658 return false; 658 return false; 659 } 659 } 660 } else if (wordn==4) { 660 } else if (wordn==4) { 661 const std::string& rs = ws[1]; 661 const std::string& rs = ws[1]; 662 float r; 662 float r; 663 if(!to<float>(rs,r)) { 663 if(!to<float>(rs,r)) { 664 a_out << "style_parser::parse :" 664 a_out << "style_parser::parse :" 665 << " in " << sout(a_s) 665 << " in " << sout(a_s) 666 << " : " << sout(rs) 666 << " : " << sout(rs) 667 << " not a number." 667 << " not a number." 668 << std::endl; 668 << std::endl; 669 return false; 669 return false; 670 } 670 } 671 const std::string& gs = ws[2]; 671 const std::string& gs = ws[2]; 672 float g; 672 float g; 673 if(!to<float>(gs,g)) { 673 if(!to<float>(gs,g)) { 674 a_out << "style_parser::parse :" 674 a_out << "style_parser::parse :" 675 << " in " << sout(a_s) 675 << " in " << sout(a_s) 676 << " : " << sout(gs) 676 << " : " << sout(gs) 677 << " not a number." 677 << " not a number." 678 << std::endl; 678 << std::endl; 679 return false; 679 return false; 680 } 680 } 681 const std::string& bs = ws[3]; 681 const std::string& bs = ws[3]; 682 float b; 682 float b; 683 if(!to<float>(bs,b)) { 683 if(!to<float>(bs,b)) { 684 a_out << "style_parser::parse :" 684 a_out << "style_parser::parse :" 685 << " in " << sout(a_s) 685 << " in " << sout(a_s) 686 << " : " << sout(bs) 686 << " : " << sout(bs) 687 << " not a number." 687 << " not a number." 688 << std::endl; 688 << std::endl; 689 return false; 689 return false; 690 } 690 } 691 m_color.set_value(r,g,b,1); 691 m_color.set_value(r,g,b,1); 692 692 693 } else if (wordn==5) { 693 } else if (wordn==5) { 694 const std::string& rs = ws[1]; 694 const std::string& rs = ws[1]; 695 float r; 695 float r; 696 if(!to<float>(rs,r)) { 696 if(!to<float>(rs,r)) { 697 a_out << "style_parser::parse :" 697 a_out << "style_parser::parse :" 698 << " in " << sout(a_s) 698 << " in " << sout(a_s) 699 << " : " << sout(rs) 699 << " : " << sout(rs) 700 << " not a number." 700 << " not a number." 701 << std::endl; 701 << std::endl; 702 return false; 702 return false; 703 } 703 } 704 const std::string& gs = ws[2]; 704 const std::string& gs = ws[2]; 705 float g; 705 float g; 706 if(!to<float>(gs,g)) { 706 if(!to<float>(gs,g)) { 707 a_out << "style_parser::parse :" 707 a_out << "style_parser::parse :" 708 << " in " << sout(a_s) 708 << " in " << sout(a_s) 709 << " : " << sout(gs) 709 << " : " << sout(gs) 710 << " not a number." 710 << " not a number." 711 << std::endl; 711 << std::endl; 712 return false; 712 return false; 713 } 713 } 714 const std::string& bs = ws[3]; 714 const std::string& bs = ws[3]; 715 float b; 715 float b; 716 if(!to<float>(bs,b)) { 716 if(!to<float>(bs,b)) { 717 a_out << "style_parser::parse :" 717 a_out << "style_parser::parse :" 718 << " in " << sout(a_s) 718 << " in " << sout(a_s) 719 << " : " << sout(bs) 719 << " : " << sout(bs) 720 << " not a number." 720 << " not a number." 721 << std::endl; 721 << std::endl; 722 return false; 722 return false; 723 } 723 } 724 const std::string& as = ws[4]; 724 const std::string& as = ws[4]; 725 float a; 725 float a; 726 if(!to<float>(as,a)) { 726 if(!to<float>(as,a)) { 727 a_out << "style_parser::parse :" 727 a_out << "style_parser::parse :" 728 << " in " << sout(a_s) 728 << " in " << sout(a_s) 729 << " : " << sout(as) 729 << " : " << sout(as) 730 << " not a number." 730 << " not a number." 731 << std::endl; 731 << std::endl; 732 return false; 732 return false; 733 } 733 } 734 m_color.set_value(r,g,b,a); 734 m_color.set_value(r,g,b,a); 735 735 736 } else { 736 } else { 737 a_out << "style_parser::parse :" 737 a_out << "style_parser::parse :" 738 << " in " << sout(a_s) 738 << " in " << sout(a_s) 739 << " : " << sout(line) 739 << " : " << sout(line) 740 << " has a bad word count (two 740 << " has a bad word count (two or four expected)." 741 << std::endl; 741 << std::endl; 742 return false; 742 return false; 743 } 743 } 744 744 745 } else if(word0=="highlight_color") { 745 } else if(word0=="highlight_color") { 746 if(wordn==2) { 746 if(wordn==2) { 747 const std::string& word1 = ws[1]; 747 const std::string& word1 = ws[1]; 748 if(!find_color(a_cmaps,word1,m_highl 748 if(!find_color(a_cmaps,word1,m_highlight_color)) { 749 a_out << "style_parser::parse :" 749 a_out << "style_parser::parse :" 750 << " in " << sout(a_s) 750 << " in " << sout(a_s) 751 << " : " << sout(word1) 751 << " : " << sout(word1) 752 << " not a color." 752 << " not a color." 753 << std::endl; 753 << std::endl; 754 return false; 754 return false; 755 } 755 } 756 } else if (wordn==4) { 756 } else if (wordn==4) { 757 const std::string& rs = ws[1]; 757 const std::string& rs = ws[1]; 758 float r; 758 float r; 759 if(!to<float>(rs,r)) { 759 if(!to<float>(rs,r)) { 760 a_out << "style_parser::parse :" 760 a_out << "style_parser::parse :" 761 << " in " << sout(a_s) 761 << " in " << sout(a_s) 762 << " : " << sout(rs) 762 << " : " << sout(rs) 763 << " not a number." 763 << " not a number." 764 << std::endl; 764 << std::endl; 765 return false; 765 return false; 766 } 766 } 767 const std::string& gs = ws[2]; 767 const std::string& gs = ws[2]; 768 float g; 768 float g; 769 if(!to<float>(gs,g)) { 769 if(!to<float>(gs,g)) { 770 a_out << "style_parser::parse :" 770 a_out << "style_parser::parse :" 771 << " in " << sout(a_s) 771 << " in " << sout(a_s) 772 << " : " << sout(gs) 772 << " : " << sout(gs) 773 << " not a number." 773 << " not a number." 774 << std::endl; 774 << std::endl; 775 return false; 775 return false; 776 } 776 } 777 const std::string& bs = ws[3]; 777 const std::string& bs = ws[3]; 778 float b; 778 float b; 779 if(!to<float>(bs,b)) { 779 if(!to<float>(bs,b)) { 780 a_out << "style_parser::parse :" 780 a_out << "style_parser::parse :" 781 << " in " << sout(a_s) 781 << " in " << sout(a_s) 782 << " : " << sout(bs) 782 << " : " << sout(bs) 783 << " not a number." 783 << " not a number." 784 << std::endl; 784 << std::endl; 785 return false; 785 return false; 786 } 786 } 787 m_highlight_color.set_value(r,g,b,1) 787 m_highlight_color.set_value(r,g,b,1); 788 788 789 } else if (wordn==5) { 789 } else if (wordn==5) { 790 const std::string& rs = ws[1]; 790 const std::string& rs = ws[1]; 791 float r; 791 float r; 792 if(!to<float>(rs,r)) { 792 if(!to<float>(rs,r)) { 793 a_out << "style_parser::parse :" 793 a_out << "style_parser::parse :" 794 << " in " << sout(a_s) 794 << " in " << sout(a_s) 795 << " : " << sout(rs) 795 << " : " << sout(rs) 796 << " not a number." 796 << " not a number." 797 << std::endl; 797 << std::endl; 798 return false; 798 return false; 799 } 799 } 800 const std::string& gs = ws[2]; 800 const std::string& gs = ws[2]; 801 float g; 801 float g; 802 if(!to<float>(gs,g)) { 802 if(!to<float>(gs,g)) { 803 a_out << "style_parser::parse :" 803 a_out << "style_parser::parse :" 804 << " in " << sout(a_s) 804 << " in " << sout(a_s) 805 << " : " << sout(gs) 805 << " : " << sout(gs) 806 << " not a number." 806 << " not a number." 807 << std::endl; 807 << std::endl; 808 return false; 808 return false; 809 } 809 } 810 const std::string& bs = ws[3]; 810 const std::string& bs = ws[3]; 811 float b; 811 float b; 812 if(!to<float>(bs,b)) { 812 if(!to<float>(bs,b)) { 813 a_out << "style_parser::parse :" 813 a_out << "style_parser::parse :" 814 << " in " << sout(a_s) 814 << " in " << sout(a_s) 815 << " : " << sout(bs) 815 << " : " << sout(bs) 816 << " not a number." 816 << " not a number." 817 << std::endl; 817 << std::endl; 818 return false; 818 return false; 819 } 819 } 820 const std::string& as = ws[4]; 820 const std::string& as = ws[4]; 821 float a; 821 float a; 822 if(!to<float>(as,a)) { 822 if(!to<float>(as,a)) { 823 a_out << "style_parser::parse :" 823 a_out << "style_parser::parse :" 824 << " in " << sout(a_s) 824 << " in " << sout(a_s) 825 << " : " << sout(as) 825 << " : " << sout(as) 826 << " not a number." 826 << " not a number." 827 << std::endl; 827 << std::endl; 828 return false; 828 return false; 829 } 829 } 830 m_highlight_color.set_value(r,g,b,a) 830 m_highlight_color.set_value(r,g,b,a); 831 831 832 } else { 832 } else { 833 a_out << "style_parser::parse :" 833 a_out << "style_parser::parse :" 834 << " in " << sout(a_s) 834 << " in " << sout(a_s) 835 << " : " << sout(line) 835 << " : " << sout(line) 836 << " has a bad word count (two 836 << " has a bad word count (two or four expected)." 837 << std::endl; 837 << std::endl; 838 return false; 838 return false; 839 } 839 } 840 840 841 } else if(word0=="back_color") { 841 } else if(word0=="back_color") { 842 if(wordn==2) { 842 if(wordn==2) { 843 const std::string& word1 = ws[1]; 843 const std::string& word1 = ws[1]; 844 if(!find_color(a_cmaps,word1,m_back_ 844 if(!find_color(a_cmaps,word1,m_back_color)) { 845 a_out << "style_parser::parse :" 845 a_out << "style_parser::parse :" 846 << " in " << sout(a_s) 846 << " in " << sout(a_s) 847 << " : " << sout(word1) 847 << " : " << sout(word1) 848 << " not a color." 848 << " not a color." 849 << std::endl; 849 << std::endl; 850 return false; 850 return false; 851 } 851 } 852 } else if (wordn==4) { 852 } else if (wordn==4) { 853 const std::string& rs = ws[1]; 853 const std::string& rs = ws[1]; 854 float r; 854 float r; 855 if(!to<float>(rs,r)) { 855 if(!to<float>(rs,r)) { 856 a_out << "style_parser::parse :" 856 a_out << "style_parser::parse :" 857 << " in " << sout(a_s) 857 << " in " << sout(a_s) 858 << " : " << sout(rs) 858 << " : " << sout(rs) 859 << " not a number." 859 << " not a number." 860 << std::endl; 860 << std::endl; 861 return false; 861 return false; 862 } 862 } 863 const std::string& gs = ws[2]; 863 const std::string& gs = ws[2]; 864 float g; 864 float g; 865 if(!to<float>(gs,g)) { 865 if(!to<float>(gs,g)) { 866 a_out << "style_parser::parse :" 866 a_out << "style_parser::parse :" 867 << " in " << sout(a_s) 867 << " in " << sout(a_s) 868 << " : " << sout(gs) 868 << " : " << sout(gs) 869 << " not a number." 869 << " not a number." 870 << std::endl; 870 << std::endl; 871 return false; 871 return false; 872 } 872 } 873 const std::string& bs = ws[3]; 873 const std::string& bs = ws[3]; 874 float b; 874 float b; 875 if(!to<float>(bs,b)) { 875 if(!to<float>(bs,b)) { 876 a_out << "style_parser::parse :" 876 a_out << "style_parser::parse :" 877 << " in " << sout(a_s) 877 << " in " << sout(a_s) 878 << " : " << sout(bs) 878 << " : " << sout(bs) 879 << " not a number." 879 << " not a number." 880 << std::endl; 880 << std::endl; 881 return false; 881 return false; 882 } 882 } 883 m_back_color.set_value(r,g,b,1); 883 m_back_color.set_value(r,g,b,1); 884 884 885 } else if (wordn==5) { 885 } else if (wordn==5) { 886 const std::string& rs = ws[1]; 886 const std::string& rs = ws[1]; 887 float r; 887 float r; 888 if(!to<float>(rs,r)) { 888 if(!to<float>(rs,r)) { 889 a_out << "style_parser::parse :" 889 a_out << "style_parser::parse :" 890 << " in " << sout(a_s) 890 << " in " << sout(a_s) 891 << " : " << sout(rs) 891 << " : " << sout(rs) 892 << " not a number." 892 << " not a number." 893 << std::endl; 893 << std::endl; 894 return false; 894 return false; 895 } 895 } 896 const std::string& gs = ws[2]; 896 const std::string& gs = ws[2]; 897 float g; 897 float g; 898 if(!to<float>(gs,g)) { 898 if(!to<float>(gs,g)) { 899 a_out << "style_parser::parse :" 899 a_out << "style_parser::parse :" 900 << " in " << sout(a_s) 900 << " in " << sout(a_s) 901 << " : " << sout(gs) 901 << " : " << sout(gs) 902 << " not a number." 902 << " not a number." 903 << std::endl; 903 << std::endl; 904 return false; 904 return false; 905 } 905 } 906 const std::string& bs = ws[3]; 906 const std::string& bs = ws[3]; 907 float b; 907 float b; 908 if(!to<float>(bs,b)) { 908 if(!to<float>(bs,b)) { 909 a_out << "style_parser::parse :" 909 a_out << "style_parser::parse :" 910 << " in " << sout(a_s) 910 << " in " << sout(a_s) 911 << " : " << sout(bs) 911 << " : " << sout(bs) 912 << " not a number." 912 << " not a number." 913 << std::endl; 913 << std::endl; 914 return false; 914 return false; 915 } 915 } 916 const std::string& as = ws[4]; 916 const std::string& as = ws[4]; 917 float a; 917 float a; 918 if(!to<float>(as,a)) { 918 if(!to<float>(as,a)) { 919 a_out << "style_parser::parse :" 919 a_out << "style_parser::parse :" 920 << " in " << sout(a_s) 920 << " in " << sout(a_s) 921 << " : " << sout(as) 921 << " : " << sout(as) 922 << " not a number." 922 << " not a number." 923 << std::endl; 923 << std::endl; 924 return false; 924 return false; 925 } 925 } 926 m_back_color.set_value(r,g,b,a); 926 m_back_color.set_value(r,g,b,a); 927 927 928 } else { 928 } else { 929 a_out << "style_parser::parse :" 929 a_out << "style_parser::parse :" 930 << " in " << sout(a_s) 930 << " in " << sout(a_s) 931 << " : " << sout(line) 931 << " : " << sout(line) 932 << " has a bad word count (two 932 << " has a bad word count (two or four expected)." 933 << std::endl; 933 << std::endl; 934 return false; 934 return false; 935 } 935 } 936 936 937 } else if(word0=="pattern") { 937 } else if(word0=="pattern") { 938 if(!check_2(wordn,a_s,line,a_out)) ret 938 if(!check_2(wordn,a_s,line,a_out)) return false; 939 const std::string& word1 = ws[1]; 939 const std::string& word1 = ws[1]; 940 unsigned long ul; 940 unsigned long ul; 941 if(!sline_pattern(word1,m_pattern)) { 941 if(!sline_pattern(word1,m_pattern)) { 942 if(!to_ulong(word1,ul)) { 942 if(!to_ulong(word1,ul)) { 943 a_out << "style_parser::parse :" 943 a_out << "style_parser::parse :" 944 << " in " << sout(a_s) 944 << " in " << sout(a_s) 945 << " : " << sout(word1) 945 << " : " << sout(word1) 946 << " not a line pattern." 946 << " not a line pattern." 947 << std::endl; 947 << std::endl; 948 return false; 948 return false; 949 } 949 } 950 m_pattern = (lpat)ul; 950 m_pattern = (lpat)ul; 951 } 951 } 952 952 953 } else if(word0=="line_pattern") { 953 } else if(word0=="line_pattern") { 954 if(!check_2(wordn,a_s,line,a_out)) ret 954 if(!check_2(wordn,a_s,line,a_out)) return false; 955 const std::string& word1 = ws[1]; 955 const std::string& word1 = ws[1]; 956 unsigned long ul; 956 unsigned long ul; 957 if(!sline_pattern(word1,m_line_pattern 957 if(!sline_pattern(word1,m_line_pattern)) { 958 if(!to_ulong(word1,ul)) { 958 if(!to_ulong(word1,ul)) { 959 a_out << "style_parser::parse :" 959 a_out << "style_parser::parse :" 960 << " in " << sout(a_s) 960 << " in " << sout(a_s) 961 << " : " << sout(word1) 961 << " : " << sout(word1) 962 << " not a line pattern." 962 << " not a line pattern." 963 << std::endl; 963 << std::endl; 964 return false; 964 return false; 965 } 965 } 966 m_line_pattern = (lpat)ul; 966 m_line_pattern = (lpat)ul; 967 } 967 } 968 } else if(word0=="marker_style") { 968 } else if(word0=="marker_style") { 969 if(!check_2(wordn,a_s,line,a_out)) ret 969 if(!check_2(wordn,a_s,line,a_out)) return false; 970 const std::string& word1 = ws[1]; 970 const std::string& word1 = ws[1]; 971 if(!smarker_style(word1,m_marker_style 971 if(!smarker_style(word1,m_marker_style)) { 972 a_out << "style_parser::parse :" 972 a_out << "style_parser::parse :" 973 << " in " << sout(a_s) 973 << " in " << sout(a_s) 974 << " : " << sout(word1) 974 << " : " << sout(word1) 975 << " not a marker_style." 975 << " not a marker_style." 976 << std::endl; 976 << std::endl; 977 return false; 977 return false; 978 } 978 } 979 } else if(word0=="area_style") { 979 } else if(word0=="area_style") { 980 if(!check_2(wordn,a_s,line,a_out)) ret 980 if(!check_2(wordn,a_s,line,a_out)) return false; 981 const std::string& word1 = ws[1]; 981 const std::string& word1 = ws[1]; 982 if(!sarea_style(word1,m_area_style)) { 982 if(!sarea_style(word1,m_area_style)) { 983 a_out << "style_parser::parse :" 983 a_out << "style_parser::parse :" 984 << " in " << sout(a_s) 984 << " in " << sout(a_s) 985 << " : " << sout(word1) 985 << " : " << sout(word1) 986 << " not a area_style." 986 << " not a area_style." 987 << std::endl; 987 << std::endl; 988 return false; 988 return false; 989 } 989 } 990 } else if(word0=="modeling") { 990 } else if(word0=="modeling") { 991 if(!check_2(wordn,a_s,line,a_out)) ret 991 if(!check_2(wordn,a_s,line,a_out)) return false; 992 m_modeling = ws[1]; 992 m_modeling = ws[1]; 993 } else if(word0=="light_model") { 993 } else if(word0=="light_model") { 994 if(!check_2(wordn,a_s,line,a_out)) ret 994 if(!check_2(wordn,a_s,line,a_out)) return false; 995 m_light_model = ws[1]; 995 m_light_model = ws[1]; 996 } else if(word0=="tick_modeling") { 996 } else if(word0=="tick_modeling") { 997 if(!check_2(wordn,a_s,line,a_out)) ret 997 if(!check_2(wordn,a_s,line,a_out)) return false; 998 m_tick_modeling = ws[1]; 998 m_tick_modeling = ws[1]; 999 } else if(word0=="encoding") { 999 } else if(word0=="encoding") { 1000 if(!check_2(wordn,a_s,line,a_out)) re 1000 if(!check_2(wordn,a_s,line,a_out)) return false; 1001 m_encoding = ws[1]; 1001 m_encoding = ws[1]; 1002 } else if(word0=="smoothing") { 1002 } else if(word0=="smoothing") { 1003 if(!check_2(wordn,a_s,line,a_out)) re 1003 if(!check_2(wordn,a_s,line,a_out)) return false; 1004 bool value; 1004 bool value; 1005 if(!check_bool(ws[1],a_s,a_out,value) 1005 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1006 m_smoothing = value; 1006 m_smoothing = value; 1007 } else if(word0=="hinting") { 1007 } else if(word0=="hinting") { 1008 if(!check_2(wordn,a_s,line,a_out)) re 1008 if(!check_2(wordn,a_s,line,a_out)) return false; 1009 bool value; 1009 bool value; 1010 if(!check_bool(ws[1],a_s,a_out,value) 1010 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1011 m_hinting = value; 1011 m_hinting = value; 1012 } else if(word0=="enforced") { 1012 } else if(word0=="enforced") { 1013 if(!check_2(wordn,a_s,line,a_out)) re 1013 if(!check_2(wordn,a_s,line,a_out)) return false; 1014 bool value; 1014 bool value; 1015 if(!check_bool(ws[1],a_s,a_out,value) 1015 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1016 m_enforced = value; 1016 m_enforced = value; 1017 } else if(word0=="cut") { 1017 } else if(word0=="cut") { 1018 m_cut = ""; 1018 m_cut = ""; 1019 for(unsigned int wordi=1;wordi<wordn; 1019 for(unsigned int wordi=1;wordi<wordn;wordi++) { 1020 if(wordi!=1) m_cut += " "; 1020 if(wordi!=1) m_cut += " "; 1021 m_cut += ws[wordi]; 1021 m_cut += ws[wordi]; 1022 } 1022 } 1023 } else if(word0=="options") { 1023 } else if(word0=="options") { 1024 m_options = ""; 1024 m_options = ""; 1025 for(unsigned int wordi=1;wordi<wordn; 1025 for(unsigned int wordi=1;wordi<wordn;wordi++) { 1026 if(wordi!=1) m_options += " "; 1026 if(wordi!=1) m_options += " "; 1027 m_options += ws[wordi]; 1027 m_options += ws[wordi]; 1028 } 1028 } 1029 } else if(word0=="color_mapping") { 1029 } else if(word0=="color_mapping") { 1030 m_color_mapping = ""; 1030 m_color_mapping = ""; 1031 for(unsigned int wordi=1;wordi<wordn; 1031 for(unsigned int wordi=1;wordi<wordn;wordi++) { 1032 if(wordi!=1) m_color_mapping += " " 1032 if(wordi!=1) m_color_mapping += " "; 1033 m_color_mapping += ws[wordi]; 1033 m_color_mapping += ws[wordi]; 1034 } 1034 } 1035 } else if(word0=="painting") { 1035 } else if(word0=="painting") { 1036 if(!check_2(wordn,a_s,line,a_out)) re 1036 if(!check_2(wordn,a_s,line,a_out)) return false; 1037 if(!spainting_policy(ws[1],m_painting 1037 if(!spainting_policy(ws[1],m_painting)) { 1038 a_out << "style_parser::parse :" 1038 a_out << "style_parser::parse :" 1039 << " in " << sout(a_s) 1039 << " in " << sout(a_s) 1040 << " : " << sout(ws[1]) 1040 << " : " << sout(ws[1]) 1041 << " not a painting_policy." 1041 << " not a painting_policy." 1042 << std::endl; 1042 << std::endl; 1043 return false; 1043 return false; 1044 } 1044 } 1045 } else if(word0=="hatching") { 1045 } else if(word0=="hatching") { 1046 if(!check_2(wordn,a_s,line,a_out)) re 1046 if(!check_2(wordn,a_s,line,a_out)) return false; 1047 if(!shatching_policy(ws[1],m_hatching 1047 if(!shatching_policy(ws[1],m_hatching)) { 1048 a_out << "style_parser::parse :" 1048 a_out << "style_parser::parse :" 1049 << " in " << sout(a_s) 1049 << " in " << sout(a_s) 1050 << " : " << sout(ws[1]) 1050 << " : " << sout(ws[1]) 1051 << " not a hatching_policy." 1051 << " not a hatching_policy." 1052 << std::endl; 1052 << std::endl; 1053 return false; 1053 return false; 1054 } 1054 } 1055 } else if(word0=="projection") { 1055 } else if(word0=="projection") { 1056 if(!check_2(wordn,a_s,line,a_out)) re 1056 if(!check_2(wordn,a_s,line,a_out)) return false; 1057 if(!sprojection_type(ws[1],m_projecti 1057 if(!sprojection_type(ws[1],m_projection)) { 1058 a_out << "style_parser::parse :" 1058 a_out << "style_parser::parse :" 1059 << " in " << sout(a_s) 1059 << " in " << sout(a_s) 1060 << " : " << sout(ws[1]) 1060 << " : " << sout(ws[1]) 1061 << " not a projection_type." 1061 << " not a projection_type." 1062 << std::endl; 1062 << std::endl; 1063 return false; 1063 return false; 1064 } 1064 } 1065 } else if(word0=="font") { 1065 } else if(word0=="font") { 1066 if(!check_2(wordn,a_s,line,a_out)) re 1066 if(!check_2(wordn,a_s,line,a_out)) return false; 1067 font(ws[1]); 1067 font(ws[1]); 1068 } else if(word0=="width") { 1068 } else if(word0=="width") { 1069 if(!check_2(wordn,a_s,line,a_out)) re 1069 if(!check_2(wordn,a_s,line,a_out)) return false; 1070 float value; 1070 float value; 1071 if(!check_float(ws[1],a_s,a_out,value 1071 if(!check_float(ws[1],a_s,a_out,value)) return false; 1072 m_width = value; 1072 m_width = value; 1073 } else if(word0=="line_width") { 1073 } else if(word0=="line_width") { 1074 if(!check_2(wordn,a_s,line,a_out)) re 1074 if(!check_2(wordn,a_s,line,a_out)) return false; 1075 float value; 1075 float value; 1076 if(!check_float(ws[1],a_s,a_out,value 1076 if(!check_float(ws[1],a_s,a_out,value)) return false; 1077 m_line_width = value; 1077 m_line_width = value; 1078 } else if(word0=="marker_size") { 1078 } else if(word0=="marker_size") { 1079 if(!check_2(wordn,a_s,line,a_out)) re 1079 if(!check_2(wordn,a_s,line,a_out)) return false; 1080 float value; 1080 float value; 1081 if(!check_float(ws[1],a_s,a_out,value 1081 if(!check_float(ws[1],a_s,a_out,value)) return false; 1082 m_marker_size = value; 1082 m_marker_size = value; 1083 } else if(word0=="point_size") { 1083 } else if(word0=="point_size") { 1084 if(!check_2(wordn,a_s,line,a_out)) re 1084 if(!check_2(wordn,a_s,line,a_out)) return false; 1085 float value; 1085 float value; 1086 if(!check_float(ws[1],a_s,a_out,value 1086 if(!check_float(ws[1],a_s,a_out,value)) return false; 1087 m_point_size = value; 1087 m_point_size = value; 1088 } else if(word0=="font_size") { 1088 } else if(word0=="font_size") { 1089 if(!check_2(wordn,a_s,line,a_out)) re 1089 if(!check_2(wordn,a_s,line,a_out)) return false; 1090 float value; 1090 float value; 1091 if(!check_float(ws[1],a_s,a_out,value 1091 if(!check_float(ws[1],a_s,a_out,value)) return false; 1092 m_font_size = value; 1092 m_font_size = value; 1093 } else if(word0=="font_modeling") { 1093 } else if(word0=="font_modeling") { 1094 if(!check_2(wordn,a_s,line,a_out)) re 1094 if(!check_2(wordn,a_s,line,a_out)) return false; 1095 if(ws[1]==s_font_outline()) m_fo 1095 if(ws[1]==s_font_outline()) m_font_modeling = font_outline; 1096 else if(ws[1]==s_font_filled()) m_fo 1096 else if(ws[1]==s_font_filled()) m_font_modeling = font_filled; 1097 else if(ws[1]==s_font_pixmap()) m_fo 1097 else if(ws[1]==s_font_pixmap()) m_font_modeling = font_pixmap; 1098 else { 1098 else { 1099 a_out << "style_parser::parse :" 1099 a_out << "style_parser::parse :" 1100 << " in " << sout(a_s) 1100 << " in " << sout(a_s) 1101 << " : " << sout(ws[1]) 1101 << " : " << sout(ws[1]) 1102 << " not a font_modeling." 1102 << " not a font_modeling." 1103 << std::endl; 1103 << std::endl; 1104 return false; 1104 return false; 1105 } 1105 } 1106 } else if(word0=="back_shadow") { 1106 } else if(word0=="back_shadow") { 1107 if(!check_2(wordn,a_s,line,a_out)) re 1107 if(!check_2(wordn,a_s,line,a_out)) return false; 1108 float value; 1108 float value; 1109 if(!check_float(ws[1],a_s,a_out,value 1109 if(!check_float(ws[1],a_s,a_out,value)) return false; 1110 if(value<0.F) value = 0.F; 1110 if(value<0.F) value = 0.F; 1111 m_back_shadow = value; 1111 m_back_shadow = value; 1112 } else if(word0=="multi_node_limit") { 1112 } else if(word0=="multi_node_limit") { 1113 if(!check_2(wordn,a_s,line,a_out)) re 1113 if(!check_2(wordn,a_s,line,a_out)) return false; 1114 int value = 0; 1114 int value = 0; 1115 if(!check_int(ws[1],a_s,a_out,value)) 1115 if(!check_int(ws[1],a_s,a_out,value)) return false; 1116 m_multi_node_limit = value; 1116 m_multi_node_limit = value; 1117 } else if(word0=="divisions") { 1117 } else if(word0=="divisions") { 1118 if(!check_2(wordn,a_s,line,a_out)) re 1118 if(!check_2(wordn,a_s,line,a_out)) return false; 1119 int value = 0; 1119 int value = 0; 1120 if(!check_int(ws[1],a_s,a_out,value)) 1120 if(!check_int(ws[1],a_s,a_out,value)) return false; 1121 m_divisions = value; 1121 m_divisions = value; 1122 } else if(word0=="rotation_steps") { 1122 } else if(word0=="rotation_steps") { 1123 if(!check_2(wordn,a_s,line,a_out)) re 1123 if(!check_2(wordn,a_s,line,a_out)) return false; 1124 unsigned int value; 1124 unsigned int value; 1125 if(!check_uint(ws[1],a_s,a_out,value) 1125 if(!check_uint(ws[1],a_s,a_out,value)) return false; 1126 m_rotation_steps = value; 1126 m_rotation_steps = value; 1127 } else if(word0=="angle") { 1127 } else if(word0=="angle") { 1128 if(!check_2(wordn,a_s,line,a_out)) re 1128 if(!check_2(wordn,a_s,line,a_out)) return false; 1129 float value; 1129 float value; 1130 if(!check_float(ws[1],a_s,a_out,value 1130 if(!check_float(ws[1],a_s,a_out,value)) return false; 1131 m_angle = value; 1131 m_angle = value; 1132 } else if(word0=="scale") { 1132 } else if(word0=="scale") { 1133 if(!check_2(wordn,a_s,line,a_out)) re 1133 if(!check_2(wordn,a_s,line,a_out)) return false; 1134 float value; 1134 float value; 1135 if(!check_float(ws[1],a_s,a_out,value 1135 if(!check_float(ws[1],a_s,a_out,value)) return false; 1136 m_scale = value; 1136 m_scale = value; 1137 } else if(word0=="offset") { 1137 } else if(word0=="offset") { 1138 if(!check_2(wordn,a_s,line,a_out)) re 1138 if(!check_2(wordn,a_s,line,a_out)) return false; 1139 float value; 1139 float value; 1140 if(!check_float(ws[1],a_s,a_out,value 1140 if(!check_float(ws[1],a_s,a_out,value)) return false; 1141 m_offset = value; 1141 m_offset = value; 1142 } else if(word0=="strip_width") { 1142 } else if(word0=="strip_width") { 1143 if(!check_2(wordn,a_s,line,a_out)) re 1143 if(!check_2(wordn,a_s,line,a_out)) return false; 1144 float value; 1144 float value; 1145 if(!check_float(ws[1],a_s,a_out,value 1145 if(!check_float(ws[1],a_s,a_out,value)) return false; 1146 m_strip_width = value; 1146 m_strip_width = value; 1147 } else if(word0=="spacing") { 1147 } else if(word0=="spacing") { 1148 if(!check_2(wordn,a_s,line,a_out)) re 1148 if(!check_2(wordn,a_s,line,a_out)) return false; 1149 float value; 1149 float value; 1150 if(!check_float(ws[1],a_s,a_out,value 1150 if(!check_float(ws[1],a_s,a_out,value)) return false; 1151 m_spacing = value; 1151 m_spacing = value; 1152 } else if(word0=="visible") { 1152 } else if(word0=="visible") { 1153 if(!check_2(wordn,a_s,line,a_out)) re 1153 if(!check_2(wordn,a_s,line,a_out)) return false; 1154 bool value; 1154 bool value; 1155 if(!check_bool(ws[1],a_s,a_out,value) 1155 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1156 m_visible = value; 1156 m_visible = value; 1157 } else if(word0=="editable") { 1157 } else if(word0=="editable") { 1158 if(!check_2(wordn,a_s,line,a_out)) re 1158 if(!check_2(wordn,a_s,line,a_out)) return false; 1159 bool value; 1159 bool value; 1160 if(!check_bool(ws[1],a_s,a_out,value) 1160 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1161 m_editable = value; 1161 m_editable = value; 1162 } else if(word0=="pickable") { 1162 } else if(word0=="pickable") { 1163 if(!check_2(wordn,a_s,line,a_out)) re 1163 if(!check_2(wordn,a_s,line,a_out)) return false; 1164 bool value; 1164 bool value; 1165 if(!check_bool(ws[1],a_s,a_out,value) 1165 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1166 m_pickable = value; 1166 m_pickable = value; 1167 } else if(word0=="automated") { 1167 } else if(word0=="automated") { 1168 if(!check_2(wordn,a_s,line,a_out)) re 1168 if(!check_2(wordn,a_s,line,a_out)) return false; 1169 bool value; 1169 bool value; 1170 if(!check_bool(ws[1],a_s,a_out,value) 1170 if(!check_bool(ws[1],a_s,a_out,value)) return false; 1171 m_automated = value; 1171 m_automated = value; 1172 } else if(word0=="bar_offset") { 1172 } else if(word0=="bar_offset") { 1173 if(!check_2(wordn,a_s,line,a_out)) re 1173 if(!check_2(wordn,a_s,line,a_out)) return false; 1174 float value; 1174 float value; 1175 if(!check_float(ws[1],a_s,a_out,value 1175 if(!check_float(ws[1],a_s,a_out,value)) return false; 1176 m_bar_offset = value; 1176 m_bar_offset = value; 1177 } else if(word0=="bar_width") { 1177 } else if(word0=="bar_width") { 1178 if(!check_2(wordn,a_s,line,a_out)) re 1178 if(!check_2(wordn,a_s,line,a_out)) return false; 1179 float value; 1179 float value; 1180 if(!check_float(ws[1],a_s,a_out,value 1180 if(!check_float(ws[1],a_s,a_out,value)) return false; 1181 m_bar_width = value; 1181 m_bar_width = value; 1182 1182 1183 } else if(word0=="translation") { 1183 } else if(word0=="translation") { 1184 if (wordn==4) { 1184 if (wordn==4) { 1185 const std::string& sx = ws[1]; 1185 const std::string& sx = ws[1]; 1186 float x; 1186 float x; 1187 if(!to<float>(sx,x)) { 1187 if(!to<float>(sx,x)) { 1188 a_out << "style_parser::parse :" 1188 a_out << "style_parser::parse :" 1189 << " in " << sout(a_s) 1189 << " in " << sout(a_s) 1190 << " : " << sout(sx) 1190 << " : " << sout(sx) 1191 << " not a number." 1191 << " not a number." 1192 << std::endl; 1192 << std::endl; 1193 return false; 1193 return false; 1194 } 1194 } 1195 const std::string& sy = ws[2]; 1195 const std::string& sy = ws[2]; 1196 float y; 1196 float y; 1197 if(!to<float>(sy,y)) { 1197 if(!to<float>(sy,y)) { 1198 a_out << "style_parser::parse :" 1198 a_out << "style_parser::parse :" 1199 << " in " << sout(a_s) 1199 << " in " << sout(a_s) 1200 << " : " << sout(sy) 1200 << " : " << sout(sy) 1201 << " not a number." 1201 << " not a number." 1202 << std::endl; 1202 << std::endl; 1203 return false; 1203 return false; 1204 } 1204 } 1205 const std::string& sz = ws[3]; 1205 const std::string& sz = ws[3]; 1206 float z; 1206 float z; 1207 if(!to<float>(sz,z)) { 1207 if(!to<float>(sz,z)) { 1208 a_out << "style_parser::parse :" 1208 a_out << "style_parser::parse :" 1209 << " in " << sout(a_s) 1209 << " in " << sout(a_s) 1210 << " : " << sout(sz) 1210 << " : " << sout(sz) 1211 << " not a number." 1211 << " not a number." 1212 << std::endl; 1212 << std::endl; 1213 return false; 1213 return false; 1214 } 1214 } 1215 m_translation.set_value(x,y,z); 1215 m_translation.set_value(x,y,z); 1216 } else { 1216 } else { 1217 a_out << "style_parser::parse :" 1217 a_out << "style_parser::parse :" 1218 << " in " << sout(a_s) 1218 << " in " << sout(a_s) 1219 << " has a bad word count (fo 1219 << " has a bad word count (four expected)." 1220 << std::endl; 1220 << std::endl; 1221 return false; 1221 return false; 1222 } 1222 } 1223 1223 1224 } else if(word0=="front_face") { 1224 } else if(word0=="front_face") { 1225 if(!check_2(wordn,a_s,line,a_out)) re 1225 if(!check_2(wordn,a_s,line,a_out)) return false; 1226 const std::string& word1 = ws[1]; 1226 const std::string& word1 = ws[1]; 1227 if(word1=="ccw") { 1227 if(word1=="ccw") { 1228 m_front_face = winding_ccw; 1228 m_front_face = winding_ccw; 1229 } else if(word1=="cw") { 1229 } else if(word1=="cw") { 1230 m_front_face = winding_cw; 1230 m_front_face = winding_cw; 1231 } else { //ccw 1231 } else { //ccw 1232 a_out << "style_parser::parse :" 1232 a_out << "style_parser::parse :" 1233 << " in " << sout(a_s) 1233 << " in " << sout(a_s) 1234 << " : " << sout(word1) 1234 << " : " << sout(word1) 1235 << " not a winding type." 1235 << " not a winding type." 1236 << std::endl; 1236 << std::endl; 1237 return false; 1237 return false; 1238 } 1238 } 1239 1239 1240 } else if(word0=="hjust") { 1240 } else if(word0=="hjust") { 1241 if(!check_2(wordn,a_s,line,a_out)) re 1241 if(!check_2(wordn,a_s,line,a_out)) return false; 1242 const std::string& word1 = ws[1]; 1242 const std::string& word1 = ws[1]; 1243 if(!shjust(word1,m_hjust)) { 1243 if(!shjust(word1,m_hjust)) { 1244 a_out << "style_parser::parse :" 1244 a_out << "style_parser::parse :" 1245 << " in " << sout(a_s) 1245 << " in " << sout(a_s) 1246 << " : " << sout(word1) 1246 << " : " << sout(word1) 1247 << " not a hjust." 1247 << " not a hjust." 1248 << std::endl; 1248 << std::endl; 1249 return false; 1249 return false; 1250 } 1250 } 1251 1251 1252 } else if(word0=="vjust") { 1252 } else if(word0=="vjust") { 1253 if(!check_2(wordn,a_s,line,a_out)) re 1253 if(!check_2(wordn,a_s,line,a_out)) return false; 1254 const std::string& word1 = ws[1]; 1254 const std::string& word1 = ws[1]; 1255 if(!svjust(word1,m_vjust)) { 1255 if(!svjust(word1,m_vjust)) { 1256 a_out << "style_parser::parse :" 1256 a_out << "style_parser::parse :" 1257 << " in " << sout(a_s) 1257 << " in " << sout(a_s) 1258 << " : " << sout(word1) 1258 << " : " << sout(word1) 1259 << " not a vjust." 1259 << " not a vjust." 1260 << std::endl; 1260 << std::endl; 1261 return false; 1261 return false; 1262 } 1262 } 1263 1263 1264 } else if(word0=="coloring") { 1264 } else if(word0=="coloring") { 1265 if(!check_2(wordn,a_s,line,a_out)) re 1265 if(!check_2(wordn,a_s,line,a_out)) return false; 1266 m_coloring = ws[1]; 1266 m_coloring = ws[1]; 1267 1267 1268 } else if(word0=="title") { 1268 } else if(word0=="title") { 1269 if(!check_2(wordn,a_s,line,a_out)) re 1269 if(!check_2(wordn,a_s,line,a_out)) return false; 1270 m_title = ws[1]; 1270 m_title = ws[1]; 1271 1271 1272 } else { 1272 } else { 1273 a_out << "style_parser::parse :" 1273 a_out << "style_parser::parse :" 1274 << " in " << sout(a_s) 1274 << " in " << sout(a_s) 1275 << " : " << sout(word0) 1275 << " : " << sout(word0) 1276 << " bad option." 1276 << " bad option." 1277 << std::endl; 1277 << std::endl; 1278 return false; 1278 return false; 1279 } 1279 } 1280 } 1280 } 1281 return true; 1281 return true; 1282 } 1282 } 1283 1283 1284 protected: 1284 protected: 1285 static bool check_2(size_t a_n, 1285 static bool check_2(size_t a_n, 1286 const std::string& a_s, 1286 const std::string& a_s, 1287 const std::string& a_li 1287 const std::string& a_line,std::ostream& a_out) { 1288 if(a_n!=2) { 1288 if(a_n!=2) { 1289 a_out << "style_parser::parse :" 1289 a_out << "style_parser::parse :" 1290 << " in " << sout(a_s) 1290 << " in " << sout(a_s) 1291 << " : " << sout(a_line) 1291 << " : " << sout(a_line) 1292 << " has a bad word count (two ex 1292 << " has a bad word count (two expected)." 1293 << std::endl; 1293 << std::endl; 1294 return false; 1294 return false; 1295 } 1295 } 1296 return true; 1296 return true; 1297 } 1297 } 1298 1298 1299 static bool check_bool(const std::string& a 1299 static bool check_bool(const std::string& a_w, 1300 const std::string& a 1300 const std::string& a_s,std::ostream& a_out,bool& a_v){ 1301 if(!to(a_w,a_v)){ 1301 if(!to(a_w,a_v)){ 1302 a_out << "style_parser::parse :" 1302 a_out << "style_parser::parse :" 1303 << " in " << sout(a_s) 1303 << " in " << sout(a_s) 1304 << " : " << sout(a_w) 1304 << " : " << sout(a_w) 1305 << " not a boolean." 1305 << " not a boolean." 1306 << std::endl; 1306 << std::endl; 1307 return false; 1307 return false; 1308 } 1308 } 1309 return true; 1309 return true; 1310 } 1310 } 1311 1311 1312 static bool check_int(const std::string& a_ 1312 static bool check_int(const std::string& a_w, 1313 const std::string& a_ 1313 const std::string& a_s,std::ostream& a_out,int& a_v) { 1314 if(!to<int>(a_w,a_v)){ 1314 if(!to<int>(a_w,a_v)){ 1315 a_out << "style_parser::parse :" 1315 a_out << "style_parser::parse :" 1316 << " in " << sout(a_s) 1316 << " in " << sout(a_s) 1317 << " : " << sout(a_w) 1317 << " : " << sout(a_w) 1318 << " not an int." 1318 << " not an int." 1319 << std::endl; 1319 << std::endl; 1320 return false; 1320 return false; 1321 } 1321 } 1322 return true; 1322 return true; 1323 } 1323 } 1324 1324 1325 static bool check_uint(const std::string& a 1325 static bool check_uint(const std::string& a_w, 1326 const std::string& a_s,std::o 1326 const std::string& a_s,std::ostream& a_out,unsigned int& a_v) { 1327 if(!to<unsigned int>(a_w,a_v)){ 1327 if(!to<unsigned int>(a_w,a_v)){ 1328 a_out << "style_parser::parse :" 1328 a_out << "style_parser::parse :" 1329 << " in " << sout(a_s) 1329 << " in " << sout(a_s) 1330 << " : " << sout(a_w) 1330 << " : " << sout(a_w) 1331 << " not an unsigned int." 1331 << " not an unsigned int." 1332 << std::endl; 1332 << std::endl; 1333 return false; 1333 return false; 1334 } 1334 } 1335 return true; 1335 return true; 1336 } 1336 } 1337 1337 1338 static bool check_float(const std::string& 1338 static bool check_float(const std::string& a_w, 1339 const std::string& a_s,std::o 1339 const std::string& a_s,std::ostream& a_out,float& a_v) { 1340 if(!to<float>(a_w,a_v)){ 1340 if(!to<float>(a_w,a_v)){ 1341 a_out << "style_parser::parse :" 1341 a_out << "style_parser::parse :" 1342 << " in " << sout(a_s) 1342 << " in " << sout(a_s) 1343 << " : " << sout(a_w) 1343 << " : " << sout(a_w) 1344 << " not a float." 1344 << " not a float." 1345 << std::endl; 1345 << std::endl; 1346 return false; 1346 return false; 1347 } 1347 } 1348 return true; 1348 return true; 1349 } 1349 } 1350 1350 1351 protected: 1351 protected: 1352 colorf m_color; 1352 colorf m_color; 1353 colorf m_highlight_color; 1353 colorf m_highlight_color; 1354 colorf m_back_color; 1354 colorf m_back_color; 1355 float m_width; 1355 float m_width; 1356 float m_line_width; 1356 float m_line_width; 1357 float m_marker_size; 1357 float m_marker_size; 1358 float m_point_size; 1358 float m_point_size; 1359 float m_font_size; 1359 float m_font_size; 1360 sg::font_modeling m_font_modeling; 1360 sg::font_modeling m_font_modeling; 1361 lpat m_pattern; 1361 lpat m_pattern; 1362 lpat m_line_pattern; 1362 lpat m_line_pattern; 1363 sg::marker_style m_marker_style; 1363 sg::marker_style m_marker_style; 1364 sg::area_style m_area_style; 1364 sg::area_style m_area_style; 1365 std::string m_modeling; 1365 std::string m_modeling; 1366 std::string m_light_model; 1366 std::string m_light_model; 1367 std::string m_tick_modeling; 1367 std::string m_tick_modeling; 1368 std::string m_encoding; 1368 std::string m_encoding; 1369 bool m_smoothing; 1369 bool m_smoothing; 1370 bool m_hinting; 1370 bool m_hinting; 1371 std::string m_cut; 1371 std::string m_cut; 1372 sg::painting_policy m_painting; 1372 sg::painting_policy m_painting; 1373 sg::hatching_policy m_hatching; 1373 sg::hatching_policy m_hatching; 1374 sg::projection_type m_projection; 1374 sg::projection_type m_projection; 1375 std::string m_font; 1375 std::string m_font; 1376 int m_multi_node_limit; //could be no_limit 1376 int m_multi_node_limit; //could be no_limit = -1. 1377 int m_divisions; 1377 int m_divisions; 1378 unsigned int m_rotation_steps; 1378 unsigned int m_rotation_steps; 1379 float m_back_shadow; 1379 float m_back_shadow; 1380 float m_spacing; 1380 float m_spacing; 1381 float m_angle; 1381 float m_angle; 1382 float m_scale; 1382 float m_scale; 1383 float m_offset; 1383 float m_offset; 1384 float m_strip_width; 1384 float m_strip_width; 1385 bool m_visible; 1385 bool m_visible; 1386 float m_bar_offset; 1386 float m_bar_offset; 1387 float m_bar_width; 1387 float m_bar_width; 1388 bool m_editable; 1388 bool m_editable; 1389 bool m_automated; 1389 bool m_automated; 1390 std::string m_options; 1390 std::string m_options; 1391 std::string m_color_mapping; 1391 std::string m_color_mapping; 1392 bool m_enforced; 1392 bool m_enforced; 1393 vec3f m_translation; 1393 vec3f m_translation; 1394 winding_type m_front_face; 1394 winding_type m_front_face; 1395 sg::hjust m_hjust; 1395 sg::hjust m_hjust; 1396 sg::vjust m_vjust; 1396 sg::vjust m_vjust; 1397 std::string m_coloring; 1397 std::string m_coloring; 1398 std::string m_title; 1398 std::string m_title; 1399 bool m_pickable; 1399 bool m_pickable; 1400 }; 1400 }; 1401 1401 1402 }} 1402 }} 1403 1403 1404 #endif 1404 #endif