2024-02-06 06:19:53 +00:00
|
|
|
#include "printviewwindow.h"
|
|
|
|
#include "ui_printviewwindow.h"
|
|
|
|
|
|
|
|
PrintViewWindow::PrintViewWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::PrintViewWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setWindowModality(Qt::ApplicationModal);
|
|
|
|
m_startPoint = 0;
|
|
|
|
m_printNumber = 0;
|
|
|
|
m_filePath.clear();
|
|
|
|
m_addNewFileFlag = 0;
|
|
|
|
m_view = NULL;
|
|
|
|
|
|
|
|
//整数
|
|
|
|
QIntValidator *Validator = new QIntValidator(this);
|
|
|
|
ui->lineEdit_start->setValidator(Validator);
|
|
|
|
ui->lineEdit_number->setValidator(Validator);
|
|
|
|
|
|
|
|
m_view = new MyGraphicsView();
|
|
|
|
connect(m_view,SIGNAL(siMouseMove(QPointF)),this,SLOT(slotShowPoint(QPointF)));
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintViewWindow::~PrintViewWindow()
|
|
|
|
{
|
|
|
|
if(m_view != NULL)
|
|
|
|
{
|
|
|
|
delete m_view;
|
|
|
|
m_view = NULL;
|
|
|
|
}
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
void PrintViewWindow::refreshLanguage()
|
|
|
|
{
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
void PrintViewWindow::refreshShow(McFilesInfo &mcFilesInfo,int paperWidth,int butSpace,int rightSpace,int penWidth,int flag)
|
2024-02-06 06:19:53 +00:00
|
|
|
{
|
|
|
|
m_startPoint = 0;
|
|
|
|
m_printNumber = 1;
|
|
|
|
m_addNewFileFlag = flag;
|
|
|
|
if(flag == 1)
|
|
|
|
{
|
|
|
|
ui->lineEdit_number->setText("1");
|
|
|
|
ui->lineEdit_start->setText("0");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->lineEdit_number->setText(QString::number(mcFilesInfo.m_printNum));
|
|
|
|
ui->lineEdit_start->setText(QString::number(mcFilesInfo.m_startPoint));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_filePath = mcFilesInfo.m_filePath;
|
|
|
|
|
|
|
|
m_view->cleanView();
|
2024-03-22 07:58:53 +00:00
|
|
|
CreatPictureStr picStr;
|
2024-02-06 06:19:53 +00:00
|
|
|
if(mcFilesInfo.m_fileType == TYPE_FILE)
|
|
|
|
{
|
2024-03-22 07:58:53 +00:00
|
|
|
picStr = m_view->getPictureByDat(mcFilesInfo.m_marker,paperWidth,butSpace,rightSpace,penWidth);
|
2024-02-06 06:19:53 +00:00
|
|
|
}
|
|
|
|
else if(mcFilesInfo.m_fileType == TYPE_IMAGE)
|
|
|
|
{
|
2024-03-22 07:58:53 +00:00
|
|
|
picStr = m_view->getPictureByBmp(mcFilesInfo.m_pixmap,paperWidth,butSpace,rightSpace,penWidth);
|
2024-02-06 06:19:53 +00:00
|
|
|
}
|
2024-03-22 07:58:53 +00:00
|
|
|
mcFilesInfo.m_showPic = picStr.showPic;
|
|
|
|
mcFilesInfo.m_sendPic = picStr.sendPic;
|
|
|
|
mcFilesInfo.m_fileRect = picStr.sendPic.boundingRect();
|
|
|
|
|
|
|
|
m_length = (mcFilesInfo.m_fileRect.right() - mcFilesInfo.m_fileRect.left())/MMPIXELY;
|
|
|
|
int width = (mcFilesInfo.m_fileRect.bottom() - mcFilesInfo.m_fileRect.top())/MMPIXELY;
|
|
|
|
this->setWindowTitle(m_filePath+"("+QString::number(m_length)+"mm"+" * " + QString::number(width) + "mm)");
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
//如果是最大化变为正常大小
|
|
|
|
if(this->windowState() == Qt::WindowMaximized)
|
|
|
|
{
|
|
|
|
this->setWindowState(Qt::WindowMinimized);
|
|
|
|
this->showNormal();
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->horizontalLayout_view->addWidget(m_view);
|
|
|
|
QMainWindow::show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintViewWindow::setStartLineText(QString str)
|
|
|
|
{
|
|
|
|
ui->lineEdit_start->setText(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintViewWindow::setNumberLineText(QString str)
|
|
|
|
{
|
|
|
|
ui->lineEdit_number->setText(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintViewWindow::slotShowPoint(QPointF point)
|
|
|
|
{
|
|
|
|
ui->lineEdit_x->setText(QString::number((int)point.x())+"mm");
|
|
|
|
ui->lineEdit_y->setText(QString::number((int)point.y())+"mm");
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintViewWindow::on_pushButton_draw_clicked()
|
|
|
|
{
|
|
|
|
m_startPoint = ui->lineEdit_start->text().toInt();
|
|
|
|
m_printNumber = ui->lineEdit_number->text().toInt();
|
|
|
|
|
|
|
|
if(m_printNumber > 255 || m_printNumber <= 0 || m_startPoint < 0 || m_startPoint >= m_length)
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
tr("Prompt"),
|
|
|
|
tr("Unreasonable value input!"),//数值输入不合理
|
|
|
|
QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
emit siAddNewFile(m_addNewFileFlag);
|
2024-02-06 06:19:53 +00:00
|
|
|
this->close();
|
|
|
|
}
|