📄 rs_filterdxf1.cpp
字号:
do { dxfCode=getBufLine(); if(dxfCode) code=dxfCode.toInt(); if(dxfCode && code!=0) { dxfLine=getBufLine(); if(dxfLine) { switch(code) { case 8: // Layer // if(dxfLine!=lastLayer) { if (dxfLine=="(null)" || dxfLine=="default") { dxfLine = "0"; } graphic->activateLayer(dxfLine); //lastLayer=dxfLine; //} break; case 10: // X1 vx1 = dxfLine.toDouble(); break; case 20: // Y1 vy1 = dxfLine.toDouble(); //graphic->Vec[vc].CreatePoint(vy1, vx1, currentLayerNum); //if(vc<vElements-1) ++vc; break; case 11: // X2 vx2 = dxfLine.toDouble(); break; case 21: // Y2 vy2 = dxfLine.toDouble(); //graphic->Vec[vc].CreatePoint(vy2, vx2, currentLayerNum); //if(vc<vElements-1) ++vc; break; default: break; } } } }while(dxfCode && code!=0); / * if(!mt.CompFloat(vx1, vx2) || !mt.CompFloat(vy1, vy2)) { graphic->Vec[vc].CreateLine(vx1, vy1, vx2, vy2, currentLayerNum); if(vc<vElements-1) ++vc; } if(++updProgress==1000) { np->getStateWin()->UpdateProgressBar((int)(pcFact*vc)+25); updProgress=0; } * / } */ // ----- // Text: // ----- else if(dxfLine=="TEXT") { RS_String vtext; // the text char vtextStyle[256]; // text style (normal_ro, cursive_ri, normal_st, ...) double vheight=10.0; // text height double vtextAng=0.0; // text angle //double vradius=0.0; // text radius //double vletterspace=2.0; // Text letter space //double vwordspace=6.0; // Text wordspace RS_String vfont; // font "normal", "cursive", ... RS2::HAlign vhalign=RS2::HAlignLeft; // alignment (0=left, 1=center, 2=right) //int vattachement=7; // 1=top left, 2, 3, 4, 5, 6, 7, 8, 9=bottom right //uint vfl=0; // special flags bool codeSeven=false; // Have we found a code seven? vtextStyle[0] = '\0'; vfont="normal"; do { dxfCode=getBufLine(); if(dxfCode) code=dxfCode.toInt(); if(dxfCode && code!=0) { if(code!=1 && code!=3 && code!=7) dxfLine=getBufLine(); if(dxfLine || code==1 || code==3 || code==7) { switch(code) { case 1: // Text itself vtext=getBufLine(); strDecodeDxfString(vtext); break; case 3: // Text parts (always 250 chars) vtext=getBufLine(); break; case 6: // style pen.setLineType(RS_FilterDXF::nameToLineType(dxfLine)); break; case 7: // Text style (normal_ro#50.0, // cursive_ri#20.0, normal_st) qstrncpy(vtextStyle, getBufLine(), 249); // get font typ: // { char dummy[256]; sscanf(vtextStyle, "%[^_#\n]", dummy); vfont=dummy; } // get text style: // /* if(strstr(vtextStyle, "_ro")) vfl=vfl|E_ROUNDOUT; else if(strstr(vtextStyle, "_ri")) vfl=vfl|E_ROUNDIN; else vfl=vfl|E_STRAIGHT; */ /*if(strstr(vtextStyle, "_fix")) { vfl=vfl|E_FIXEDWIDTH; }*/ // get radius, letterspace, wordspace: // { char *ptr; // pointer to value ptr = strchr(vtextStyle, '#'); if(ptr) { // Parse radius /*if(vfl&E_ROUNDOUT || vfl&E_ROUNDIN) { ++ptr; if(ptr[0]) { sscanf(ptr, "%lf", &vradius); } ptr = strchr(ptr, '#'); }*/ /*if(ptr) { // Parse letter space: ++ptr; if(ptr[0]) { sscanf(ptr, "%lf", &vletterspace); } // Parse word space: ptr = strchr(ptr, '#'); if(ptr) { ++ptr; if(ptr[0]) { sscanf(ptr, "%lf", &vwordspace); } } }*/ } } codeSeven=true; break; case 8: // Layer //if(dxfLine!=lastLayer) { if (dxfLine=="(null)" || dxfLine=="default") { dxfLine = "0"; } graphic->activateLayer(dxfLine); //lastLayer=dxfLine; //} break; case 10: // X1 dxfLine.replace( QRegExp(","), "." ); vx1 = dxfLine.toDouble(); break; case 20: // Y1 dxfLine.replace( QRegExp(","), "." ); vy1 = dxfLine.toDouble(); break; case 40: // height dxfLine.replace( QRegExp(","), "." ); vheight = dxfLine.toDouble(); /*if(!codeSeven) { vletterspace = vheight*0.2; vwordspace = vheight*0.6; }*/ break; case 50: // angle dxfLine.replace( QRegExp(","), "." ); vtextAng = dxfLine.toDouble() / ARAD; break; case 72: {// alignment //if(!mtext) { int v = dxfLine.toInt(); if(v==1) vhalign = RS2::HAlignCenter; else if(v==2) vhalign = RS2::HAlignRight; else vhalign = RS2::HAlignLeft; //} } break; case 39: // Thickness pen.setWidth(RS_FilterDXF::numberToWidth(dxfLine.toInt())); break; case 62: // Color pen.setColor(RS_FilterDXF::numberToColor(dxfLine.toInt())); break; default: break; } } } } while(dxfCode && code!=0); char* i=strchr(vtextStyle, '#'); if (i!=NULL) { i[0] = '\0'; } graphic->addEntity( new RS_Text(graphic, RS_TextData( RS_Vector(vx1, vy1), vheight, 100.0, RS2::VAlignBottom, vhalign, RS2::LeftToRight, RS2::Exact, 1.0, vtext, vtextStyle, vtextAng ) ) ); } // ---------- // Dimension: // ---------- else if(dxfLine=="DIMENSION") { int typ=1; double v10=0.0, v20=0.0; double v13=0.0, v23=0.0; double v14=0.0, v24=0.0; double v15=0.0, v25=0.0; double v16=0.0, v26=0.0; double v40=0.0, v50=0.0; RS_String dimText; do { dxfCode=getBufLine(); if(dxfCode) { code=dxfCode.toInt(); } if(dxfCode && code!=0) { dxfLine=getBufLine(); if(dxfLine) { switch(code) { case 1: // Text (if any) dimText=dxfLine; // Mend unproper savings of older versions: if(dimText==" " || dimText==";;") dimText=""; //else dimText.replace(QRegExp("%%c"), "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -