上对比图,左侧是原本,右侧是仿造,有些地方比例还是有问题
其实这个程序没有啥技术含量,就是画
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QLayout> #include <QDebug> int painter_x =800, painter_y =580; int temp_temp_1 = 4408; float temp_temp_2 = 10; int temp_temp = 4408; int angle = 0; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setWindowTitle("HUG_G"); pixmap1.load(":/images/0001.png"); pixmap2.load(":/images/0002.png"); pixmap3.load(":/images/0003.png"); pixmap4.load(":/images/0004.png"); ui->label->installEventFilter(this); this->centralWidget()->layout()->setMargin(0); painter(painter_x,painter_y); timer = new QTimer; timer1 = new QTimer; connect(timer,SIGNAL(timeout()),this,SLOT(timer_out())); connect(timer1,SIGNAL(timeout()),this,SLOT(timer_out1())); timer->start(200); timer1->start(50); about_d = new about(this); } MainWindow::~MainWindow() { timer->stop(); timer1->stop(); delete ui; } // show Full SCreen void MainWindow::on_action_triggered() { this->showFullScreen(); this->menuBar()->hide(); } // ESC quit FullScreen void MainWindow::keyPressEvent(QKeyEvent *event) { if(event->key() == Qt::Key_Escape) { this->showNormal(); this->menuBar()->show(); } else if (event->key() == Qt::Key_Enter||event->key() == Qt::Key_Return) { this->showFullScreen(); this->menuBar()->hide(); } else { } } bool MainWindow::eventFilter(QObject *watched, QEvent *event) { if((watched == ui->label) && (event->type() == QEvent::Paint)) { painter(painter_x,painter_y); return true; } else { } return false; } void MainWindow::timer_out() { if(temp_temp<99999) { temp_temp++; } else { temp_temp = 1000; } if(angle>=-360) { angle--; } else { angle = 0; } } void MainWindow::timer_out1() { if(temp_temp_1<99999) { temp_temp_1++; } else { temp_temp_1=1000; } if(temp_temp_2<99999) { temp_temp_2=temp_temp_2+0.1; } else { temp_temp_2=10.0; } this->update(); } void MainWindow::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); painter_x = ui->label->width(); painter_y = ui->label->height(); // painter(painter_x,painter_y); } //4:3 void MainWindow::painter(int x, int y) { QPainter painter(ui->label); painter.setPen(QPen(Qt::green,2.0)); painter.setFont(QFont("等线",12,QFont::Bold)); if(x>=(y/3*4)) { float temp_x = y/3*4; float flag_1 = y*175/1080.0; float flag_2 = flag_1+40; float flag_3 = y*110/1080.0; painter.drawText(QRect((x-y)/2,flag_1,100,20),Qt::AlignLeft,"A 0.2"); painter.drawText(QRect((x-y)/2,flag_1+20,100,20),Qt::AlignLeft,"G 5.00"); painter.drawText(QRect((x-y)/2,flag_1+40,100,20),Qt::AlignLeft,"GM 4.2"); painter.drawText(QRect((x-y)/2,flag_1+60,100,20),Qt::AlignLeft," 0.0"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+20,100,20),Qt::AlignLeft,"IEOS"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+40,100,20),Qt::AlignLeft,"RΘ"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+60,100,20),Qt::AlignLeft,"DGFT"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+80,100,20),Qt::AlignLeft,"LOAL"); painter.drawText(QRect((x-y)/2+(y*60/580),y-(y*120/580.0)+60*(y/580.0),100,20),Qt::AlignLeft,"MRM"); painter.drawText(QRect((x-y)/2+(y*60/580),y-(y*120/580.0)+80*(y/580.0),100,20),Qt::AlignLeft,"T:40"); painter.drawText(QRect((x-y)/2+(y*60/580),y-(y*120/580.0)+100*(y/580.0),100,20),Qt::AlignLeft,"2/4"); painter.drawText(QRect(x-(x-y)/2-100,flag_1-5,100,20),Qt::AlignRight,"00 0.0"); painter.drawText(QRect(x-(x-y)/2-100,flag_1+25,100,20),Qt::AlignRight,"Time=0.00"); painter.drawText(QRect(x-(x-y)/2-100,flag_1+40,100,20),Qt::AlignRight,"1500.0 Kg"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+20,100,20),Qt::AlignRight,"0.0"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+40,100,20),Qt::AlignRight," 0R"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+60,100,20),Qt::AlignRight,"+0"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+80,100,20),Qt::AlignRight,"IRM"); painter.drawLine(x/2-1,flag_2,x/2-1,flag_2+flag_3); painter.drawLine(x/2-1-(temp_x*54/1920)/2,(flag_2+flag_3)-flag_3*2/11,x/2-1+(temp_x*54/1920)/2,(flag_2+flag_3)-flag_3*2/11); int flag_r = (temp_x*54/1920*23/54); painter.drawArc((x/2-1)-flag_r/2,(flag_2+flag_3)-flag_3*2/11-flag_r/2,flag_r,flag_r,0,16*360); float line_temp = y*30/1080.0; float line_temp_1 = y*3/1080.0; float line_y = flag_1+80; float line_x = (x-y)/2+50; int line_temp_2 = temp_temp+100; float line_y_1 = (float)(line_y+line_temp_1*(line_temp_2%10)); for(int i = 1;i<=200;i++) { if(line_temp_2%50 ==0) { painter.drawLine(line_x,line_y_1,line_x-x*30/1920.0,line_y_1); painter.drawText(QRect(line_x-105-x*30/1920.0,line_y_1-10,100,20),Qt::AlignRight,QString::number(line_temp_2/10,10)); line_y_1=line_y_1+line_temp; } else { painter.drawLine(line_x,line_y_1,line_x-x*19/1920.0,line_y_1); if(line_temp_2%10 ==0) { line_y_1=line_y_1+line_temp; } } line_temp_2--; } painter.setBrush(Qt::black); painter.drawRect(line_x-55-x*30/1920.0,(line_y+line_temp*10),50,20); painter.drawText(QRect(line_x-105-x*30/1920.0,(line_y+line_temp*10),100,20),Qt::AlignRight,QString::number(temp_temp,10)); line_temp = y*30/1080.0; line_temp_1 = y*3/1080.0; line_y = flag_1+80; line_x = x-(x-y)/2-50; int line_temp_3 = temp_temp_1+100; line_y_1 = (float)(line_y+line_temp_1*(line_temp_3%10)); for(int j = 1;j<=200;j++) { if(line_temp_3%50 ==0) { painter.drawLine(line_x,line_y_1,line_x+x*30/1920.0,line_y_1); painter.drawText(QRect(line_x-70+x*30/1920.0,line_y_1-10,100,20),Qt::AlignRight,QString::number(line_temp_3/100.0,10.0,1)); line_y_1=line_y_1+line_temp; } else { painter.drawLine(line_x,line_y_1,line_x+x*19/1920.0,line_y_1); if(line_temp_3%10 ==0) { line_y_1=line_y_1+line_temp; } } line_temp_3--; } painter.setBrush(Qt::black); painter.drawRect(line_x+3+x*30/1920.0,(line_y+line_temp*10),50,20); painter.drawLine(line_x-70*(y/800.0)+x*30/1920.0,(line_y+line_temp*10)+10,line_x-20*(y/800.0)+x*30/1920.0,(line_y+line_temp*10)+10); painter.drawText(QRect(line_x+3+x*30/1920.0,(line_y+line_temp*10),50,20),Qt::AlignLeft,QString::number(temp_temp_1,10)); painter.drawText(QRect(line_x-90*(y/800.0)+x*30/1920.0,(line_y+line_temp*10)-10,50,20),Qt::AlignRight,"+0.0"); painter.drawText(QRect(line_x-90*(y/800.0)+x*30/1920.0,(line_y+line_temp*10)+10,50,20),Qt::AlignRight,"'H"); float line_temp_H = y*134/1080.0; float line_H_x = x-(x-y)/2.0-line_temp_H*2*(int(temp_temp_2*10)%10/10.0); float lint_temp_d = y*20/1080; float line_H_y = flag_1-10; for(int k =1;k<=7;k++) { if(k%2!=0) { painter.drawLine(line_H_x,line_H_y,line_H_x,line_H_y-lint_temp_d); painter.drawText(QRect(line_H_x-25,(line_H_y-lint_temp_d-20),50,20),Qt::AlignCenter,QString::number(temp_temp_2,10.0,1)); } else { painter.drawLine(line_H_x,line_H_y,line_H_x,line_H_y-lint_temp_d/2.0); } line_H_x = line_H_x-line_temp_H; } // painter.drawArc((x-y)/2,(y/2.0-40),80,80,180*16,16*270); painter.drawPixmap((x-y)/2+112*(y/1080.0),y/2,112*(y/1080.0),124*(y/1080.0),pixmap1); painter.drawPixmap((x-y)/2+217*(y/1080.0),y-58*(y/1080.0),434*(y/1080.0),38*(y/1080.0),pixmap2); painter.translate((x/2-1),(y/2)); painter.rotate(angle); painter.save(); painter.drawLine(-220,0,-30,0); painter.drawLine(30,0,220,0); painter.drawLine(-180*(y/800.0),-150*(y/580.0),-30*(y/800.0),-150*(y/580.0)); painter.drawLine(-180*(y/800.0),-150*(y/580.0),-180*(y/800.0),-150*(y/580.0)+20); painter.drawText(QRect(-230*(y/800.0),-150*(y/580.0),50,20),Qt::AlignCenter,"05"); painter.drawLine(30*(y/800.0),-150*(y/580.0),180*(y/800.0),-150*(y/580.0)); painter.drawLine(180*(y/800.0),-150*(y/580.0),180*(y/800.0),-150*(y/580.0)+20); painter.drawText(QRect(180*(y/800.0),-150*(y/580.0),50,20),Qt::AlignCenter,"05"); painter.drawLine(-180*(y/800.0),-300*(y/580.0),-30*(y/800.0),-300*(y/580.0)); painter.drawLine(-180*(y/800.0),-300*(y/580.0),-180*(y/800.0),-300*(y/580.0)+20); painter.drawText(QRect(-230*(y/800.0),-300*(y/580.0),50,20),Qt::AlignCenter,"10"); painter.drawLine(30*(y/800.0),-300*(y/580.0),180*(y/800.0),-300*(y/580.0)); painter.drawLine(180*(y/800.0),-300*(y/580.0),180*(y/800.0),-300*(y/580.0)+20); painter.drawText(QRect(180*(y/800.0),-300*(y/580.0),50,20),Qt::AlignCenter,"10"); // painter.setPen(QPen(Qt::green,2.0,Qt::DotLine)); painter.drawLine(-180*(y/800.0),150*(y/580.0),-30*(y/800.0),150*(y/580.0)); painter.drawLine(-180*(y/800.0),150*(y/580.0),-180*(y/800.0),150*(y/580.0)-20); painter.drawText(QRect(-230*(y/800.0),150*(y/580.0),50,20),Qt::AlignCenter,"-05"); painter.drawLine(30*(y/800.0),150*(y/580.0),180*(y/800.0),150*(y/580.0)); painter.drawLine(180*(y/800.0),150*(y/580.0),180*(y/800.0),150*(y/580.0)-20); painter.drawText(QRect(180*(y/800.0),150*(y/580.0),50,20),Qt::AlignCenter,"-05"); painter.drawLine(-180*(y/800.0),300*(y/580.0),-30*(y/800.0),300*(y/580.0)); painter.drawLine(-180*(y/800.0),300*(y/580.0),-180*(y/800.0),300*(y/580.0)-20); painter.drawText(QRect(-230*(y/800.0),300*(y/580.0),50,20),Qt::AlignCenter,"-10"); painter.drawLine(30*(y/800.0),300*(y/580.0),180*(y/800.0),300*(y/580.0)); painter.drawLine(180*(y/800.0),300*(y/580.0),180*(y/800.0),300*(y/580.0)-20); painter.drawText(QRect(180*(y/800.0),300*(y/580.0),50,20),Qt::AlignCenter,"-10"); painter.restore(); } else { y = x*3/4; int temp_x = x; int flag_1 = y*175/1080; int flag_2 = flag_1+40; int flag_3 = y*110/1080; painter.drawText(QRect((x-y)/2,flag_1,100,20),Qt::AlignLeft,"A 0.2"); painter.drawText(QRect((x-y)/2,flag_1+20,100,20),Qt::AlignLeft,"G 5.00"); painter.drawText(QRect((x-y)/2,flag_1+40,100,20),Qt::AlignLeft,"GM 4.2"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+20,100,20),Qt::AlignLeft,"IEOS"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+40,100,20),Qt::AlignLeft,"RΘ"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+60,100,20),Qt::AlignLeft,"DGFT"); painter.drawText(QRect((x-y)/2,y-(y*120/580.0)+80,100,20),Qt::AlignLeft,"LOAL"); painter.drawText(QRect((x-y)/2+(y*60/580),y-(y*120/580.0)+60*(y/580.0),100,20),Qt::AlignLeft,"MRM"); painter.drawText(QRect((x-y)/2+(y*60/580),y-(y*120/580.0)+80*(y/580.0),100,20),Qt::AlignLeft,"T:40"); painter.drawText(QRect((x-y)/2+(y*60/580),y-(y*120/580.0)+100*(y/580.0),100,20),Qt::AlignLeft,"2/4"); painter.drawText(QRect(x-(x-y)/2-100,flag_1-5,100,20),Qt::AlignRight,"00 0.0"); painter.drawText(QRect(x-(x-y)/2-100,flag_1+25,100,20),Qt::AlignRight,"Time=0.00"); painter.drawText(QRect(x-(x-y)/2-100,flag_1+40,100,20),Qt::AlignRight,"1500.0 Kg"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+20,100,20),Qt::AlignRight,"0.0"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+40,100,20),Qt::AlignRight," 0R"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+60,100,20),Qt::AlignRight,"+0"); painter.drawText(QRect(x-(x-y)/2-100,y-(y*120/580.0)+80,100,20),Qt::AlignRight,"IRM"); painter.drawLine(x/2-1,flag_2,x/2-1,flag_2+flag_3); painter.drawLine(x/2-1-(temp_x*54/1920)/2,(flag_2+flag_3)-flag_3*2/11,x/2-1+(temp_x*54/1920)/2,(flag_2+flag_3)-flag_3*2/11); int flag_r = (temp_x*54/1920*23/54); painter.drawArc((x/2-1)-flag_r/2,(flag_2+flag_3)-flag_3*2/11-flag_r/2,flag_r,flag_r,0,16*360); float line_temp = y*30/1080.0; float line_temp_1 = y*3/1080.0; float line_y = flag_1+80; float line_x = (x-y)/2+50; int line_temp_2 = temp_temp+100; float line_y_1 = (float)(line_y+line_temp_1*(line_temp_2%10)); for(int i = 1;i<=200;i++) { if(line_temp_2%50 ==0) { painter.drawLine(line_x,line_y_1,line_x-x*30/1920.0,line_y_1); painter.drawText(QRect(line_x-105-x*30/1920.0,line_y_1-10,100,20),Qt::AlignRight,QString::number(line_temp_2/10,10)); line_y_1=line_y_1+line_temp; } else { painter.drawLine(line_x,line_y_1,line_x-x*19/1920.0,line_y_1); if(line_temp_2%10 ==0) { line_y_1=line_y_1+line_temp; } } line_temp_2--; } painter.setBrush(Qt::black); painter.drawRect(line_x-55-x*30/1920.0,(line_y+line_temp*10),50,20); painter.drawText(QRect(line_x-105-x*30/1920.0,(line_y+line_temp*10),100,20),Qt::AlignRight,QString::number(temp_temp,10)); line_temp = y*30/1080.0; line_temp_1 = y*3/1080.0; line_y = flag_1+80; line_x = x-(x-y)/2-50; int line_temp_3 = temp_temp_1+100; line_y_1 = (float)(line_y+line_temp_1*(line_temp_3%10)); for(int j = 1;j<=200;j++) { if(line_temp_3%50 ==0) { painter.drawLine(line_x,line_y_1,line_x+x*30/1920.0,line_y_1); painter.drawText(QRect(line_x-70+x*30/1920.0,line_y_1-10,100,20),Qt::AlignRight,QString::number(line_temp_3/10,10)); line_y_1=line_y_1+line_temp; } else { painter.drawLine(line_x,line_y_1,line_x+x*19/1920.0,line_y_1); if(line_temp_3%10 ==0) { line_y_1=line_y_1+line_temp; } } line_temp_3--; } painter.setBrush(Qt::black); painter.drawRect(line_x+3+x*30/1920.0,(line_y+line_temp*10),50,20); painter.drawText(QRect(line_x+3+x*30/1920.0,(line_y+line_temp*10),50,20),Qt::AlignLeft,QString::number(temp_temp_1,10)); float line_temp_H = y*134/1080.0; float line_H_x = x-(x-y)/2.0-line_temp_H*2*(int(temp_temp_2*10)%10/10.0); float lint_temp_d = y*20/1080; float line_H_y = flag_1-10; for(int k =1;k<=7;k++) { if(k%2!=0) { painter.drawLine(line_H_x,line_H_y,line_H_x,line_H_y-lint_temp_d); painter.drawText(QRect(line_H_x-25,(line_H_y-lint_temp_d-20),50,20),Qt::AlignCenter,QString::number(temp_temp_2,10.0,1)); } else { painter.drawLine(line_H_x,line_H_y,line_H_x,line_H_y-lint_temp_d/2.0); } line_H_x = line_H_x-line_temp_H; } painter.drawPixmap((x-y)/2+112*(y/1080.0),y/2,112*(y/1080.0),124*(y/1080.0),pixmap1); painter.drawPixmap((x-y)/2+217*(y/1080.0),y-58*(y/1080.0),434*(y/1080.0),38*(y/1080.0),pixmap2); painter.translate((x/2-1),(y/2)); painter.rotate(angle); painter.save(); painter.drawLine(-220,0,-30,0); painter.drawLine(30,0,220,0); painter.drawLine(-180*(y/800.0),-150*(y/580.0),-30*(y/800.0),-150*(y/580.0)); painter.drawLine(-180*(y/800.0),-150*(y/580.0),-180*(y/800.0),-150*(y/580.0)+20); painter.drawText(QRect(-230*(y/800.0),-150*(y/580.0),50,20),Qt::AlignCenter,"05"); painter.drawLine(30*(y/800.0),-150*(y/580.0),180*(y/800.0),-150*(y/580.0)); painter.drawLine(180*(y/800.0),-150*(y/580.0),180*(y/800.0),-150*(y/580.0)+20); painter.drawText(QRect(180*(y/800.0),-150*(y/580.0),50,20),Qt::AlignCenter,"05"); painter.drawLine(-180*(y/800.0),-300*(y/580.0),-30*(y/800.0),-300*(y/580.0)); painter.drawLine(-180*(y/800.0),-300*(y/580.0),-180*(y/800.0),-300*(y/580.0)+20); painter.drawText(QRect(-230*(y/800.0),-300*(y/580.0),50,20),Qt::AlignCenter,"10"); painter.drawLine(30*(y/800.0),-300*(y/580.0),180*(y/800.0),-300*(y/580.0)); painter.drawLine(180*(y/800.0),-300*(y/580.0),180*(y/800.0),-300*(y/580.0)+20); painter.drawText(QRect(180*(y/800.0),-300*(y/580.0),50,20),Qt::AlignCenter,"10"); // painter.setPen(QPen(Qt::green,2.0,Qt::DotLine)); painter.drawLine(-180*(y/800.0),150*(y/580.0),-30*(y/800.0),150*(y/580.0)); painter.drawLine(-180*(y/800.0),150*(y/580.0),-180*(y/800.0),150*(y/580.0)-20); painter.drawText(QRect(-230*(y/800.0),150*(y/580.0),50,20),Qt::AlignCenter,"-05"); painter.drawLine(30*(y/800.0),150*(y/580.0),180*(y/800.0),150*(y/580.0)); painter.drawLine(180*(y/800.0),150*(y/580.0),180*(y/800.0),150*(y/580.0)-20); painter.drawText(QRect(180*(y/800.0),150*(y/580.0),50,20),Qt::AlignCenter,"-05"); painter.drawLine(-180*(y/800.0),300*(y/580.0),-30*(y/800.0),300*(y/580.0)); painter.drawLine(-180*(y/800.0),300*(y/580.0),-180*(y/800.0),300*(y/580.0)-20); painter.drawText(QRect(-230*(y/800.0),300*(y/580.0),50,20),Qt::AlignCenter,"-10"); painter.drawLine(30*(y/800.0),300*(y/580.0),180*(y/800.0),300*(y/580.0)); painter.drawLine(180*(y/800.0),300*(y/580.0),180*(y/800.0),300*(y/580.0)-20); painter.drawText(QRect(180*(y/800.0),300*(y/580.0),50,20),Qt::AlignCenter,"-10"); painter.restore(); } } void MainWindow::on_action_HUD_G_triggered() { about_d->show(); }