static void PDF_PrintWord(OBJECT x, int hpos, int vpos) { FULL_CHAR *p, *q, *a, *b, *lig, *unacc; int ksize; char *command; MAPPING m; unsigned short *composite; COMPOSITE *cmp; /* currently unused - JeffK */ static int last_hpos; /* does not need to be initialised */ static int next_hpos = -1; #if 0 struct metrics *fnt; #endif debug6(DPF, DD, "PrintWord( %s, %d, %d ) font %d colour %d%s", string(x), hpos, vpos, word_font(x), word_colour(x), word_outline(x) ? " outline" : ""); TotalWordCount++; /* if font is different to previous word then print change */ if( word_font(x) != currentfont ) { currentfont = word_font(x); currentxheight2 = FontHalfXHeight(currentfont); PDFFont_Set(out_fp, FontSize(currentfont, x), FontName(currentfont)); } /* if colour is different to previous word then print change */ if( word_colour(x) != currentcolour ) { currentcolour = word_colour(x); if( currentcolour > 0 ) { char str[256]; sprintf(str, "%s ", ColourCommand(currentcolour)); PDFPage_Write(out_fp, str); } } /* move to coordinate of x */ debug1(DPF, DDD, " currentxheight2 = %d", currentxheight2); vpos = vpos - currentxheight2; if( cpexists && (currenty == vpos) && PDFHasValidTextMatrix() ) { /* printnum(hpos, out_fp); */ command = "s"; /* Note: I calculate the width of the space char here in case the font has changed. This prevents subtle spacing errors. */ #if 0 fnt = finfo[currentfont].size_table; if( (next_hpos + fnt[' '].right /* width of space char */ ) == hpos ) command = " "; #endif } else { currenty = vpos; /* printnum(hpos, out_fp); fputs(" ", out_fp); printnum(currenty, out_fp); */ command = "m"; cpexists = TRUE; } /* convert ligature sequences into ligature characters */ lig = finfo[word_font(x)].lig_table; p = q = string(x); do { /* check for missing glyph (lig[] == 1) or ligatures (lig[] > 1) */ if( lig[*q++ = *p++] ) { if( lig[*(q-1)] == 1 ) continue; else { a = &lig[ lig[*(p-1)] + MAX_CHARS ]; while( *a++ == *(p-1) ) { b = p; while( *a == *b && *(a+1) != '\0' && *b != '\0' ) a++, b++; if( *(a+1) == '\0' ) { *(q-1) = *a; p = b; break; } else { while( *++a ); a++; } } } } } while( *p ); *q = '\0'; switch (command[0]) { case 'm': PDFText_OpenXY(out_fp, hpos, vpos); last_hpos = hpos; next_hpos = hpos + fwd(x, COLM); /* fwd(x, COLM) = width of wd */ break; case 's': #if 0 PDFText_Open(out_fp); PDFText_Kern(out_fp, hpos - next_hpos); #else PDFText_OpenX(out_fp, hpos - last_hpos); #endif last_hpos = hpos; next_hpos = hpos + fwd(x, COLM); /* fwd(x, COLM) = width of wd */ break; #if 0 case ' ': PDFText_Open(out_fp); #if 1 /* try kerning to get correct position */ PDFText_Kern(out_fp, fnt[' '].right); #else PDFPage_Write(out_fp, EightBitToPrintForm[' ']); #endif next_hpos += fwd(x, COLM) + fnt[' '].right; /* width of space ch */ break; #endif } p = string(x); PDFPage_Write(out_fp, EightBitToPrintForm[*p]); m = font_mapping(finfo[word_font(x)].font_table); unacc = MapTable[m]->map[MAP_UNACCENTED]; /* acc = MapTable[m]->map[MAP_ACCENT]; */ for( p++; *p; p++ ) { /* *** this seems right but is actually wrong for PDF, which according to Uwe uses original units for kerning KernLength(word_font(x), unacc, *(p-1), *p, ksize); *** */ KernLength(font_num(finfo[word_font(x)].original_face), unacc, *(p-1), *p, ksize); if ( ksize != 0 ) { PDFText_Kern(out_fp, ksize); } PDFPage_Write(out_fp, EightBitToPrintForm[*p]); } PDFText_Close(out_fp); debug0(DPF, DDD, "PDF_PrintWord returning"); } /* end PDF_PrintWord */
void MainWindow::paintEvent(QPaintEvent *) { QPainter painter(this); painter.save(); //fist, draw a rounded rect for header & graphic area; painter.drawRoundedRect(header_area,15,15); painter.drawRoundedRect(curve_area.x(),curve_area.y(),curve_area.width(),table_area.y()+table_area.height()-curve_area.y(),15,15); //painter.drawRoundedRect(curve_area,15,15); painter.setPen(Qt::SolidLine); QFont Nr_font("Arial",8); QPen nom_line_pen(Qt::black, 1.5, Qt::SolidLine); QPen act_line_pen(Qt::red, 1.5 ,Qt::SolidLine); QPen line_pen(Qt::blue, 1 , Qt::SolidLine); QPen tol_line_pen(Qt::green, 1 , Qt::SolidLine); //move the painter to the left mid position painter.translate(curve_area.x()+gap,curve_area.center().y()); //draw coordinate axis QPen axis_pen(Qt::blue,1,Qt::SolidLine); painter.setPen(axis_pen); painter.drawLine(0,curve_area.height()/2-10,curve_area.width()-gap*2,curve_area.height()/2-10); painter.drawLine(curve_area.width()/2-gap,curve_area.height()/2,curve_area.width()/2-gap,-curve_area.height()/2); //draw X axis sign & number painter.setFont(Nr_font); int be,en; be = std::ceil(min_x)+1; en = std::floor(max_x)-1; for(int i=be;i<=en;++i) { painter.drawLine((i-min_x)*scale_x,curve_area.height()/2-5,(i-min_x)*scale_x,curve_area.height()/2-15); painter.drawText((i-min_x)*scale_x+3,curve_area.height()/2,QString("%1").arg(i)); } //draw Y axis sign & number be = std::ceil(min_y*1000); en = std::floor(max_y*1000); be-=3; en+=4; //draw 10e-3 painter.drawText(curve_area.width()/2-gap-20,-curve_area.height()/2+10, 10,10, Qt::AlignRight|Qt::AlignVCenter,QString("10")); painter.setFont(QFont("Arial",6)); painter.drawText(curve_area.width()/2-gap-12,-curve_area.height()/2+7, 10,10, Qt::AlignRight|Qt::AlignVCenter,QString("-3")); for(int i=be;i<=en;i++) { if (i%2==0) { painter.drawLine(curve_area.width()/2-gap-5,(double(i)/1000-(min_y+max_y)/2)*scale_y, curve_area.width()/2-gap+5,(double(i)/1000-(min_y+max_y)/2)*scale_y); painter.drawText(curve_area.width()/2-gap-15,(double(i)/1000-(min_y+max_y)/2)*scale_y-5, 10,10, Qt::AlignRight|Qt::AlignVCenter,QString("%1").arg(i)); } else { painter.drawLine(curve_area.width()/2-gap-2,(double(i)/1000-(min_y+max_y)/2)*scale_y, curve_area.width()/2-gap+2,(double(i)/1000-(min_y+max_y)/2)*scale_y); } } //draw nominal und actual curves painter.setPen(nom_line_pen); painter.drawPath(*nom_path); painter.setPen(act_line_pen); painter.drawPath(*act_path); painter.setPen(tol_line_pen); painter.drawPath(*ut_path); painter.drawPath(*lt_path); //painter.drawPoints(nom_points,data->size()); //draw nominal points as single points painter.setPen(line_pen); for(int i=0;i<size;++i) { painter.drawEllipse(nom_points[i],1.2,1.2); } //draw nominal points number for(int i=0;i<28;i++) { painter.drawLine(nom_points[i],QPointF(nom_points[i].x(),-curve_area.height()/2+50)); painter.save(); painter.translate(nom_points[i].x()-2,-curve_area.height()/2+50); painter.rotate(-40); painter.setFont(Nr_font); painter.drawText(0,0,QString("%1").arg(i+1)); painter.restore(); } //draw profile value painter.restore(); painter.save(); painter.translate(table_area.center().x(),table_area.y()); for(int i=0;i<3;++i) { painter.drawRect(-90+i*60,5,60,20); } painter.drawArc(-70,10,20,20,0,180*16); painter.drawText(-30,5,60,20,Qt::AlignCenter,QString("%1").arg(profil)); painter.drawText(30,5,60,20,Qt::AlignCenter,QString("%1").arg(QString::number(act_profil,'f',4))); //draw data tables painter.restore(); painter.save(); painter.translate(table_area.x(),table_area.y()); //set draw paras for the table lines & fonts painter.setPen(axis_pen); QRectF one_cell(0,0,50,15); QRectF title_cell(0,0,80,15); QPointF start_pos(60,40); QFont word_font("Times New Roman",10); QFont num_font("Times New Roman",10); num_font.setLetterSpacing(QFont::AbsoluteSpacing,1.5); //draw first line table and data painter.drawRect(start_pos.x(),start_pos.y(),title_cell.width(),title_cell.height()); for(int i=1;i<5;++i) { painter.drawRect(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height()); } for(int j=1;j<15;++j) { painter.drawRect(start_pos.x()+title_cell.width()+gap+(j-1)*one_cell.width(),start_pos.y(),one_cell.width(),one_cell.height()); for(int i=1;i<5;++i) { painter.drawRect(start_pos.x()+title_cell.width()+gap+(j-1)*one_cell.width(),start_pos.y()+one_cell.height()*i+5,one_cell.width(),one_cell.height()); } } //draw text for titles painter.setFont(word_font); painter.drawText(start_pos.x(),start_pos.y(),title_cell.width(),title_cell.height(),Qt::AlignHCenter|Qt::AlignBottom, QString("number")); { int i; i=1; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("X [mm]")); i=2; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("Ys [um]")); i=3; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("Yi [um]")); i=4; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("dev.[um]")); } //draw the data painter.setFont(num_font); for (int i=0;i<14;++i) { painter.drawText(start_pos.x()+title_cell.width()+gap+(i)*one_cell.width(),start_pos.y(),one_cell.width(),one_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("%1").arg(i+1)); { int j=1; painter.drawText(start_pos.x()+title_cell.width()+gap+(i)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number(nom_data->at(i).x,'f',2))); j=2; painter.drawText(start_pos.x()+title_cell.width()+gap+(i)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number(nom_data->at(i).y*1000,'f',2))); j=3; painter.drawText(start_pos.x()+title_cell.width()+gap+(i)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number(act_data->at(i).y*1000,'f',2))); j=4; painter.drawText(start_pos.x()+title_cell.width()+gap+(i)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number((act_data->at(i).y-nom_data->at(i).y)*1000,'f',2))); } } painter.translate(0,90); painter.drawRect(start_pos.x(),start_pos.y(),title_cell.width(),title_cell.height()); for(int i=1;i<5;++i) { painter.drawRect(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height()); } for(int j=1;j<15;++j) { painter.drawRect(start_pos.x()+title_cell.width()+gap+(j-1)*one_cell.width(),start_pos.y(),one_cell.width(),one_cell.height()); for(int i=1;i<5;++i) { painter.drawRect(start_pos.x()+title_cell.width()+gap+(j-1)*one_cell.width(),start_pos.y()+one_cell.height()*i+5,one_cell.width(),one_cell.height()); } } //draw text for titles painter.setFont(word_font); painter.drawText(start_pos.x(),start_pos.y(),title_cell.width(),title_cell.height(),Qt::AlignHCenter|Qt::AlignBottom, QString("number")); { int i; i=1; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("X [mm]")); i=2; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("Ys [um]")); i=3; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("Yi [um]")); i=4; painter.drawText(start_pos.x(),start_pos.y()+title_cell.height()*i+5,title_cell.width(),title_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("dev.[um]")); } //draw the data painter.setFont(num_font); for (int i=14;i<28;++i) { painter.drawText(start_pos.x()+title_cell.width()+gap+(i-14)*one_cell.width(),start_pos.y(),one_cell.width(),one_cell.height(), Qt::AlignHCenter|Qt::AlignBottom,QString("%1").arg(i+1)); { int j=1; painter.drawText(start_pos.x()+title_cell.width()+gap+(i-14)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number(nom_data->at(i).x,'f',2))); j=2; painter.drawText(start_pos.x()+title_cell.width()+gap+(i-14)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number(nom_data->at(i).y*1000,'f',2))); j=3; painter.drawText(start_pos.x()+title_cell.width()+gap+(i-14)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number(act_data->at(i).y*1000,'f',2))); j=4; painter.drawText(start_pos.x()+title_cell.width()+gap+(i-14)*one_cell.width(),start_pos.y()+one_cell.height()*j+5, one_cell.width()-2,one_cell.height(), Qt::AlignVCenter|Qt::AlignRight, QString("%1").arg(QString::number((act_data->at(i).y-nom_data->at(i).y)*1000,'f',2))); } } //draw a header and LOGO painter.restore(); painter.drawPixmap(header_area.x()+20,header_area.y()+1,header_area.height()-2,header_area.height()-2,*logo); painter.translate(header_area.x(),header_area.y()); QFont header_font("Arial",header_area.height()*3/10,10,true); painter.setFont(header_font); painter.drawText(0,0,header_area.width(),header_area.height()*6/10,Qt::AlignHCenter|Qt::AlignBottom,QString("PROFILFORM")); header_font.setPointSize(header_area.height()*2/10); painter.setFont(header_font); painter.drawText(0,0,header_area.width(),header_area.height()*9/10,Qt::AlignHCenter|Qt::AlignBottom,QString("ISO 1101")); header_font.setItalic(false); header_font.setPointSize(9); header_font.setFixedPitch(true); painter.setFont(header_font); painter.drawText(header_area.width()*8/10,header_area.height()*2/10,header_area.width()*2/10,header_area.height()*0.2, Qt::AlignLeft|Qt::AlignVCenter, QString("Inspector ")); painter.drawText(header_area.width()*8/10,header_area.height()*4/10,header_area.width()*2/10,header_area.height()*0.2, Qt::AlignLeft|Qt::AlignVCenter, QString("Date ")); painter.drawText(header_area.width()*8/10,header_area.height()*6/10,header_area.width()*2/10,header_area.height()*0.2, Qt::AlignLeft|Qt::AlignVCenter, QString("Time ")); painter.drawText(header_area.width()*9/10,header_area.height()*2/10,header_area.width()*1/10,header_area.height()*0.2, Qt::AlignLeft|Qt::AlignVCenter, QString(": %1").arg(xml_info->paras.value("operid"))); painter.drawText(header_area.width()*9/10,header_area.height()*4/10,header_area.width()*1/10,header_area.height()*0.2, Qt::AlignLeft|Qt::AlignVCenter, QString(": %1").arg(xml_info->paras.value("date"))); painter.drawText(header_area.width()*9/10,header_area.height()*6/10,header_area.width()*1/10,header_area.height()*0.2, Qt::AlignLeft|Qt::AlignVCenter, QString(": %1").arg(xml_info->paras.value("time"))); }