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_valop2sg 4 #ifndef tools_sg_valop2sg 5 #define tools_sg_valop2sg 5 #define tools_sg_valop2sg 6 6 7 #include "bbox_action" 7 #include "bbox_action" 8 #include "strings" 8 #include "strings" 9 #include "separator" 9 #include "separator" 10 #include "matrix" 10 #include "matrix" 11 #include "vertices" 11 #include "vertices" 12 #include "base_freetype" 12 #include "base_freetype" 13 #include "mnmx" 13 #include "mnmx" 14 14 15 #include "../valop" 15 #include "../valop" 16 #include "../smath" 16 #include "../smath" 17 17 18 namespace tools { 18 namespace tools { 19 19 20 class valop2sg : public virtual valop_visitor 20 class valop2sg : public virtual valop_visitor { 21 public: 21 public: 22 virtual bool binary(unsigned int a_type,cons 22 virtual bool binary(unsigned int a_type,const valop& a_1,const valop& a_2) { 23 sg::separator* sep = new sg::separator; 23 sg::separator* sep = new sg::separator; 24 24 25 sg::separator* sep1 = new sg::separator; 25 sg::separator* sep1 = new sg::separator; 26 sep->add(sep1); 26 sep->add(sep1); 27 sg::matrix* tsf1 = new sg::matrix; 27 sg::matrix* tsf1 = new sg::matrix; 28 sep1->add(tsf1); 28 sep1->add(tsf1); 29 vec3f mn1,mx1; 29 vec3f mn1,mx1; 30 {valop2sg v(m_out,*sep1,m_ttf); 30 {valop2sg v(m_out,*sep1,m_ttf); 31 if(!v.visit(a_1)) { 31 if(!v.visit(a_1)) { 32 delete sep; 32 delete sep; 33 return false; 33 return false; 34 } 34 } 35 mnmx(m_out,*sep1,mn1,mx1);} 35 mnmx(m_out,*sep1,mn1,mx1);} 36 36 37 sg::separator* op_sep = new sg::separator; 37 sg::separator* op_sep = new sg::separator; 38 sep->add(op_sep); 38 sep->add(op_sep); 39 sg::matrix* op_tsf = new sg::matrix; 39 sg::matrix* op_tsf = new sg::matrix; 40 op_sep->add(op_tsf); 40 op_sep->add(op_tsf); 41 41 42 sg::separator* sep2 = new sg::separator; 42 sg::separator* sep2 = new sg::separator; 43 sep->add(sep2); 43 sep->add(sep2); 44 sg::matrix* tsf2 = new sg::matrix; 44 sg::matrix* tsf2 = new sg::matrix; 45 sep2->add(tsf2); 45 sep2->add(tsf2); 46 vec3f mn2,mx2; 46 vec3f mn2,mx2; 47 {valop2sg v(m_out,*sep2,m_ttf); 47 {valop2sg v(m_out,*sep2,m_ttf); 48 if(!v.visit(a_2)) { 48 if(!v.visit(a_2)) { 49 delete sep; 49 delete sep; 50 return false; 50 return false; 51 } 51 } 52 mnmx(m_out,*sep2,mn2,mx2);} 52 mnmx(m_out,*sep2,mn2,mx2);} 53 53 54 if((a_type==valop::ADD) || 54 if((a_type==valop::ADD) || 55 (a_type==valop::SUB) || 55 (a_type==valop::SUB) || 56 (a_type==valop::MUL) || 56 (a_type==valop::MUL) || 57 (a_type==valop::EQUAL) ){ 57 (a_type==valop::EQUAL) ){ 58 58 59 sg::base_freetype* tft = sg::base_freety 59 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 60 60 61 if(a_type==valop::ADD) unichar2sg 61 if(a_type==valop::ADD) unichar2sg(0x0002B,*tft); // + 62 //else if(a_type==valop::SUB) unichar2sg 62 //else if(a_type==valop::SUB) unichar2sg(0x0002D,*tft); // - 63 else if(a_type==valop::SUB) unichar2sg 63 else if(a_type==valop::SUB) unichar2sg(0x02212,*tft); 64 //else if(a_type==valop::MUL) unichar2sg 64 //else if(a_type==valop::MUL) unichar2sg(0x0002A,*tft); // * 65 //else if(a_type==valop::MUL) unichar2sg 65 //else if(a_type==valop::MUL) unichar2sg(0x02219,*tft); // . 66 else if(a_type==valop::MUL) unichar2sg 66 else if(a_type==valop::MUL) unichar2sg(0x02A2F,*tft); // x 67 else if(a_type==valop::EQUAL) unichar2sg 67 else if(a_type==valop::EQUAL) unichar2sg(0x0003D,*tft); // = 68 op_sep->add(tft); 68 op_sep->add(tft); 69 69 70 vec3f omn,omx; 70 vec3f omn,omx; 71 mnmx(m_out,*tft,omn,omx); 71 mnmx(m_out,*tft,omn,omx); 72 72 73 float odx = omx[0]-omn[0]; 73 float odx = omx[0]-omn[0]; 74 float xmargin = odx*0.1f; 74 float xmargin = odx*0.1f; 75 75 76 op_tsf->mul_translate(-omn[0]+mx1[0]+xma 76 op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0); 77 77 78 tsf2->mul_translate(-mn2[0]+mx1[0]+xmarg 78 tsf2->mul_translate(-mn2[0]+mx1[0]+xmargin+odx+xmargin,0,0); 79 79 80 } else if( (a_type==valop::ASIDE) || 80 } else if( (a_type==valop::ASIDE) || 81 (a_type==valop::NVMUL) ){ 81 (a_type==valop::NVMUL) ){ 82 82 83 float xspace = (mx1[0]-mn1[0])*0.1f; 83 float xspace = (mx1[0]-mn1[0])*0.1f; 84 84 85 tsf2->mul_translate(-mn2[0]+mx1[0]+xspac 85 tsf2->mul_translate(-mn2[0]+mx1[0]+xspace,0,0); 86 86 87 } else if(a_type==valop::DIV) { 87 } else if(a_type==valop::DIV) { 88 88 89 // the bar : 89 // the bar : 90 sg::vertices* vtcs = new sg::vertices; 90 sg::vertices* vtcs = new sg::vertices; 91 op_sep->add(vtcs); 91 op_sep->add(vtcs); 92 float w2 = 0.5f; 92 float w2 = 0.5f; 93 float h = 0.101f; 93 float h = 0.101f; 94 vtcs->add(-w2,0,0); 94 vtcs->add(-w2,0,0); 95 vtcs->add( w2,0,0); 95 vtcs->add( w2,0,0); 96 vtcs->add( w2,h,0); 96 vtcs->add( w2,h,0); 97 vtcs->add(-w2,h,0); 97 vtcs->add(-w2,h,0); 98 if(m_wf) { 98 if(m_wf) { 99 vtcs->mode = gl::line_strip(); 99 vtcs->mode = gl::line_strip(); 100 vtcs->add(-w2,0,0); 100 vtcs->add(-w2,0,0); 101 } else { 101 } else { 102 vtcs->mode = gl::triangle_fan(); 102 vtcs->mode = gl::triangle_fan(); 103 } 103 } 104 104 105 float ymargin = h; 105 float ymargin = h; 106 106 107 float osx = mx(mx1[0]-mn1[0],mx2[0]-mn2[ 107 float osx = mx(mx1[0]-mn1[0],mx2[0]-mn2[0]); 108 osx *= 1.1f; 108 osx *= 1.1f; 109 109 110 op_tsf->mul_scale(osx,1,1); 110 op_tsf->mul_scale(osx,1,1); 111 111 112 //put a_1 symbol in the middle of the ba 112 //put a_1 symbol in the middle of the bar. 113 //put a_1 symbol on top of the bar (with 113 //put a_1 symbol on top of the bar (with an ymargin). 114 float dx1 = -(mn1[0]+mx1[0])*0.5f; 114 float dx1 = -(mn1[0]+mx1[0])*0.5f; 115 float dy1 = -mn1[1]+h+ymargin; 115 float dy1 = -mn1[1]+h+ymargin; 116 tsf1->mul_translate(dx1,dy1,0); 116 tsf1->mul_translate(dx1,dy1,0); 117 117 118 //put a_2 symbol in the middle of the ba 118 //put a_2 symbol in the middle of the bar. 119 //put a_2 symbol under the bar (with an 119 //put a_2 symbol under the bar (with an ymargin). 120 float dx2 = -(mn2[0]+mx2[0])*0.5f; 120 float dx2 = -(mn2[0]+mx2[0])*0.5f; 121 float dy2 = -mx2[1]-ymargin; 121 float dy2 = -mx2[1]-ymargin; 122 tsf2->mul_translate(dx2,dy2,0); 122 tsf2->mul_translate(dx2,dy2,0); 123 123 124 } else if(a_type==valop::SUPS) { 124 } else if(a_type==valop::SUPS) { 125 125 126 if(mx2[0]==mn2[0]) { 126 if(mx2[0]==mn2[0]) { 127 delete sep; 127 delete sep; 128 return false; 128 return false; 129 } 129 } 130 130 131 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]- 131 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size. 132 tsf2->set_scale(s2,s2,1); 132 tsf2->set_scale(s2,s2,1); 133 mnmx(m_out,*sep2,mn2,mx2); 133 mnmx(m_out,*sep2,mn2,mx2); 134 134 135 float xshift = (mx1[0]-mn1[0])*0.1f; 135 float xshift = (mx1[0]-mn1[0])*0.1f; 136 float dx2 = -mn2[0]+mx1[0]+xshift; 136 float dx2 = -mn2[0]+mx1[0]+xshift; 137 137 138 float yshift = (mx1[1]-mn1[1])*0.3f; 138 float yshift = (mx1[1]-mn1[1])*0.3f; 139 float dy2 = -mn2[1]+mx1[1]-yshift; 139 float dy2 = -mn2[1]+mx1[1]-yshift; 140 140 141 tsf2->set_translate(dx2,dy2,0); 141 tsf2->set_translate(dx2,dy2,0); 142 tsf2->mul_scale(s2,s2,1); //applied firs 142 tsf2->mul_scale(s2,s2,1); //applied first 143 143 144 } else if(a_type==valop::SUBS) { 144 } else if(a_type==valop::SUBS) { 145 145 146 if(mx2[0]==mn2[0]) { 146 if(mx2[0]==mn2[0]) { 147 delete sep; 147 delete sep; 148 return false; 148 return false; 149 } 149 } 150 150 151 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]- 151 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size. 152 tsf2->set_scale(s2,s2,1); 152 tsf2->set_scale(s2,s2,1); 153 mnmx(m_out,*sep2,mn2,mx2); 153 mnmx(m_out,*sep2,mn2,mx2); 154 154 155 float xshift = (mx1[0]-mn1[0])*0.1f; 155 float xshift = (mx1[0]-mn1[0])*0.1f; 156 float dx2 = -mn2[0]+mx1[0]+xshift; 156 float dx2 = -mn2[0]+mx1[0]+xshift; 157 157 158 float yshift = (mx1[1]-mn1[1])*0.3f; 158 float yshift = (mx1[1]-mn1[1])*0.3f; 159 float dy2 = -mn2[1]-yshift; 159 float dy2 = -mn2[1]-yshift; 160 160 161 tsf2->set_translate(dx2,dy2,0); 161 tsf2->set_translate(dx2,dy2,0); 162 tsf2->mul_scale(s2,s2,1); //applied firs 162 tsf2->mul_scale(s2,s2,1); //applied first 163 163 164 } else { 164 } else { 165 delete sep; 165 delete sep; 166 return false; 166 return false; 167 } 167 } 168 168 169 m_group.add(sep); 169 m_group.add(sep); 170 170 171 return true; 171 return true; 172 } 172 } 173 173 174 virtual bool unary(unsigned int a_type,const 174 virtual bool unary(unsigned int a_type,const valop& a_1) { 175 if(a_type==valop::MINUS) { 175 if(a_type==valop::MINUS) { 176 sg::separator* sep = new sg::separator; 176 sg::separator* sep = new sg::separator; 177 177 178 sg::separator* sep1 = new sg::separator; 178 sg::separator* sep1 = new sg::separator; 179 sep->add(sep1); 179 sep->add(sep1); 180 sg::matrix* tsf1 = new sg::matrix; 180 sg::matrix* tsf1 = new sg::matrix; 181 sep1->add(tsf1); 181 sep1->add(tsf1); 182 vec3f mn1,mx1; 182 vec3f mn1,mx1; 183 {valop2sg v(m_out,*sep1,m_ttf); 183 {valop2sg v(m_out,*sep1,m_ttf); 184 if(!v.visit(a_1)) { 184 if(!v.visit(a_1)) { 185 delete sep; 185 delete sep; 186 return false; 186 return false; 187 } 187 } 188 mnmx(m_out,*sep1,mn1,mx1);} 188 mnmx(m_out,*sep1,mn1,mx1);} 189 189 190 m_group.add(sep); 190 m_group.add(sep); 191 191 192 //////////////////////////////////////// 192 //////////////////////////////////////////////////////// 193 /// minus symbol /////////////////////// 193 /// minus symbol /////////////////////////////////////// 194 //////////////////////////////////////// 194 //////////////////////////////////////////////////////// 195 sg::separator* op_sep = new sg::separato 195 sg::separator* op_sep = new sg::separator; 196 sep->add(op_sep); 196 sep->add(op_sep); 197 //sg::matrix* op_tsf = new sg::matrix; 197 //sg::matrix* op_tsf = new sg::matrix; 198 //op_sep->add(op_tsf); 198 //op_sep->add(op_tsf); 199 199 200 sg::base_freetype* tft = sg::base_freety 200 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 201 //TTNODE* tft = new TTNODE(); 201 //TTNODE* tft = new TTNODE(); 202 unichar2sg(0x0002D,*tft); 202 unichar2sg(0x0002D,*tft); 203 op_sep->add(tft); 203 op_sep->add(tft); 204 vec3f omn,omx; 204 vec3f omn,omx; 205 mnmx(m_out,*tft,omn,omx); 205 mnmx(m_out,*tft,omn,omx); 206 206 207 float odx = omx[0]-omn[0]; 207 float odx = omx[0]-omn[0]; 208 float xmargin = odx*0.1f; 208 float xmargin = odx*0.1f; 209 209 210 //push a_1 at right of minus symbol 210 //push a_1 at right of minus symbol 211 tsf1->mul_translate(-mn1[0]+omx[0]+xmarg 211 tsf1->mul_translate(-mn1[0]+omx[0]+xmargin,0,0); 212 212 213 return true; 213 return true; 214 214 215 } else { 215 } else { 216 return false; 216 return false; 217 } 217 } 218 } 218 } 219 219 220 virtual bool variable(unsigned int a_type,co 220 virtual bool variable(unsigned int a_type,const value& a_var) { 221 221 222 sg::base_freetype* tft = sg::base_freetype 222 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 223 //TTNODE* tft = new TTNODE(); 223 //TTNODE* tft = new TTNODE(); 224 224 225 if(a_type==valop::SYMBOL) { 225 if(a_type==valop::SYMBOL) { 226 if(rcmp(a_var.get_string(),s_psi())) { 226 if(rcmp(a_var.get_string(),s_psi())) { 227 unichar2sg(0x003C8,*tft); 227 unichar2sg(0x003C8,*tft); 228 m_group.add(tft); 228 m_group.add(tft); 229 return true; 229 return true; 230 } else if(rcmp(a_var.get_string(),s_gamm 230 } else if(rcmp(a_var.get_string(),s_gamma())) { 231 unichar2sg(0x003B3,*tft); 231 unichar2sg(0x003B3,*tft); 232 m_group.add(tft); 232 m_group.add(tft); 233 return true; 233 return true; 234 } else if(rcmp(a_var.get_string(),s_mu() 234 } else if(rcmp(a_var.get_string(),s_mu())) { 235 unichar2sg(0x003BC,*tft); 235 unichar2sg(0x003BC,*tft); 236 m_group.add(tft); 236 m_group.add(tft); 237 return true; 237 return true; 238 } else if(rcmp(a_var.get_string(),s_uppe 238 } else if(rcmp(a_var.get_string(),s_upper_delta())) { 239 unichar2sg(0x02206,*tft); 239 unichar2sg(0x02206,*tft); 240 m_group.add(tft); 240 m_group.add(tft); 241 return true; 241 return true; 242 } else if(rcmp(a_var.get_string(),s_part 242 } else if(rcmp(a_var.get_string(),s_partial_derivative())){ 243 unichar2sg(0x02202,*tft); //d ronde 243 unichar2sg(0x02202,*tft); //d ronde 244 m_group.add(tft); 244 m_group.add(tft); 245 return true; 245 return true; 246 } else if(rcmp(a_var.get_string(),s_h_ba 246 } else if(rcmp(a_var.get_string(),s_h_bar())){ 247 unichar2sg(0x0210F,*tft); 247 unichar2sg(0x0210F,*tft); 248 m_group.add(tft); 248 m_group.add(tft); 249 return true; 249 return true; 250 } 250 } 251 251 252 } else if(a_type==valop::REAL){ 252 } else if(a_type==valop::REAL){ 253 s2sg(value::to_string(a_var),*tft); 253 s2sg(value::to_string(a_var),*tft); 254 m_group.add(tft); 254 m_group.add(tft); 255 return true; 255 return true; 256 256 257 } else if(a_type==valop::STRING){ 257 } else if(a_type==valop::STRING){ 258 if(a_var.type()==value::STRING){ 258 if(a_var.type()==value::STRING){ 259 s2sg(a_var.get_string(),*tft); 259 s2sg(a_var.get_string(),*tft); 260 m_group.add(tft); 260 m_group.add(tft); 261 return true; 261 return true; 262 } else { 262 } else { 263 m_out << "valop2sg::variable :" 263 m_out << "valop2sg::variable :" 264 << " expected a value::STRING." 264 << " expected a value::STRING." 265 << " Got " << a_var.stype() << " 265 << " Got " << a_var.stype() << "." 266 << std::endl; 266 << std::endl; 267 } 267 } 268 } 268 } 269 269 270 delete tft; 270 delete tft; 271 return false; 271 return false; 272 } 272 } 273 273 274 virtual bool option(const valop& a_node) { 274 virtual bool option(const valop& a_node) { 275 sg::base_freetype* tft = sg::base_freetype 275 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 276 //TTNODE* tft = new TTNODE(); 276 //TTNODE* tft = new TTNODE(); 277 s2sg(a_node.m_name,*tft); 277 s2sg(a_node.m_name,*tft); 278 m_group.add(tft); 278 m_group.add(tft); 279 return true; 279 return true; 280 } 280 } 281 281 282 virtual bool func_1(const valop& a_f,const v 282 virtual bool func_1(const valop& a_f,const valop& a_1) { 283 if(rcmp(a_f.m_function->name(),s_sqrt())) 283 if(rcmp(a_f.m_function->name(),s_sqrt())) { 284 284 285 sg::separator* sep = new sg::separator; 285 sg::separator* sep = new sg::separator; 286 286 287 sg::separator* sep1 = new sg::separator; 287 sg::separator* sep1 = new sg::separator; 288 sep->add(sep1); 288 sep->add(sep1); 289 vec3f mn1,mx1; 289 vec3f mn1,mx1; 290 {valop2sg v(m_out,*sep1,m_ttf); 290 {valop2sg v(m_out,*sep1,m_ttf); 291 if(!v.visit(a_1)) { 291 if(!v.visit(a_1)) { 292 delete sep; 292 delete sep; 293 return false; 293 return false; 294 } 294 } 295 mnmx(m_out,*sep1,mn1,mx1);} 295 mnmx(m_out,*sep1,mn1,mx1);} 296 296 297 m_group.add(sep); 297 m_group.add(sep); 298 298 299 //////////////////////////////////////// 299 //////////////////////////////////////////////////////// 300 /// sqrt symbol //////////////////////// 300 /// sqrt symbol //////////////////////////////////////// 301 //////////////////////////////////////// 301 //////////////////////////////////////////////////////// 302 sg::separator* op_sep = new sg::separato 302 sg::separator* op_sep = new sg::separator; 303 sep->add(op_sep); 303 sep->add(op_sep); 304 sg::matrix* op_tsf = new sg::matrix; 304 sg::matrix* op_tsf = new sg::matrix; 305 op_sep->add(op_tsf); 305 op_sep->add(op_tsf); 306 306 307 sg::base_freetype* tft = sg::base_freety 307 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 308 //TTNODE* tft = new TTNODE(); 308 //TTNODE* tft = new TTNODE(); 309 unichar2sg(0x0221A,*tft); 309 unichar2sg(0x0221A,*tft); 310 op_sep->add(tft); 310 op_sep->add(tft); 311 vec3f omn,omx; 311 vec3f omn,omx; 312 mnmx(m_out,*tft,omn,omx); 312 mnmx(m_out,*tft,omn,omx); 313 313 314 // upper bar : 314 // upper bar : 315 sg::vertices* vtcs = new sg::vertices; 315 sg::vertices* vtcs = new sg::vertices; 316 op_sep->add(vtcs); 316 op_sep->add(vtcs); 317 float dx = 0.05f; //to cover the top of 317 float dx = 0.05f; //to cover the top of the sqrt symbol. 318 float w = mx1[0]-mn1[0]; 318 float w = mx1[0]-mn1[0]; 319 w *= 1.05f; 319 w *= 1.05f; 320 float h = 0.09f; 320 float h = 0.09f; 321 vtcs->add(omx[0]-dx ,omx[1]-h,0); 321 vtcs->add(omx[0]-dx ,omx[1]-h,0); 322 vtcs->add(omx[0]+w ,omx[1]-h,0); 322 vtcs->add(omx[0]+w ,omx[1]-h,0); 323 vtcs->add(omx[0]+w ,omx[1] ,0); 323 vtcs->add(omx[0]+w ,omx[1] ,0); 324 vtcs->add(omx[0]-dx ,omx[1] ,0); 324 vtcs->add(omx[0]-dx ,omx[1] ,0); 325 if(m_wf) { 325 if(m_wf) { 326 vtcs->mode = gl::line_strip(); 326 vtcs->mode = gl::line_strip(); 327 vtcs->add(omx[0]-dx ,omx[1]-h,0); 327 vtcs->add(omx[0]-dx ,omx[1]-h,0); 328 } else { 328 } else { 329 vtcs->mode = gl::triangle_fan(); 329 vtcs->mode = gl::triangle_fan(); 330 } 330 } 331 331 332 //float odx = omx[0]-omn[0]; 332 //float odx = omx[0]-omn[0]; 333 //float xmargin = odx*0.1f; 333 //float xmargin = odx*0.1f; 334 float xmargin = 0; 334 float xmargin = 0; 335 335 336 //push sqrt-symbol at left of a_1 336 //push sqrt-symbol at left of a_1 337 //scale sqrt-symbol to match a_1 y heigh 337 //scale sqrt-symbol to match a_1 y height. 338 //y translate sqrt-symbol so that a_1 is 338 //y translate sqrt-symbol so that a_1 is under the bar : 339 339 340 float osy = (mx1[1]-mn1[1])/(omx[1]-omn[ 340 float osy = (mx1[1]-mn1[1])/(omx[1]-omn[1]); 341 float ody = -omn[1]*osy + mn1[1]; 341 float ody = -omn[1]*osy + mn1[1]; 342 342 343 osy *= 1.2f; 343 osy *= 1.2f; 344 344 345 op_tsf->mul_translate(-omx[0]+mn1[0]-xma 345 op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,ody,0); //second 346 op_tsf->mul_scale(1,osy,1); 346 op_tsf->mul_scale(1,osy,1); //first 347 347 348 return true; 348 return true; 349 } else { 349 } else { 350 // generic case : <func_name>(rep of a_1 350 // generic case : <func_name>(rep of a_1) 351 351 352 sg::separator* sep = new sg::separator; 352 sg::separator* sep = new sg::separator; 353 353 354 sg::separator* sep1 = new sg::separator; 354 sg::separator* sep1 = new sg::separator; 355 sep->add(sep1); 355 sep->add(sep1); 356 vec3f mn1,mx1; 356 vec3f mn1,mx1; 357 {valop2sg v(m_out,*sep1,m_ttf); 357 {valop2sg v(m_out,*sep1,m_ttf); 358 if(!v.visit(a_1)) { 358 if(!v.visit(a_1)) { 359 delete sep; 359 delete sep; 360 return false; 360 return false; 361 } 361 } 362 mnmx(m_out,*sep1,mn1,mx1);} 362 mnmx(m_out,*sep1,mn1,mx1);} 363 363 364 m_group.add(sep); 364 m_group.add(sep); 365 365 366 //////////////////////////////////////// 366 //////////////////////////////////////////////////////// 367 /// left func symbol : <func_name> ( 367 /// left func symbol : <func_name> ( ///////////// 368 //////////////////////////////////////// 368 //////////////////////////////////////////////////////// 369 {sg::separator* op_sep = new sg::separato 369 {sg::separator* op_sep = new sg::separator; 370 sep->add(op_sep); 370 sep->add(op_sep); 371 sg::matrix* op_tsf = new sg::matrix; 371 sg::matrix* op_tsf = new sg::matrix; 372 op_sep->add(op_tsf); 372 op_sep->add(op_tsf); 373 373 374 sg::base_freetype* tft = sg::base_freety 374 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 375 //TTNODE* tft = new TTNODE(); 375 //TTNODE* tft = new TTNODE(); 376 s2sg(a_f.m_function->name(),*tft); 376 s2sg(a_f.m_function->name(),*tft); 377 tft->unitext[0].push_back(0x00028); // ( 377 tft->unitext[0].push_back(0x00028); // ( 378 op_sep->add(tft); 378 op_sep->add(tft); 379 379 380 vec3f omn,omx; 380 vec3f omn,omx; 381 mnmx(m_out,*tft,omn,omx); 381 mnmx(m_out,*tft,omn,omx); 382 382 383 //push func-symbol at left of a_1 : 383 //push func-symbol at left of a_1 : 384 //float odx = omx[0]-omn[0]; 384 //float odx = omx[0]-omn[0]; 385 //float xmargin = odx*0.1f; 385 //float xmargin = odx*0.1f; 386 float xmargin = 0; 386 float xmargin = 0; 387 op_tsf->mul_translate(-omx[0]+mn1[0]-xma 387 op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,0,0); 388 } //end left op 388 } //end left op 389 389 390 //////////////////////////////////////// 390 //////////////////////////////////////////////////////// 391 /// right func symbol : ) 391 /// right func symbol : ) ///////////// 392 //////////////////////////////////////// 392 //////////////////////////////////////////////////////// 393 {sg::separator* op_sep = new sg::separato 393 {sg::separator* op_sep = new sg::separator; 394 sep->add(op_sep); 394 sep->add(op_sep); 395 sg::matrix* op_tsf = new sg::matrix; 395 sg::matrix* op_tsf = new sg::matrix; 396 op_sep->add(op_tsf); 396 op_sep->add(op_tsf); 397 397 398 sg::base_freetype* tft = sg::base_freety 398 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 399 //TTNODE* tft = new TTNODE(); 399 //TTNODE* tft = new TTNODE(); 400 unichar2sg(0x00029,*tft); 400 unichar2sg(0x00029,*tft); 401 op_sep->add(tft); 401 op_sep->add(tft); 402 vec3f omn,omx; 402 vec3f omn,omx; 403 mnmx(m_out,*tft,omn,omx); 403 mnmx(m_out,*tft,omn,omx); 404 404 405 //push func-symbol at right of a_1 : 405 //push func-symbol at right of a_1 : 406 //float odx = omx[0]-omn[0]; 406 //float odx = omx[0]-omn[0]; 407 //float xmargin = odx*0.1f; 407 //float xmargin = odx*0.1f; 408 float xmargin = 0; 408 float xmargin = 0; 409 op_tsf->mul_translate(-omn[0]+mx1[0]+xma 409 op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0); 410 } //end right op 410 } //end right op 411 411 412 return true; 412 return true; 413 } 413 } 414 } 414 } 415 virtual bool func_2(const valop& a_f,const v 415 virtual bool func_2(const valop& a_f,const valop& a_1,const valop& a_2) { 416 if(rcmp(a_f.m_function->name(),s_pow())) { 416 if(rcmp(a_f.m_function->name(),s_pow())) { 417 417 418 sg::separator* sep = new sg::separator; 418 sg::separator* sep = new sg::separator; 419 419 420 sg::separator* sep1 = new sg::separator; 420 sg::separator* sep1 = new sg::separator; 421 sep->add(sep1); 421 sep->add(sep1); 422 sg::matrix* tsf1 = new sg::matrix; 422 sg::matrix* tsf1 = new sg::matrix; 423 sep1->add(tsf1); 423 sep1->add(tsf1); 424 vec3f mn1,mx1; 424 vec3f mn1,mx1; 425 {valop2sg v(m_out,*sep1,m_ttf); 425 {valop2sg v(m_out,*sep1,m_ttf); 426 if(!v.visit(a_1)) { 426 if(!v.visit(a_1)) { 427 delete sep; 427 delete sep; 428 return false; 428 return false; 429 } 429 } 430 mnmx(m_out,*sep1,mn1,mx1);} 430 mnmx(m_out,*sep1,mn1,mx1);} 431 431 432 //sg::separator* op_sep = new sg::separa 432 //sg::separator* op_sep = new sg::separator; 433 //sep->add(op_sep); 433 //sep->add(op_sep); 434 //sg::matrix* op_tsf = new sg::matrix; 434 //sg::matrix* op_tsf = new sg::matrix; 435 //op_sep->add(op_tsf); 435 //op_sep->add(op_tsf); 436 436 437 sg::separator* sep2 = new sg::separator; 437 sg::separator* sep2 = new sg::separator; 438 sep->add(sep2); 438 sep->add(sep2); 439 sg::matrix* tsf2 = new sg::matrix; 439 sg::matrix* tsf2 = new sg::matrix; 440 sep2->add(tsf2); 440 sep2->add(tsf2); 441 vec3f mn2,mx2; 441 vec3f mn2,mx2; 442 {valop2sg v(m_out,*sep2,m_ttf); 442 {valop2sg v(m_out,*sep2,m_ttf); 443 if(!v.visit(a_2)) { 443 if(!v.visit(a_2)) { 444 delete sep; 444 delete sep; 445 return false; 445 return false; 446 } 446 } 447 mnmx(m_out,*sep2,mn2,mx2);} 447 mnmx(m_out,*sep2,mn2,mx2);} 448 448 449 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]- 449 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size. 450 if(mx2[0]==mn2[0]) { 450 if(mx2[0]==mn2[0]) { 451 delete sep; 451 delete sep; 452 return false; 452 return false; 453 } 453 } 454 tsf2->set_scale(s2,s2,1); 454 tsf2->set_scale(s2,s2,1); 455 mnmx(m_out,*sep2,mn2,mx2); 455 mnmx(m_out,*sep2,mn2,mx2); 456 456 457 float xshift = (mx1[0]-mn1[0])*0.1f; 457 float xshift = (mx1[0]-mn1[0])*0.1f; 458 float dx2 = -mn2[0]+mx1[0]+xshift; 458 float dx2 = -mn2[0]+mx1[0]+xshift; 459 459 460 float yshift = (mx1[1]-mn1[1])*0.3f; 460 float yshift = (mx1[1]-mn1[1])*0.3f; 461 float dy2 = -mn2[1]+mx1[1]-yshift; 461 float dy2 = -mn2[1]+mx1[1]-yshift; 462 462 463 tsf2->set_identity(); 463 tsf2->set_identity(); 464 tsf2->mul_translate(dx2,dy2,0); 464 tsf2->mul_translate(dx2,dy2,0); 465 tsf2->mul_scale(s2,s2,1); //applied firs 465 tsf2->mul_scale(s2,s2,1); //applied first 466 466 467 m_group.add(sep); 467 m_group.add(sep); 468 468 469 return true; 469 return true; 470 470 471 } else { 471 } else { 472 // generic case : <func_name>(rep of a_1 472 // generic case : <func_name>(rep of a_1, rep of a_2) 473 473 474 sg::separator* sep = new sg::separator; 474 sg::separator* sep = new sg::separator; 475 475 476 sg::separator* sep1 = new sg::separator; 476 sg::separator* sep1 = new sg::separator; 477 sep->add(sep1); 477 sep->add(sep1); 478 vec3f mn1,mx1; 478 vec3f mn1,mx1; 479 {valop2sg v(m_out,*sep1,m_ttf); 479 {valop2sg v(m_out,*sep1,m_ttf); 480 if(!v.visit(a_1)) { 480 if(!v.visit(a_1)) { 481 delete sep; 481 delete sep; 482 return false; 482 return false; 483 } 483 } 484 mnmx(m_out,*sep1,mn1,mx1);} 484 mnmx(m_out,*sep1,mn1,mx1);} 485 485 486 sg::separator* sep2 = new sg::separator; 486 sg::separator* sep2 = new sg::separator; 487 sep->add(sep2); 487 sep->add(sep2); 488 sg::matrix* tsf2 = new sg::matrix; 488 sg::matrix* tsf2 = new sg::matrix; 489 sep2->add(tsf2); 489 sep2->add(tsf2); 490 vec3f mn2,mx2; 490 vec3f mn2,mx2; 491 {valop2sg v(m_out,*sep2,m_ttf); 491 {valop2sg v(m_out,*sep2,m_ttf); 492 if(!v.visit(a_2)) { 492 if(!v.visit(a_2)) { 493 delete sep; 493 delete sep; 494 return false; 494 return false; 495 } 495 } 496 mnmx(m_out,*sep2,mn2,mx2);} 496 mnmx(m_out,*sep2,mn2,mx2);} 497 497 498 m_group.add(sep); 498 m_group.add(sep); 499 499 500 //////////////////////////////////////// 500 //////////////////////////////////////////////////////// 501 /// left func symbol : <func_name> ( 501 /// left func symbol : <func_name> ( ///////////// 502 //////////////////////////////////////// 502 //////////////////////////////////////////////////////// 503 {sg::separator* op_sep = new sg::separato 503 {sg::separator* op_sep = new sg::separator; 504 sep->add(op_sep); 504 sep->add(op_sep); 505 sg::matrix* op_tsf = new sg::matrix; 505 sg::matrix* op_tsf = new sg::matrix; 506 op_sep->add(op_tsf); 506 op_sep->add(op_tsf); 507 507 508 sg::base_freetype* tft = sg::base_freety 508 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 509 //TTNODE* tft = new TTNODE(); 509 //TTNODE* tft = new TTNODE(); 510 s2sg(a_f.m_function->name(),*tft); 510 s2sg(a_f.m_function->name(),*tft); 511 tft->unitext[0].push_back(0x00028); // ( 511 tft->unitext[0].push_back(0x00028); // ( 512 op_sep->add(tft); 512 op_sep->add(tft); 513 513 514 vec3f omn,omx; 514 vec3f omn,omx; 515 mnmx(m_out,*tft,omn,omx); 515 mnmx(m_out,*tft,omn,omx); 516 516 517 //push func-symbol at left of a_1 : 517 //push func-symbol at left of a_1 : 518 //float odx = omx[0]-omn[0]; 518 //float odx = omx[0]-omn[0]; 519 //float xmargin = odx*0.1f; 519 //float xmargin = odx*0.1f; 520 float xmargin = 0; 520 float xmargin = 0; 521 op_tsf->mul_translate(-omx[0]+mn1[0]-xma 521 op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,0,0); 522 } //end left op 522 } //end left op 523 523 524 //////////////////////////////////////// 524 //////////////////////////////////////////////////////// 525 /// , 525 /// , ///////////// 526 //////////////////////////////////////// 526 //////////////////////////////////////////////////////// 527 float xend2 = 0; 527 float xend2 = 0; 528 {sg::separator* op_sep = new sg::separato 528 {sg::separator* op_sep = new sg::separator; 529 sep->add(op_sep); 529 sep->add(op_sep); 530 sg::matrix* op_tsf = new sg::matrix; 530 sg::matrix* op_tsf = new sg::matrix; 531 op_sep->add(op_tsf); 531 op_sep->add(op_tsf); 532 532 533 sg::base_freetype* tft = sg::base_freety 533 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 534 //TTNODE* tft = new TTNODE(); 534 //TTNODE* tft = new TTNODE(); 535 unichar2sg(0x0002C,*tft); // , 535 unichar2sg(0x0002C,*tft); // , 536 op_sep->add(tft); 536 op_sep->add(tft); 537 vec3f omn,omx; 537 vec3f omn,omx; 538 mnmx(m_out,*tft,omn,omx); 538 mnmx(m_out,*tft,omn,omx); 539 539 540 //push comma-symbol at right of a_1 : 540 //push comma-symbol at right of a_1 : 541 float odx = omx[0]-omn[0]; 541 float odx = omx[0]-omn[0]; 542 float xmargin = odx*0.1f; 542 float xmargin = odx*0.1f; 543 op_tsf->mul_translate(-omn[0]+mx1[0]+xma 543 op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0); 544 544 545 float xendcomma = mx1[0]+xmargin+(omx[0] 545 float xendcomma = mx1[0]+xmargin+(omx[0]-omn[0]); 546 546 547 tsf2->mul_translate(-mn2[0]+xendcomma+xm 547 tsf2->mul_translate(-mn2[0]+xendcomma+xmargin,0,0); 548 548 549 xend2 = xendcomma+(mx2[0]-mn2[0]); 549 xend2 = xendcomma+(mx2[0]-mn2[0]); 550 } //end comma 550 } //end comma 551 551 552 //////////////////////////////////////// 552 //////////////////////////////////////////////////////// 553 /// right func symbol : ) 553 /// right func symbol : ) ///////////// 554 //////////////////////////////////////// 554 //////////////////////////////////////////////////////// 555 {sg::separator* op_sep = new sg::separato 555 {sg::separator* op_sep = new sg::separator; 556 sep->add(op_sep); 556 sep->add(op_sep); 557 sg::matrix* op_tsf = new sg::matrix; 557 sg::matrix* op_tsf = new sg::matrix; 558 op_sep->add(op_tsf); 558 op_sep->add(op_tsf); 559 559 560 sg::base_freetype* tft = sg::base_freety 560 sg::base_freetype* tft = sg::base_freetype::create(m_ttf); 561 //TTNODE* tft = new TTNODE(); 561 //TTNODE* tft = new TTNODE(); 562 unichar2sg(0x00029,*tft); 562 unichar2sg(0x00029,*tft); 563 op_sep->add(tft); 563 op_sep->add(tft); 564 vec3f omn,omx; 564 vec3f omn,omx; 565 mnmx(m_out,*tft,omn,omx); 565 mnmx(m_out,*tft,omn,omx); 566 566 567 //push ")" at right of a_2 : 567 //push ")" at right of a_2 : 568 //float odx = omx[0]-omn[0]; 568 //float odx = omx[0]-omn[0]; 569 //float xmargin = odx*0.1f; 569 //float xmargin = odx*0.1f; 570 float xmargin = 0; 570 float xmargin = 0; 571 op_tsf->mul_translate(-omn[0]+xend2+xmar 571 op_tsf->mul_translate(-omn[0]+xend2+xmargin,0,0); 572 } //end right op 572 } //end right op 573 573 574 return true; 574 return true; 575 } 575 } 576 } 576 } 577 virtual bool func_3(const valop&,const valop 577 virtual bool func_3(const valop&,const valop&,const valop&,const valop&) { 578 return false; 578 return false; 579 } 579 } 580 virtual bool func_4(const valop&,const valop 580 virtual bool func_4(const valop&,const valop&,const valop&,const valop&,const valop&) { 581 return false; 581 return false; 582 } 582 } 583 virtual bool func_5(const valop&,const valop 583 virtual bool func_5(const valop&,const valop&,const valop&,const valop&,const valop&,const valop&) { 584 return false; 584 return false; 585 } 585 } 586 virtual bool func_6(const valop&,const valop 586 virtual bool func_6(const valop&,const valop&,const valop&,const valop&,const valop&,const valop&,const valop&) { 587 return false; 587 return false; 588 } 588 } 589 public: 589 public: 590 valop2sg(std::ostream& a_out, 590 valop2sg(std::ostream& a_out, 591 sg::group& a_group, 591 sg::group& a_group, 592 const sg::base_freetype& a_ttf) 592 const sg::base_freetype& a_ttf) 593 :m_out(a_out) 593 :m_out(a_out) 594 ,m_group(a_group) 594 ,m_group(a_group) 595 //,m_wf(true) 595 //,m_wf(true) 596 ,m_wf(false) 596 ,m_wf(false) 597 ,m_ttf(a_ttf) 597 ,m_ttf(a_ttf) 598 {} 598 {} 599 virtual ~valop2sg() {} 599 virtual ~valop2sg() {} 600 public: 600 public: 601 valop2sg(const valop2sg& a_from) 601 valop2sg(const valop2sg& a_from) 602 :valop_visitor(a_from) 602 :valop_visitor(a_from) 603 ,m_out(a_from.m_out) 603 ,m_out(a_from.m_out) 604 ,m_group(a_from.m_group) 604 ,m_group(a_from.m_group) 605 ,m_wf(a_from.m_wf) 605 ,m_wf(a_from.m_wf) 606 ,m_ttf(a_from.m_ttf) 606 ,m_ttf(a_from.m_ttf) 607 {} 607 {} 608 valop2sg& operator=(const valop2sg& a_from){ 608 valop2sg& operator=(const valop2sg& a_from){ 609 m_wf = a_from.m_wf; 609 m_wf = a_from.m_wf; 610 return *this; 610 return *this; 611 } 611 } 612 protected: 612 protected: 613 typedef unsigned int unichar; 613 typedef unsigned int unichar; 614 614 615 unichar char2stix(char a_c) { 615 unichar char2stix(char a_c) { 616 if(a_c=='-') return 0x0002D; 616 if(a_c=='-') return 0x0002D; 617 if(a_c=='.') return 0x0002E; 617 if(a_c=='.') return 0x0002E; 618 618 619 if(a_c=='0') return 0x00030; 619 if(a_c=='0') return 0x00030; 620 if(a_c=='1') return 0x00031; 620 if(a_c=='1') return 0x00031; 621 if(a_c=='2') return 0x00032; 621 if(a_c=='2') return 0x00032; 622 if(a_c=='3') return 0x00033; 622 if(a_c=='3') return 0x00033; 623 if(a_c=='4') return 0x00034; 623 if(a_c=='4') return 0x00034; 624 if(a_c=='5') return 0x00035; 624 if(a_c=='5') return 0x00035; 625 if(a_c=='6') return 0x00036; 625 if(a_c=='6') return 0x00036; 626 if(a_c=='7') return 0x00037; 626 if(a_c=='7') return 0x00037; 627 if(a_c=='8') return 0x00038; 627 if(a_c=='8') return 0x00038; 628 if(a_c=='9') return 0x00039; 628 if(a_c=='9') return 0x00039; 629 629 630 if(a_c=='A') return 0x00041; 630 if(a_c=='A') return 0x00041; 631 if(a_c=='B') return 0x00042; 631 if(a_c=='B') return 0x00042; 632 if(a_c=='C') return 0x00043; 632 if(a_c=='C') return 0x00043; 633 if(a_c=='D') return 0x00044; 633 if(a_c=='D') return 0x00044; 634 if(a_c=='E') return 0x00045; 634 if(a_c=='E') return 0x00045; 635 if(a_c=='F') return 0x00046; 635 if(a_c=='F') return 0x00046; 636 if(a_c=='G') return 0x00047; 636 if(a_c=='G') return 0x00047; 637 if(a_c=='H') return 0x00048; 637 if(a_c=='H') return 0x00048; 638 if(a_c=='I') return 0x00049; 638 if(a_c=='I') return 0x00049; 639 if(a_c=='J') return 0x0004A; 639 if(a_c=='J') return 0x0004A; 640 if(a_c=='K') return 0x0004B; 640 if(a_c=='K') return 0x0004B; 641 if(a_c=='L') return 0x0004C; 641 if(a_c=='L') return 0x0004C; 642 if(a_c=='M') return 0x0004D; 642 if(a_c=='M') return 0x0004D; 643 if(a_c=='N') return 0x0004E; 643 if(a_c=='N') return 0x0004E; 644 if(a_c=='O') return 0x0004F; 644 if(a_c=='O') return 0x0004F; 645 if(a_c=='P') return 0x00050; 645 if(a_c=='P') return 0x00050; 646 if(a_c=='Q') return 0x00051; 646 if(a_c=='Q') return 0x00051; 647 if(a_c=='R') return 0x00052; 647 if(a_c=='R') return 0x00052; 648 if(a_c=='S') return 0x00053; 648 if(a_c=='S') return 0x00053; 649 if(a_c=='T') return 0x00054; 649 if(a_c=='T') return 0x00054; 650 if(a_c=='U') return 0x00055; 650 if(a_c=='U') return 0x00055; 651 if(a_c=='V') return 0x00056; 651 if(a_c=='V') return 0x00056; 652 if(a_c=='W') return 0x00057; 652 if(a_c=='W') return 0x00057; 653 if(a_c=='X') return 0x00058; 653 if(a_c=='X') return 0x00058; 654 if(a_c=='Y') return 0x00059; 654 if(a_c=='Y') return 0x00059; 655 if(a_c=='Z') return 0x0005A; 655 if(a_c=='Z') return 0x0005A; 656 656 657 if(a_c=='a') return 0x00061; 657 if(a_c=='a') return 0x00061; 658 if(a_c=='b') return 0x00062; 658 if(a_c=='b') return 0x00062; 659 if(a_c=='c') return 0x00063; 659 if(a_c=='c') return 0x00063; 660 if(a_c=='d') return 0x00064; 660 if(a_c=='d') return 0x00064; 661 if(a_c=='e') return 0x00065; 661 if(a_c=='e') return 0x00065; 662 if(a_c=='f') return 0x00066; 662 if(a_c=='f') return 0x00066; 663 if(a_c=='g') return 0x00067; 663 if(a_c=='g') return 0x00067; 664 if(a_c=='h') return 0x00068; 664 if(a_c=='h') return 0x00068; 665 if(a_c=='i') return 0x00069; 665 if(a_c=='i') return 0x00069; 666 if(a_c=='j') return 0x0006A; 666 if(a_c=='j') return 0x0006A; 667 if(a_c=='k') return 0x0006B; 667 if(a_c=='k') return 0x0006B; 668 if(a_c=='l') return 0x0006C; 668 if(a_c=='l') return 0x0006C; 669 if(a_c=='m') return 0x0006D; 669 if(a_c=='m') return 0x0006D; 670 if(a_c=='n') return 0x0006E; 670 if(a_c=='n') return 0x0006E; 671 if(a_c=='o') return 0x0006F; 671 if(a_c=='o') return 0x0006F; 672 if(a_c=='p') return 0x00070; 672 if(a_c=='p') return 0x00070; 673 if(a_c=='q') return 0x00071; 673 if(a_c=='q') return 0x00071; 674 if(a_c=='r') return 0x00072; 674 if(a_c=='r') return 0x00072; 675 if(a_c=='s') return 0x00073; 675 if(a_c=='s') return 0x00073; 676 if(a_c=='t') return 0x00074; 676 if(a_c=='t') return 0x00074; 677 if(a_c=='u') return 0x00075; 677 if(a_c=='u') return 0x00075; 678 if(a_c=='v') return 0x00076; 678 if(a_c=='v') return 0x00076; 679 if(a_c=='w') return 0x00077; 679 if(a_c=='w') return 0x00077; 680 if(a_c=='x') return 0x00078; 680 if(a_c=='x') return 0x00078; 681 if(a_c=='y') return 0x00079; 681 if(a_c=='y') return 0x00079; 682 if(a_c=='z') return 0x0007A; 682 if(a_c=='z') return 0x0007A; 683 683 684 if(a_c=='_') return 0x0005F; 684 if(a_c=='_') return 0x0005F; 685 685 686 return 0x0003F; //? 686 return 0x0003F; //? 687 } 687 } 688 688 689 void unichar2sg(unichar a_unichar,sg::base_f 689 void unichar2sg(unichar a_unichar,sg::base_freetype& a_node){ 690 if(m_wf) a_node.modeling = sg::font_outlin 690 if(m_wf) a_node.modeling = sg::font_outline; 691 691 692 a_node.font = sg::font_stixgeneral_otf(); 692 a_node.font = sg::font_stixgeneral_otf(); 693 693 694 std::vector<unichar> line; 694 std::vector<unichar> line; 695 line.push_back(a_unichar); 695 line.push_back(a_unichar); 696 696 697 a_node.unitext.add(line); 697 a_node.unitext.add(line); 698 } 698 } 699 699 700 void s2sg(const std::string& a_s,sg::base_fr 700 void s2sg(const std::string& a_s,sg::base_freetype& a_node){ 701 if(m_wf) a_node.modeling = sg::font_outlin 701 if(m_wf) a_node.modeling = sg::font_outline; //else font_filled, font_pixmap. 702 702 703 a_node.font = sg::font_stixgeneral_otf(); 703 a_node.font = sg::font_stixgeneral_otf(); 704 704 705 std::vector<unichar> line; 705 std::vector<unichar> line; 706 tools_sforcit(a_s,it) line.push_back(char2 706 tools_sforcit(a_s,it) line.push_back(char2stix(*it)); 707 707 708 a_node.unitext.add(line); 708 a_node.unitext.add(line); 709 } 709 } 710 710 711 protected: 711 protected: 712 std::ostream& m_out; 712 std::ostream& m_out; 713 sg::group& m_group; 713 sg::group& m_group; 714 bool m_wf; 714 bool m_wf; 715 const sg::base_freetype& m_ttf; 715 const sg::base_freetype& m_ttf; 716 }; 716 }; 717 717 718 } 718 } 719 719 720 #endif 720 #endif