2024-02-06 06:19:53 +00:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
|
QMainWindow(parent),
|
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
this->showMaximized();
|
|
|
|
|
iniViewModel();
|
|
|
|
|
qRegisterMetaType<QVector<int> >("QVector<int>");//对自定义类型注册
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
|
|
|
|
if(m_autoPrintLoadThread.isRunning() == true)
|
|
|
|
|
{
|
|
|
|
|
while(m_autoPrintLoadThread.isRunning())
|
|
|
|
|
{
|
|
|
|
|
m_breakAutoLoadThread = 1;//暂停、取消线程的运行
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_drawingSetDlg != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_drawingSetDlg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_plotterSetDlg!= NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_plotterSetDlg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_historyDlg != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_historyDlg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_printViewWi != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_printViewWi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_pTimer != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_pTimer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_printInfoDlg != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_printInfoDlg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_preView != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_preView;
|
|
|
|
|
m_preView = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < g_machineList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
g_machineList[i]->m_mcPrintInfo.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *e)
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Do you want to exit the program?"),//是否退出程序?
|
|
|
|
|
QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok)
|
|
|
|
|
{
|
|
|
|
|
e->accept();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e->ignore();
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::reflushPreview(int row)
|
|
|
|
|
{
|
|
|
|
|
if(row < 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(row >= g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size())
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
m_preView->cleanView();
|
|
|
|
|
m_tabelViewModelFile->removeRows(0,m_tabelViewModelFile->rowCount());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(row < 0)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_selectBlockNum = 0;//上次查看的文件的块数选择置为0
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_curBlockRow = -1;
|
|
|
|
|
ui->tableView_fileList->selectRow(row);
|
|
|
|
|
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_creatBmpFlag != 1)
|
|
|
|
|
{
|
|
|
|
|
ui->tableView_fileList->setEnabled(false);
|
|
|
|
|
ui->tableView_Connection->setEnabled(false);
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
int penWidth = m_pSettings->value("DrawSet/linewidth").toInt();
|
2024-03-22 07:58:53 +00:00
|
|
|
|
int paperWidth = m_pSettings->value("DrawSet/paperwidth").toInt();
|
|
|
|
|
int butSpace = m_pSettings->value("DrawSet/buttmargin").toInt();
|
|
|
|
|
int rightSpace = m_pSettings->value("DrawSet/rightmargin").toInt();
|
2024-03-08 08:33:05 +00:00
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
//生成绘制图
|
2024-03-22 07:58:53 +00:00
|
|
|
|
CreatPictureStr picStr;
|
|
|
|
|
picStr = creatFilePicture(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row],paperWidth,butSpace,rightSpace,penWidth);
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_showPic = picStr.showPic;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_sendPic = picStr.sendPic;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
2024-03-22 07:58:53 +00:00
|
|
|
|
int num = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_sendPic.width() / PIXMAPWIDTH;
|
|
|
|
|
int lwidth = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_sendPic.width() % PIXMAPWIDTH;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
if(lwidth != 0)
|
|
|
|
|
{
|
|
|
|
|
num +=1;
|
|
|
|
|
}
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_totalBlocks = num;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_leaveBlockNum = num;//剩余打印块数
|
|
|
|
|
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_creatBmpFlag = 1;
|
|
|
|
|
ui->tableView_fileList->setEnabled(true);
|
|
|
|
|
ui->tableView_Connection->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//刷新图形
|
|
|
|
|
m_preView->cleanView();
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QPicture pic = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row].m_showPic;
|
|
|
|
|
m_preView->swithViewByPic(pic);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_curFilesInfo = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[row];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::reflushMcFileInfo()
|
|
|
|
|
{
|
|
|
|
|
ui->label_fileTotalVal->setText(QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileNums));
|
|
|
|
|
ui->label_fileTotalLenthVal->setText(QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileTotalLength)+"mm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::changeRowData(int move)
|
|
|
|
|
{
|
|
|
|
|
int row = m_curFileRow;
|
|
|
|
|
if(NULL == m_tabelViewModelFile || row < 0 || row > m_tabelViewModelFile->rowCount()-1)
|
|
|
|
|
{
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//判断是否正在打印,如果正在打印时不可移动
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow].m_curPrintBlock != 0)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Printing this file, it cannot be moved!"),//正在打印此文件,不可移动!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
if(move == 1)
|
|
|
|
|
{
|
|
|
|
|
//下移需要判断最后一行,不移动
|
|
|
|
|
if(row == m_tabelViewModelFile->rowCount()-1)
|
|
|
|
|
{
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(move == -1)
|
|
|
|
|
{
|
|
|
|
|
//上移需要判断是否第一行,不移动
|
|
|
|
|
if(row == 0)
|
|
|
|
|
{
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_machineList[m_curMcIdx]->moveFilePrintDat(m_curFileRow,move);
|
|
|
|
|
QList<QStandardItem *> listItem = m_tabelViewModelFile->takeRow(row);
|
|
|
|
|
m_curFileRow = row + move;
|
|
|
|
|
m_tabelViewModelFile->insertRow(m_curFileRow,listItem);
|
|
|
|
|
ui->tableView_fileList->selectRow(m_curFileRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::deleteDir(QString path)
|
|
|
|
|
{
|
|
|
|
|
if (path.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QDir dir(path);
|
|
|
|
|
if(!dir.exists())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); //设置过滤
|
|
|
|
|
QFileInfoList fileList = dir.entryInfoList(); // 获取所有的文件信息
|
|
|
|
|
foreach (QFileInfo file, fileList)
|
|
|
|
|
{
|
|
|
|
|
//遍历文件信息
|
|
|
|
|
if (file.isFile())
|
|
|
|
|
{
|
|
|
|
|
// 是文件,删除
|
|
|
|
|
file.dir().remove(file.fileName());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 递归删除
|
|
|
|
|
deleteDir(file.absoluteFilePath());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dir.rmdir(dir.absolutePath()); // 删除文件夹
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::startCreatBmpAndSend(int mcIdx)
|
|
|
|
|
{
|
|
|
|
|
int mcBegIdx, mcEndIdx;
|
|
|
|
|
mcBegIdx = mcEndIdx = 0;
|
|
|
|
|
|
|
|
|
|
//自动打印时mcIdx为-1
|
|
|
|
|
//mcIdx = -1;
|
|
|
|
|
|
|
|
|
|
if(mcIdx == -1)
|
|
|
|
|
{
|
|
|
|
|
mcBegIdx = 0;
|
|
|
|
|
mcEndIdx = g_machineList.size();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mcBegIdx = mcIdx;
|
|
|
|
|
mcEndIdx = mcIdx + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = mcBegIdx; i < mcEndIdx; i++)
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//全部启动的情况下,全部暂停时m_workState = WORK_PAUSE时返回
|
|
|
|
|
if(m_workState == WORK_PAUSE && mcIdx == -1)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//生成bmp块
|
|
|
|
|
QDir printDir(m_printPath);//总的打印目录
|
|
|
|
|
if(!printDir.exists())
|
|
|
|
|
{
|
|
|
|
|
printDir.mkdir(m_printPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString mcFile = m_printPath + printDir.separator() + PRINTMCDIR + QString::number(g_machineList[i]->m_mcPrintInfo.m_mcNum);
|
|
|
|
|
QDir mcDir(mcFile);//对应每台机器打印目录
|
|
|
|
|
if(!mcDir.exists())
|
|
|
|
|
{
|
|
|
|
|
mcDir.mkdir(mcFile);
|
|
|
|
|
}
|
|
|
|
|
g_machineList[i]->creatPrintDat(m_curFileRow);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
|
|
|
|
|
if(m_curFileRow > 0)
|
|
|
|
|
{
|
|
|
|
|
QString strPro = QString::number(0,'f',2)+"%";
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(i,CONN_COLUMN_MCPROGRESS),strPro);
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
|
|
|
|
|
if(m_curFileRow > 0)
|
|
|
|
|
{
|
|
|
|
|
ui->progressBar_print->setValue(0);
|
|
|
|
|
ui->progressBar_print->setFormat(QString("%1%").arg(QString::number(0,'f',2)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if(m_curMcIdx >= 0)
|
|
|
|
|
// {
|
|
|
|
|
// ui->tableView_fileList->selectRow(0);
|
|
|
|
|
// reflushPreview(0);
|
|
|
|
|
// }
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
void MainWindow::stopPrint(int mcIdx)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
int mcBegIdx, mcEndIdx;
|
|
|
|
|
mcBegIdx = mcEndIdx = 0;
|
|
|
|
|
|
|
|
|
|
//自动打印时mcIdx为-1
|
|
|
|
|
//mcIdx = -1;
|
|
|
|
|
|
|
|
|
|
if(mcIdx == -1)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
mcBegIdx = 0;
|
|
|
|
|
mcEndIdx = g_machineList.size();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
else
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
mcBegIdx = mcIdx;
|
|
|
|
|
mcEndIdx = mcIdx + 1;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
for(int i = mcBegIdx; i < mcEndIdx; i++)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
g_machineList[i]->stopPrint();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(mcIdx >= 0)
|
|
|
|
|
{
|
|
|
|
|
if(mcIdx < g_machineList.size())
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
g_machineList[mcIdx]->m_mcPrintInfo.m_mcWorkState = NotBusy;
|
|
|
|
|
QString str = tr("Idle");//空闲中
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(mcIdx,CONN_COLUMN_MCWORKSTATE),str);
|
|
|
|
|
}
|
|
|
|
|
if(m_curFileRow >= 0 && mcIdx < g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
if(m_curFileRow < g_machineList[mcIdx]->m_mcPrintInfo.m_filesList.size())
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
g_machineList[mcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow].m_printState = Pause;
|
|
|
|
|
QString str = tr("Pause print");//暂停打印
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(m_curFileRow,COLUMN_STATE),str);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
CreatPictureStr MainWindow::creatFilePicture(McFilesInfo & mcFileInfo,int paperWidth,int butSpace,int rightSpace,s16 penWidth)
|
2024-03-08 08:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
//将图片画在picture上
|
2024-03-22 07:58:53 +00:00
|
|
|
|
CreatPictureStr picStr;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(mcFileInfo.m_fileType == TYPE_IMAGE)
|
|
|
|
|
{
|
2024-03-22 07:58:53 +00:00
|
|
|
|
picStr = creatPictureByBmp(mcFileInfo.m_pixmap,paperWidth,butSpace,rightSpace,penWidth);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-22 07:58:53 +00:00
|
|
|
|
picStr = creatPictureByData(mcFileInfo.m_marker,paperWidth,butSpace,rightSpace,penWidth);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
return picStr;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refConnectUi()
|
|
|
|
|
{
|
|
|
|
|
for(int i = 0; i < g_machineList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
refConnectUi(g_machineList[i], g_machineList[i]->m_mcPrintInfo.m_mcConnState, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//刷新连接状态
|
|
|
|
|
void MainWindow::refConnectUi(Machine *pMachine, int &linkSta, int idx)
|
|
|
|
|
{
|
|
|
|
|
if (pMachine != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (linkSta != pMachine->isConnected() ||
|
|
|
|
|
pMachine->isConnected() == Connectting)
|
|
|
|
|
{
|
|
|
|
|
linkSta = pMachine->isConnected();//获取连接状态
|
|
|
|
|
QString strConn;
|
|
|
|
|
if (linkSta == Connectting)//连接中...
|
|
|
|
|
{
|
|
|
|
|
strConn = tr("Connnecting...");//连接中...
|
|
|
|
|
}
|
|
|
|
|
else if (linkSta == Connected)//已连接
|
|
|
|
|
{
|
|
|
|
|
strConn = tr("Connected");//已连接
|
|
|
|
|
}
|
|
|
|
|
else//未连接
|
|
|
|
|
{
|
|
|
|
|
strConn = tr("NotConnected");//未连接
|
|
|
|
|
}
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(idx, CONN_COLUMN_MCCONSTATE),strConn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshMcListShow()
|
|
|
|
|
{
|
|
|
|
|
if(g_machineList.size() <= 0)
|
|
|
|
|
{
|
|
|
|
|
ui->menuFile_F->setEnabled(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0; i < g_machineList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
int row = m_tabelViewModelConn->rowCount();//当前表格的行数
|
|
|
|
|
m_tabelViewModelConn->insertRow(row);//在最后一行的后面插入一行
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row, CONN_COLUMN_MCNAME),g_machineList[i]->m_mcPrintInfo.m_mcName);
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCIP),g_machineList[i]->m_mcPrintInfo.m_ip);
|
|
|
|
|
|
|
|
|
|
QString strConn = tr("NotConnected");//未连接
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCCONSTATE),strConn);
|
|
|
|
|
|
|
|
|
|
QString str;
|
|
|
|
|
if(g_machineList[i]->m_mcPrintInfo.m_mcWorkState == NotBusy)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Idle");//空闲中
|
|
|
|
|
}
|
|
|
|
|
else if(g_machineList[i]->m_mcPrintInfo.m_mcWorkState == Busying)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Working");//工作中
|
|
|
|
|
}
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCWORKSTATE),str);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString strPro = QString::number(g_machineList[i]->m_mcPrintInfo.m_mcSendProgress,'f',2)+"%";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCPROGRESS),strPro);
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
connect(g_machineList[i], SIGNAL(siOneFilePrintFinished(int,int,int)),
|
|
|
|
|
this, SLOT(slotDeleteFileFromList(int,int,int)), Qt::AutoConnection); // 完成一个文件的打印
|
|
|
|
|
connect(g_machineList[i], SIGNAL(siRefreshPrintProgress(int,int)),
|
|
|
|
|
this, SLOT(slotRefreshPrintProgress(int,int)), Qt::AutoConnection); // 刷新打印进度
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
// m_curMcIdx = 0;
|
|
|
|
|
// ui->tableView_Connection->selectRow(m_curMcIdx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshOneMcShow(int row,int idx)
|
|
|
|
|
{
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row, CONN_COLUMN_MCNAME),g_machineList[idx]->m_mcPrintInfo.m_mcName);
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCIP),g_machineList[idx]->m_mcPrintInfo.m_ip);
|
|
|
|
|
|
|
|
|
|
QString strConn = tr("NotConnected");//未连接
|
|
|
|
|
if(g_machineList[idx]->m_mcPrintInfo.m_mcWorkState == Connectting)
|
|
|
|
|
{
|
|
|
|
|
strConn = tr("Connnecting...");//连接中...
|
|
|
|
|
}
|
|
|
|
|
else if(g_machineList[idx]->m_mcPrintInfo.m_mcWorkState == Connected)
|
|
|
|
|
{
|
|
|
|
|
strConn = tr("Connected");//已连接
|
|
|
|
|
}
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCCONSTATE),strConn);
|
|
|
|
|
|
|
|
|
|
QString str;
|
|
|
|
|
if(g_machineList[idx]->m_mcPrintInfo.m_mcWorkState == NotBusy)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Idle");//空闲中
|
|
|
|
|
}
|
|
|
|
|
else if(g_machineList[idx]->m_mcPrintInfo.m_mcWorkState == Busying)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Working");//工作中
|
|
|
|
|
}
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCWORKSTATE),str);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString strPro = QString::number(g_machineList[idx]->m_mcPrintInfo.m_mcSendProgress,'f',2)+"%";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(row,CONN_COLUMN_MCPROGRESS),strPro);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MainWindow::refreshMcFileListShow(int idx)
|
|
|
|
|
{
|
|
|
|
|
if(m_autoPrintLoadThread.isRunning() == true)
|
|
|
|
|
{
|
|
|
|
|
m_breakAutoLoadThread = 1;//暂停、取消线程的运行
|
|
|
|
|
while(m_autoPrintLoadThread.isRunning() == true)
|
|
|
|
|
{
|
|
|
|
|
//等待线程结束
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_curMcIdx = idx;
|
|
|
|
|
m_tabelViewModelFile->removeRows(0,m_tabelViewModelFile->rowCount());
|
|
|
|
|
m_preView->cleanView();
|
|
|
|
|
|
|
|
|
|
QString iniName = "MachineNo" + QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcNum) + ".ini";
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
|
|
|
|
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
|
|
|
|
QString dirPath = setting.value("AutoPrintDir/fileDir").toString();
|
|
|
|
|
QDir dir(dirPath);
|
|
|
|
|
//存在自动绘图目录或上次未打印完成文件时首次点击先加载文件
|
|
|
|
|
if(dir.exists() && dirPath.length() != 0 && g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag < 0)
|
|
|
|
|
{
|
|
|
|
|
//并发线程的使用,为了避免同时加载窗体和加载文件时的窗体卡顿
|
|
|
|
|
m_autoPrintLoadThread = QtConcurrent::run(this,this->slotLoadAutoPrintFiles);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag = 1;
|
|
|
|
|
QList<McFilesInfo> filesList = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList;
|
|
|
|
|
int size = filesList.size();
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < size; i++)
|
|
|
|
|
{
|
|
|
|
|
m_tabelViewModelFile->insertRow(i);//在最后一行的后面插入一行
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_FILENAME),filesList[i].m_fileName);
|
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QRectF rect = filesList[i].m_fileRect;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_LENGTH),length);
|
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_WIDTH),width);
|
|
|
|
|
|
|
|
|
|
QString start = QString::number(filesList[i].m_startPoint)+"mm";
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_START),start);
|
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_PRINTEDLENGTH),"0mm");
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
double val = 0;
|
|
|
|
|
if(filesList[i].m_totalBlocks != 0)
|
|
|
|
|
{
|
|
|
|
|
val = (double)filesList[i].m_printedBlockNum / (double)filesList[i].m_totalBlocks;
|
|
|
|
|
}
|
|
|
|
|
QString progress = QString::number(val,'f',2)+"%";
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_PRINTPROGRESS),progress);
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
QString number = QString::number(filesList[i].m_printNum);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_NUMBERS),number);
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString str;
|
|
|
|
|
if(filesList[i].m_printState == Waitting)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Waitting");//未打印
|
|
|
|
|
}
|
|
|
|
|
else if(filesList[i].m_printState == Printting)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Printting");//打印中
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_STATE),str);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(i,COLUMN_FILEPATH),filesList[i].m_filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reflushMcFileInfo();
|
|
|
|
|
qDebug()<<"reflushMcFileInfo();";
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_curFileRow < 0)
|
|
|
|
|
{
|
|
|
|
|
m_curFileRow = 0;
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
ui->tableView_fileList->selectRow(m_curFileRow);//选中
|
|
|
|
|
reflushPreview(m_curFileRow);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::loadAutoPrintDirFiles()
|
|
|
|
|
{
|
|
|
|
|
//并发线程的使用,为了避免同时加载窗体和加载文件时的窗体卡顿
|
|
|
|
|
m_autoPrintLoadThread = QtConcurrent::run(this,this->slotLoadAutoPrintFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化所有窗体
|
|
|
|
|
void MainWindow::initAllWinForm()
|
|
|
|
|
{
|
|
|
|
|
refreshMcListShow();
|
|
|
|
|
|
|
|
|
|
m_curMcIdx = -1;
|
|
|
|
|
m_curFileRow = -1;
|
|
|
|
|
m_curPrintFileIdx = -1;
|
|
|
|
|
m_curBlockRow = -1;
|
|
|
|
|
m_preView = NULL;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_rotateAngle = 0;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_workState = WORK_PAUSE;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_printMode = NOAUTOPRINT;
|
|
|
|
|
m_breakAutoLoadThread = 0;
|
|
|
|
|
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
m_printPath = apppath.path() + apppath.separator() + "print";
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString configfile;
|
|
|
|
|
configfile = apppath.path() + apppath.separator() + "config.ini";
|
|
|
|
|
m_pSettings = new QSettings(configfile,QSettings::IniFormat);
|
|
|
|
|
bool rotate90 = m_pSettings->value("DrawSet/rotate90").toBool();//是否正向旋转90度
|
|
|
|
|
if(rotate90 == true)
|
|
|
|
|
{
|
|
|
|
|
//90度为逆时针旋转,270度为顺时针旋转
|
|
|
|
|
m_rotateAngle = 270;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_preView = new MyGraphicsView();
|
|
|
|
|
ui->verticalLayout_drawing->addWidget(m_preView);
|
|
|
|
|
|
|
|
|
|
m_drawingSetDlg= new DrawingSetDialog();
|
|
|
|
|
m_plotterSetDlg = new PlotterSetDialog();
|
|
|
|
|
m_historyDlg = new HistoryDialog();
|
|
|
|
|
m_printViewWi = new PrintViewWindow(this);
|
|
|
|
|
connect(m_printViewWi,SIGNAL(siAddNewFile(int)),this,SLOT(slotAddNewFileToList(int)));
|
|
|
|
|
|
|
|
|
|
m_printInfoDlg = new PrintInfoDialog();
|
|
|
|
|
|
|
|
|
|
//定时器
|
|
|
|
|
m_pTimer = new QTimer(this);
|
|
|
|
|
m_pTimer->setInterval(1000); // 设置定时间隔1秒
|
|
|
|
|
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(onOneSecondTimer()));
|
|
|
|
|
m_pTimer->start();
|
|
|
|
|
|
|
|
|
|
m_drawingSetDlg->hide();
|
|
|
|
|
m_plotterSetDlg->hide();
|
|
|
|
|
m_historyDlg->hide();
|
|
|
|
|
m_printViewWi->hide();
|
|
|
|
|
m_printInfoDlg->hide();
|
|
|
|
|
|
|
|
|
|
//删除位图文件夹
|
|
|
|
|
deleteDir(m_printPath);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
refreshBtnEnable();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::iniViewModel()
|
|
|
|
|
{
|
|
|
|
|
//QTabelView
|
|
|
|
|
m_tabelViewModelFile = new QStandardItemModel(0, COLUMN_NUM, ui->tableView_fileList);
|
|
|
|
|
QStringList header; //QString类型的List容器
|
|
|
|
|
header<<tr("FileName")<<tr("Length")<<tr("Width")
|
2024-03-08 08:33:05 +00:00
|
|
|
|
<<tr("StartPoint")<<tr("Printed")<<tr("Progress")<<tr("Numbers")<<tr("State")<<tr("FilePath");//设置内容是文件名、长度、宽度、起始打印点、已打印长度、打印进度、份数、状态、文件路径
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setHorizontalHeaderLabels(header);
|
|
|
|
|
ui->tableView_fileList->setModel(m_tabelViewModelFile);
|
|
|
|
|
ui->tableView_fileList->setSelectionBehavior(QAbstractItemView::SelectRows);//单击选择一行
|
|
|
|
|
ui->tableView_fileList->setEditTriggers(QAbstractItemView::NoEditTriggers);//每行不可编辑
|
|
|
|
|
ui->tableView_fileList->setSelectionMode(QAbstractItemView::SingleSelection);//只能选择一行
|
|
|
|
|
ui->tableView_fileList->setColumnWidth(0,COLUMN_COLWIDTH+100);//设置列宽
|
|
|
|
|
for(int i = 1; i < COLUMN_NUM-1; i++)
|
|
|
|
|
{
|
|
|
|
|
ui->tableView_fileList->setColumnWidth(i,COLUMN_COLWIDTH);//设置列宽
|
|
|
|
|
}
|
|
|
|
|
ui->tableView_fileList->setColumnWidth(COLUMN_NUM-1,COLUMN_COLWIDTH+200);//设置列宽
|
|
|
|
|
ui->tableView_fileList->horizontalHeader()->setHighlightSections(false);//设置表头字体不变粗
|
|
|
|
|
//ui->tableView_fileList->horizontalHeader()->setStyleSheet("border-bottom-width: 0.5px;border-style: outset;border-color: rgb(229,229,229);");//表头和第一行之间加分割线
|
|
|
|
|
|
|
|
|
|
ui->tableView_fileList->setContextMenuPolicy(Qt::CustomContextMenu);//设置右击菜单
|
|
|
|
|
connect(ui->tableView_fileList,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(slotFileListMenu(QPoint)));
|
|
|
|
|
|
|
|
|
|
//建立数据模型对象空间并指定父对象
|
|
|
|
|
m_tabelViewModelConn = new QStandardItemModel(0, CONN_COLUMN_NUM, ui->tableView_Connection);
|
|
|
|
|
QStringList headerConn; //QString类型的List容器
|
|
|
|
|
headerConn<<tr("McName")<<tr("McIp")<<tr("McConState")<<tr("McState")<<tr("McProgress");//设置内容是机器名称、机器IP、机器连接状态、机器工作状态、机器发送进度
|
|
|
|
|
m_tabelViewModelConn->setHorizontalHeaderLabels(headerConn);
|
|
|
|
|
ui->tableView_Connection->setModel(m_tabelViewModelConn);
|
|
|
|
|
ui->tableView_Connection->setSelectionBehavior(QAbstractItemView::SelectRows);//单击选择一行
|
|
|
|
|
ui->tableView_Connection->setEditTriggers(QAbstractItemView::NoEditTriggers);//每行不可编辑
|
|
|
|
|
ui->tableView_Connection->setSelectionMode(QAbstractItemView::SingleSelection);//只能选择一行
|
|
|
|
|
for(int i = 0; i < CONN_COLUMN_NUM; i++)
|
|
|
|
|
{
|
|
|
|
|
ui->tableView_Connection->setColumnWidth(i,CONN_COLUMN_COLWIDTH);//设置列宽
|
|
|
|
|
}
|
|
|
|
|
ui->tableView_Connection->horizontalHeader()->setHighlightSections(false);//设置表头字体不变粗
|
|
|
|
|
ui->tableView_Connection->setContextMenuPolicy(Qt::CustomContextMenu);//设置右击菜单
|
|
|
|
|
connect(ui->tableView_Connection,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(slotMcListMenu(QPoint)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotAddNewFileToList(int newFlag)
|
|
|
|
|
{
|
|
|
|
|
if(newFlag == 0)//非新文件
|
|
|
|
|
{
|
|
|
|
|
int start = m_printViewWi->getStartPoint();
|
|
|
|
|
int number = m_printViewWi->getPrintNumber();
|
|
|
|
|
|
|
|
|
|
int oldStart = m_tabelViewModelFile->item(m_curFileRow,COLUMN_START)->text().remove("mm").toInt();
|
|
|
|
|
int oldNumber = m_tabelViewModelFile->item(m_curFileRow,COLUMN_NUMBERS)->text().toInt();
|
|
|
|
|
|
|
|
|
|
if(start != oldStart)
|
|
|
|
|
{
|
|
|
|
|
m_tabelViewModelFile->item(m_curFileRow,COLUMN_START)->setText(QString::number(start)+"mm");
|
|
|
|
|
}
|
|
|
|
|
if(number != oldNumber)
|
|
|
|
|
{
|
|
|
|
|
m_tabelViewModelFile->item(m_curFileRow,COLUMN_NUMBERS)->setText(QString::number(number));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_curFilesInfo.m_printNum = number;
|
|
|
|
|
m_curFilesInfo.m_startPoint = start;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow] = m_curFilesInfo;
|
|
|
|
|
}
|
|
|
|
|
else //新文件
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
s16 state = Waitting;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
int row = m_tabelViewModelFile->rowCount();//当前表格的行数
|
|
|
|
|
m_tabelViewModelFile->insertRow(row);//在最后一行的后面插入一行
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_FILENAME),m_curFilesInfo.m_fileName);
|
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QRectF rect = m_curFilesInfo.m_fileRect;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_LENGTH),length);
|
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_WIDTH),width);
|
|
|
|
|
|
|
|
|
|
QString start = QString::number(m_printViewWi->getStartPoint())+"mm";
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_START),start);
|
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_PRINTEDLENGTH),"0mm");
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
double val = 0;
|
|
|
|
|
if(m_curFilesInfo.m_totalBlocks != 0)
|
|
|
|
|
{
|
|
|
|
|
val = (double)m_curFilesInfo.m_printedBlockNum / (double)m_curFilesInfo.m_totalBlocks;
|
|
|
|
|
}
|
|
|
|
|
QString progress = QString::number(val,'f',2)+"%";
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_PRINTPROGRESS),progress);
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
QString number = QString::number(m_printViewWi->getPrintNumber());
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_NUMBERS),number);
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString str;
|
|
|
|
|
if(state == Waitting)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
str = tr("Waitting");//未打印
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
else if(state == Printting)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
str = tr("Printting");//打印中
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_STATE),str);
|
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row,COLUMN_FILEPATH),m_curFilesInfo.m_filePath);
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_curFilesInfo.m_creatBmpFlag = 1;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
2024-03-22 07:58:53 +00:00
|
|
|
|
int num = m_curFilesInfo.m_sendPic.width() / PIXMAPWIDTH;
|
|
|
|
|
int lwidth = m_curFilesInfo.m_sendPic.width() % PIXMAPWIDTH;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
if(lwidth != 0)
|
|
|
|
|
{
|
|
|
|
|
num +=1;
|
|
|
|
|
}
|
|
|
|
|
m_curFilesInfo.m_totalBlocks = num;
|
|
|
|
|
m_curFilesInfo.m_curPrintBlock = 0;//当前打印块数
|
|
|
|
|
m_curFilesInfo.m_printedBlockNum = 0;//已打印块数
|
|
|
|
|
m_curFilesInfo.m_leaveBlockNum = num;//剩余打印块数
|
|
|
|
|
m_curFilesInfo.m_selectBlockNum = 0;//当前选择块数
|
|
|
|
|
|
|
|
|
|
m_curFilesInfo.m_printNum = number.toInt();
|
|
|
|
|
m_curFilesInfo.m_startPoint = m_printViewWi->getStartPoint();
|
|
|
|
|
m_curFilesInfo.m_printState = state;
|
|
|
|
|
|
|
|
|
|
McPrintInfo McF;
|
|
|
|
|
McF.m_fileNums = row+1;
|
2024-03-22 07:58:53 +00:00
|
|
|
|
McF.m_fileTotalLength = (m_curFilesInfo.m_fileRect.right() - m_curFilesInfo.m_fileRect.left())/MMPIXELY;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
McF.m_filesList.append(m_curFilesInfo);
|
|
|
|
|
m_curFileRow = row;
|
|
|
|
|
|
|
|
|
|
ui->tableView_fileList->selectRow(row);//选中
|
2024-03-08 08:33:05 +00:00
|
|
|
|
ui->frame_fileBtn->setEnabled(true);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
if(g_machineList.size() <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
//g_machineList.append(McF);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileNums = row+1;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileTotalLength += McF.m_fileTotalLength;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.append(m_curFilesInfo);
|
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
reflushPreview(row);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
reflushMcFileInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotFileListMenu(QPoint pos)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex index = ui->tableView_fileList->indexAt(pos);
|
|
|
|
|
int row = index.row();
|
|
|
|
|
|
|
|
|
|
if(row < 0){return;}
|
|
|
|
|
|
|
|
|
|
QMenu* menu = new QMenu(this);//创建菜单
|
|
|
|
|
QAction* action1 = new QAction(tr("Print preview"), this);//打印预览
|
|
|
|
|
QAction* action2 = new QAction(tr("Number of modified print"), this);//修改打印份数
|
|
|
|
|
QAction* action3 = new QAction(tr("Modify the starting print point"), this);//修改起始打印点
|
|
|
|
|
QAction* action4 = new QAction(tr("View print information"), this);//查看打印信息
|
|
|
|
|
QAction* action5 = new QAction(tr("Delete"), this);//删除
|
|
|
|
|
|
|
|
|
|
connect (action1,SIGNAL(triggered()),this,SLOT(slotPrintPreview()));
|
|
|
|
|
connect (action2,SIGNAL(triggered()),this,SLOT(slotPrintNumberSetDlgShow()));
|
|
|
|
|
connect (action3,SIGNAL(triggered()),this,SLOT(slotStartSetDlgShow()));
|
|
|
|
|
connect (action4,SIGNAL(triggered()),this,SLOT(slotViewPrintInfo()));
|
|
|
|
|
connect (action5,SIGNAL(triggered()),this,SLOT(slotDeleteFile()));
|
|
|
|
|
|
|
|
|
|
menu->addAction(action1);//将action放入菜单中
|
|
|
|
|
menu->addAction(action2);//将action放入菜单中
|
|
|
|
|
menu->addAction(action3);//将action放入菜单中
|
|
|
|
|
menu->addAction(action4);//将action放入菜单中
|
|
|
|
|
menu->addAction(action5);//将action放入菜单中
|
|
|
|
|
menu->popup(ui->tableView_fileList->viewport()->mapToGlobal(pos));//将菜单显示到鼠标所在位置
|
|
|
|
|
|
|
|
|
|
if(m_curFileRow != row)
|
|
|
|
|
{
|
|
|
|
|
reflushPreview(row);
|
|
|
|
|
}
|
|
|
|
|
m_curFileRow = row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotMcListMenu(QPoint pos)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex index = ui->tableView_Connection->indexAt(pos);
|
|
|
|
|
int row = index.row();
|
|
|
|
|
|
|
|
|
|
if(row < 0){return;}
|
|
|
|
|
|
|
|
|
|
QMenu* menu = new QMenu(this);//创建菜单
|
|
|
|
|
QAction* action1 = new QAction(tr("Delete"), this);//删除
|
|
|
|
|
connect (action1,SIGNAL(triggered()),this,SLOT(slotDeleteMc()));
|
|
|
|
|
|
|
|
|
|
menu->addAction(action1);//将action放入菜单中
|
|
|
|
|
menu->popup(ui->tableView_Connection->viewport()->mapToGlobal(pos));//将菜单显示到鼠标所在位置
|
|
|
|
|
|
|
|
|
|
if(m_curMcIdx != row)
|
|
|
|
|
{
|
|
|
|
|
refreshMcFileListShow(row);
|
|
|
|
|
ui->tableView_Connection->selectRow(m_curMcIdx);
|
|
|
|
|
m_curMcIdx = row;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotPrintPreview()
|
|
|
|
|
{
|
2024-03-22 07:58:53 +00:00
|
|
|
|
int penWidth = m_pSettings->value("DrawSet/linewidth").toInt();
|
|
|
|
|
int paperWidth = m_pSettings->value("DrawSet/paperwidth").toInt();
|
|
|
|
|
int butSpace = m_pSettings->value("DrawSet/buttmargin").toInt();
|
|
|
|
|
int rightSpace = m_pSettings->value("DrawSet/rightmargin").toInt();
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_curFilesInfo = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow];
|
2024-03-22 07:58:53 +00:00
|
|
|
|
m_printViewWi->refreshShow(m_curFilesInfo,paperWidth,butSpace,rightSpace,penWidth,0);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotPrintNumberSetDlgShow()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = m_curFilesInfo.m_fileName;
|
|
|
|
|
QString printNumber= QString::number(m_curFilesInfo.m_printNum);
|
|
|
|
|
PrintNumberSetDialog numberSetDlg;
|
|
|
|
|
if(numberSetDlg.exec(fileName,printNumber) == 1)
|
|
|
|
|
{
|
|
|
|
|
int number = numberSetDlg.getPrintNumber();
|
|
|
|
|
m_curFilesInfo.m_printNum = number;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow] = m_curFilesInfo;
|
|
|
|
|
m_tabelViewModelFile->item(m_curFileRow,COLUMN_NUMBERS)->setText(QString::number(number));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotStartSetDlgShow()
|
|
|
|
|
{
|
|
|
|
|
QString fileName = m_curFilesInfo.m_fileName;
|
|
|
|
|
QString startPoint= QString::number(m_curFilesInfo.m_startPoint);
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString length= QString::number((int)((m_curFilesInfo.m_fileRect.right()-m_curFilesInfo.m_fileRect.left())/MMPIXELY));
|
2024-02-06 06:19:53 +00:00
|
|
|
|
StartSetDialog startSetDlg;
|
|
|
|
|
if(startSetDlg.exec(fileName,startPoint,length) == 1)
|
|
|
|
|
{
|
|
|
|
|
int startPoint = startSetDlg.getStartPoint();
|
|
|
|
|
m_curFilesInfo.m_startPoint = startPoint;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow] = m_curFilesInfo;
|
|
|
|
|
m_tabelViewModelFile->item(m_curFileRow,COLUMN_START)->setText(QString::number(startPoint)+"mm");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotViewPrintInfo()
|
|
|
|
|
{
|
|
|
|
|
if(m_printInfoDlg != NULL)
|
|
|
|
|
{
|
|
|
|
|
m_printInfoDlg->setFilesInfo(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotDeleteFile()
|
|
|
|
|
{
|
|
|
|
|
if(m_curMcIdx < 0 || m_curMcIdx >= g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_curFileRow < 0 || m_curFileRow >= g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//判断是否正在打印,如果正在打印时不可删除
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow].m_curPrintBlock != 0 &&
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcWorkState == Busying)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Printing this file, it cannot be deleted!"),//正在打印此文件,不可删除!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
if(QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Do you want to delete this drawing?"),//是否删除该项绘图?
|
|
|
|
|
QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok)
|
|
|
|
|
{
|
|
|
|
|
g_machineList[m_curMcIdx]->deleteFilePrintDat(m_curFileRow);
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_tabelViewModelFile->removeRow(m_curFileRow);
|
|
|
|
|
m_preView->cleanView();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
reflushMcFileInfo();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_curFileRow >= g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
m_curFileRow -= 1;
|
|
|
|
|
}
|
|
|
|
|
ui->tableView_fileList->selectRow(m_curFileRow);
|
|
|
|
|
reflushPreview(m_curFileRow);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotDeleteMc()
|
|
|
|
|
{
|
|
|
|
|
if(QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("After deletion, the machine cannot be controlled. Do you want to delete this machine?"),//删除后将不能控制机器,是否删除此机器?
|
|
|
|
|
QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok)
|
|
|
|
|
{
|
|
|
|
|
if(m_curMcIdx < 0 || m_curMcIdx >= g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//要删除的机器为正在加载文件的机器
|
|
|
|
|
if(m_autoPrintLoadThread.isRunning() == true
|
|
|
|
|
&& g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag != 1)
|
|
|
|
|
{
|
|
|
|
|
m_breakAutoLoadThread = 1; //暂停、取消线程的运行
|
|
|
|
|
while(m_autoPrintLoadThread.isRunning() == true)
|
|
|
|
|
{
|
|
|
|
|
//等待线程停止
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//清除机器数据
|
|
|
|
|
for(int i = 0; i < g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].clear();
|
|
|
|
|
}
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.clear();
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.clear();
|
|
|
|
|
|
|
|
|
|
g_machineList.removeAt(m_curMcIdx);//从列表中删除
|
|
|
|
|
m_tabelViewModelConn->removeRow(m_curMcIdx);
|
|
|
|
|
m_tabelViewModelFile->removeRows(0,m_tabelViewModelFile->rowCount());
|
|
|
|
|
m_preView->cleanView();
|
|
|
|
|
ui->tableView_Connection->clearSelection();
|
|
|
|
|
ui->label_fileTotalVal->setText("");
|
|
|
|
|
ui->label_fileTotalLenthVal->setText("");
|
|
|
|
|
|
|
|
|
|
//删除该机器的配置文件
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
QString str = "MachineNo" + QString::number(m_curMcIdx+1);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_pSettings->remove(str);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_curMcIdx = -1;
|
|
|
|
|
QString iniFilePath = apppath.path() + apppath.separator() + str + ".ini";
|
|
|
|
|
QFile::remove(iniFilePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotLoadAutoPrintFiles()
|
|
|
|
|
{
|
|
|
|
|
QString iniName = "MachineNo" + QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcNum) + ".ini";
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
|
|
|
|
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
|
|
|
|
QString dirPath = setting.value("AutoPrintDir/fileDir").toString();
|
|
|
|
|
QDir dir(dirPath);
|
|
|
|
|
if(!dir.exists())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString state = tr("Waitting");
|
|
|
|
|
QString number = "1";
|
|
|
|
|
QString start = "0mm";
|
|
|
|
|
|
|
|
|
|
QStringList filter;
|
|
|
|
|
filter << QString("*.plt") << QString("*.PLT")
|
|
|
|
|
<< QString("*.png") << QString("*.PNG")
|
|
|
|
|
<< QString("*.bmp") << QString("*.BMP")
|
|
|
|
|
<< QString("*.jpg") << QString("*.JPG");
|
|
|
|
|
QFileInfoList fileList = dir.entryInfoList(filter, QDir::Files | QDir::NoSymLinks);
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < fileList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
if(m_breakAutoLoadThread == 1)
|
|
|
|
|
{
|
|
|
|
|
m_breakAutoLoadThread = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QCoreApplication::processEvents(QEventLoop::AllEvents);
|
|
|
|
|
|
|
|
|
|
QFileInfo fileInfo(fileList[i]);
|
|
|
|
|
QString filePath = fileInfo.filePath();
|
|
|
|
|
|
|
|
|
|
int row = m_tabelViewModelFile->rowCount();//当前表格的行数
|
|
|
|
|
m_tabelViewModelFile->insertRow(row);//在最后一行的后面插入一行
|
|
|
|
|
|
|
|
|
|
if(i < g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_creatDataFlag == 1)
|
|
|
|
|
{
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILENAME),g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileName);
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QRectF rect = g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_fileRect;
|
|
|
|
|
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_LENGTH),length);
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_WIDTH),width);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_START),start);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_PRINTEDLENGTH),"0mm");
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_PRINTPROGRESS),"0.00%");
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_NUMBERS),number);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_STATE),state);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILEPATH),g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].m_filePath);
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
McFilesInfo curFilesInfo;//当前文件信息
|
2024-03-08 08:33:05 +00:00
|
|
|
|
creatMarkerDat(curFilesInfo,m_printPath,filePath,-1,m_rotateAngle);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILENAME),curFilesInfo.m_fileName);
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QRectF rect = curFilesInfo.m_fileRect;
|
|
|
|
|
QString length = QString::number((int)((rect.right() - rect.left())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_LENGTH),length);
|
2024-03-22 07:58:53 +00:00
|
|
|
|
QString width = QString::number((int)((rect.bottom() - rect.top())/MMPIXELY))+"mm";
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_WIDTH),width);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_START),start);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_PRINTEDLENGTH),"0mm");
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_PRINTPROGRESS),"0.00%");
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_NUMBERS),number);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_STATE),state);
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(row, COLUMN_FILEPATH),curFilesInfo.m_filePath);
|
|
|
|
|
|
2024-03-22 07:58:53 +00:00
|
|
|
|
long long fileTotalLength = (curFilesInfo.m_fileRect.right() - curFilesInfo.m_fileRect.left())/MMPIXELY;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileNums = i+1;
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileTotalLength += fileTotalLength;
|
|
|
|
|
ui->label_fileTotalVal->setText(QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileNums));
|
|
|
|
|
ui->label_fileTotalLenthVal->setText(QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileTotalLength)+"mm");
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.append(curFilesInfo);
|
|
|
|
|
}
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//1秒定时器
|
|
|
|
|
void MainWindow::onOneSecondTimer()
|
|
|
|
|
{
|
|
|
|
|
refConnectUi();//刷新连接
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
void MainWindow::slotDeleteFileFromList(int mcNum, int fileIdx, int refreshFlag)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//是否自动打印
|
|
|
|
|
int autoPrint = 0;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//刷新进度
|
|
|
|
|
if(refreshFlag != 0)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
slotRefreshPrintProgress(mcNum,fileIdx);
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
for(int i = 0; i < g_machineList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
if(mcNum == g_machineList[i]->m_mcPrintInfo.m_mcNum)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(fileIdx >= g_machineList[i]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
qDebug()<<"slotDeleteFileFromList return"<<fileIdx<<g_machineList[i]->m_mcPrintInfo.m_filesList.size();
|
|
|
|
|
//return;
|
|
|
|
|
}
|
|
|
|
|
if(i == m_curMcIdx)//当前删除文件的操作正为所选机器的预览显示
|
|
|
|
|
{
|
|
|
|
|
//从列表中删除一行
|
|
|
|
|
m_tabelViewModelFile->removeRow(fileIdx);
|
|
|
|
|
m_preView->cleanView();
|
|
|
|
|
g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].clear();
|
|
|
|
|
g_machineList[i]->m_mcPrintInfo.m_filesList.removeAt(fileIdx);//删除机器文件列表中已打印完成的文件
|
|
|
|
|
|
|
|
|
|
//自动打印模式且打印起始文件为最后一个时,打印完此文件不再打印
|
|
|
|
|
if(autoPrint == 1 && m_curFileRow == g_machineList[i]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
m_curFileRow = -1;
|
|
|
|
|
}
|
|
|
|
|
else if(m_curFileRow == g_machineList[i]->m_mcPrintInfo.m_filesList.size())//跳到上一个
|
|
|
|
|
{
|
|
|
|
|
m_curFileRow -= 1;
|
|
|
|
|
reflushPreview(m_curFileRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(g_machineList[i]->m_mcPrintInfo.m_filesList.size() <= 0)
|
|
|
|
|
{
|
|
|
|
|
m_curFileRow = -1;
|
|
|
|
|
}
|
|
|
|
|
reflushPreview(m_curFileRow);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//都不选中
|
|
|
|
|
if(m_curFileRow == -1)
|
|
|
|
|
{
|
|
|
|
|
ui->tableView_fileList->clearSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_curFileRow >= 0 && autoPrint == 1)
|
|
|
|
|
{
|
|
|
|
|
g_machineList[i]->creatPrintDat(m_curFileRow,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotRefreshPrintProgress(int mcNum, int fileIdx)
|
|
|
|
|
{
|
|
|
|
|
for(int i = 0; i < g_machineList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
QString str;
|
|
|
|
|
if(g_machineList[i]->m_mcPrintInfo.m_mcWorkState == NotBusy)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
str = tr("Idle");//空闲中
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
else if(g_machineList[i]->m_mcPrintInfo.m_mcWorkState == Busying)
|
|
|
|
|
{
|
|
|
|
|
str = tr("Working");//工作中
|
|
|
|
|
}
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(i,CONN_COLUMN_MCWORKSTATE),str);
|
|
|
|
|
QString strPro = QString::number(g_machineList[i]->m_mcPrintInfo.m_mcSendProgress,'f',2)+"%";
|
|
|
|
|
m_tabelViewModelConn->setData(m_tabelViewModelConn->index(i,CONN_COLUMN_MCPROGRESS),strPro);
|
|
|
|
|
|
|
|
|
|
if(mcNum == g_machineList[i]->m_mcPrintInfo.m_mcNum)
|
|
|
|
|
{
|
|
|
|
|
if(fileIdx >= g_machineList[i]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(i == m_curMcIdx)//当前操作正为所选机器的预览显示
|
|
|
|
|
{
|
|
|
|
|
//刷新进度显示
|
|
|
|
|
double val = g_machineList[i]->m_mcPrintInfo.m_mcSendProgress;
|
|
|
|
|
ui->progressBar_print->setValue(round(val));
|
|
|
|
|
ui->progressBar_print->setFormat(QString("%1%").arg(QString::number(val,'f',2)));
|
|
|
|
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
if(m_curFileRow >= 0)
|
|
|
|
|
{
|
|
|
|
|
idx = m_curFileRow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = (double)g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_printedBlockNum / (double)g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_totalBlocks * 100.0;
|
|
|
|
|
QString progress = QString::number(val,'f',2)+"%";
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(idx,COLUMN_PRINTPROGRESS),progress);
|
|
|
|
|
|
|
|
|
|
int printLen = (g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_printedBlockNum*PIXMAPWIDTH)/MMPIXELY;
|
|
|
|
|
QString str = QString::number(printLen) + "mm";
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(idx, COLUMN_PRINTEDLENGTH),str);
|
|
|
|
|
|
|
|
|
|
QString stateStr;
|
|
|
|
|
if(g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_printState == Waitting)
|
|
|
|
|
{
|
|
|
|
|
stateStr = tr("Waitting");//未打印
|
|
|
|
|
}
|
|
|
|
|
else if(g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_printState == Printting)
|
|
|
|
|
{
|
|
|
|
|
stateStr = tr("Printting");//打印中
|
|
|
|
|
}
|
|
|
|
|
else if(g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_printState == Pause)
|
|
|
|
|
{
|
|
|
|
|
stateStr = tr("Pause print");//暂停打印
|
|
|
|
|
}
|
|
|
|
|
else if(g_machineList[i]->m_mcPrintInfo.m_filesList[fileIdx].m_printState == Complete)
|
|
|
|
|
{
|
|
|
|
|
stateStr = tr("Complete");//打印完成
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_tabelViewModelFile->setData(m_tabelViewModelFile->index(idx,COLUMN_STATE),stateStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshBtnEnable()
|
|
|
|
|
{
|
|
|
|
|
if(m_curMcIdx < 0)
|
|
|
|
|
{
|
|
|
|
|
ui->actionDeletMachine->setEnabled(false);
|
|
|
|
|
ui->actionOpen_File->setEnabled(false);
|
|
|
|
|
ui->actionOpen_Image->setEnabled(false);
|
|
|
|
|
ui->menuTesting->setEnabled(false);
|
|
|
|
|
ui->actionAuto_Print_Dir->setEnabled(false);
|
|
|
|
|
ui->actionlog->setEnabled(false);
|
|
|
|
|
ui->menuSetting_S->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
ui->toolBar->setEnabled(false);
|
|
|
|
|
ui->frame_fileBtn->setEnabled(false);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
ui->actionDeletMachine->setEnabled(true);
|
|
|
|
|
ui->actionOpen_File->setEnabled(true);
|
|
|
|
|
ui->actionOpen_Image->setEnabled(true);
|
|
|
|
|
ui->menuTesting->setEnabled(true);
|
|
|
|
|
ui->actionAuto_Print_Dir->setEnabled(true);
|
|
|
|
|
ui->actionlog->setEnabled(true);
|
|
|
|
|
ui->menuSetting_S->setEnabled(true);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
ui->toolBar->setEnabled(true);
|
|
|
|
|
ui->frame_fileBtn->setEnabled(true);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_curFileRow < 0)
|
|
|
|
|
{
|
|
|
|
|
ui->frame_fileBtn->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui->frame_fileBtn->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::switchLanguage(s16 languageType)
|
|
|
|
|
{
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
m_pSettings->setValue("HMI/language",languageType);
|
|
|
|
|
|
|
|
|
|
QString languagePath;
|
|
|
|
|
switch (languageType)
|
|
|
|
|
{
|
|
|
|
|
case chinese://中文
|
|
|
|
|
languagePath = apppath.path() + apppath.separator() + "chinese.qm";
|
|
|
|
|
break;
|
|
|
|
|
case english://英文
|
|
|
|
|
languagePath = apppath.path() + apppath.separator() + "english.qm";
|
|
|
|
|
break;
|
|
|
|
|
default://中文
|
|
|
|
|
languagePath = apppath.path() + apppath.separator() + "chinese.qm";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//刷新翻译显示
|
|
|
|
|
g_pTranslator->load(languagePath);
|
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
m_drawingSetDlg->refreshLanguage();
|
|
|
|
|
m_plotterSetDlg->refreshLanguage();
|
|
|
|
|
m_historyDlg->refreshLanguage();
|
|
|
|
|
m_printViewWi->refreshLanguage();
|
|
|
|
|
m_printInfoDlg->refreshLanguage();
|
|
|
|
|
|
|
|
|
|
//重新设置一下tableview的头显示,否则翻译不会更新
|
|
|
|
|
QStringList header; //QString类型的List容器
|
|
|
|
|
header<<tr("FileName")<<tr("Length")<<tr("Width")
|
|
|
|
|
<<tr("StartPoint")<<tr("Printed")<<tr("Progress")<<tr("Numbers")<<tr("State")<<tr("FilePath");//设置内容是文件名、长度、宽度、起始打印点、已打印长度、打印进度、份数、状态、文件路径
|
|
|
|
|
m_tabelViewModelFile->setHorizontalHeaderLabels(header);
|
|
|
|
|
|
|
|
|
|
QStringList headerConn; //QString类型的List容器
|
|
|
|
|
headerConn<<tr("McName")<<tr("McIp")<<tr("McConState")<<tr("McState")<<tr("McProgress");//设置内容是机器名称、机器IP、机器连接状态、机器工作状态、机器发送进度
|
|
|
|
|
m_tabelViewModelConn->setHorizontalHeaderLabels(headerConn);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionDrawing_Setting_triggered()
|
|
|
|
|
{
|
|
|
|
|
if(m_drawingSetDlg!= NULL)
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_drawingSetDlg->refreshConfigPara(m_pSettings->fileName());
|
|
|
|
|
if(m_drawingSetDlg->exec() == 1)
|
|
|
|
|
{
|
|
|
|
|
m_rotateAngle = m_drawingSetDlg->getRotateAngle();
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionPlotter_Setting_triggered()
|
|
|
|
|
{
|
|
|
|
|
if(m_plotterSetDlg != NULL)
|
|
|
|
|
{
|
|
|
|
|
m_plotterSetDlg->exec();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionlog_triggered()
|
|
|
|
|
{
|
|
|
|
|
if(m_historyDlg!= NULL)
|
|
|
|
|
{
|
|
|
|
|
m_historyDlg->exec();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpen_File_triggered()
|
|
|
|
|
{
|
|
|
|
|
if(m_curMcIdx < 0 || m_curMcIdx >= g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Please select a machine!"), //请选择机器!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag < 0)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Loading file, please wait!"), //正在加载文件,请等待!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString lastPath = m_pSettings->value("LastFilePath/filePath").toString(); //获取上次的打开路径
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
QString filePath;
|
|
|
|
|
|
|
|
|
|
filePath = QFileDialog::getOpenFileName(this,
|
|
|
|
|
tr("Open File Dialog"),//打开文件对话框
|
|
|
|
|
lastPath,
|
|
|
|
|
tr("File(*.plt *.dxf)"));//plt 文件
|
|
|
|
|
|
|
|
|
|
if (filePath.isNull() == 0)
|
|
|
|
|
{
|
|
|
|
|
QFileInfo fileInfo(filePath);
|
|
|
|
|
QString fileName = fileInfo.fileName();
|
|
|
|
|
QString path = filePath;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_pSettings->setValue("LastFilePath/filePath",path.remove(fileName)); //记录路径到QSetting中保存
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
#if(1)
|
|
|
|
|
creatMarkerDat(m_curFilesInfo,m_printPath,filePath,-1,m_rotateAngle);
|
|
|
|
|
#else
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_curFilesInfo.m_marker.Initialize();
|
|
|
|
|
if(fileInfo.suffix().toUpper() == "DXF")
|
|
|
|
|
{
|
|
|
|
|
DxfHelper dxfHelper;
|
|
|
|
|
if(dxfHelper.generateDxf(filePath))
|
|
|
|
|
{
|
|
|
|
|
dxfHelper.getDxfPaths(); // 获取转换出来的dxf所有类型图形的点集
|
|
|
|
|
QImage img = dxfHelper.generateDXFImage(); // 获取预览图像
|
|
|
|
|
img.save("D:\\1.png");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(fileInfo.suffix().toUpper() == "PLT")
|
|
|
|
|
{
|
|
|
|
|
ImportHPGL importHPGL;
|
|
|
|
|
//判断是否为加密文件
|
|
|
|
|
if (importHPGL.IsSecretFile(filePath) == true)
|
|
|
|
|
{
|
|
|
|
|
// 文件路径
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
QString strSecretFile = apppath.path() + apppath.separator() + "Secret.plt";
|
|
|
|
|
|
|
|
|
|
importHPGL.BitMapDtat(filePath,strSecretFile);
|
|
|
|
|
importHPGL.IniPara();
|
|
|
|
|
importHPGL.ReadSecretFile(strSecretFile,&m_curFilesInfo.m_marker);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
importHPGL.IniPara();
|
|
|
|
|
importHPGL.Read(filePath,&m_curFilesInfo.m_marker);
|
|
|
|
|
}
|
|
|
|
|
//importHPGL.creatPolylinePainterPath();
|
|
|
|
|
|
|
|
|
|
QFileInfo file(filePath);
|
|
|
|
|
m_curFilesInfo.m_filePath = filePath;
|
|
|
|
|
m_curFilesInfo.m_fileName = file.fileName();
|
|
|
|
|
m_curFilesInfo.m_fileType = TYPE_FILE;
|
|
|
|
|
m_curFilesInfo.m_fileRect = m_curFilesInfo.m_marker.GetRect();
|
|
|
|
|
//m_curFilesInfo.m_painterPath = importHPGL.GetPolylinePainterPath();
|
|
|
|
|
}
|
2024-03-08 08:33:05 +00:00
|
|
|
|
#endif
|
2024-03-22 07:58:53 +00:00
|
|
|
|
int penWidth = m_pSettings->value("DrawSet/linewidth").toInt();
|
|
|
|
|
int paperWidth = m_pSettings->value("DrawSet/paperwidth").toInt();
|
|
|
|
|
int butSpace = m_pSettings->value("DrawSet/buttmargin").toInt();
|
|
|
|
|
int rightSpace = m_pSettings->value("DrawSet/rightmargin").toInt();
|
|
|
|
|
m_printViewWi->refreshShow(m_curFilesInfo,paperWidth,butSpace,rightSpace,penWidth,1);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_tableView_fileList_clicked(const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
int row = index.row();
|
|
|
|
|
m_curFileRow = row;
|
|
|
|
|
reflushPreview(row);
|
|
|
|
|
|
|
|
|
|
//判断是否正在打印,如果正在打印时不可删除、移动、修改打印信息
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(row >= g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
ui->frame_fileBtn->setEnabled(true);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[m_curFileRow].m_curPrintBlock != 0
|
|
|
|
|
&& g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcWorkState == Busying)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
ui->frame_fileBtn->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcWorkState == Busying)
|
|
|
|
|
{
|
|
|
|
|
if((m_curFileRow+1) == m_curPrintFileIdx)
|
|
|
|
|
{
|
|
|
|
|
ui->pushButton_up->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_up_clicked()
|
|
|
|
|
{
|
|
|
|
|
changeRowData(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_down_clicked()
|
|
|
|
|
{
|
|
|
|
|
changeRowData(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_delete_clicked()
|
|
|
|
|
{
|
|
|
|
|
slotDeleteFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_preview_clicked()
|
|
|
|
|
{
|
|
|
|
|
slotPrintPreview();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpenFileIcon_triggered()
|
|
|
|
|
{
|
|
|
|
|
on_actionOpen_File_triggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpen_Image_triggered()
|
|
|
|
|
{
|
|
|
|
|
if(m_curMcIdx < 0 || m_curMcIdx >= g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Please select a machine!"), //请选择机器!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag < 0)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Loading file, please wait!"), //正在加载文件,请等待!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString lastPath = m_pSettings->value("LastFilePath/filePath").toString(); //获取上次的打开路径
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
QString filePath;
|
|
|
|
|
|
|
|
|
|
filePath = QFileDialog::getOpenFileName(this,
|
|
|
|
|
tr("Open File Dialog"),//打开文件对话框
|
|
|
|
|
lastPath,
|
|
|
|
|
tr("Image File(*.png *.bmp *.jpg)"));//图像文件
|
|
|
|
|
|
|
|
|
|
if (filePath.isNull() == 0)
|
|
|
|
|
{
|
|
|
|
|
QFileInfo fileInfo(filePath);
|
|
|
|
|
QString fileName = fileInfo.fileName();
|
|
|
|
|
QString path = filePath;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_pSettings->setValue("LastFilePath/filePath",path.remove(fileName)); //记录路径到QSetting中保存
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
m_curFilesInfo.m_marker.Initialize();
|
|
|
|
|
m_curFilesInfo.m_filePath = filePath;
|
|
|
|
|
m_curFilesInfo.m_fileName = fileName;
|
|
|
|
|
m_curFilesInfo.m_fileType = TYPE_IMAGE;
|
|
|
|
|
|
|
|
|
|
QBitmap pixmap;
|
|
|
|
|
pixmap.load(filePath);
|
|
|
|
|
QRect rect;
|
2024-03-22 07:58:53 +00:00
|
|
|
|
rect.setRect(0,0,pixmap.width()/MMPIXELY*MMPIXELY,pixmap.height()/MMPIXELY*MMPIXELY);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
m_curFilesInfo.m_pixmap = pixmap;
|
|
|
|
|
m_curFilesInfo.m_fileRect = rect;
|
2024-03-22 07:58:53 +00:00
|
|
|
|
int penWidth = m_pSettings->value("DrawSet/linewidth").toInt();
|
|
|
|
|
int paperWidth = m_pSettings->value("DrawSet/paperwidth").toInt();
|
|
|
|
|
int butSpace = m_pSettings->value("DrawSet/buttmargin").toInt();
|
|
|
|
|
int rightSpace = m_pSettings->value("DrawSet/rightmargin").toInt();
|
|
|
|
|
m_printViewWi->refreshShow(m_curFilesInfo,paperWidth,butSpace,rightSpace,penWidth,1);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionOpenImageIcon_triggered()
|
|
|
|
|
{
|
|
|
|
|
on_actionOpen_Image_triggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionAuto_Print_Dir_triggered()
|
|
|
|
|
{
|
|
|
|
|
if(m_curMcIdx < 0)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Please select the machine you want to set the directory!"),//请选择要设置目录的机器!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//以机器编号命名ini文件
|
|
|
|
|
QString iniName = "MachineNo" + QString::number(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcNum) + ".ini";
|
|
|
|
|
QDir apppath(qApp->applicationDirPath());
|
|
|
|
|
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
|
|
|
|
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
|
|
|
|
|
|
|
|
|
// 获取文件路径
|
|
|
|
|
QString fileDir = QFileDialog::getExistingDirectory(this, tr("Select Folder"));
|
|
|
|
|
if (!fileDir.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
setting.setValue("AutoPrintDir/fileDir",fileDir); //记录路径到QSetting中保存
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_loadFileFinishFlag = -1;
|
|
|
|
|
for(int i = 0; i < g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList[i].clear();
|
|
|
|
|
}
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_filesList.clear();
|
|
|
|
|
g_machineList[m_curMcIdx]->m_mcPrintInfo.m_fileTotalLength = 0;
|
|
|
|
|
refreshMcFileListShow(m_curMcIdx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//全部启动
|
2024-02-06 06:19:53 +00:00
|
|
|
|
void MainWindow::on_actionStart_triggered()
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_workState == WORK_START)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("Do you want to start printing on all machines?"),//是否启动所有机器打印?
|
|
|
|
|
QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok)
|
|
|
|
|
{
|
|
|
|
|
m_workState = WORK_START;
|
|
|
|
|
startCreatBmpAndSend(-1);
|
|
|
|
|
}
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//当前机器启动
|
2024-02-06 06:19:53 +00:00
|
|
|
|
void MainWindow::on_actionStartIcon_triggered()
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_curMcIdx >= g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcWorkState == Busying)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-06 06:19:53 +00:00
|
|
|
|
startCreatBmpAndSend(m_curMcIdx);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//全部暂停
|
2024-02-06 06:19:53 +00:00
|
|
|
|
void MainWindow::on_actionPause_triggered()
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_workState == WORK_PAUSE)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_workState = WORK_PAUSE;
|
|
|
|
|
ui->frame_fileBtn->setEnabled(true);
|
|
|
|
|
stopPrint(-1);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
//当前机器暂停
|
2024-02-06 06:19:53 +00:00
|
|
|
|
void MainWindow::on_actionPauseIcon_triggered()
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_curMcIdx >= g_machineList.size())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(g_machineList[m_curMcIdx]->m_mcPrintInfo.m_mcWorkState == NotBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stopPrint(m_curMcIdx);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionAddMachine_triggered()
|
|
|
|
|
{
|
|
|
|
|
AddMachineDialog addMcDlg;
|
|
|
|
|
if(addMcDlg.exec() == 1)
|
|
|
|
|
{
|
|
|
|
|
//读取配置文件是否存在同名的机器名称
|
|
|
|
|
QString mcName = addMcDlg.getMcName();
|
|
|
|
|
QString serverIp = addMcDlg.getMcIp();
|
|
|
|
|
quint16 serverPort = 5000;
|
|
|
|
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
for(int i = 1; i <= MACHINE_NUM; i++)
|
|
|
|
|
{
|
|
|
|
|
QString str = "MachineNo" + QString::number(i);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString keyStr = str + "/name";
|
|
|
|
|
bool bl = m_pSettings->contains(keyStr);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
if(bl == false)
|
|
|
|
|
{
|
|
|
|
|
QString strName = str + "/name";
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_pSettings->setValue(strName,mcName);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
QString strIp = str + "/ip";
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_pSettings->setValue(strIp,serverIp);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
QString strPort = str + "/port";
|
2024-03-08 08:33:05 +00:00
|
|
|
|
m_pSettings->setValue(strPort,serverPort);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
idx = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(idx == 0)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
|
tr("Prompt"),
|
|
|
|
|
tr("The maximum number of connections has been reached and cannot be added again!"),//已达到最大连接数量,不可再添加!
|
|
|
|
|
QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//本地IP和端口
|
2024-03-08 08:33:05 +00:00
|
|
|
|
QString localIp = m_pSettings->value("Local/ip").toString();
|
|
|
|
|
quint16 localPort = m_pSettings->value("Local/port").toInt();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
|
|
Machine *pMachine = new Machine(); //建立连接
|
|
|
|
|
pMachine->setIpAndPort(mcName,serverIp,serverPort,localIp,localPort);//设置IP和端口
|
|
|
|
|
pMachine->startCommunication();
|
|
|
|
|
McPrintInfo mcf;
|
|
|
|
|
mcf.m_mcNum = idx;
|
|
|
|
|
mcf.m_mcName = mcName;
|
|
|
|
|
mcf.m_ip = serverIp;
|
|
|
|
|
mcf.m_port = serverPort;
|
|
|
|
|
mcf.m_loadFileFinishFlag = 1;
|
|
|
|
|
pMachine->m_mcPrintInfo = mcf;
|
|
|
|
|
g_machineList.append(pMachine);
|
|
|
|
|
|
|
|
|
|
int row = m_tabelViewModelConn->rowCount();//当前表格的行数
|
|
|
|
|
m_tabelViewModelConn->insertRow(row);//在最后一行的后面插入一行
|
|
|
|
|
refreshMcFileListShow(row);
|
|
|
|
|
ui->tableView_Connection->selectRow(row);
|
|
|
|
|
refreshOneMcShow(row,g_machineList.size()-1);
|
|
|
|
|
if(!ui->menuFile_F->isEnabled())
|
|
|
|
|
{
|
|
|
|
|
if(g_machineList.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
ui->menuFile_F->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionDeletMachine_triggered()
|
|
|
|
|
{
|
|
|
|
|
slotDeleteMc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_tableView_Connection_clicked(const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
refreshMcFileListShow(index.row());
|
|
|
|
|
ui->tableView_Connection->selectRow(m_curMcIdx);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
|
|
|
|
|
double val = g_machineList[index.row()]->m_mcPrintInfo.m_mcSendProgress;
|
|
|
|
|
ui->progressBar_print->setValue(round(val));
|
|
|
|
|
ui->progressBar_print->setFormat(QString("%1%").arg(QString::number(val,'f',2)));
|
|
|
|
|
refreshBtnEnable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionChinese_triggered()
|
|
|
|
|
{
|
|
|
|
|
switchLanguage(chinese);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionEnglish_triggered()
|
|
|
|
|
{
|
|
|
|
|
switchLanguage(english);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|