Warning, /include/Geant4/tools/sg/valop2sg is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_valop2sg
0005 #define tools_sg_valop2sg
0006
0007 #include "bbox_action"
0008 #include "strings"
0009 #include "separator"
0010 #include "matrix"
0011 #include "vertices"
0012 #include "base_freetype"
0013 #include "mnmx"
0014
0015 #include "../valop"
0016 #include "../smath"
0017
0018 namespace tools {
0019
0020 class valop2sg : public virtual valop_visitor {
0021 public:
0022 virtual bool binary(unsigned int a_type,const valop& a_1,const valop& a_2) {
0023 sg::separator* sep = new sg::separator;
0024
0025 sg::separator* sep1 = new sg::separator;
0026 sep->add(sep1);
0027 sg::matrix* tsf1 = new sg::matrix;
0028 sep1->add(tsf1);
0029 vec3f mn1,mx1;
0030 {valop2sg v(m_out,*sep1,m_ttf);
0031 if(!v.visit(a_1)) {
0032 delete sep;
0033 return false;
0034 }
0035 mnmx(m_out,*sep1,mn1,mx1);}
0036
0037 sg::separator* op_sep = new sg::separator;
0038 sep->add(op_sep);
0039 sg::matrix* op_tsf = new sg::matrix;
0040 op_sep->add(op_tsf);
0041
0042 sg::separator* sep2 = new sg::separator;
0043 sep->add(sep2);
0044 sg::matrix* tsf2 = new sg::matrix;
0045 sep2->add(tsf2);
0046 vec3f mn2,mx2;
0047 {valop2sg v(m_out,*sep2,m_ttf);
0048 if(!v.visit(a_2)) {
0049 delete sep;
0050 return false;
0051 }
0052 mnmx(m_out,*sep2,mn2,mx2);}
0053
0054 if((a_type==valop::ADD) ||
0055 (a_type==valop::SUB) ||
0056 (a_type==valop::MUL) ||
0057 (a_type==valop::EQUAL) ){
0058
0059 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0060
0061 if(a_type==valop::ADD) unichar2sg(0x0002B,*tft); // +
0062 //else if(a_type==valop::SUB) unichar2sg(0x0002D,*tft); // -
0063 else if(a_type==valop::SUB) unichar2sg(0x02212,*tft);
0064 //else if(a_type==valop::MUL) unichar2sg(0x0002A,*tft); // *
0065 //else if(a_type==valop::MUL) unichar2sg(0x02219,*tft); // .
0066 else if(a_type==valop::MUL) unichar2sg(0x02A2F,*tft); // x
0067 else if(a_type==valop::EQUAL) unichar2sg(0x0003D,*tft); // =
0068 op_sep->add(tft);
0069
0070 vec3f omn,omx;
0071 mnmx(m_out,*tft,omn,omx);
0072
0073 float odx = omx[0]-omn[0];
0074 float xmargin = odx*0.1f;
0075
0076 op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0);
0077
0078 tsf2->mul_translate(-mn2[0]+mx1[0]+xmargin+odx+xmargin,0,0);
0079
0080 } else if( (a_type==valop::ASIDE) ||
0081 (a_type==valop::NVMUL) ){
0082
0083 float xspace = (mx1[0]-mn1[0])*0.1f;
0084
0085 tsf2->mul_translate(-mn2[0]+mx1[0]+xspace,0,0);
0086
0087 } else if(a_type==valop::DIV) {
0088
0089 // the bar :
0090 sg::vertices* vtcs = new sg::vertices;
0091 op_sep->add(vtcs);
0092 float w2 = 0.5f;
0093 float h = 0.101f;
0094 vtcs->add(-w2,0,0);
0095 vtcs->add( w2,0,0);
0096 vtcs->add( w2,h,0);
0097 vtcs->add(-w2,h,0);
0098 if(m_wf) {
0099 vtcs->mode = gl::line_strip();
0100 vtcs->add(-w2,0,0);
0101 } else {
0102 vtcs->mode = gl::triangle_fan();
0103 }
0104
0105 float ymargin = h;
0106
0107 float osx = mx(mx1[0]-mn1[0],mx2[0]-mn2[0]);
0108 osx *= 1.1f;
0109
0110 op_tsf->mul_scale(osx,1,1);
0111
0112 //put a_1 symbol in the middle of the bar.
0113 //put a_1 symbol on top of the bar (with an ymargin).
0114 float dx1 = -(mn1[0]+mx1[0])*0.5f;
0115 float dy1 = -mn1[1]+h+ymargin;
0116 tsf1->mul_translate(dx1,dy1,0);
0117
0118 //put a_2 symbol in the middle of the bar.
0119 //put a_2 symbol under the bar (with an ymargin).
0120 float dx2 = -(mn2[0]+mx2[0])*0.5f;
0121 float dy2 = -mx2[1]-ymargin;
0122 tsf2->mul_translate(dx2,dy2,0);
0123
0124 } else if(a_type==valop::SUPS) {
0125
0126 if(mx2[0]==mn2[0]) {
0127 delete sep;
0128 return false;
0129 }
0130
0131 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size.
0132 tsf2->set_scale(s2,s2,1);
0133 mnmx(m_out,*sep2,mn2,mx2);
0134
0135 float xshift = (mx1[0]-mn1[0])*0.1f;
0136 float dx2 = -mn2[0]+mx1[0]+xshift;
0137
0138 float yshift = (mx1[1]-mn1[1])*0.3f;
0139 float dy2 = -mn2[1]+mx1[1]-yshift;
0140
0141 tsf2->set_translate(dx2,dy2,0);
0142 tsf2->mul_scale(s2,s2,1); //applied first
0143
0144 } else if(a_type==valop::SUBS) {
0145
0146 if(mx2[0]==mn2[0]) {
0147 delete sep;
0148 return false;
0149 }
0150
0151 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size.
0152 tsf2->set_scale(s2,s2,1);
0153 mnmx(m_out,*sep2,mn2,mx2);
0154
0155 float xshift = (mx1[0]-mn1[0])*0.1f;
0156 float dx2 = -mn2[0]+mx1[0]+xshift;
0157
0158 float yshift = (mx1[1]-mn1[1])*0.3f;
0159 float dy2 = -mn2[1]-yshift;
0160
0161 tsf2->set_translate(dx2,dy2,0);
0162 tsf2->mul_scale(s2,s2,1); //applied first
0163
0164 } else {
0165 delete sep;
0166 return false;
0167 }
0168
0169 m_group.add(sep);
0170
0171 return true;
0172 }
0173
0174 virtual bool unary(unsigned int a_type,const valop& a_1) {
0175 if(a_type==valop::MINUS) {
0176 sg::separator* sep = new sg::separator;
0177
0178 sg::separator* sep1 = new sg::separator;
0179 sep->add(sep1);
0180 sg::matrix* tsf1 = new sg::matrix;
0181 sep1->add(tsf1);
0182 vec3f mn1,mx1;
0183 {valop2sg v(m_out,*sep1,m_ttf);
0184 if(!v.visit(a_1)) {
0185 delete sep;
0186 return false;
0187 }
0188 mnmx(m_out,*sep1,mn1,mx1);}
0189
0190 m_group.add(sep);
0191
0192 ////////////////////////////////////////////////////////
0193 /// minus symbol ///////////////////////////////////////
0194 ////////////////////////////////////////////////////////
0195 sg::separator* op_sep = new sg::separator;
0196 sep->add(op_sep);
0197 //sg::matrix* op_tsf = new sg::matrix;
0198 //op_sep->add(op_tsf);
0199
0200 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0201 //TTNODE* tft = new TTNODE();
0202 unichar2sg(0x0002D,*tft);
0203 op_sep->add(tft);
0204 vec3f omn,omx;
0205 mnmx(m_out,*tft,omn,omx);
0206
0207 float odx = omx[0]-omn[0];
0208 float xmargin = odx*0.1f;
0209
0210 //push a_1 at right of minus symbol
0211 tsf1->mul_translate(-mn1[0]+omx[0]+xmargin,0,0);
0212
0213 return true;
0214
0215 } else {
0216 return false;
0217 }
0218 }
0219
0220 virtual bool variable(unsigned int a_type,const value& a_var) {
0221
0222 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0223 //TTNODE* tft = new TTNODE();
0224
0225 if(a_type==valop::SYMBOL) {
0226 if(rcmp(a_var.get_string(),s_psi())) {
0227 unichar2sg(0x003C8,*tft);
0228 m_group.add(tft);
0229 return true;
0230 } else if(rcmp(a_var.get_string(),s_gamma())) {
0231 unichar2sg(0x003B3,*tft);
0232 m_group.add(tft);
0233 return true;
0234 } else if(rcmp(a_var.get_string(),s_mu())) {
0235 unichar2sg(0x003BC,*tft);
0236 m_group.add(tft);
0237 return true;
0238 } else if(rcmp(a_var.get_string(),s_upper_delta())) {
0239 unichar2sg(0x02206,*tft);
0240 m_group.add(tft);
0241 return true;
0242 } else if(rcmp(a_var.get_string(),s_partial_derivative())){
0243 unichar2sg(0x02202,*tft); //d ronde
0244 m_group.add(tft);
0245 return true;
0246 } else if(rcmp(a_var.get_string(),s_h_bar())){
0247 unichar2sg(0x0210F,*tft);
0248 m_group.add(tft);
0249 return true;
0250 }
0251
0252 } else if(a_type==valop::REAL){
0253 s2sg(value::to_string(a_var),*tft);
0254 m_group.add(tft);
0255 return true;
0256
0257 } else if(a_type==valop::STRING){
0258 if(a_var.type()==value::STRING){
0259 s2sg(a_var.get_string(),*tft);
0260 m_group.add(tft);
0261 return true;
0262 } else {
0263 m_out << "valop2sg::variable :"
0264 << " expected a value::STRING."
0265 << " Got " << a_var.stype() << "."
0266 << std::endl;
0267 }
0268 }
0269
0270 delete tft;
0271 return false;
0272 }
0273
0274 virtual bool option(const valop& a_node) {
0275 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0276 //TTNODE* tft = new TTNODE();
0277 s2sg(a_node.m_name,*tft);
0278 m_group.add(tft);
0279 return true;
0280 }
0281
0282 virtual bool func_1(const valop& a_f,const valop& a_1) {
0283 if(rcmp(a_f.m_function->name(),s_sqrt())) {
0284
0285 sg::separator* sep = new sg::separator;
0286
0287 sg::separator* sep1 = new sg::separator;
0288 sep->add(sep1);
0289 vec3f mn1,mx1;
0290 {valop2sg v(m_out,*sep1,m_ttf);
0291 if(!v.visit(a_1)) {
0292 delete sep;
0293 return false;
0294 }
0295 mnmx(m_out,*sep1,mn1,mx1);}
0296
0297 m_group.add(sep);
0298
0299 ////////////////////////////////////////////////////////
0300 /// sqrt symbol ////////////////////////////////////////
0301 ////////////////////////////////////////////////////////
0302 sg::separator* op_sep = new sg::separator;
0303 sep->add(op_sep);
0304 sg::matrix* op_tsf = new sg::matrix;
0305 op_sep->add(op_tsf);
0306
0307 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0308 //TTNODE* tft = new TTNODE();
0309 unichar2sg(0x0221A,*tft);
0310 op_sep->add(tft);
0311 vec3f omn,omx;
0312 mnmx(m_out,*tft,omn,omx);
0313
0314 // upper bar :
0315 sg::vertices* vtcs = new sg::vertices;
0316 op_sep->add(vtcs);
0317 float dx = 0.05f; //to cover the top of the sqrt symbol.
0318 float w = mx1[0]-mn1[0];
0319 w *= 1.05f;
0320 float h = 0.09f;
0321 vtcs->add(omx[0]-dx ,omx[1]-h,0);
0322 vtcs->add(omx[0]+w ,omx[1]-h,0);
0323 vtcs->add(omx[0]+w ,omx[1] ,0);
0324 vtcs->add(omx[0]-dx ,omx[1] ,0);
0325 if(m_wf) {
0326 vtcs->mode = gl::line_strip();
0327 vtcs->add(omx[0]-dx ,omx[1]-h,0);
0328 } else {
0329 vtcs->mode = gl::triangle_fan();
0330 }
0331
0332 //float odx = omx[0]-omn[0];
0333 //float xmargin = odx*0.1f;
0334 float xmargin = 0;
0335
0336 //push sqrt-symbol at left of a_1
0337 //scale sqrt-symbol to match a_1 y height.
0338 //y translate sqrt-symbol so that a_1 is under the bar :
0339
0340 float osy = (mx1[1]-mn1[1])/(omx[1]-omn[1]);
0341 float ody = -omn[1]*osy + mn1[1];
0342
0343 osy *= 1.2f;
0344
0345 op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,ody,0); //second
0346 op_tsf->mul_scale(1,osy,1); //first
0347
0348 return true;
0349 } else {
0350 // generic case : <func_name>(rep of a_1)
0351
0352 sg::separator* sep = new sg::separator;
0353
0354 sg::separator* sep1 = new sg::separator;
0355 sep->add(sep1);
0356 vec3f mn1,mx1;
0357 {valop2sg v(m_out,*sep1,m_ttf);
0358 if(!v.visit(a_1)) {
0359 delete sep;
0360 return false;
0361 }
0362 mnmx(m_out,*sep1,mn1,mx1);}
0363
0364 m_group.add(sep);
0365
0366 ////////////////////////////////////////////////////////
0367 /// left func symbol : <func_name> ( /////////////
0368 ////////////////////////////////////////////////////////
0369 {sg::separator* op_sep = new sg::separator;
0370 sep->add(op_sep);
0371 sg::matrix* op_tsf = new sg::matrix;
0372 op_sep->add(op_tsf);
0373
0374 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0375 //TTNODE* tft = new TTNODE();
0376 s2sg(a_f.m_function->name(),*tft);
0377 tft->unitext[0].push_back(0x00028); // (
0378 op_sep->add(tft);
0379
0380 vec3f omn,omx;
0381 mnmx(m_out,*tft,omn,omx);
0382
0383 //push func-symbol at left of a_1 :
0384 //float odx = omx[0]-omn[0];
0385 //float xmargin = odx*0.1f;
0386 float xmargin = 0;
0387 op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,0,0);
0388 } //end left op
0389
0390 ////////////////////////////////////////////////////////
0391 /// right func symbol : ) /////////////
0392 ////////////////////////////////////////////////////////
0393 {sg::separator* op_sep = new sg::separator;
0394 sep->add(op_sep);
0395 sg::matrix* op_tsf = new sg::matrix;
0396 op_sep->add(op_tsf);
0397
0398 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0399 //TTNODE* tft = new TTNODE();
0400 unichar2sg(0x00029,*tft);
0401 op_sep->add(tft);
0402 vec3f omn,omx;
0403 mnmx(m_out,*tft,omn,omx);
0404
0405 //push func-symbol at right of a_1 :
0406 //float odx = omx[0]-omn[0];
0407 //float xmargin = odx*0.1f;
0408 float xmargin = 0;
0409 op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0);
0410 } //end right op
0411
0412 return true;
0413 }
0414 }
0415 virtual bool func_2(const valop& a_f,const valop& a_1,const valop& a_2) {
0416 if(rcmp(a_f.m_function->name(),s_pow())) {
0417
0418 sg::separator* sep = new sg::separator;
0419
0420 sg::separator* sep1 = new sg::separator;
0421 sep->add(sep1);
0422 sg::matrix* tsf1 = new sg::matrix;
0423 sep1->add(tsf1);
0424 vec3f mn1,mx1;
0425 {valop2sg v(m_out,*sep1,m_ttf);
0426 if(!v.visit(a_1)) {
0427 delete sep;
0428 return false;
0429 }
0430 mnmx(m_out,*sep1,mn1,mx1);}
0431
0432 //sg::separator* op_sep = new sg::separator;
0433 //sep->add(op_sep);
0434 //sg::matrix* op_tsf = new sg::matrix;
0435 //op_sep->add(op_tsf);
0436
0437 sg::separator* sep2 = new sg::separator;
0438 sep->add(sep2);
0439 sg::matrix* tsf2 = new sg::matrix;
0440 sep2->add(tsf2);
0441 vec3f mn2,mx2;
0442 {valop2sg v(m_out,*sep2,m_ttf);
0443 if(!v.visit(a_2)) {
0444 delete sep;
0445 return false;
0446 }
0447 mnmx(m_out,*sep2,mn2,mx2);}
0448
0449 float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size.
0450 if(mx2[0]==mn2[0]) {
0451 delete sep;
0452 return false;
0453 }
0454 tsf2->set_scale(s2,s2,1);
0455 mnmx(m_out,*sep2,mn2,mx2);
0456
0457 float xshift = (mx1[0]-mn1[0])*0.1f;
0458 float dx2 = -mn2[0]+mx1[0]+xshift;
0459
0460 float yshift = (mx1[1]-mn1[1])*0.3f;
0461 float dy2 = -mn2[1]+mx1[1]-yshift;
0462
0463 tsf2->set_identity();
0464 tsf2->mul_translate(dx2,dy2,0);
0465 tsf2->mul_scale(s2,s2,1); //applied first
0466
0467 m_group.add(sep);
0468
0469 return true;
0470
0471 } else {
0472 // generic case : <func_name>(rep of a_1, rep of a_2)
0473
0474 sg::separator* sep = new sg::separator;
0475
0476 sg::separator* sep1 = new sg::separator;
0477 sep->add(sep1);
0478 vec3f mn1,mx1;
0479 {valop2sg v(m_out,*sep1,m_ttf);
0480 if(!v.visit(a_1)) {
0481 delete sep;
0482 return false;
0483 }
0484 mnmx(m_out,*sep1,mn1,mx1);}
0485
0486 sg::separator* sep2 = new sg::separator;
0487 sep->add(sep2);
0488 sg::matrix* tsf2 = new sg::matrix;
0489 sep2->add(tsf2);
0490 vec3f mn2,mx2;
0491 {valop2sg v(m_out,*sep2,m_ttf);
0492 if(!v.visit(a_2)) {
0493 delete sep;
0494 return false;
0495 }
0496 mnmx(m_out,*sep2,mn2,mx2);}
0497
0498 m_group.add(sep);
0499
0500 ////////////////////////////////////////////////////////
0501 /// left func symbol : <func_name> ( /////////////
0502 ////////////////////////////////////////////////////////
0503 {sg::separator* op_sep = new sg::separator;
0504 sep->add(op_sep);
0505 sg::matrix* op_tsf = new sg::matrix;
0506 op_sep->add(op_tsf);
0507
0508 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0509 //TTNODE* tft = new TTNODE();
0510 s2sg(a_f.m_function->name(),*tft);
0511 tft->unitext[0].push_back(0x00028); // (
0512 op_sep->add(tft);
0513
0514 vec3f omn,omx;
0515 mnmx(m_out,*tft,omn,omx);
0516
0517 //push func-symbol at left of a_1 :
0518 //float odx = omx[0]-omn[0];
0519 //float xmargin = odx*0.1f;
0520 float xmargin = 0;
0521 op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,0,0);
0522 } //end left op
0523
0524 ////////////////////////////////////////////////////////
0525 /// , /////////////
0526 ////////////////////////////////////////////////////////
0527 float xend2 = 0;
0528 {sg::separator* op_sep = new sg::separator;
0529 sep->add(op_sep);
0530 sg::matrix* op_tsf = new sg::matrix;
0531 op_sep->add(op_tsf);
0532
0533 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0534 //TTNODE* tft = new TTNODE();
0535 unichar2sg(0x0002C,*tft); // ,
0536 op_sep->add(tft);
0537 vec3f omn,omx;
0538 mnmx(m_out,*tft,omn,omx);
0539
0540 //push comma-symbol at right of a_1 :
0541 float odx = omx[0]-omn[0];
0542 float xmargin = odx*0.1f;
0543 op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0);
0544
0545 float xendcomma = mx1[0]+xmargin+(omx[0]-omn[0]);
0546
0547 tsf2->mul_translate(-mn2[0]+xendcomma+xmargin,0,0);
0548
0549 xend2 = xendcomma+(mx2[0]-mn2[0]);
0550 } //end comma
0551
0552 ////////////////////////////////////////////////////////
0553 /// right func symbol : ) /////////////
0554 ////////////////////////////////////////////////////////
0555 {sg::separator* op_sep = new sg::separator;
0556 sep->add(op_sep);
0557 sg::matrix* op_tsf = new sg::matrix;
0558 op_sep->add(op_tsf);
0559
0560 sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0561 //TTNODE* tft = new TTNODE();
0562 unichar2sg(0x00029,*tft);
0563 op_sep->add(tft);
0564 vec3f omn,omx;
0565 mnmx(m_out,*tft,omn,omx);
0566
0567 //push ")" at right of a_2 :
0568 //float odx = omx[0]-omn[0];
0569 //float xmargin = odx*0.1f;
0570 float xmargin = 0;
0571 op_tsf->mul_translate(-omn[0]+xend2+xmargin,0,0);
0572 } //end right op
0573
0574 return true;
0575 }
0576 }
0577 virtual bool func_3(const valop&,const valop&,const valop&,const valop&) {
0578 return false;
0579 }
0580 virtual bool func_4(const valop&,const valop&,const valop&,const valop&,const valop&) {
0581 return false;
0582 }
0583 virtual bool func_5(const valop&,const valop&,const valop&,const valop&,const valop&,const valop&) {
0584 return false;
0585 }
0586 virtual bool func_6(const valop&,const valop&,const valop&,const valop&,const valop&,const valop&,const valop&) {
0587 return false;
0588 }
0589 public:
0590 valop2sg(std::ostream& a_out,
0591 sg::group& a_group,
0592 const sg::base_freetype& a_ttf)
0593 :m_out(a_out)
0594 ,m_group(a_group)
0595 //,m_wf(true)
0596 ,m_wf(false)
0597 ,m_ttf(a_ttf)
0598 {}
0599 virtual ~valop2sg() {}
0600 public:
0601 valop2sg(const valop2sg& a_from)
0602 :valop_visitor(a_from)
0603 ,m_out(a_from.m_out)
0604 ,m_group(a_from.m_group)
0605 ,m_wf(a_from.m_wf)
0606 ,m_ttf(a_from.m_ttf)
0607 {}
0608 valop2sg& operator=(const valop2sg& a_from){
0609 m_wf = a_from.m_wf;
0610 return *this;
0611 }
0612 protected:
0613 typedef unsigned int unichar;
0614
0615 unichar char2stix(char a_c) {
0616 if(a_c=='-') return 0x0002D;
0617 if(a_c=='.') return 0x0002E;
0618
0619 if(a_c=='0') return 0x00030;
0620 if(a_c=='1') return 0x00031;
0621 if(a_c=='2') return 0x00032;
0622 if(a_c=='3') return 0x00033;
0623 if(a_c=='4') return 0x00034;
0624 if(a_c=='5') return 0x00035;
0625 if(a_c=='6') return 0x00036;
0626 if(a_c=='7') return 0x00037;
0627 if(a_c=='8') return 0x00038;
0628 if(a_c=='9') return 0x00039;
0629
0630 if(a_c=='A') return 0x00041;
0631 if(a_c=='B') return 0x00042;
0632 if(a_c=='C') return 0x00043;
0633 if(a_c=='D') return 0x00044;
0634 if(a_c=='E') return 0x00045;
0635 if(a_c=='F') return 0x00046;
0636 if(a_c=='G') return 0x00047;
0637 if(a_c=='H') return 0x00048;
0638 if(a_c=='I') return 0x00049;
0639 if(a_c=='J') return 0x0004A;
0640 if(a_c=='K') return 0x0004B;
0641 if(a_c=='L') return 0x0004C;
0642 if(a_c=='M') return 0x0004D;
0643 if(a_c=='N') return 0x0004E;
0644 if(a_c=='O') return 0x0004F;
0645 if(a_c=='P') return 0x00050;
0646 if(a_c=='Q') return 0x00051;
0647 if(a_c=='R') return 0x00052;
0648 if(a_c=='S') return 0x00053;
0649 if(a_c=='T') return 0x00054;
0650 if(a_c=='U') return 0x00055;
0651 if(a_c=='V') return 0x00056;
0652 if(a_c=='W') return 0x00057;
0653 if(a_c=='X') return 0x00058;
0654 if(a_c=='Y') return 0x00059;
0655 if(a_c=='Z') return 0x0005A;
0656
0657 if(a_c=='a') return 0x00061;
0658 if(a_c=='b') return 0x00062;
0659 if(a_c=='c') return 0x00063;
0660 if(a_c=='d') return 0x00064;
0661 if(a_c=='e') return 0x00065;
0662 if(a_c=='f') return 0x00066;
0663 if(a_c=='g') return 0x00067;
0664 if(a_c=='h') return 0x00068;
0665 if(a_c=='i') return 0x00069;
0666 if(a_c=='j') return 0x0006A;
0667 if(a_c=='k') return 0x0006B;
0668 if(a_c=='l') return 0x0006C;
0669 if(a_c=='m') return 0x0006D;
0670 if(a_c=='n') return 0x0006E;
0671 if(a_c=='o') return 0x0006F;
0672 if(a_c=='p') return 0x00070;
0673 if(a_c=='q') return 0x00071;
0674 if(a_c=='r') return 0x00072;
0675 if(a_c=='s') return 0x00073;
0676 if(a_c=='t') return 0x00074;
0677 if(a_c=='u') return 0x00075;
0678 if(a_c=='v') return 0x00076;
0679 if(a_c=='w') return 0x00077;
0680 if(a_c=='x') return 0x00078;
0681 if(a_c=='y') return 0x00079;
0682 if(a_c=='z') return 0x0007A;
0683
0684 if(a_c=='_') return 0x0005F;
0685
0686 return 0x0003F; //?
0687 }
0688
0689 void unichar2sg(unichar a_unichar,sg::base_freetype& a_node){
0690 if(m_wf) a_node.modeling = sg::font_outline;
0691
0692 a_node.font = sg::font_stixgeneral_otf();
0693
0694 std::vector<unichar> line;
0695 line.push_back(a_unichar);
0696
0697 a_node.unitext.add(line);
0698 }
0699
0700 void s2sg(const std::string& a_s,sg::base_freetype& a_node){
0701 if(m_wf) a_node.modeling = sg::font_outline; //else font_filled, font_pixmap.
0702
0703 a_node.font = sg::font_stixgeneral_otf();
0704
0705 std::vector<unichar> line;
0706 tools_sforcit(a_s,it) line.push_back(char2stix(*it));
0707
0708 a_node.unitext.add(line);
0709 }
0710
0711 protected:
0712 std::ostream& m_out;
0713 sg::group& m_group;
0714 bool m_wf;
0715 const sg::base_freetype& m_ttf;
0716 };
0717
0718 }
0719
0720 #endif