20240308
1、梳理代码,修改绘制会绘制两次的bug; 2、增加正向旋转功能,线宽设置功能; 3、测试压缩算法,完成;
This commit is contained in:
parent
dadc1c2462
commit
3ce55cebbd
10
NPlotter.pro
10
NPlotter.pro
@ -68,10 +68,10 @@ SOURCES += \
|
|||||||
machine/bmp/bwbmp.cpp \
|
machine/bmp/bwbmp.cpp \
|
||||||
machine/bmp/creatprintbmp.cpp \
|
machine/bmp/creatprintbmp.cpp \
|
||||||
machine/tcp/qbindtcpsocket.cpp \
|
machine/tcp/qbindtcpsocket.cpp \
|
||||||
machine/tcp/tcpclient.cpp
|
machine/tcp/tcpclient.cpp \
|
||||||
|
datafile/view/drawdata.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwidget.ui \
|
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
printviewwindow.ui \
|
printviewwindow.ui \
|
||||||
printnumbersetdialog.ui \
|
printnumbersetdialog.ui \
|
||||||
@ -135,7 +135,11 @@ HEADERS += \
|
|||||||
machine/bmp/creatprintbmp.h \
|
machine/bmp/creatprintbmp.h \
|
||||||
machine/tcp/qbindtcpsocket.h \
|
machine/tcp/qbindtcpsocket.h \
|
||||||
machine/tcp/tcpclient.h \
|
machine/tcp/tcpclient.h \
|
||||||
machine/printinfo/mcfiles.h
|
machine/printinfo/mcfiles.h \
|
||||||
|
datafile/view/drawdata.h
|
||||||
|
|
||||||
|
TRANSLATIONS += chinese.ts\
|
||||||
|
english.ts
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
res.qrc
|
res.qrc
|
||||||
|
BIN
chinese.qm
Normal file
BIN
chinese.qm
Normal file
Binary file not shown.
1089
chinese.ts
Normal file
1089
chinese.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -119,6 +119,7 @@ void ImportHPGL::IniPara()
|
|||||||
|
|
||||||
m_pMarker=NULL;
|
m_pMarker=NULL;
|
||||||
m_dScale=(double)1.0;
|
m_dScale=(double)1.0;
|
||||||
|
m_rotateAngle = 0;
|
||||||
|
|
||||||
m_chTerminator = 3;
|
m_chTerminator = 3;
|
||||||
m_nTerminatorMode = 1;
|
m_nTerminatorMode = 1;
|
||||||
@ -242,7 +243,7 @@ void ImportHPGL::creatPolylinePainterPath()
|
|||||||
for(int j = 0; j < nPointCount; j++)
|
for(int j = 0; j < nPointCount; j++)
|
||||||
{
|
{
|
||||||
double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY;
|
double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY;
|
||||||
double y = ((0 - (polyLine.m_listPoint.at(j).y() - minY))+(maxY-minY))/(double)M_IDPMM*MMPIXELY;
|
double y = (maxY - polyLine.m_listPoint.at(j).y())/(double)M_IDPMM*MMPIXELY;
|
||||||
QPointF point(x,y);
|
QPointF point(x,y);
|
||||||
|
|
||||||
if(j == 0)
|
if(j == 0)
|
||||||
@ -629,6 +630,11 @@ bool ImportHPGL::MoveToNextEnglishChar()
|
|||||||
//将m_listXY加入到m_pMarker中,并将m_listXY清空
|
//将m_listXY加入到m_pMarker中,并将m_listXY清空
|
||||||
void ImportHPGL::AddPolylineToMarker()
|
void ImportHPGL::AddPolylineToMarker()
|
||||||
{
|
{
|
||||||
|
if(m_listXY.size() <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//长度<0.2mm为钻孔
|
//长度<0.2mm为钻孔
|
||||||
CRPPolyline RPPolyline1;
|
CRPPolyline RPPolyline1;
|
||||||
QPoint pt1,pt2;
|
QPoint pt1,pt2;
|
||||||
@ -679,15 +685,44 @@ void ImportHPGL::AddPolylineToMarker()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_listXY.clear();
|
m_listXY.clear();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportHPGL::AddPoint2listXY(QPoint ptPoint)
|
void ImportHPGL::AddPoint2listXY(QPoint ptPoint)
|
||||||
{
|
{
|
||||||
|
double angle, sina, cosa;
|
||||||
|
double rcx, rcy;
|
||||||
|
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
angle = (m_rotateAngle * PI) / 180.0;
|
||||||
|
sina = (double)qSin(angle);
|
||||||
|
cosa = (double)qCos(angle);
|
||||||
|
}
|
||||||
|
|
||||||
if ((m_listXY.size() == 0) && (m_ptCurrentPos != ptPoint))
|
if ((m_listXY.size() == 0) && (m_ptCurrentPos != ptPoint))
|
||||||
{
|
{
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
rcx = (m_ptCurrentPos.x()*cosa - m_ptCurrentPos.y()*sina);
|
||||||
|
rcy = (m_ptCurrentPos.x()*sina + m_ptCurrentPos.y()*cosa);
|
||||||
|
|
||||||
|
m_ptCurrentPos.setX(rcx);
|
||||||
|
m_ptCurrentPos.setY(rcy);
|
||||||
|
}
|
||||||
m_listXY.append(m_ptCurrentPos);
|
m_listXY.append(m_ptCurrentPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
rcx = (ptPoint.x()*cosa - ptPoint.y()*sina);
|
||||||
|
rcy = (ptPoint.x()*sina + ptPoint.y()*cosa);
|
||||||
|
|
||||||
|
ptPoint.setX(rcx);
|
||||||
|
ptPoint.setY(rcy);
|
||||||
|
}
|
||||||
|
|
||||||
m_listXY.append(ptPoint);
|
m_listXY.append(ptPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,8 +1180,6 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
|||||||
int notchOffsetX,notchOffsetY;
|
int notchOffsetX,notchOffsetY;
|
||||||
notchOffsetX = notchOffsetY = 0;
|
notchOffsetX = notchOffsetY = 0;
|
||||||
|
|
||||||
IniPara();
|
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly))
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -1491,11 +1524,33 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
|||||||
bitmapInfo.m_ptAbPostRD.setX(bitPost[6] + m_ptOrigin.x() + m_nLength);
|
bitmapInfo.m_ptAbPostRD.setX(bitPost[6] + m_ptOrigin.x() + m_nLength);
|
||||||
bitmapInfo.m_ptAbPostRD.setY(bitPost[7] + m_ptOrigin.y());
|
bitmapInfo.m_ptAbPostRD.setY(bitPost[7] + m_ptOrigin.y());
|
||||||
|
|
||||||
|
//正向旋转90度
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
double angle,sina,cosa,rcx1,rcy1,rcx2,rcy2;
|
||||||
|
angle = (m_rotateAngle * PI) / 180.0;
|
||||||
|
sina = (double)qSin(angle);
|
||||||
|
cosa = (double)qCos(angle);
|
||||||
|
|
||||||
|
rcx1 = (bitmapInfo.m_ptAbPostLD.x()*cosa - bitmapInfo.m_ptAbPostLD.y()*sina);
|
||||||
|
rcy1 = (bitmapInfo.m_ptAbPostLD.x()*sina + bitmapInfo.m_ptAbPostLD.y()*cosa);
|
||||||
|
bitmapInfo.m_ptAbPostLD.setX(rcx1);
|
||||||
|
bitmapInfo.m_ptAbPostLD.setY(rcy1);
|
||||||
|
bitmapInfo.m_ptAbPostLU = bitmapInfo.m_ptAbPostLD;
|
||||||
|
|
||||||
|
rcx2 = (bitmapInfo.m_ptAbPostRU.x()*cosa - bitmapInfo.m_ptAbPostRU.y()*sina);
|
||||||
|
rcy2 = (bitmapInfo.m_ptAbPostRU.x()*sina + bitmapInfo.m_ptAbPostRU.y()*cosa);
|
||||||
|
bitmapInfo.m_ptAbPostRU.setX(rcx2);
|
||||||
|
bitmapInfo.m_ptAbPostRU.setY(rcy2);
|
||||||
|
bitmapInfo.m_ptAbPostRD = bitmapInfo.m_ptAbPostRU;
|
||||||
|
}
|
||||||
|
|
||||||
bitmapInfo.m_iTransparent = bitDispStyle[0];
|
bitmapInfo.m_iTransparent = bitDispStyle[0];
|
||||||
bitmapInfo.m_iBKColor = bitDispStyle[1];
|
bitmapInfo.m_iBKColor = bitDispStyle[1];
|
||||||
|
|
||||||
bitmapInfo.m_iWidth = bitGDIInfo[0];
|
bitmapInfo.m_iWidth = bitGDIInfo[0];
|
||||||
bitmapInfo.m_iHeight = bitGDIInfo[1];
|
bitmapInfo.m_iHeight = bitGDIInfo[1];
|
||||||
|
|
||||||
bitmapInfo.m_iStride = bitGDIInfo[2];
|
bitmapInfo.m_iStride = bitGDIInfo[2];
|
||||||
bitmapInfo.m_iPixelFormat = bitGDIInfo[3];
|
bitmapInfo.m_iPixelFormat = bitGDIInfo[3];
|
||||||
|
|
||||||
@ -1510,12 +1565,15 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
|||||||
unBmpArr.append(pBmpData[nCount]);
|
unBmpArr.append(pBmpData[nCount]);
|
||||||
}
|
}
|
||||||
QByteArray pUnCompressData;
|
QByteArray pUnCompressData;
|
||||||
|
pUnCompressData.clear();
|
||||||
|
|
||||||
//解压缩
|
//解压缩
|
||||||
// 文件路径
|
// 文件路径
|
||||||
QDir apppath(qApp->applicationDirPath());
|
QDir apppath(qApp->applicationDirPath());
|
||||||
QString zipPath = apppath.path();
|
QFileInfo fileInfo(stePathName);
|
||||||
QString zipFile = stePathName + "bfile.zip";
|
QString zipPath = fileInfo.absolutePath();//获取Secret.plt所在的目录
|
||||||
|
QString cpstePathName = stePathName;
|
||||||
|
QString zipFile = cpstePathName.remove(cpstePathName.length()-3,3) + "zip";
|
||||||
QFile file(zipFile);
|
QFile file(zipFile);
|
||||||
if (!file.open(QIODevice::WriteOnly))
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
@ -1525,25 +1583,81 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
|||||||
file.write(unBmpArr);
|
file.write(unBmpArr);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
QZipReader reader(zipFile);
|
//判断zip文件是否存在
|
||||||
if(!reader.exists())
|
if (!QFile::exists(zipFile))
|
||||||
{
|
{
|
||||||
|
qDebug() << "The zip file does not exist";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.extractAll(zipFile);
|
QZipReader reader(zipFile);
|
||||||
//QVector<QZipReader::FileInfo> list = reader.fileInfoList();
|
|
||||||
QZipReader::FileInfo fileInfo = reader.entryInfoAt(0);//文件夹名称
|
//解压到当前unzipfile文件夹目录
|
||||||
pUnCompressData = reader.fileData(fileInfo.filePath);
|
QString unzipPath = zipPath + apppath.separator() + "unzipfile";
|
||||||
|
QDir unzipDir(unzipPath);
|
||||||
|
if(!unzipDir.exists())
|
||||||
|
{
|
||||||
|
unzipDir.mkdir(unzipPath);
|
||||||
|
}
|
||||||
|
if (!reader.extractAll(unzipPath))
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to extract all files from the zip.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
|
unzipDir.setFilter(QDir::Files | QDir::NoDotAndDotDot); //设置过滤
|
||||||
|
QFileInfoList fileList = unzipDir.entryInfoList(); // 获取所有的文件信息
|
||||||
|
|
||||||
|
QString unzipFilePath;
|
||||||
|
foreach (QFileInfo file, fileList)
|
||||||
|
{
|
||||||
|
if (file.isFile())
|
||||||
|
{
|
||||||
|
// 解压的文件
|
||||||
|
unzipFilePath = file.filePath();
|
||||||
|
QFile uncompressedFile(unzipFilePath);
|
||||||
|
if (!uncompressedFile.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to open the uncompressedFile file";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUnCompressData = uncompressedFile.readAll();
|
||||||
|
uncompressedFile.close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pUnCompressData.length() <= 0)
|
||||||
|
{
|
||||||
|
qDebug() << "pUnCompressData.length() <= 0";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// bitmapInfo.m_pBitmap = plotBitmap.Create1BPPBitmap(bitmapInfo.m_iTransparent,bitmapInfo.m_iBKColor,bitmapInfo.m_iWidth,bitmapInfo.m_iHeight,
|
// bitmapInfo.m_pBitmap = plotBitmap.Create1BPPBitmap(bitmapInfo.m_iTransparent,bitmapInfo.m_iBKColor,bitmapInfo.m_iWidth,bitmapInfo.m_iHeight,
|
||||||
// bitmapInfo.m_iStride,bitmapInfo.m_iPixelFormat, pUnCompressData.data());
|
// bitmapInfo.m_iStride,bitmapInfo.m_iPixelFormat, pUnCompressData.data());
|
||||||
|
|
||||||
bitmapInfo.m_pBitmap = plotBitmap.Create1BPPBitmap(bitmapInfo.m_iWidth,bitmapInfo.m_iHeight, (unsigned char*)pUnCompressData.data());
|
bitmapInfo.m_pBitmap = plotBitmap.Create1BPPBitmap(bitmapInfo.m_iWidth,bitmapInfo.m_iHeight, (unsigned char*)pUnCompressData.data());
|
||||||
QString reStr = zipPath + apppath.separator() + fileInfo.filePath;
|
|
||||||
QFile::remove(reStr);
|
//正向旋转90度
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
QImage rotatedBitmap = bitmapInfo.m_pBitmap.toImage().transformed(QTransform().rotate(90));
|
||||||
|
// 将旋转后的QImage转换回QBitmap
|
||||||
|
QBitmap rotatedBitmapQt(bitmapInfo.m_pBitmap.height(),bitmapInfo.m_pBitmap.width());
|
||||||
|
rotatedBitmapQt.fill(Qt::color0);
|
||||||
|
QPainter painter(&rotatedBitmapQt);
|
||||||
|
painter.drawPixmap(0, 0, QPixmap::fromImage(rotatedBitmap));
|
||||||
|
painter.end();
|
||||||
|
bitmapInfo.m_pBitmap = rotatedBitmapQt;
|
||||||
|
//rotatedBitmap.save("D:\\1.bmp");
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile::remove(stePathName);
|
||||||
QFile::remove(zipFile);
|
QFile::remove(zipFile);
|
||||||
|
QFile::remove(unzipFilePath);
|
||||||
|
|
||||||
delete pBmpData;
|
delete pBmpData;
|
||||||
|
|
||||||
RPPolyline.m_nDrawingType = 1;
|
RPPolyline.m_nDrawingType = 1;
|
||||||
@ -1650,6 +1764,20 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
|||||||
//qrPixmap.save("D:\\1.bmp");
|
//qrPixmap.save("D:\\1.bmp");
|
||||||
bitmapInfo.m_pBitmap = qrPixmap;
|
bitmapInfo.m_pBitmap = qrPixmap;
|
||||||
|
|
||||||
|
//正向旋转90度
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
QImage rotatedBitmap = bitmapInfo.m_pBitmap.toImage().transformed(QTransform().rotate(90));
|
||||||
|
// 将旋转后的QImage转换回QBitmap
|
||||||
|
QBitmap rotatedBitmapQt(bitmapInfo.m_pBitmap.height(),bitmapInfo.m_pBitmap.width());
|
||||||
|
rotatedBitmapQt.fill(Qt::color0);
|
||||||
|
QPainter painter(&rotatedBitmapQt);
|
||||||
|
painter.drawPixmap(0, 0, QPixmap::fromImage(rotatedBitmap));
|
||||||
|
painter.end();
|
||||||
|
bitmapInfo.m_pBitmap = rotatedBitmapQt;
|
||||||
|
//rotatedBitmap.save("D:\\1.bmp");
|
||||||
|
}
|
||||||
|
|
||||||
if (code.m_nSizeY <= code.m_nSizeX)
|
if (code.m_nSizeY <= code.m_nSizeX)
|
||||||
{
|
{
|
||||||
nPixelsDot = (int)((double)code.m_nSizeY / (double)pCode->width + 0.5);
|
nPixelsDot = (int)((double)code.m_nSizeY / (double)pCode->width + 0.5);
|
||||||
@ -1687,6 +1815,26 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
|||||||
bitmapInfo.m_ptAbPostRD.setX(bitmapInfo.m_ptPostRD.x() + m_ptOrigin.x() + m_nLength);
|
bitmapInfo.m_ptAbPostRD.setX(bitmapInfo.m_ptPostRD.x() + m_ptOrigin.x() + m_nLength);
|
||||||
bitmapInfo.m_ptAbPostRD.setY(bitmapInfo.m_ptPostRD.y() + m_ptOrigin.y());
|
bitmapInfo.m_ptAbPostRD.setY(bitmapInfo.m_ptPostRD.y() + m_ptOrigin.y());
|
||||||
|
|
||||||
|
if(m_rotateAngle != 0)
|
||||||
|
{
|
||||||
|
double angle,sina,cosa,rcx1,rcy1,rcx2,rcy2;
|
||||||
|
angle = (m_rotateAngle * PI) / 180.0;
|
||||||
|
sina = (double)qSin(angle);
|
||||||
|
cosa = (double)qCos(angle);
|
||||||
|
|
||||||
|
rcx1 = (bitmapInfo.m_ptAbPostLD.x()*cosa - bitmapInfo.m_ptAbPostLD.y()*sina);
|
||||||
|
rcy1 = (bitmapInfo.m_ptAbPostLD.x()*sina + bitmapInfo.m_ptAbPostLD.y()*cosa);
|
||||||
|
bitmapInfo.m_ptAbPostLD.setX(rcx1);
|
||||||
|
bitmapInfo.m_ptAbPostLD.setY(rcy1);
|
||||||
|
bitmapInfo.m_ptAbPostLU = bitmapInfo.m_ptAbPostLD;
|
||||||
|
|
||||||
|
rcx2 = (bitmapInfo.m_ptAbPostRU.x()*cosa - bitmapInfo.m_ptAbPostRU.y()*sina);
|
||||||
|
rcy2 = (bitmapInfo.m_ptAbPostRU.x()*sina + bitmapInfo.m_ptAbPostRU.y()*cosa);
|
||||||
|
bitmapInfo.m_ptAbPostRU.setX(rcx2);
|
||||||
|
bitmapInfo.m_ptAbPostRU.setY(rcy2);
|
||||||
|
bitmapInfo.m_ptAbPostRD = bitmapInfo.m_ptAbPostRU;
|
||||||
|
}
|
||||||
|
|
||||||
bitmapInfo.m_iTransparent = 0;
|
bitmapInfo.m_iTransparent = 0;
|
||||||
bitmapInfo.m_iBKColor = qRgb(255,255,255);
|
bitmapInfo.m_iBKColor = qRgb(255,255,255);
|
||||||
|
|
||||||
@ -2079,8 +2227,6 @@ bool ImportHPGL::L_Code()
|
|||||||
connect(&vectorFont, SIGNAL(siLineTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint)));
|
connect(&vectorFont, SIGNAL(siLineTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint)));
|
||||||
connect(&vectorFont, SIGNAL(siMoveTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint)));
|
connect(&vectorFont, SIGNAL(siMoveTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint)));
|
||||||
|
|
||||||
CRPPolyline crppolylineTemp;
|
|
||||||
|
|
||||||
bOk=GetChar(&cCh1);
|
bOk=GetChar(&cCh1);
|
||||||
if (bOk)
|
if (bOk)
|
||||||
{
|
{
|
||||||
@ -2094,6 +2240,8 @@ bool ImportHPGL::L_Code()
|
|||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
case 'b':
|
case 'b':
|
||||||
|
{
|
||||||
|
CRPPolyline crppolylineTemp;
|
||||||
AddPolylineToMarker();
|
AddPolylineToMarker();
|
||||||
bOk = SearchChar(m_chTerminator,strText);
|
bOk = SearchChar(m_chTerminator,strText);
|
||||||
m_ptCurrentPos = GetTextOrigin(m_ptCurrentPos,strText);
|
m_ptCurrentPos = GetTextOrigin(m_ptCurrentPos,strText);
|
||||||
@ -2118,7 +2266,7 @@ bool ImportHPGL::L_Code()
|
|||||||
|
|
||||||
//qDebug()<<crppolylineTemp.m_text.m_strText;
|
//qDebug()<<crppolylineTemp.m_text.m_strText;
|
||||||
//m_pMarker->m_listPolyline.append(crppolylineTemp);//用文本方法绘制
|
//m_pMarker->m_listPolyline.append(crppolylineTemp);//用文本方法绘制
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
case 'o':
|
case 'o':
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <qtextcodec.h>
|
#include <qtextcodec.h>
|
||||||
|
#include <QByteArray>
|
||||||
#include "marker.h"
|
#include "marker.h"
|
||||||
#include "plotbitmap.h"
|
#include "plotbitmap.h"
|
||||||
#include "QtGui/private/qzipreader_p.h"
|
#include "QtGui/private/qzipreader_p.h"
|
||||||
@ -50,6 +51,8 @@
|
|||||||
#define PixelFormatGDI 0x00020000 // Is a GDI-supported format
|
#define PixelFormatGDI 0x00020000 // Is a GDI-supported format
|
||||||
#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
|
#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
|
||||||
|
|
||||||
|
#pragma pack(1) //设定为1字节对齐
|
||||||
|
|
||||||
struct SC
|
struct SC
|
||||||
{
|
{
|
||||||
double dXMin;
|
double dXMin;
|
||||||
@ -205,6 +208,7 @@ protected:
|
|||||||
|
|
||||||
Marker *m_pMarker; //当前使用的唛架,仅能在读文件时使用
|
Marker *m_pMarker; //当前使用的唛架,仅能在读文件时使用
|
||||||
double m_dScale; //读入文件时将切割数据文件的单位转换成内部数据单位时的比例
|
double m_dScale; //读入文件时将切割数据文件的单位转换成内部数据单位时的比例
|
||||||
|
double m_rotateAngle;//旋转角度
|
||||||
QPen m_penPen;//笔绘画笔
|
QPen m_penPen;//笔绘画笔
|
||||||
QPen m_cutPen;//切割画笔
|
QPen m_cutPen;//切割画笔
|
||||||
QPen m_halfCutPen;//半透切割画笔
|
QPen m_halfCutPen;//半透切割画笔
|
||||||
@ -250,6 +254,7 @@ public:
|
|||||||
|
|
||||||
//初始化参数,读取参数前,需将参数值重置,避免造成参数值读取错误
|
//初始化参数,读取参数前,需将参数值重置,避免造成参数值读取错误
|
||||||
void IniPara();
|
void IniPara();
|
||||||
|
inline void setRotateAngle(double angle){m_rotateAngle = angle;}
|
||||||
|
|
||||||
QPoint GetTextOrigin(QPoint pt,QString strText);
|
QPoint GetTextOrigin(QPoint pt,QString strText);
|
||||||
double GetTextAngle(double dX,double dY);
|
double GetTextAngle(double dX,double dY);
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#define CONST_PI 3.14159265359
|
#define CONST_PI 3.14159265359
|
||||||
|
|
||||||
|
#pragma pack(1) //设定为1字节对齐
|
||||||
|
|
||||||
struct LineType
|
struct LineType
|
||||||
{
|
{
|
||||||
//具体参照HPGL英文版手册216页 当LT没有设置值时,线型为实线
|
//具体参照HPGL英文版手册216页 当LT没有设置值时,线型为实线
|
||||||
@ -21,7 +23,6 @@ struct LineType
|
|||||||
int nMode;//0相对模式 缺省值 解释为P1、P2距离的百分比 1绝对模式,以毫米解释图案长度
|
int nMode;//0相对模式 缺省值 解释为P1、P2距离的百分比 1绝对模式,以毫米解释图案长度
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CBitmapInfo
|
class CBitmapInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -118,7 +118,6 @@ void VectorFont::IniVectorFont()
|
|||||||
Chinese_char1.m_wBytes=(WORD)byte[2] | ((WORD)byte[3] << 8);
|
Chinese_char1.m_wBytes=(WORD)byte[2] | ((WORD)byte[3] << 8);
|
||||||
Chinese_char1.m_dwPosition=(DWORD)byte[4] | ((DWORD)byte[5] << 8) | ((DWORD)byte[6] << 16) | ((DWORD)byte[7] << 24);
|
Chinese_char1.m_dwPosition=(DWORD)byte[4] | ((DWORD)byte[5] << 8) | ((DWORD)byte[6] << 16) | ((DWORD)byte[7] << 24);
|
||||||
|
|
||||||
|
|
||||||
m_pChinese_char[nCharCount_C-nCountChar] = Chinese_char1;
|
m_pChinese_char[nCharCount_C-nCountChar] = Chinese_char1;
|
||||||
//m_aChinese_char.append(Chinese_char1);
|
//m_aChinese_char.append(Chinese_char1);
|
||||||
nCountChar--;
|
nCountChar--;
|
||||||
@ -129,7 +128,6 @@ void VectorFont::IniVectorFont()
|
|||||||
m_dFontHeight = 0.375 * 10 * m_iDPMM;
|
m_dFontHeight = 0.375 * 10 * m_iDPMM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//输入参数:
|
//输入参数:
|
||||||
// ptPointLU 显示字符串的左上角坐标(即TextOut(...)的x,y值)
|
// ptPointLU 显示字符串的左上角坐标(即TextOut(...)的x,y值)
|
||||||
// pbyData 字符的描述数据
|
// pbyData 字符的描述数据
|
||||||
@ -411,12 +409,15 @@ void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,i
|
|||||||
if (bPenUp) MoveTo(ptPoint1);
|
if (bPenUp) MoveTo(ptPoint1);
|
||||||
else LineTo(ptPoint1);
|
else LineTo(ptPoint1);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (bClockwise) {
|
{
|
||||||
|
if (bClockwise)
|
||||||
|
{
|
||||||
dx2=-dy1;
|
dx2=-dy1;
|
||||||
dy2=dx1;
|
dy2=dx1;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
dx2=dy1;
|
dx2=dy1;
|
||||||
dy2=-dx1;
|
dy2=-dx1;
|
||||||
}
|
}
|
||||||
@ -459,10 +460,12 @@ void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,i
|
|||||||
bVerTextCommand=false;
|
bVerTextCommand=false;
|
||||||
break;
|
break;
|
||||||
case 0xD:
|
case 0xD:
|
||||||
if (bVerTextCommand) {
|
if (bVerTextCommand)
|
||||||
|
{
|
||||||
wIndex1=wIndex1+4;
|
wIndex1=wIndex1+4;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
wIndex1++;
|
wIndex1++;
|
||||||
while ((pbyData[wIndex1] != 0) || (pbyData[wIndex1+1] != 0)) {
|
while ((pbyData[wIndex1] != 0) || (pbyData[wIndex1+1] != 0)) {
|
||||||
dx1=(double)((char)pbyData[wIndex1]) * (double)nFontScale;
|
dx1=(double)((char)pbyData[wIndex1]) * (double)nFontScale;
|
||||||
@ -476,7 +479,8 @@ void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,i
|
|||||||
dD=sqrt(dx1*dx1 + dy1*dy1);
|
dD=sqrt(dx1*dx1 + dy1*dy1);
|
||||||
dH=fabs(dBulge) * dD / 127.0 / 2.0;
|
dH=fabs(dBulge) * dD / 127.0 / 2.0;
|
||||||
|
|
||||||
if (((char)pbyData[wIndex1]) == 0) {
|
if (((char)pbyData[wIndex1]) == 0)
|
||||||
|
{
|
||||||
ptCurrentPos.setX(ptCurrentPos.x() + (int)dx1);
|
ptCurrentPos.setX(ptCurrentPos.x() + (int)dx1);
|
||||||
ptCurrentPos.setY(ptCurrentPos.y() - (int)dy1);
|
ptCurrentPos.setY(ptCurrentPos.y() - (int)dy1);
|
||||||
ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale);
|
ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale);
|
||||||
@ -486,12 +490,15 @@ void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,i
|
|||||||
else
|
else
|
||||||
LineTo(ptPoint1);
|
LineTo(ptPoint1);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (bClockwise) {
|
{
|
||||||
|
if (bClockwise)
|
||||||
|
{
|
||||||
dx2=-dy1;
|
dx2=-dy1;
|
||||||
dy2=dx1;
|
dy2=dx1;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
dx2=dy1;
|
dx2=dy1;
|
||||||
dy2=-dx1;
|
dy2=-dx1;
|
||||||
}
|
}
|
||||||
@ -571,6 +578,7 @@ QPoint VectorFont::CPToLP(QPoint ptCP,int nHeight,QPoint ptPointLU,double dSin,d
|
|||||||
|
|
||||||
return ptPoint1;
|
return ptPoint1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//抬笔移动到点(x,y)
|
//抬笔移动到点(x,y)
|
||||||
void VectorFont::MoveTo(long x, long y)
|
void VectorFont::MoveTo(long x, long y)
|
||||||
{
|
{
|
||||||
@ -584,7 +592,6 @@ void VectorFont::MoveTo(QPoint ptPoint)
|
|||||||
emit siMoveTo(true,ptPoint);
|
emit siMoveTo(true,ptPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//从当前位置画线到点(x,y),
|
//从当前位置画线到点(x,y),
|
||||||
void VectorFont::LineTo(long x, long y)
|
void VectorFont::LineTo(long x, long y)
|
||||||
{
|
{
|
||||||
@ -732,6 +739,7 @@ void VectorFont::TextOutString(int x, int y, const char* lpszString, int nCount)
|
|||||||
fileEnglish.close();
|
fileEnglish.close();
|
||||||
fileChinese.close();
|
fileChinese.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//画弧,从Start逆时针画到End
|
//画弧,从Start逆时针画到End
|
||||||
void VectorFont::Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,
|
void VectorFont::Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,
|
||||||
int nXStartArc,int nYStartArc,int nXEndArc,int nYEndArc)
|
int nXStartArc,int nYStartArc,int nXEndArc,int nYEndArc)
|
||||||
@ -775,14 +783,14 @@ void VectorFont::Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,
|
|||||||
dy=dRadius * dSin + dYC;
|
dy=dRadius * dSin + dYC;
|
||||||
LineTo(dx+0.5,dy+0.5);
|
LineTo(dx+0.5,dy+0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint VectorFont::GetNextCoodinate(WORD wDirection,WORD wLength,QPoint ptPoint)
|
QPoint VectorFont::GetNextCoodinate(WORD wDirection,WORD wLength,QPoint ptPoint)
|
||||||
{
|
{
|
||||||
QPoint ptPoint1;
|
QPoint ptPoint1;
|
||||||
|
|
||||||
switch (wDirection) {
|
switch (wDirection)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
ptPoint1.setX( ptPoint.x() + (int)wLength);
|
ptPoint1.setX( ptPoint.x() + (int)wLength);
|
||||||
ptPoint1.setY(ptPoint.y());
|
ptPoint1.setY(ptPoint.y());
|
||||||
|
183
datafile/view/drawdata.cpp
Normal file
183
datafile/view/drawdata.cpp
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
#include "drawdata.h"
|
||||||
|
|
||||||
|
QPicture creatPictureByData(Marker marker, QPainterPath &painterPath, int penWidth)
|
||||||
|
{
|
||||||
|
CBitmapInfo bitmapInfo;
|
||||||
|
QRect rect = marker.GetRect();
|
||||||
|
int minX = rect.left();
|
||||||
|
int maxY = rect.bottom();
|
||||||
|
|
||||||
|
int nLineCount = marker.m_listPolyline.size();
|
||||||
|
for(int i = 0; i < nLineCount; i++)
|
||||||
|
{
|
||||||
|
CRPPolyline polyLine = marker.m_listPolyline.at(i);
|
||||||
|
int type = polyLine.m_nDrawingType;
|
||||||
|
// if(polyLine.m_nDrawingType == 3)//文字
|
||||||
|
// {
|
||||||
|
// CRPText text = polyLine->m_text;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(type == 0)//直线
|
||||||
|
{
|
||||||
|
int nPointCount = polyLine.m_listPoint.size();
|
||||||
|
for(int j = 0; j < nPointCount; j++)
|
||||||
|
{
|
||||||
|
double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY;
|
||||||
|
double y = (maxY - polyLine.m_listPoint.at(j).y())/(double)M_IDPMM*MMPIXELY;
|
||||||
|
QPointF point(x,y);
|
||||||
|
|
||||||
|
if(j == 0)
|
||||||
|
{
|
||||||
|
painterPath.moveTo(point);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painterPath.lineTo(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(type == 1)//位图
|
||||||
|
{
|
||||||
|
bitmapInfo = polyLine.m_bitmapInfo;
|
||||||
|
|
||||||
|
int lux = bitmapInfo.m_ptAbPostLU.x();
|
||||||
|
int luy = bitmapInfo.m_ptAbPostLU.y();
|
||||||
|
int nlux = (lux - minX)/M_IDPMM*MMPIXELY;
|
||||||
|
int nluy = (maxY-luy)/M_IDPMM*MMPIXELY;
|
||||||
|
bitmapInfo.m_ptAbPostLU.setX(nlux);
|
||||||
|
bitmapInfo.m_ptAbPostLU.setY(nluy);
|
||||||
|
|
||||||
|
int rdx = bitmapInfo.m_ptAbPostRD.x();
|
||||||
|
int rdy = bitmapInfo.m_ptAbPostRD.y();
|
||||||
|
int nrdx = (rdx - minX)/M_IDPMM*MMPIXELY;
|
||||||
|
int nrdy = (maxY-rdy)/M_IDPMM*MMPIXELY;
|
||||||
|
bitmapInfo.m_ptAbPostRD.setX(nrdx);
|
||||||
|
bitmapInfo.m_ptAbPostRD.setY(nrdy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(painterPath.isEmpty())
|
||||||
|
{
|
||||||
|
qDebug()<<"painterPath.isEmpty";
|
||||||
|
}
|
||||||
|
|
||||||
|
//将路径画在picture上
|
||||||
|
QPicture pic;
|
||||||
|
QPen pen(Qt::black, penWidth, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
|
||||||
|
//pen.setCosmetic(true); // 对于固定宽度的笔划很有用
|
||||||
|
|
||||||
|
QPainter painter;
|
||||||
|
painter.begin(&pic);
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawPath(painterPath);
|
||||||
|
if(bitmapInfo.m_iBytes > 0)//有位图
|
||||||
|
{
|
||||||
|
int startx = bitmapInfo.m_ptAbPostLU.x();
|
||||||
|
int starty = bitmapInfo.m_ptAbPostLU.y();
|
||||||
|
//bitmapInfo.m_pBitmap.save("D:\\1.bmp");
|
||||||
|
int targetWidth = abs(bitmapInfo.m_ptAbPostRD.x() - bitmapInfo.m_ptAbPostLU.x());
|
||||||
|
int targetHeight = abs(bitmapInfo.m_ptAbPostRD.y() - bitmapInfo.m_ptAbPostLU.y());
|
||||||
|
painter.drawPixmap(startx,starty,targetWidth,targetHeight,bitmapInfo.m_pBitmap,
|
||||||
|
startx,starty, bitmapInfo.m_pBitmap.width(), bitmapInfo.m_pBitmap.height());
|
||||||
|
// painter.drawPixmap(bitmapInfo.m_ptAbPostLU.x(),bitmapInfo.m_ptAbPostLU.y(),bitmapInfo.m_pBitmap);
|
||||||
|
}
|
||||||
|
painter.end();
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPicture creatPictureByBmp(QPixmap pixmap,int penWidth)
|
||||||
|
{
|
||||||
|
//将图片画在picture上
|
||||||
|
QPicture pic;
|
||||||
|
QPen pen;
|
||||||
|
pen.setWidth(penWidth);//设置笔号
|
||||||
|
pen.setColor(QColor(Qt::black));
|
||||||
|
|
||||||
|
QPainter painter;
|
||||||
|
painter.begin(&pic);
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawPixmap(0,0,pixmap);
|
||||||
|
painter.end();
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void creatMarkerDat(McFilesInfo &curFilesInfo, QString printDir, QString filePath, int fileIdx, double angle)
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(fileInfo.suffix().toUpper() == "PLT")
|
||||||
|
{
|
||||||
|
ImportHPGL importHPGL;
|
||||||
|
curFilesInfo.m_fileType = TYPE_FILE;
|
||||||
|
|
||||||
|
//判断是否为加密文件
|
||||||
|
if (importHPGL.IsSecretFile(filePath) == true)
|
||||||
|
{
|
||||||
|
QString strSecretFile;
|
||||||
|
if(fileIdx == -1)
|
||||||
|
{
|
||||||
|
// 文件路径
|
||||||
|
QDir apppath(qApp->applicationDirPath());
|
||||||
|
strSecretFile = apppath.path() + apppath.separator() + "Secret.plt";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 文件路径
|
||||||
|
strSecretFile = printDir + QString::number(fileIdx+1) ;
|
||||||
|
|
||||||
|
QDir fileDir(strSecretFile);//对应每台机器的每个文件打印目录
|
||||||
|
if(!fileDir.exists())
|
||||||
|
{
|
||||||
|
fileDir.mkdir(strSecretFile);
|
||||||
|
}
|
||||||
|
strSecretFile = strSecretFile + fileDir.separator() + "Secret.plt";
|
||||||
|
}
|
||||||
|
//qDebug()<<"strSecretFile"<<strSecretFile;
|
||||||
|
|
||||||
|
importHPGL.BitMapDtat(filePath,strSecretFile);
|
||||||
|
importHPGL.IniPara();
|
||||||
|
importHPGL.setRotateAngle(angle);
|
||||||
|
importHPGL.ReadSecretFile(strSecretFile,&curFilesInfo.m_marker);
|
||||||
|
//qDebug()<<"importHPGL.IsSecretFile";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
importHPGL.IniPara();
|
||||||
|
importHPGL.setRotateAngle(angle);
|
||||||
|
importHPGL.Read(filePath,&curFilesInfo.m_marker);
|
||||||
|
}
|
||||||
|
curFilesInfo.m_fileRect = curFilesInfo.m_marker.GetRect();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curFilesInfo.m_fileType = TYPE_IMAGE;
|
||||||
|
QBitmap pixmap;
|
||||||
|
pixmap.load(filePath);
|
||||||
|
QRect rect;
|
||||||
|
rect.setRect(0,0,pixmap.width()/MMPIXELY*M_IDPMM,pixmap.height()/MMPIXELY*M_IDPMM);
|
||||||
|
|
||||||
|
curFilesInfo.m_pixmap = pixmap;
|
||||||
|
curFilesInfo.m_fileRect = rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
curFilesInfo.m_filePath = filePath;
|
||||||
|
curFilesInfo.m_fileName = fileInfo.fileName();
|
||||||
|
curFilesInfo.m_printNum = 1;
|
||||||
|
curFilesInfo.m_startPoint = 0;
|
||||||
|
curFilesInfo.m_printState = Waitting;
|
||||||
|
curFilesInfo.m_curPrintBlock = 0;//当前打印块数
|
||||||
|
curFilesInfo.m_printedBlockNum = 0;//已打印块数
|
||||||
|
curFilesInfo.m_selectBlockNum = 0;//当前选择块数
|
||||||
|
curFilesInfo.m_creatDataFlag = 1;
|
||||||
|
}
|
16
datafile/view/drawdata.h
Normal file
16
datafile/view/drawdata.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef DRAWDATA_H
|
||||||
|
#define DRAWDATA_H
|
||||||
|
|
||||||
|
#include <QPicture>
|
||||||
|
#include "datafile/dxf/dxfhelper.h"
|
||||||
|
#include "datafile/hpgl/importhpgl.h"
|
||||||
|
#include "machine/printinfo/mcfiles.h"
|
||||||
|
|
||||||
|
#define TYPE_FILE 0
|
||||||
|
#define TYPE_IMAGE 1
|
||||||
|
|
||||||
|
QPicture creatPictureByData(Marker marker, QPainterPath &painterPath,int penWidth = 1);
|
||||||
|
QPicture creatPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
||||||
|
void creatMarkerDat(McFilesInfo &curFilesInfo, QString printDir, QString filePath, int fileIdx = -1, double angle = 0);//创建Marker数据
|
||||||
|
|
||||||
|
#endif // DRAWDATA_H
|
@ -4,6 +4,7 @@ MyGraphicsItem::MyGraphicsItem()
|
|||||||
{
|
{
|
||||||
m_point.setX(0);
|
m_point.setX(0);
|
||||||
m_point.setY(0);
|
m_point.setY(0);
|
||||||
|
m_fileType = TYPE_FILE;
|
||||||
|
|
||||||
//使item可以被选择
|
//使item可以被选择
|
||||||
//this->setFlag(QGraphicsItem::ItemIsSelectable);
|
//this->setFlag(QGraphicsItem::ItemIsSelectable);
|
||||||
@ -32,89 +33,58 @@ void MyGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
return QGraphicsItem::mouseReleaseEvent(event);
|
return QGraphicsItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPicture MyGraphicsItem::getPicture(Marker marker,int penWidth)
|
QPicture MyGraphicsItem::getPictureByDat(Marker marker,int penWidth)
|
||||||
{
|
{
|
||||||
|
m_fileType = TYPE_FILE;
|
||||||
if(penWidth != 1)
|
if(penWidth != 1)
|
||||||
{
|
{
|
||||||
QPicture pic;
|
QPicture pic;
|
||||||
CBitmapInfo bitmapInfo;
|
pic = creatPictureByData(marker,m_drawPath,penWidth);
|
||||||
QPainterPath painterPath;
|
m_boundingRect = pic.boundingRect();
|
||||||
QRect rect = marker.GetRect();
|
|
||||||
int minX = rect.left();
|
|
||||||
int minY = rect.top();
|
|
||||||
int maxY = rect.bottom();
|
|
||||||
|
|
||||||
int nLineCount = marker.m_listPolyline.size();
|
|
||||||
for(int i = 0; i < nLineCount; i++)
|
|
||||||
{
|
|
||||||
CRPPolyline polyLine = marker.m_listPolyline.at(i);
|
|
||||||
int type = polyLine.m_nDrawingType;
|
|
||||||
|
|
||||||
if(type == 0)//直线
|
|
||||||
{
|
|
||||||
int nPointCount = polyLine.m_listPoint.size();
|
|
||||||
for(int j = 0; j < nPointCount; j++)
|
|
||||||
{
|
|
||||||
double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY;
|
|
||||||
double y = ((0 - (polyLine.m_listPoint.at(j).y() - minY))+(maxY-minY))/(double)M_IDPMM*MMPIXELY;
|
|
||||||
QPointF point(x,y);
|
|
||||||
|
|
||||||
if(j == 0)
|
|
||||||
{
|
|
||||||
painterPath.moveTo(point);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painterPath.lineTo(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(type == 1)//位图
|
|
||||||
{
|
|
||||||
bitmapInfo = polyLine.m_bitmapInfo;
|
|
||||||
int x = bitmapInfo.m_ptAbPostLU.x();
|
|
||||||
int y = bitmapInfo.m_ptAbPostLU.y();
|
|
||||||
|
|
||||||
int nx = (x - minX)/M_IDPMM*MMPIXELY;
|
|
||||||
int ny = ((0 - (y - minY))+(maxY-minY))/M_IDPMM*MMPIXELY;
|
|
||||||
|
|
||||||
bitmapInfo.m_ptAbPostLU.setX(nx);
|
|
||||||
bitmapInfo.m_ptAbPostLU.setY(ny);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(painterPath.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug()<<"painterPath isEmpty";
|
|
||||||
}
|
|
||||||
|
|
||||||
//将路径画在picture上
|
|
||||||
QPen pen;
|
|
||||||
pen.setWidth(penWidth);//设置笔号
|
|
||||||
pen.setColor(QColor(Qt::black));
|
|
||||||
|
|
||||||
QPainter painter;
|
|
||||||
painter.begin(&pic);
|
|
||||||
painter.setPen(pen);
|
|
||||||
painter.drawPath(painterPath);
|
|
||||||
if(bitmapInfo.m_iBytes > 0)//有位图
|
|
||||||
{
|
|
||||||
painter.drawPixmap(bitmapInfo.m_ptAbPostLU.x(),bitmapInfo.m_ptAbPostLU.y(),bitmapInfo.m_pBitmap);
|
|
||||||
}
|
|
||||||
painter.end();
|
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
return m_picture;
|
return m_picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPicture MyGraphicsItem::getPictureByBmp(QPixmap pixmap,int penWidth)
|
||||||
|
{
|
||||||
|
m_fileType = TYPE_IMAGE;
|
||||||
|
m_picture = creatPictureByBmp(pixmap,penWidth);
|
||||||
|
m_boundingRect = m_picture.boundingRect();
|
||||||
|
return m_picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath MyGraphicsItem::getDrawPath()
|
||||||
|
{
|
||||||
|
return m_drawPath;
|
||||||
|
}
|
||||||
|
|
||||||
void MyGraphicsItem::setPicture(QPicture pic)
|
void MyGraphicsItem::setPicture(QPicture pic)
|
||||||
{
|
{
|
||||||
|
m_fileType = TYPE_IMAGE;
|
||||||
m_picture = pic;
|
m_picture = pic;
|
||||||
// 外矩形
|
// 外矩形
|
||||||
m_boundingRect = m_picture.boundingRect();
|
m_boundingRect = m_picture.boundingRect();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyGraphicsItem::setPaintPath(QPainterPath path)
|
||||||
|
{
|
||||||
|
m_fileType = TYPE_FILE;
|
||||||
|
m_drawPath = path;
|
||||||
|
m_boundingRect = m_drawPath.boundingRect();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyGraphicsItem::setPaintPathAndPic(QPainterPath path, QPicture pic)
|
||||||
|
{
|
||||||
|
m_fileType = TYPE_FILE;
|
||||||
|
m_drawPath = path;
|
||||||
|
m_picture = pic;
|
||||||
|
m_boundingRect = m_drawPath.boundingRect();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void MyGraphicsItem::reflushBlockPos(QPoint p)
|
void MyGraphicsItem::reflushBlockPos(QPoint p)
|
||||||
{
|
{
|
||||||
m_point = p;
|
m_point = p;
|
||||||
@ -145,7 +115,12 @@ void MyGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||||||
QBrush brush;
|
QBrush brush;
|
||||||
brush.setStyle(Qt::SolidPattern);
|
brush.setStyle(Qt::SolidPattern);
|
||||||
pen.setWidth(1);
|
pen.setWidth(1);
|
||||||
double scaleFactor = painter->matrix().m11();
|
|
||||||
|
// 获取当前的变换矩阵
|
||||||
|
QTransform transform = painter->worldTransform();
|
||||||
|
double scaleFactor = std::sqrt(transform.m11() * transform.m11() +
|
||||||
|
transform.m22() * transform.m22());
|
||||||
|
|
||||||
double width = pen.width()/scaleFactor;
|
double width = pen.width()/scaleFactor;
|
||||||
pen.setWidthF(width); // 线段保持原来的线宽
|
pen.setWidthF(width); // 线段保持原来的线宽
|
||||||
pen.setColor(QColor(Qt::black));
|
pen.setColor(QColor(Qt::black));
|
||||||
@ -158,104 +133,15 @@ void MyGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||||||
// painter->setRenderHint(QPainter::Antialiasing, true);
|
// painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
// painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
|
// painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
|
|
||||||
|
//用MyGraphicsItem画图缩放时如果笔宽不为1,直接画QPicture时线条会很轻,所以用m_drawPath绘制,pic就为原笔宽pic
|
||||||
|
//文件类型用m_drawPath,图片类型为m_picture
|
||||||
|
if(m_fileType == TYPE_FILE)
|
||||||
|
{
|
||||||
|
painter->drawPath(m_drawPath);
|
||||||
|
}
|
||||||
|
else if(m_fileType == TYPE_IMAGE)
|
||||||
|
{
|
||||||
painter->drawPicture(0,0,m_picture);
|
painter->drawPicture(0,0,m_picture);
|
||||||
|
}
|
||||||
painter->drawPixmap(m_point.x(),m_point.y(),m_blockPixmap);
|
painter->drawPixmap(m_point.x(),m_point.y(),m_blockPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsItem::creatPicture(Marker marker)
|
|
||||||
{
|
|
||||||
CBitmapInfo bitmapInfo;
|
|
||||||
QPainterPath painterPath;
|
|
||||||
QRect rect = marker.GetRect();
|
|
||||||
int minX = rect.left();
|
|
||||||
int minY = rect.top();
|
|
||||||
int maxY = rect.bottom();
|
|
||||||
|
|
||||||
int nLineCount = marker.m_listPolyline.size();
|
|
||||||
for(int i = 0; i < nLineCount; i++)
|
|
||||||
{
|
|
||||||
CRPPolyline polyLine = marker.m_listPolyline.at(i);
|
|
||||||
int type = polyLine.m_nDrawingType;
|
|
||||||
// if(polyLine.m_nDrawingType == 3)//文字
|
|
||||||
// {
|
|
||||||
// CRPText text = polyLine.m_text;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(type == 0)//直线
|
|
||||||
{
|
|
||||||
int nPointCount = polyLine.m_listPoint.size();
|
|
||||||
for(int j = 0; j < nPointCount; j++)
|
|
||||||
{
|
|
||||||
double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY;
|
|
||||||
double y = ((0 - (polyLine.m_listPoint.at(j).y() - minY))+(maxY-minY))/(double)M_IDPMM*MMPIXELY;
|
|
||||||
QPointF point(x,y);
|
|
||||||
|
|
||||||
if(j == 0)
|
|
||||||
{
|
|
||||||
painterPath.moveTo(point);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painterPath.lineTo(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(type == 1)//位图
|
|
||||||
{
|
|
||||||
bitmapInfo = polyLine.m_bitmapInfo;
|
|
||||||
int x = bitmapInfo.m_ptAbPostLU.x();
|
|
||||||
int y = bitmapInfo.m_ptAbPostLU.y();
|
|
||||||
|
|
||||||
int nx = (x - minX)/M_IDPMM*MMPIXELY;
|
|
||||||
int ny = ((0 - (y - minY))+(maxY-minY))/M_IDPMM*MMPIXELY;
|
|
||||||
|
|
||||||
bitmapInfo.m_ptAbPostLU.setX(nx);
|
|
||||||
bitmapInfo.m_ptAbPostLU.setY(ny);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(painterPath.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug()<<"painterPath.isEmpty";
|
|
||||||
}
|
|
||||||
|
|
||||||
//将路径画在picture上
|
|
||||||
QPicture pic;
|
|
||||||
QPen pen;
|
|
||||||
pen.setWidth(1);//设置笔号
|
|
||||||
pen.setColor(QColor(Qt::black));
|
|
||||||
|
|
||||||
QPainter painter;
|
|
||||||
painter.begin(&pic);
|
|
||||||
painter.setPen(pen);
|
|
||||||
painter.drawPath(painterPath);
|
|
||||||
if(bitmapInfo.m_iBytes > 0)//有位图
|
|
||||||
{
|
|
||||||
//bitmapInfo.m_pBitmap.save("D:\\1.bmp");
|
|
||||||
painter.drawPixmap(bitmapInfo.m_ptAbPostLU.x(),bitmapInfo.m_ptAbPostLU.y(),bitmapInfo.m_pBitmap);
|
|
||||||
}
|
|
||||||
painter.end();
|
|
||||||
m_picture = pic;
|
|
||||||
|
|
||||||
// 外矩形
|
|
||||||
m_boundingRect = m_picture.boundingRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyGraphicsItem::creatPicture(QPixmap pixmap)
|
|
||||||
{
|
|
||||||
//将图片画在picture上
|
|
||||||
QPicture pic;
|
|
||||||
QPen pen;
|
|
||||||
pen.setWidth(1);//设置笔号
|
|
||||||
pen.setColor(QColor(Qt::black));
|
|
||||||
|
|
||||||
QPainter painter;
|
|
||||||
painter.begin(&pic);
|
|
||||||
painter.setPen(pen);
|
|
||||||
painter.drawPixmap(0,0,pixmap);
|
|
||||||
painter.end();
|
|
||||||
m_picture = pic;
|
|
||||||
|
|
||||||
// 外矩形
|
|
||||||
m_boundingRect = m_picture.boundingRect();
|
|
||||||
}
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "machine/bmp/creatprintbmp.h"
|
#include "machine/bmp/creatprintbmp.h"
|
||||||
#include "datafile/hpgl/importhpgl.h"
|
#include "datafile/view/drawdata.h"
|
||||||
|
|
||||||
class MyGraphicsItem : public QObject, public QGraphicsItem
|
class MyGraphicsItem : public QObject, public QGraphicsItem
|
||||||
{
|
{
|
||||||
@ -29,9 +29,6 @@ public:
|
|||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget = 0);
|
QWidget *widget = 0);
|
||||||
|
|
||||||
void creatPicture(Marker marker);
|
|
||||||
void creatPicture(QPixmap pixmap);
|
|
||||||
|
|
||||||
protected: //事件
|
protected: //事件
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
@ -39,13 +36,19 @@ protected: //事件
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPicture m_picture;
|
QPicture m_picture;
|
||||||
|
QPainterPath m_drawPath;
|
||||||
QPixmap m_blockPixmap;
|
QPixmap m_blockPixmap;
|
||||||
QPoint m_point;
|
QPoint m_point;
|
||||||
QRectF m_boundingRect;//返回形状
|
QRectF m_boundingRect;//返回形状
|
||||||
|
int m_fileType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
QPicture getPictureByDat(Marker marker,int penWidth = 1);
|
||||||
|
QPicture getPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
||||||
|
QPainterPath getDrawPath();
|
||||||
void setPicture(QPicture pic);
|
void setPicture(QPicture pic);
|
||||||
|
void setPaintPath(QPainterPath path);
|
||||||
|
void setPaintPathAndPic(QPainterPath path,QPicture pic);
|
||||||
void reflushBlockPos(QPoint p);//更显打印块位置
|
void reflushBlockPos(QPoint p);//更显打印块位置
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -29,19 +29,18 @@ void MyGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|||||||
return QGraphicsScene::mouseReleaseEvent(mouseEvent);
|
return QGraphicsScene::mouseReleaseEvent(mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsScene::createScene(Marker marker)
|
void MyGraphicsScene::createScenePathAndPic(QPainterPath path, QPicture pic)
|
||||||
{
|
{
|
||||||
m_myGraphicsItem->creatPicture(marker);
|
if(m_myGraphicsItem != NULL)
|
||||||
//绘制留边
|
{
|
||||||
this->setSceneRect(0,0,m_myGraphicsItem->boundingRect().width()+DRAWMARGINS,m_myGraphicsItem->boundingRect().height()+DRAWMARGINS);
|
this->clear();
|
||||||
//如果scene未超过graphicsView的范围,图形就是居中显示的
|
m_myGraphicsItem->setPaintPathAndPic(path,pic);
|
||||||
this->addItem(m_myGraphicsItem);
|
this->addItem(m_myGraphicsItem);
|
||||||
m_myGraphicsItem->moveBy(DRAWMARGINS/2.0,DRAWMARGINS/2.0);//item居中显示
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsScene::createScene(QPixmap pixmap)
|
void MyGraphicsScene::addItemToScene()
|
||||||
{
|
{
|
||||||
m_myGraphicsItem->creatPicture(pixmap);
|
|
||||||
//绘制留边
|
//绘制留边
|
||||||
this->setSceneRect(0,0,m_myGraphicsItem->boundingRect().width()+DRAWMARGINS,m_myGraphicsItem->boundingRect().height()+DRAWMARGINS);
|
this->setSceneRect(0,0,m_myGraphicsItem->boundingRect().width()+DRAWMARGINS,m_myGraphicsItem->boundingRect().height()+DRAWMARGINS);
|
||||||
//如果scene未超过graphicsView的范围,图形就是居中显示的
|
//如果scene未超过graphicsView的范围,图形就是居中显示的
|
||||||
@ -57,25 +56,56 @@ void MyGraphicsScene::cleanScene()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPicture MyGraphicsScene::getPicture(Marker marker,int penWidth)
|
QPicture MyGraphicsScene::getPictureByDat(Marker marker,int penWidth)
|
||||||
{
|
{
|
||||||
QPicture pic;
|
QPicture pic;
|
||||||
if(m_myGraphicsItem != NULL)
|
if(m_myGraphicsItem != NULL)
|
||||||
{
|
{
|
||||||
pic = m_myGraphicsItem->getPicture(marker,penWidth);
|
pic = m_myGraphicsItem->getPictureByDat(marker,penWidth);
|
||||||
}
|
}
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsScene::swithScene(QPicture pic)
|
QPicture MyGraphicsScene::getPictureByBmp(QPixmap pixmap,int penWidth)
|
||||||
|
{
|
||||||
|
QPicture pic;
|
||||||
|
if(m_myGraphicsItem != NULL)
|
||||||
|
{
|
||||||
|
pic = m_myGraphicsItem->getPictureByBmp(pixmap,penWidth);
|
||||||
|
}
|
||||||
|
return pic;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath MyGraphicsScene::getDrawPath()
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
if(m_myGraphicsItem != NULL)
|
||||||
|
{
|
||||||
|
path = m_myGraphicsItem->getDrawPath();
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyGraphicsScene::swithSceneByPic(QPicture pic)
|
||||||
{
|
{
|
||||||
if(m_myGraphicsItem != NULL)
|
if(m_myGraphicsItem != NULL)
|
||||||
{
|
{
|
||||||
|
this->clear();
|
||||||
m_myGraphicsItem->setPicture(pic);
|
m_myGraphicsItem->setPicture(pic);
|
||||||
this->addItem(m_myGraphicsItem);
|
this->addItem(m_myGraphicsItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyGraphicsScene::swithSceneByPath(QPainterPath path)
|
||||||
|
{
|
||||||
|
if(m_myGraphicsItem != NULL)
|
||||||
|
{
|
||||||
|
this->clear();
|
||||||
|
m_myGraphicsItem->setPaintPath(path);
|
||||||
|
this->addItem(m_myGraphicsItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyGraphicsScene::ReflushBlockScene(QPoint p)
|
void MyGraphicsScene::ReflushBlockScene(QPoint p)
|
||||||
{
|
{
|
||||||
if(m_myGraphicsItem != NULL)
|
if(m_myGraphicsItem != NULL)
|
||||||
|
@ -23,11 +23,14 @@ private:
|
|||||||
MyGraphicsItem *m_myGraphicsItem;
|
MyGraphicsItem *m_myGraphicsItem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createScene(Marker marker);
|
void createScenePathAndPic(QPainterPath path,QPicture pic);
|
||||||
void createScene(QPixmap pixmap);
|
void addItemToScene();
|
||||||
void cleanScene();
|
void cleanScene();
|
||||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
QPicture getPictureByDat(Marker marker,int penWidth = 1);
|
||||||
void swithScene(QPicture pic);
|
QPicture getPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
||||||
|
QPainterPath getDrawPath();
|
||||||
|
void swithSceneByPic(QPicture pic);
|
||||||
|
void swithSceneByPath(QPainterPath path);
|
||||||
void ReflushBlockScene(QPoint p);
|
void ReflushBlockScene(QPoint p);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -120,8 +120,12 @@ void MyGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
QPoint viewPoint = event->pos();
|
QPoint viewPoint = event->pos();
|
||||||
//QGraphicsScene坐标
|
//QGraphicsScene坐标
|
||||||
QPointF scenePoint = mapToScene(viewPoint);
|
QPointF scenePoint = mapToScene(viewPoint);
|
||||||
double x = scenePoint.x() / MMPIXELY;
|
// double x = scenePoint.x() / MMPIXELY;
|
||||||
double y = abs(abs(scenePoint.y()) - m_scene->itemsBoundingRect().height()) / MMPIXELY;
|
// double y = abs(abs(scenePoint.y()) - m_scene->itemsBoundingRect().height()) / MMPIXELY;
|
||||||
|
|
||||||
|
double x = (scenePoint.x() - DRAWMARGINS/2.0) / MMPIXELY;
|
||||||
|
double y = (m_scene->itemsBoundingRect().height() - scenePoint.y() + DRAWMARGINS/2.0) / MMPIXELY;
|
||||||
|
|
||||||
scenePoint.setX(x);
|
scenePoint.setX(x);
|
||||||
scenePoint.setY(y);
|
scenePoint.setY(y);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@ -179,31 +183,47 @@ void MyGraphicsView::wheelEvent(QWheelEvent *event)
|
|||||||
verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
|
verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPicture MyGraphicsView::getPicture(Marker marker,int penWidth)
|
QPicture MyGraphicsView::getPictureByDat(Marker marker,int penWidth)
|
||||||
{
|
{
|
||||||
QPicture pic;
|
QPicture pic;
|
||||||
if(m_scene != NULL)
|
if(m_scene != NULL)
|
||||||
{
|
{
|
||||||
pic = m_scene->getPicture(marker,penWidth);
|
pic = m_scene->getPictureByDat(marker,penWidth);
|
||||||
|
m_scene->addItemToScene();
|
||||||
|
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||||
|
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsView::creatView(Marker marker)
|
QPicture MyGraphicsView::getPictureByBmp(QPixmap pixmap,int penWidth)
|
||||||
{
|
{
|
||||||
|
QPicture pic;
|
||||||
if(m_scene != NULL)
|
if(m_scene != NULL)
|
||||||
{
|
{
|
||||||
m_scene->createScene(marker);
|
pic = m_scene->getPictureByBmp(pixmap,penWidth);
|
||||||
|
m_scene->addItemToScene();
|
||||||
QRectF rectItem = m_scene->itemsBoundingRect();
|
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||||
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsView::creatView(QPixmap pixmap)
|
QPainterPath MyGraphicsView::getDrawPath()
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
if(m_scene != NULL)
|
||||||
|
{
|
||||||
|
path = m_scene->getDrawPath();
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyGraphicsView::creatViewPathAndPic(QPainterPath path,QPicture pic)
|
||||||
{
|
{
|
||||||
if(m_scene != NULL)
|
if(m_scene != NULL)
|
||||||
{
|
{
|
||||||
m_scene->createScene(pixmap);
|
m_scene->createScenePathAndPic(path,pic);
|
||||||
QRectF rectItem = m_scene->itemsBoundingRect();
|
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||||
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
@ -221,11 +241,21 @@ void MyGraphicsView::cleanView()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGraphicsView::swithView(QPicture pic)
|
void MyGraphicsView::swithViewByPic(QPicture pic)
|
||||||
{
|
{
|
||||||
if(m_scene != NULL)
|
if(m_scene != NULL)
|
||||||
{
|
{
|
||||||
m_scene->swithScene(pic);
|
m_scene->swithSceneByPic(pic);
|
||||||
|
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||||
|
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyGraphicsView::swithViewByPath(QPainterPath path)
|
||||||
|
{
|
||||||
|
if(m_scene != NULL)
|
||||||
|
{
|
||||||
|
m_scene->swithSceneByPath(path);
|
||||||
QRectF rectItem = m_scene->itemsBoundingRect();
|
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||||
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,13 @@ protected:
|
|||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
QPicture getPictureByDat(Marker marker,int penWidth = 1);
|
||||||
void creatView(Marker marker);
|
QPicture getPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
||||||
void creatView(QPixmap pixmap);
|
QPainterPath getDrawPath();
|
||||||
|
void creatViewPathAndPic(QPainterPath path,QPicture pic);
|
||||||
void cleanView();
|
void cleanView();
|
||||||
void swithView(QPicture pic);
|
void swithViewByPic(QPicture pic);
|
||||||
|
void swithViewByPath(QPainterPath path);
|
||||||
void reflushBlockView(QPoint p);
|
void reflushBlockView(QPoint p);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -8,9 +8,90 @@ DrawingSetDialog::DrawingSetDialog(QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowModality(Qt::ApplicationModal);
|
setWindowModality(Qt::ApplicationModal);
|
||||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||||
|
|
||||||
|
QIntValidator *validator1 = new QIntValidator(1, 10, this);
|
||||||
|
ui->lineEdit_lineWidth->setValidator(validator1);
|
||||||
|
|
||||||
|
QIntValidator *validator2 = new QIntValidator(50, 3030, this);
|
||||||
|
ui->lineEdit_paperWidth->setValidator(validator2);
|
||||||
|
|
||||||
|
QIntValidator *validator3 = new QIntValidator(0, 1300, this);
|
||||||
|
ui->lineEdit_right->setValidator(validator3);
|
||||||
|
|
||||||
|
QIntValidator *validator4 = new QIntValidator(0, 500, this);
|
||||||
|
ui->lineEdit_mark->setValidator(validator4);
|
||||||
|
|
||||||
|
QIntValidator *validator5 = new QIntValidator(20, 1000, this);
|
||||||
|
ui->lineEdit_butt->setValidator(validator5);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawingSetDialog::~DrawingSetDialog()
|
DrawingSetDialog::~DrawingSetDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawingSetDialog::refreshLanguage()
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawingSetDialog::refreshConfigPara(QString filePath)
|
||||||
|
{
|
||||||
|
m_configfile = filePath;
|
||||||
|
QSettings settings(filePath, QSettings::IniFormat);
|
||||||
|
|
||||||
|
bool rotate90 = settings.value("DrawSet/rotate90").toBool();//是否正向旋转90度
|
||||||
|
bool vecfont = settings.value("DrawSet/vecfont").toBool();//是否使用矢量字体
|
||||||
|
QString lineWidth = settings.value("DrawSet/linewidth").toString();//线宽
|
||||||
|
QString paperWidth = settings.value("DrawSet/paperwidth").toString();//纸张宽度
|
||||||
|
QString rightMargin = settings.value("DrawSet/rightmargin").toString();//右边距
|
||||||
|
QString markMargin = settings.value("DrawSet/markmargin").toString();//马克间距
|
||||||
|
QString buttMargin = settings.value("DrawSet/buttmargin").toString();//对接符间距
|
||||||
|
|
||||||
|
ui->checkBox_angle->setChecked(rotate90);
|
||||||
|
ui->checkBox_font->setChecked(vecfont);
|
||||||
|
ui->lineEdit_lineWidth->setText(lineWidth);
|
||||||
|
ui->lineEdit_paperWidth->setText(paperWidth);
|
||||||
|
ui->lineEdit_right->setText(rightMargin);
|
||||||
|
ui->lineEdit_mark->setText(markMargin);
|
||||||
|
ui->lineEdit_butt->setText(buttMargin);
|
||||||
|
}
|
||||||
|
|
||||||
|
double DrawingSetDialog::getRotateAngle()
|
||||||
|
{
|
||||||
|
double angle = 0;
|
||||||
|
bool bl = ui->checkBox_angle->isChecked();
|
||||||
|
if(bl == true)
|
||||||
|
{
|
||||||
|
angle = 270;
|
||||||
|
}
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawingSetDialog::on_pushButton_cancel_clicked()
|
||||||
|
{
|
||||||
|
done(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawingSetDialog::on_pushButton_ok_clicked()
|
||||||
|
{
|
||||||
|
QSettings settings(m_configfile, QSettings::IniFormat);
|
||||||
|
|
||||||
|
int rotate90 = ui->checkBox_angle->isChecked();//是否正向旋转90度
|
||||||
|
int vecfont = ui->checkBox_font->isChecked();//是否使用矢量字体
|
||||||
|
QString lineWidth = ui->lineEdit_lineWidth->text();//线宽
|
||||||
|
QString paperWidth = ui->lineEdit_paperWidth->text();//纸张宽度
|
||||||
|
QString rightMargin = ui->lineEdit_right->text();//右边距
|
||||||
|
QString markMargin = ui->lineEdit_mark->text();//马克间距
|
||||||
|
QString buttMargin = ui->lineEdit_butt->text();//对接符间距
|
||||||
|
|
||||||
|
settings.setValue("DrawSet/rotate90",rotate90);
|
||||||
|
settings.setValue("DrawSet/vecfont",vecfont);
|
||||||
|
settings.setValue("DrawSet/linewidth",lineWidth);
|
||||||
|
settings.setValue("DrawSet/paperwidth",paperWidth);
|
||||||
|
settings.setValue("DrawSet/rightmargin",rightMargin);
|
||||||
|
settings.setValue("DrawSet/markmargin",markMargin);
|
||||||
|
settings.setValue("DrawSet/buttmargin",buttMargin);
|
||||||
|
|
||||||
|
done(1);
|
||||||
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define DRAWINGSETDIALOG_H
|
#define DRAWINGSETDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DrawingSetDialog;
|
class DrawingSetDialog;
|
||||||
@ -14,9 +16,18 @@ class DrawingSetDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit DrawingSetDialog(QWidget *parent = 0);
|
explicit DrawingSetDialog(QWidget *parent = 0);
|
||||||
~DrawingSetDialog();
|
~DrawingSetDialog();
|
||||||
|
void refreshLanguage();
|
||||||
|
void refreshConfigPara(QString filePath);//刷新配置参数
|
||||||
|
double getRotateAngle();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_cancel_clicked();
|
||||||
|
void on_pushButton_ok_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DrawingSetDialog *ui;
|
Ui::DrawingSetDialog *ui;
|
||||||
|
QString m_configfile;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DRAWINGSETDIALOG_H
|
#endif // DRAWINGSETDIALOG_H
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use vector fonts</string>
|
<string extracomment="使用矢量字体">Use vector fonts</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox" name="checkBox_angle">
|
<widget class="QCheckBox" name="checkBox_angle">
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Graph positive rotation angle</string>
|
<string extracomment="图形正向旋转90度">Graph positive rotation 90 angle</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_ok">
|
<widget class="QPushButton" name="pushButton_ok">
|
||||||
@ -62,7 +62,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Boundary and alignment spacing</string>
|
<string extracomment="边界及对位间距">Boundary and alignment spacing</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label_rightUnit">
|
<widget class="QLabel" name="label_rightUnit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -100,7 +100,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Right margin:</string>
|
<string extracomment="右边距:">Right margin:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_mark">
|
<widget class="QLineEdit" name="lineEdit_mark">
|
||||||
@ -139,7 +139,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mark margin:</string>
|
<string extracomment="马克间距:">Mark margin:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_butt">
|
<widget class="QLabel" name="label_butt">
|
||||||
@ -152,7 +152,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Butt joint margin:</string>
|
<string extracomment="对接符间距:">Butt joint margin:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_buttUnit">
|
<widget class="QLabel" name="label_buttUnit">
|
||||||
@ -240,13 +240,13 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Paper Width</string>
|
<string extracomment="纸张宽度">Paper Width</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label_paperWidthUnit">
|
<widget class="QLabel" name="label_paperWidthUnit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>170</x>
|
<x>170</x>
|
||||||
<y>24</y>
|
<y>28</y>
|
||||||
<width>54</width>
|
<width>54</width>
|
||||||
<height>12</height>
|
<height>12</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -259,7 +259,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>70</x>
|
<x>70</x>
|
||||||
<y>20</y>
|
<y>25</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -272,7 +272,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>20</y>
|
<y>24</y>
|
||||||
<width>42</width>
|
<width>42</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -308,26 +308,26 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Lineweight settings</string>
|
<string extracomment="线宽设置">Lineweight settings</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label_lineWidth">
|
<widget class="QLabel" name="label_lineWidth">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>20</y>
|
<y>24</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Lineweight:</string>
|
<string extracomment="线宽:">Lineweight:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_lineWidth">
|
<widget class="QLineEdit" name="lineEdit_lineWidth">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>110</x>
|
<x>110</x>
|
||||||
<y>20</y>
|
<y>24</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -340,13 +340,13 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>210</x>
|
||||||
<y>19</y>
|
<y>24</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
1089
english.ts
Normal file
1089
english.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -14,3 +14,8 @@ HistoryDialog::~HistoryDialog()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryDialog::refreshLanguage()
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
}
|
||||||
|
@ -14,6 +14,7 @@ class HistoryDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit HistoryDialog(QWidget *parent = 0);
|
explicit HistoryDialog(QWidget *parent = 0);
|
||||||
~HistoryDialog();
|
~HistoryDialog();
|
||||||
|
void refreshLanguage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::HistoryDialog *ui;
|
Ui::HistoryDialog *ui;
|
||||||
|
@ -70,15 +70,493 @@ int BWBmp::SavePrBmp(QString filename)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
这段C++代码实现了一个名为BWBmp的类的成员函数Compress,该函数的作用是对黑白位图数据进行压缩处理,以便减少喷墨绘图仪的数据传输量。按照注释所描述的压缩算法,算法主要针对的是单个墨盒(假设宽度固定为300像素)的位图数据,其高度可变,最多支持4个墨盒。
|
||||||
|
整个函数通过对图像数据进行逐行扫描,统计连续相同颜色像素的数量,并利用特殊的编码规则进行压缩,从而达到减小数据体积的目的。当遇到不适合压缩的情况时,会选择直接复制原始数据,以保证不会因压缩反而增大数据量。
|
||||||
|
|
||||||
|
为了减少喷墨绘图仪的数据传输量,对黑白位图数据进行压缩。
|
||||||
|
压缩算法如下:
|
||||||
|
|
||||||
int BWBmp::Compress(int dir)
|
每个墨盒的位图数据宽度为300像素,高度不确定,墨盒数量支持1--4个
|
||||||
|
|
||||||
|
每个字节分为两段
|
||||||
|
用属性+值 的方式表示
|
||||||
|
__________________________________________________
|
||||||
|
| bit7 bit6 | bit5 bit4 bit3 bit2 bit1 bit0 |
|
||||||
|
--------------------------------------------------
|
||||||
|
| 属性 | 值 |
|
||||||
|
--------------------------------------------------
|
||||||
|
| 0 0 | 原始数据 |
|
||||||
|
--------------------------------------------------
|
||||||
|
| 0 1 | 连续数据1的个数 |
|
||||||
|
--------------------------------------------------
|
||||||
|
| 1 0 | 连续65个数据0的个数 |
|
||||||
|
--------------------------------------------------
|
||||||
|
| 1 1 | 连续数据0的个数 |
|
||||||
|
--------------------------------------------------
|
||||||
|
*/
|
||||||
|
int BWBmp::Compress(int idx, int dir, int segWidth, int segHeight)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// qint64 startTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||||
|
// 确保dir参数正确设置为1或-1,表示读取图像数据的方向(从上到下或从下到上)。
|
||||||
|
if (dir < 0)
|
||||||
|
{
|
||||||
|
dir = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理目标压缩数据缓冲区,并检查源位图数据是否为空,若为空则返回错误码-1。
|
||||||
|
m_prDdat.clear();
|
||||||
|
if (m_bwDdat.isEmpty() == 1)
|
||||||
|
{
|
||||||
|
qDebug() << "bit dat empty";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化临时压缩数据缓冲区tmppr,并从源位图数据中获取图像的基本信息,如宽度、高度、实际占用的字节数(行字节数),并检查这些信息的有效性,如有问题则返回错误码-2。
|
||||||
|
|
||||||
|
BitmapHead * pHead = (BitmapHead *)(m_bwDdat.data());
|
||||||
|
|
||||||
|
int width = pHead->biWidth; // 文件宽度
|
||||||
|
int height = pHead->biHeight; // 文件高度
|
||||||
|
int widthBytes = (int)((width + (32-1)) / 32) * 4; // 文件每行字节数
|
||||||
|
|
||||||
|
int wsegnum = (int)((width + segWidth - 1) / segWidth); // 宽分块数量
|
||||||
|
int hsegnum = (int)((height + segHeight - 1) / segHeight); // 高分块数量
|
||||||
|
int fill = (int)((segWidth + (8-1)) / 8) * 8 - segWidth; // 分块后每行补充Bit数
|
||||||
|
int msegnum = (segWidth + fill) * segHeight; // 每块字节数
|
||||||
|
|
||||||
|
if (0)
|
||||||
|
{
|
||||||
|
qDebug() << "Img dir"<<dir;
|
||||||
|
qDebug() << "Img width"<<width;
|
||||||
|
qDebug() << "Img height"<<height;
|
||||||
|
qDebug() << "Img wsegnum"<<wsegnum;
|
||||||
|
qDebug() << "Img hsegnum"<<hsegnum;
|
||||||
|
qDebug() << "Img msegnum"<<msegnum;
|
||||||
|
qDebug() << "Img fill"<<fill;
|
||||||
|
qDebug() << "Img widthBytes"<<widthBytes;
|
||||||
|
qDebug() << "Img bitDatOffset"<<pHead->bitDatOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widthBytes <= 0 || height < 1 || width > 0x1000000)
|
||||||
|
{
|
||||||
|
qDebug() << "bit dat error";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned char * pBitDatBeg = (unsigned char *)(m_bwDdat.data() + pHead->bitDatOffset);
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// 读取位图信息,对数组赋值
|
||||||
|
unsigned char sta,tmpdat,mod;
|
||||||
|
const unsigned char * pBitDat;
|
||||||
|
int i, j, k, l, m, n;
|
||||||
|
int addr;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
//------------------------------------
|
||||||
|
int * segdat = new int [msegnum];
|
||||||
|
|
||||||
|
//------------------------------------
|
||||||
|
unsigned char tgtdat;
|
||||||
|
QVector<unsigned char> compType(wsegnum); // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩(分段压缩);
|
||||||
|
QVector<unsigned int> compSegOffset(wsegnum); // 分段数据起始位置
|
||||||
|
|
||||||
|
if (dir < 0) // 反向
|
||||||
|
{
|
||||||
|
pBitDatBeg += widthBytes * (height -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < wsegnum; i++)
|
||||||
|
{// 分块
|
||||||
|
addr = m_prDdat.size(); // 压缩前的字节数
|
||||||
|
compType[i] = 1; // 按字节压缩(分段压缩);
|
||||||
|
compSegOffset[i] = m_prDdat.size(); // 数据地址
|
||||||
|
|
||||||
|
if (1)
|
||||||
|
{
|
||||||
|
for (j = 0; j < hsegnum; j++)
|
||||||
|
{// 分块
|
||||||
|
if (dir > 0) // 正向
|
||||||
|
{
|
||||||
|
y = j * segHeight; // 起始坐标点 Y
|
||||||
|
m = 0; // 分割后数组的索引
|
||||||
|
|
||||||
|
for (l = 0; l < segHeight; l++,y++)
|
||||||
|
{// Y扫描
|
||||||
|
|
||||||
|
x = i * segWidth; // 起始坐标点 X
|
||||||
|
|
||||||
|
for (k = 0; k < segWidth; k++,x++)
|
||||||
|
{// x扫描赋值
|
||||||
|
if ((x < width) && (y < height))
|
||||||
|
{// 采集当前点数据
|
||||||
|
pBitDat = pBitDatBeg + (widthBytes * (height-y-1)) + (x / 8);
|
||||||
|
|
||||||
|
tmpdat = *pBitDat;
|
||||||
|
mod = 0x80 >> (x % 8);
|
||||||
|
if ((tmpdat & mod) == 0)
|
||||||
|
{
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sta = 1;
|
||||||
|
// qDebug() << "x =" << x << ",y =" << y
|
||||||
|
// << ",[i =" << i << ",j =" << j
|
||||||
|
// << ",l =" << l << ",k =" << k
|
||||||
|
// << ",m =" << m << "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// X,Y超出最大范围后,使用默认值:0
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < fill; k++)
|
||||||
|
{// x结尾处 字节对齐
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else//if (dir > 0)
|
||||||
|
{// 反向
|
||||||
|
y = (hsegnum - j) * segHeight - 1; // 起始坐标点 Y
|
||||||
|
m = 0; // 分割后数组的索引
|
||||||
|
|
||||||
|
for (l = 0; l < segHeight; l++,y--)
|
||||||
|
{// Y反向扫描
|
||||||
|
x = i * segWidth; // 起始坐标点 X
|
||||||
|
|
||||||
|
for (k = 0; k < segWidth; k++,x++)
|
||||||
|
{// x扫描赋值
|
||||||
|
if ((x < width) && (y < height))
|
||||||
|
{// 采集当前点数据
|
||||||
|
pBitDat = pBitDatBeg - (widthBytes * y) + (x / 8);
|
||||||
|
|
||||||
|
tmpdat = *pBitDat;
|
||||||
|
mod = 0x80 >> (x % 8);
|
||||||
|
if ((tmpdat & mod) == 0)
|
||||||
|
{
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sta = 1;
|
||||||
|
// qDebug() << "x =" << x << ",y =" << y
|
||||||
|
// << ",[i =" << i << ",j =" << j
|
||||||
|
// << ",l =" << l << ",k =" << k
|
||||||
|
// << "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// X,Y超出最大范围后,使用默认值:0
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < fill; k++)
|
||||||
|
{// x结尾处 字节对齐
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// 对数据进行压缩
|
||||||
|
for (k = 0; k < msegnum; k = l)
|
||||||
|
{
|
||||||
|
n = 0; // 连续的个数
|
||||||
|
sta = segdat[k]; // 前一次的状态
|
||||||
|
tgtdat = 0;
|
||||||
|
|
||||||
|
// 求连续相同状态的个数
|
||||||
|
for (l = k; l < msegnum; l++)
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
if (n <= 6)
|
||||||
|
{// 预先计算原始数据
|
||||||
|
tgtdat <<= 1;
|
||||||
|
|
||||||
|
if (segdat[l] != 0)
|
||||||
|
{
|
||||||
|
tgtdat |= 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == 6)
|
||||||
|
{// 判断前六个位图是否相同
|
||||||
|
if (((sta == 0) && (tgtdat != 0)) ||
|
||||||
|
((sta != 0) && (tgtdat != 0x3f)) ||
|
||||||
|
0)
|
||||||
|
{
|
||||||
|
l++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else// if (n > 6)
|
||||||
|
{
|
||||||
|
if (segdat[l] != sta)
|
||||||
|
{
|
||||||
|
n--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sta == 0)
|
||||||
|
{// 连续0 (最多 4160)
|
||||||
|
if (n == 4160)
|
||||||
|
{
|
||||||
|
l++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// 连续1 (最多64)
|
||||||
|
if (n == 64)
|
||||||
|
{
|
||||||
|
l++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ;n<6;n++)
|
||||||
|
{// 原始位图时,如果结尾不足6位,低位补零
|
||||||
|
tgtdat <<= 1;
|
||||||
|
// qDebug() << "for ( ;n<6;n++) n =" << n << ",l =" << l ;
|
||||||
|
}
|
||||||
|
|
||||||
|
{// 生成压缩数据
|
||||||
|
if (n == 6)
|
||||||
|
{
|
||||||
|
m_prDdat.append(tgtdat); // 添加原始位图数据
|
||||||
|
}
|
||||||
|
else if (sta == 0)
|
||||||
|
{
|
||||||
|
if (n <= 64)
|
||||||
|
{
|
||||||
|
tgtdat = 0xC0 | (n & 0x3f);
|
||||||
|
m_prDdat.append(tgtdat); // 添加连续数据0的个数数据
|
||||||
|
}
|
||||||
|
else if (n == 4160)
|
||||||
|
{
|
||||||
|
tgtdat = 0x80;
|
||||||
|
m_prDdat.append(tgtdat); // 添加连续 65 个数据0的个数数据
|
||||||
|
}
|
||||||
|
else // (64 < n < 4160)
|
||||||
|
{
|
||||||
|
tgtdat = 0x80 | (n / 65);
|
||||||
|
m_prDdat.append(tgtdat); // 添加连续 65 个数据0的个数数据
|
||||||
|
|
||||||
|
tgtdat = n % 65;
|
||||||
|
if (tgtdat != 0)
|
||||||
|
{
|
||||||
|
tgtdat = 0xC0 | tgtdat;
|
||||||
|
m_prDdat.append(tgtdat); // 添加连续数据0的个数数据
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // if (sta == 1)
|
||||||
|
{
|
||||||
|
tgtdat = 0x40 | (n & 0x3f);
|
||||||
|
m_prDdat.append(tgtdat); // 添加 连续数据1的个数 数据
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // for (j = 0; j < hsegnum; j++)
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// 判断压缩后的数据是否比压缩前的小
|
||||||
|
if ((m_prDdat.size() - addr) > (msegnum * hsegnum / 7))
|
||||||
|
{// 使用原始数据
|
||||||
|
m_prDdat.truncate(addr); // 删除当前段的压缩数据
|
||||||
|
compType[i] = 0; // 不压缩,使用原始数据;
|
||||||
|
|
||||||
|
for (j = 0; j < hsegnum; j++)
|
||||||
|
{// 分块
|
||||||
|
if (dir > 0) // 正向
|
||||||
|
{
|
||||||
|
y = j * segHeight; // 起始坐标点 Y
|
||||||
|
m = 0; // 分割后数组的索引
|
||||||
|
|
||||||
|
for (l = 0; l < segHeight; l++,y++)
|
||||||
|
{// Y扫描
|
||||||
|
|
||||||
|
x = i * segWidth; // 起始坐标点 X
|
||||||
|
|
||||||
|
for (k = 0; k < segWidth; k++,x++)
|
||||||
|
{// x扫描赋值
|
||||||
|
if ((x < width) && (y < height))
|
||||||
|
{// 采集当前点数据
|
||||||
|
pBitDat = pBitDatBeg + (widthBytes * (height-y-1)) + (x / 8);
|
||||||
|
|
||||||
|
tmpdat = *pBitDat;
|
||||||
|
mod = 0x80 >> (x % 8);
|
||||||
|
if ((tmpdat & mod) == 0)
|
||||||
|
{
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sta = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// X,Y超出最大范围后,使用默认值:0
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < fill; k++)
|
||||||
|
{// x结尾处 字节对齐
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else//if (dir > 0)
|
||||||
|
{// 反向
|
||||||
|
y = (hsegnum - j) * segHeight - 1; // 起始坐标点 Y
|
||||||
|
m = 0; // 分割后数组的索引
|
||||||
|
|
||||||
|
for (l = 0; l < segHeight; l++,y--)
|
||||||
|
{// Y反向扫描
|
||||||
|
x = i * segWidth; // 起始坐标点 X
|
||||||
|
|
||||||
|
for (k = 0; k < segWidth; k++,x++)
|
||||||
|
{// x扫描赋值
|
||||||
|
if ((x < width) && (y < height))
|
||||||
|
{// 采集当前点数据
|
||||||
|
pBitDat = pBitDatBeg - (widthBytes * y) + (x / 8);
|
||||||
|
|
||||||
|
tmpdat = *pBitDat;
|
||||||
|
mod = 0x80 >> (x % 8);
|
||||||
|
if ((tmpdat & mod) == 0)
|
||||||
|
{
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sta = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// X,Y超出最大范围后,使用默认值:0
|
||||||
|
sta = 0;
|
||||||
|
}
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < fill; k++)
|
||||||
|
{// x结尾处 字节对齐
|
||||||
|
segdat[m++] = sta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成原始数据
|
||||||
|
n = 0;
|
||||||
|
for (m = 0; m < msegnum; m++)
|
||||||
|
{
|
||||||
|
tgtdat <<= 1;
|
||||||
|
if (segdat[m] != 0)
|
||||||
|
{
|
||||||
|
tgtdat |= 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
n++;
|
||||||
|
if ((n % 8) == 0)
|
||||||
|
{
|
||||||
|
m_prDdat.append(tgtdat); // 添加 连续数据1的个数 数据
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} // for (i = 0; i < wsegnum; i++)
|
||||||
|
|
||||||
|
// qint64 time1 = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||||
|
// qDebug() << "time1:" << time1 - startTime;
|
||||||
|
|
||||||
|
delete []segdat;
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// 构造压缩位图头部信息CompBmpHead,包含块索引、压缩方向、压缩类型以及压缩后的数据大小等信息。
|
||||||
|
// 添加文件头
|
||||||
|
CompBmpHead prHead;
|
||||||
|
memset(&prHead, 0, sizeof(CompBmpHead));
|
||||||
|
|
||||||
|
prHead.fileId = 0; // 整个位图文件标识
|
||||||
|
prHead.blkIdx = idx; // 当前位图块号(位图分块后的编号)
|
||||||
|
prHead.datSize = m_prDdat.size(); // 本块位图数据区的大小(字节数)
|
||||||
|
prHead.biHeight = segHeight * hsegnum; // 本块位图有效宽度,以像素为单位
|
||||||
|
prHead.biWidth = segWidth * wsegnum; // 本块位图有效高度,以像素为单位
|
||||||
|
prHead.dataChecksum = 0; // 本块位图数据累加校验和
|
||||||
|
|
||||||
|
if (dir < 0) // 本块位图压缩方向, =0, 从上到下; =1, 从下到上;(喷墨方向)
|
||||||
|
{
|
||||||
|
prHead.compDir = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prHead.compDir = 0;
|
||||||
|
}
|
||||||
|
prHead.compSegWidth = segWidth; // 分段宽度(0,默认整个宽度,分段宽度必须能被本块位图有效宽度整除)
|
||||||
|
prHead.compSegHeight = segHeight; // 分段高度(0,默认1行的高度)
|
||||||
|
prHead.compFillWidth = fill; // 压缩填充位数
|
||||||
|
|
||||||
|
for (i=0;i<4;i++)
|
||||||
|
{
|
||||||
|
if (i < wsegnum)
|
||||||
|
{
|
||||||
|
prHead.compType[i] = compType[i]; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩(分段压缩);
|
||||||
|
prHead.compSegOffset[i] = compSegOffset[i]; // 分段数据起始位置
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// {// 打印压缩数据
|
||||||
|
// j = m_prDdat.size();
|
||||||
|
// const unsigned char * pPrint = (unsigned char *)(m_prDdat.data());
|
||||||
|
|
||||||
|
// for (i=0;i<j;i++)
|
||||||
|
// {
|
||||||
|
// tmpdat = *pPrint++;
|
||||||
|
|
||||||
|
// qDebug() << "addr =" << i << ",dat =" << tmpdat;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
m_prDdat.insert(0,(char*)(&prHead),sizeof(CompBmpHead)); // 插入文件头
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray BWBmp::getPrBmpDat()
|
||||||
|
{
|
||||||
|
return m_prDdat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
这段C++代码实现了一个名为BWBmp的类的成员函数Compress,该函数的作用是对黑白位图数据进行压缩处理,以便减少喷墨绘图仪的数据传输量。按照注释所描述的压缩算法,算法主要针对的是单个墨盒(假设宽度固定为300像素)的位图数据,其高度可变,最多支持4个墨盒。
|
||||||
|
整个函数通过对图像数据进行逐行扫描,统计连续相同颜色像素的数量,并利用特殊的编码规则进行压缩,从而达到减小数据体积的目的。当遇到不适合压缩的情况时,会选择直接复制原始数据,以保证不会因压缩反而增大数据量。
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
为了减少喷墨绘图仪的数据传输量,对黑白位图数据进行压缩。
|
为了减少喷墨绘图仪的数据传输量,对黑白位图数据进行压缩。
|
||||||
压缩算法如下:
|
压缩算法如下:
|
||||||
|
|
||||||
每个墨盒的位图数据宽度为300像素,高度不确定
|
每个墨盒的位图数据宽度为300像素,高度不确定,墨盒数量支持1--4个
|
||||||
|
|
||||||
每个字节分为两段
|
每个字节分为两段
|
||||||
用属性+值 的方式表示
|
用属性+值 的方式表示
|
||||||
@ -96,7 +574,11 @@ int BWBmp::Compress(int dir)
|
|||||||
| 1 1 | 连续数据0的个数 |
|
| 1 1 | 连续数据0的个数 |
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
int Compress_Bak(int idx, int dir)
|
||||||
|
{
|
||||||
|
|
||||||
|
// 确保dir参数正确设置为1或-1,表示读取图像数据的方向(从上到下或从下到上)。
|
||||||
if (dir < 0)
|
if (dir < 0)
|
||||||
{
|
{
|
||||||
dir = -1;
|
dir = -1;
|
||||||
@ -106,6 +588,7 @@ int BWBmp::Compress(int dir)
|
|||||||
dir = 1;
|
dir = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清理目标压缩数据缓冲区,并检查源位图数据是否为空,若为空则返回错误码-1。
|
||||||
m_prDdat.clear();
|
m_prDdat.clear();
|
||||||
if (m_bwDdat.isEmpty() == 1)
|
if (m_bwDdat.isEmpty() == 1)
|
||||||
{
|
{
|
||||||
@ -113,6 +596,10 @@ int BWBmp::Compress(int dir)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化临时压缩数据缓冲区tmppr,并从源位图数据中获取图像的基本信息,如宽度、高度、实际占用的字节数(行字节数),并检查这些信息的有效性,如有问题则返回错误码-2。
|
||||||
|
QByteArray tmppr;
|
||||||
|
tmppr.clear();
|
||||||
|
|
||||||
BitmapHead * pHead = (BitmapHead *)(m_bwDdat.data());
|
BitmapHead * pHead = (BitmapHead *)(m_bwDdat.data());
|
||||||
|
|
||||||
int width = pHead->biWidth;
|
int width = pHead->biWidth;
|
||||||
@ -125,15 +612,25 @@ int BWBmp::Compress(int dir)
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char * pBitDat = (unsigned char *)(m_bwDdat.data() + pHead->bitDatOffset);
|
qDebug() << "Img dir"<<dir;
|
||||||
|
qDebug() << "Img width"<<width;
|
||||||
|
qDebug() << "Img height"<<height;
|
||||||
|
qDebug() << "Img widthBytes"<<widthBytes;
|
||||||
|
qDebug() << "Img bitDatOffset"<<pHead->bitDatOffset;
|
||||||
|
|
||||||
|
const unsigned char * pBitDatBeg = (unsigned char *)(m_bwDdat.data() + pHead->bitDatOffset);
|
||||||
|
|
||||||
const unsigned char * pTmpDat;
|
const unsigned char * pTmpDat;
|
||||||
|
|
||||||
|
// 按照给定的dir值定位到位图数据的起始位置。
|
||||||
if (dir == -1)
|
if (dir == -1)
|
||||||
{
|
{
|
||||||
pBitDat += widthBytes * (height -1);
|
pBitDatBeg += widthBytes * (height -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const unsigned char * pBitDat = pBitDatBeg;
|
||||||
|
|
||||||
|
// 使用一个整数数组 countBuff 来记录每行中连续的0和1的个数,初始化各种计数器。
|
||||||
int * countBuff = new int [width];
|
int * countBuff = new int [width];
|
||||||
if (countBuff == NULL)
|
if (countBuff == NULL)
|
||||||
{
|
{
|
||||||
@ -148,6 +645,7 @@ int BWBmp::Compress(int dir)
|
|||||||
int count1 = 0;
|
int count1 = 0;
|
||||||
|
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
|
|
||||||
for (i = 0; i < height; i++) // 行计数
|
for (i = 0; i < height; i++) // 行计数
|
||||||
{
|
{
|
||||||
pTmpDat = pBitDat;
|
pTmpDat = pBitDat;
|
||||||
@ -155,24 +653,20 @@ int BWBmp::Compress(int dir)
|
|||||||
count0 = 0;
|
count0 = 0;
|
||||||
count1 = 0;
|
count1 = 0;
|
||||||
|
|
||||||
|
// 遍历图像的每一行,统计当前行中连续0和1的个数,并将其存入countBuff数组。
|
||||||
for (j = 0, k = 0; (j < widthBytes) && (k < width); j++) // 行内扫描,检测出每段连续0和1的个数
|
for (j = 0, k = 0; (j < widthBytes) && (k < width); j++) // 行内扫描,检测出每段连续0和1的个数
|
||||||
{
|
{
|
||||||
tmpdat = *pTmpDat++;
|
tmpdat = *pTmpDat++;
|
||||||
// if(j+i*widthBytes > 12879)
|
|
||||||
// {
|
|
||||||
//qDebug()<<j+i*widthBytes<<" "<<tmpdat;
|
//qDebug()<<j+i*widthBytes<<" "<<tmpdat;
|
||||||
// }
|
|
||||||
|
|
||||||
//mod = 0x80;
|
mod = 0x80;
|
||||||
mod = 0x01;
|
|
||||||
|
|
||||||
if((width - k) <= 8)
|
if((width - k) <= 8)
|
||||||
{
|
{
|
||||||
tmpdat = tmpdat >> (8 - (width - k ));
|
// tmpdat = tmpdat >> (8 - (width - k ));
|
||||||
}
|
}
|
||||||
|
|
||||||
//for (mod = 0x80; (mod != 0) && (k < width); k++, mod /= 2)
|
for (mod = 0x80; (mod != 0) && (k < width); k++, mod /= 2)
|
||||||
for (mod = 0x01; (mod != 0) && (k < width); k++, mod *= 2)
|
|
||||||
{
|
{
|
||||||
if ((tmpdat & mod) == 0)
|
if ((tmpdat & mod) == 0)
|
||||||
{
|
{
|
||||||
@ -216,6 +710,7 @@ int BWBmp::Compress(int dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 对countBuff中的数据进行分析和编码,生成压缩数据并追加到tmppr中。根据算法描述,压缩数据是以每个字节的高两位作为“属性”位,低六位作为“值”位来表示连续0或1的个数,或者直接存放原始数据。
|
||||||
int psta = 0;
|
int psta = 0;
|
||||||
int pcount = 0;
|
int pcount = 0;
|
||||||
unsigned char tgtdat = 0, pmod = 0x20, nums;
|
unsigned char tgtdat = 0, pmod = 0x20, nums;
|
||||||
@ -237,15 +732,13 @@ int BWBmp::Compress(int dir)
|
|||||||
tgtdat |= pmod;
|
tgtdat |= pmod;
|
||||||
pcount--;
|
pcount--;
|
||||||
count1--;
|
count1--;
|
||||||
//pmod /= 2;
|
|
||||||
pmod *= 2;
|
pmod *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcount == 0) // 够一个位图
|
if (pcount == 0) // 够一个位图
|
||||||
{
|
{
|
||||||
tgtdat &= 0x3f;
|
tgtdat &= 0x3f;
|
||||||
m_prDdat.append(tgtdat); // 添加
|
tmppr.append(tgtdat); // 添加
|
||||||
//qDebug()<<m_prDdat.size()<<tgtdat;
|
|
||||||
tgtdat = 0x00;
|
tgtdat = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,7 +751,6 @@ int BWBmp::Compress(int dir)
|
|||||||
{
|
{
|
||||||
psta = 0x00; // 位图模式
|
psta = 0x00; // 位图模式
|
||||||
tgtdat = psta;
|
tgtdat = psta;
|
||||||
//pmod = 0x20;
|
|
||||||
pmod = 0x01;
|
pmod = 0x01;
|
||||||
pcount = 6;
|
pcount = 6;
|
||||||
break;
|
break;
|
||||||
@ -277,8 +769,8 @@ int BWBmp::Compress(int dir)
|
|||||||
psta = 0x40;
|
psta = 0x40;
|
||||||
tgtdat = psta;
|
tgtdat = psta;
|
||||||
tgtdat |= (nums & 0x3f);
|
tgtdat |= (nums & 0x3f);
|
||||||
m_prDdat.append(tgtdat); // 添加
|
tmppr.append(tgtdat); // 添加
|
||||||
//qDebug()<<m_prDdat.size()<<tgtdat;
|
//qDebug()<<tmppr.size()<<tgtdat;
|
||||||
count1 -= nums;
|
count1 -= nums;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,8 +798,8 @@ int BWBmp::Compress(int dir)
|
|||||||
if (pcount == 0) // 够一个位图
|
if (pcount == 0) // 够一个位图
|
||||||
{
|
{
|
||||||
tgtdat &= 0x3f;
|
tgtdat &= 0x3f;
|
||||||
m_prDdat.append(tgtdat); // 添加
|
tmppr.append(tgtdat); // 添加
|
||||||
//qDebug()<<m_prDdat.size()<<tgtdat;
|
//qDebug()<<tmppr.size()<<tgtdat;
|
||||||
tgtdat = 0x00;
|
tgtdat = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,7 +826,6 @@ int BWBmp::Compress(int dir)
|
|||||||
muti = 10;
|
muti = 10;
|
||||||
psta = 0x80;
|
psta = 0x80;
|
||||||
}
|
}
|
||||||
//else if (count0 > 64)
|
|
||||||
else if (count0 >= 64)
|
else if (count0 >= 64)
|
||||||
{
|
{
|
||||||
nums = (int)(count0/10);
|
nums = (int)(count0/10);
|
||||||
@ -350,8 +841,8 @@ int BWBmp::Compress(int dir)
|
|||||||
|
|
||||||
tgtdat = psta;
|
tgtdat = psta;
|
||||||
tgtdat |= (nums & 0x3f);
|
tgtdat |= (nums & 0x3f);
|
||||||
m_prDdat.append(tgtdat); // 添加
|
tmppr.append(tgtdat); // 添加
|
||||||
//qDebug()<<m_prDdat.size()<<tgtdat;
|
//qDebug()<<tmppr.size()<<tgtdat;
|
||||||
count0 -= nums * muti;
|
count0 -= nums * muti;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,122 +855,109 @@ int BWBmp::Compress(int dir)
|
|||||||
{
|
{
|
||||||
pcount = 0;
|
pcount = 0;
|
||||||
tgtdat &= 0x3f;
|
tgtdat &= 0x3f;
|
||||||
m_prDdat.append(tgtdat); // 添加
|
tmppr.append(tgtdat); // 添加
|
||||||
tgtdat = 0x00;
|
tgtdat = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下一行
|
// 下一行
|
||||||
pBitDat += widthBytes * dir;
|
pBitDat += widthBytes * dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete []countBuff;
|
delete []countBuff;
|
||||||
|
|
||||||
// m_prDdat.append((char*)); // 添加文件头
|
// 构造压缩位图头部信息CompBmpHead,包含块索引、压缩方向、压缩类型以及压缩后的数据大小等信息。
|
||||||
|
// 添加文件头
|
||||||
|
CompBmpHead prHead;
|
||||||
|
memset(&prHead, 0, sizeof(CompBmpHead));
|
||||||
|
prHead.blkIdx = idx;
|
||||||
|
prHead.biHeight = pHead->biHeight;
|
||||||
|
prHead.biWidth = pHead->biWidth;
|
||||||
|
|
||||||
// int size = m_prDdat.size();
|
if (dir < 0)
|
||||||
// for(int p = 0; p < size; p++)
|
{
|
||||||
// {
|
prHead.compDir = 1;
|
||||||
// unsigned char ch = m_prDdat[p];
|
}
|
||||||
// qDebug()<<p<<" "<<ch;
|
else
|
||||||
// }
|
{
|
||||||
|
prHead.compDir = 0;
|
||||||
|
}
|
||||||
|
// 若压缩后数据量(tmppr.size())大于原位图数据量,则放弃压缩,直接复制原数据。
|
||||||
|
unsigned int prsize = tmppr.size();
|
||||||
|
if (prsize >= pHead->biBitmapDatSize) // 压缩率不足
|
||||||
|
{
|
||||||
|
prHead.compType = 0; // 不压缩
|
||||||
|
prHead.datSize = pHead->biBitmapDatSize;
|
||||||
|
|
||||||
|
tmppr.clear();
|
||||||
|
pBitDat = pBitDatBeg;
|
||||||
|
|
||||||
|
for (i = 0; i < height; i++) // 行计数
|
||||||
|
{
|
||||||
|
tmppr.append((const char*)pBitDat, widthBytes);
|
||||||
|
pBitDat += widthBytes * dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prHead.compType = 1;
|
||||||
|
prHead.datSize = prsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_prDdat.append((char*)(&prHead), sizeof(CompBmpHead));
|
||||||
|
m_prDdat.append(tmppr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BWBmp::LoadPrBmp(QString filename)
|
|
||||||
{
|
{
|
||||||
m_fileName = filename;
|
|
||||||
m_rbwDdat.clear();
|
|
||||||
m_prDdat.clear();
|
|
||||||
|
|
||||||
QFile file(filename);
|
#define VAL_OUTBMP 0xff // 位图之外的默认数据
|
||||||
int rslt = file.open(QFile::ReadOnly);
|
|
||||||
if (rslt == 0)
|
|
||||||
{
|
|
||||||
qDebug() << "open file error" << filename;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_prDdat = file.readAll();
|
m_rbwDdat.append((char*)(&bmpHead), sizeof(BitmapHead));
|
||||||
if (m_prDdat.size() <= 0)
|
|
||||||
{
|
|
||||||
file.close();
|
|
||||||
qDebug() << "file size error, size=" << m_prDdat.size();
|
|
||||||
m_prDdat.clear();
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BWBmp::Unpress()
|
|
||||||
{
|
|
||||||
m_rbwDdat.clear();
|
|
||||||
QByteArray arrdat;
|
|
||||||
arrdat.clear();
|
|
||||||
|
|
||||||
QByteArray barr;
|
|
||||||
barr.clear();
|
|
||||||
QFileInfo file(m_fileName);
|
|
||||||
QString name = file.filePath().remove("."+file.suffix());
|
|
||||||
|
|
||||||
QFile bfile(name);
|
|
||||||
bfile.open(QFile::ReadOnly);
|
|
||||||
barr = bfile.readAll();
|
|
||||||
BitmapHead * pHead = (BitmapHead *)(barr.data());
|
|
||||||
|
|
||||||
int widthBytes = (int)((pHead->biWidth + 31) / 32) * 4;
|
|
||||||
m_rbwDdat.append((char*)pHead,sizeof(BitmapHead));
|
|
||||||
|
|
||||||
if (m_prDdat.isEmpty() == 1)
|
|
||||||
{
|
|
||||||
qDebug() << "pr dat empty";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char sdat = 0;
|
unsigned char sdat = 0;
|
||||||
int count0,count1,flag;
|
int count0,count1,flag;
|
||||||
count0 = count1 = 0;
|
count0 = count1 = 0;
|
||||||
flag = -1;
|
flag = -1;
|
||||||
|
|
||||||
int size = m_prDdat.size();
|
|
||||||
for(int i = 0; i < size; i++)
|
for(int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
// if(i > 3250)
|
|
||||||
// {
|
|
||||||
// int a = 0;
|
|
||||||
// a = 1;
|
|
||||||
// }
|
|
||||||
count0 = count1 = 0;
|
count0 = count1 = 0;
|
||||||
flag = -1;
|
flag = -1;
|
||||||
|
|
||||||
sdat = m_prDdat[i];
|
sdat = pPrDdat[i];
|
||||||
|
|
||||||
if((sdat & 0xC0) == 0xC0) // 连续0
|
if((sdat & 0xC0) == 0xC0) // 连续0
|
||||||
{
|
{
|
||||||
count0 = sdat & 0x3f;
|
count0 = sdat & 0x3f;
|
||||||
|
if (count0 == 0)
|
||||||
|
{
|
||||||
|
count0 = 64;
|
||||||
|
}
|
||||||
flag = 0;
|
flag = 0;
|
||||||
}
|
}
|
||||||
else
|
else if((sdat & 0xC0) == 0x40) // 连续1
|
||||||
{
|
|
||||||
if((sdat & 0x40) == 0x40) // 连续1
|
|
||||||
{
|
{
|
||||||
count1 = sdat & 0x3f;
|
count1 = sdat & 0x3f;
|
||||||
|
if (count1 == 0)
|
||||||
|
{
|
||||||
|
count1 = 64;
|
||||||
|
}
|
||||||
flag = 1;
|
flag = 1;
|
||||||
}
|
}
|
||||||
else if((sdat & 0x80) == 0x80) // 连续10个0
|
else if((sdat & 0xC0) == 0x80) // 连续10个0
|
||||||
{
|
{
|
||||||
count0 = (sdat & 0x3f ) * 10;
|
count0 = (sdat & 0x3f ) * 10;
|
||||||
|
if (count0 == 0)
|
||||||
|
{
|
||||||
|
count0 = 640;
|
||||||
|
}
|
||||||
flag = 0;
|
flag = 0;
|
||||||
}
|
}
|
||||||
else // 原始数据
|
else // 原始数据
|
||||||
{
|
{//每行扫描时最后一个像素为原始数据时原始数据个数
|
||||||
//每行扫描时最后一个像素为原始数据时原始数据个数
|
|
||||||
int pcount = 6;
|
int pcount = 6;
|
||||||
int val = arrdat.size() % pHead->biWidth;
|
int val = arrdat.size() % biWidth;
|
||||||
int cnt = pHead->biWidth - val;
|
int cnt = biWidth - val;
|
||||||
int cnt1 = abs(pHead->biWidth - (widthBytes-1) * 8);
|
int cnt1 = abs((int)biWidth - ((int)widthBytes-1) * 8);
|
||||||
if(cnt >= cnt1)
|
if(cnt >= cnt1)
|
||||||
{
|
{
|
||||||
pcount = 6;
|
pcount = 6;
|
||||||
@ -515,7 +993,6 @@ int BWBmp::Unpress()
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
unsigned char ch = 0;
|
unsigned char ch = 0;
|
||||||
@ -537,36 +1014,38 @@ int BWBmp::Unpress()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
unsigned char abyte = 0;
|
unsigned int lst = ((biWidth/8)*8+8);
|
||||||
unsigned int cnt = 0;
|
|
||||||
for(unsigned int n = 0; n < pHead->biHeight; n++)
|
for(unsigned int n = 0; n < biHeight; n++)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < widthBytes; j++)
|
for(int j = 0; j < widthBytes; j++)
|
||||||
{
|
{
|
||||||
abyte = 0;
|
unsigned int cnt = j*8;
|
||||||
for(int i = 0; i < 8; i++)
|
unsigned char abyte = 0;
|
||||||
|
|
||||||
|
int idx = n*biWidth+j*8;
|
||||||
|
for(int i = 0; i < 8; i++, idx++, cnt++)
|
||||||
{
|
{
|
||||||
int idx = n*pHead->biWidth+j*8+i;
|
|
||||||
//qDebug()<<"idx"<<idx;
|
//qDebug()<<"idx"<<idx;
|
||||||
unsigned char ch = arrdat[idx] << i;
|
|
||||||
//qDebug()<<"ch"<<ch;
|
//qDebug()<<"ch"<<ch;
|
||||||
|
|
||||||
cnt = j*8 + i;
|
if (cnt < biWidth)
|
||||||
if(cnt < pHead->biWidth)
|
|
||||||
{
|
{
|
||||||
abyte |= ch;
|
unsigned char ch = arrdat[idx];
|
||||||
|
if (ch != 0)
|
||||||
|
{
|
||||||
|
abyte |= (ch << (7-i));
|
||||||
}
|
}
|
||||||
else if(cnt == pHead->biWidth)
|
|
||||||
{
|
|
||||||
abyte = abyte << (8 - i);
|
|
||||||
}
|
}
|
||||||
else if(cnt >= ((pHead->biWidth/8)*8+8))
|
else if(cnt >= lst)
|
||||||
{
|
{
|
||||||
abyte = 0;
|
abyte = VAL_OUTBMP; // 默认值
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
continue;
|
abyte |= ((VAL_OUTBMP) >> (i)); // 默认值
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,27 +1057,6 @@ int BWBmp::Unpress()
|
|||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int BWBmp::SaveBiBmp(QString filename)
|
|
||||||
{
|
|
||||||
QFile file(filename);
|
|
||||||
int rslt = file.open(QFile::ReadWrite | QFile::Truncate);
|
|
||||||
if (rslt == 0)
|
|
||||||
{
|
|
||||||
qDebug() << "open file error" << filename;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.write(m_rbwDdat);
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray BWBmp::getPrBmpDat()
|
|
||||||
{
|
|
||||||
return m_prDdat;
|
|
||||||
}
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include "machine/comm/protocol.h"
|
||||||
|
|
||||||
#pragma pack(1) //设定为1字节对齐
|
#pragma pack(1) //设定为1字节对齐
|
||||||
|
|
||||||
@ -37,8 +38,6 @@ typedef struct
|
|||||||
BmpRgbQuad palette[2]; // 调色板
|
BmpRgbQuad palette[2]; // 调色板
|
||||||
}__attribute__ ((packed)) BitmapHead;
|
}__attribute__ ((packed)) BitmapHead;
|
||||||
|
|
||||||
#pragma pack(4)
|
|
||||||
|
|
||||||
|
|
||||||
class BWBmp
|
class BWBmp
|
||||||
{
|
{
|
||||||
@ -48,26 +47,30 @@ public:
|
|||||||
public:
|
public:
|
||||||
int LoadBiBmp(QString filename);
|
int LoadBiBmp(QString filename);
|
||||||
int SavePrBmp(QString filename);
|
int SavePrBmp(QString filename);
|
||||||
int Compress(int dir = 1);
|
int Compress(int idx = 0, int dir = 1, int segWidth = 300, int segHeight = 50);
|
||||||
|
|
||||||
int LoadPrBmp(QString filename);
|
|
||||||
int Unpress();
|
|
||||||
int SaveBiBmp(QString filename);
|
|
||||||
|
|
||||||
QByteArray getPrBmpDat();
|
QByteArray getPrBmpDat();
|
||||||
|
|
||||||
|
/*
|
||||||
|
int CompressSeg(const unsigned char * pBitDatBeg,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
unsigned int segWidth, unsigned int segHeight, unsigned char fill,
|
||||||
|
int compDir,
|
||||||
|
QByteArray & prDat);
|
||||||
|
int UnpressSeg(const unsigned char * pBitDatBeg,
|
||||||
|
unsigned int width, unsigned int height,
|
||||||
|
unsigned int segWidth, unsigned int segHeight, unsigned char fill,
|
||||||
|
int compDir,
|
||||||
|
QByteArray & prDat);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QByteArray m_bwDdat;
|
QByteArray m_bwDdat; // 单色BMP
|
||||||
QByteArray m_prDdat;
|
QByteArray m_prDdat;
|
||||||
|
|
||||||
QByteArray m_rbwDdat;
|
QByteArray m_rbwDdat;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BWBMP_H
|
#endif // BWBMP_H
|
||||||
|
@ -3,18 +3,19 @@
|
|||||||
CreatPrintBmp::CreatPrintBmp(QObject *parent) : QObject(parent)
|
CreatPrintBmp::CreatPrintBmp(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_savePath.clear();
|
m_savePath.clear();
|
||||||
m_workState = PAUSE;
|
m_workState = WORK_PAUSE;
|
||||||
m_beginPrintFileIdx = -1;
|
|
||||||
m_fileBegIdx = -1;
|
m_fileBegIdx = -1;
|
||||||
m_fileEndIdx = -1;
|
m_fileEndIdx = -1;
|
||||||
m_deleteFileIdx = -1;
|
m_deleteFileIdx = -1;
|
||||||
m_curFileIdx = -1;//当前生成数据的文件索引
|
m_listFileIdx = -1;//当前生成数据的文件索引
|
||||||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||||||
m_mcPrintInfo = NULL;
|
m_mcPrintInfo = NULL;
|
||||||
m_conpressDir = 1;
|
m_conpressDir = 1;
|
||||||
m_printFileDir.clear();
|
m_printFileDir.clear();
|
||||||
m_moveFileIdx = -1;//上下移动打印文件索引
|
m_moveFileIdx = -1;//上下移动打印文件索引
|
||||||
m_moveDir = 0;//-1,上移 1,下移
|
m_moveDir = 0;//-1,上移 1,下移
|
||||||
|
m_rotateAngle = 0;
|
||||||
|
m_autoDirFilesList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatPrintBmp::~CreatPrintBmp()
|
CreatPrintBmp::~CreatPrintBmp()
|
||||||
@ -26,216 +27,61 @@ CreatPrintBmp::~CreatPrintBmp()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CreatPrintBmp::creatFileListMarker()
|
int CreatPrintBmp::creatFileListMarker(int idx)
|
||||||
{
|
|
||||||
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
|
||||||
{
|
|
||||||
QString iniName = "MachineNo" + QString::number(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())
|
|
||||||
{
|
|
||||||
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_workState == WORK_PAUSE)
|
if(m_workState == WORK_PAUSE)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//QCoreApplication::processEvents(QEventLoop::AllEvents);
|
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||||||
|
{
|
||||||
|
if(idx >= m_autoDirFilesList.size())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
QFileInfo fileInfo(fileList[i]);
|
QFileInfo fileInfo(m_autoDirFilesList[idx]);
|
||||||
QString filePath = fileInfo.filePath();
|
QString filePath = fileInfo.filePath();
|
||||||
|
|
||||||
if(m_mcPrintInfo->m_filesList.size() > i)
|
int creatDataFlag = 0;//是否已经生成Marker数据的标志
|
||||||
|
if(idx < m_mcPrintInfo->m_filesList.size())
|
||||||
{
|
{
|
||||||
|
if(m_mcPrintInfo->m_filesList[idx].m_creatDataFlag != 0)
|
||||||
|
{
|
||||||
|
creatDataFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//已经生成数据的跳过
|
//已经生成数据的跳过
|
||||||
if(m_mcPrintInfo->m_filesList[i].m_creatDataFlag != 1)
|
if(creatDataFlag == 0)
|
||||||
{
|
{
|
||||||
McFilesInfo curFilesInfo;//当前文件信息
|
McFilesInfo curFilesInfo;//当前文件信息
|
||||||
creatMarkerDat(curFilesInfo,filePath,i);
|
creatMarkerDat(curFilesInfo,m_printFileDir,filePath,m_listFileIdx,m_rotateAngle);
|
||||||
long long fileTotalLength = (curFilesInfo.m_fileRect.right() - curFilesInfo.m_fileRect.left())/M_IDPMM;
|
long long fileTotalLength = (curFilesInfo.m_fileRect.right() - curFilesInfo.m_fileRect.left())/M_IDPMM;
|
||||||
m_mcPrintInfo->m_fileNums = i+1;
|
m_mcPrintInfo->m_fileNums += 1;
|
||||||
m_mcPrintInfo->m_fileTotalLength += fileTotalLength;
|
m_mcPrintInfo->m_fileTotalLength += fileTotalLength;
|
||||||
m_mcPrintInfo->m_filesList.append(curFilesInfo);
|
m_mcPrintInfo->m_filesList.append(curFilesInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||||||
|
{
|
||||||
|
//全部文件Marker数据加载完成
|
||||||
|
if(m_mcPrintInfo->m_filesList.size() == m_autoDirFilesList.size())
|
||||||
{
|
{
|
||||||
McFilesInfo curFilesInfo;//当前文件信息
|
|
||||||
creatMarkerDat(curFilesInfo,filePath,i);
|
|
||||||
long long fileTotalLength = (curFilesInfo.m_fileRect.right() - curFilesInfo.m_fileRect.left())/M_IDPMM;
|
|
||||||
m_mcPrintInfo->m_fileNums = i+1;
|
|
||||||
m_mcPrintInfo->m_fileTotalLength += fileTotalLength;
|
|
||||||
m_mcPrintInfo->m_filesList.append(curFilesInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_mcPrintInfo->m_loadFileFinishFlag = 1;
|
m_mcPrintInfo->m_loadFileFinishFlag = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir apppath(qApp->applicationDirPath());
|
|
||||||
QString printPath = apppath.path() + apppath.separator() + PRINTDIR;
|
|
||||||
QDir printDir(printPath);//总的打印目录
|
|
||||||
if(!printDir.exists())
|
|
||||||
{
|
|
||||||
printDir.mkdir(printPath);
|
|
||||||
}
|
|
||||||
QString mcFile = printPath + printDir.separator() + PRINTMCDIR + QString::number(m_mcPrintInfo->m_mcNum);
|
|
||||||
QDir mcDir(mcFile);//对应每台机器打印目录
|
|
||||||
if(!mcDir.exists())
|
|
||||||
{
|
|
||||||
mcDir.mkdir(mcFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatPrintBmp::creatMarkerDat(McFilesInfo &curFilesInfo, QString filePath, int fileIdx)
|
|
||||||
{
|
|
||||||
QFileInfo fileInfo(filePath);
|
|
||||||
curFilesInfo.m_marker.Initialize();
|
|
||||||
|
|
||||||
if(fileInfo.suffix().toUpper() == "PLT")
|
|
||||||
{
|
|
||||||
ImportHPGL importHPGL;
|
|
||||||
curFilesInfo.m_fileType = TYPE_FILE;
|
|
||||||
|
|
||||||
//判断是否为加密文件
|
|
||||||
if (importHPGL.IsSecretFile(filePath) == true)
|
|
||||||
{
|
|
||||||
// 文件路径
|
|
||||||
QString strSecretFile = m_printFileDir + QString::number(fileIdx+1) ;
|
|
||||||
|
|
||||||
QDir fileDir(strSecretFile);//对应每台机器的每个文件打印目录
|
|
||||||
if(!fileDir.exists())
|
|
||||||
{
|
|
||||||
fileDir.mkdir(strSecretFile);
|
|
||||||
}
|
|
||||||
strSecretFile = strSecretFile + fileDir.separator() + "Secret.plt";
|
|
||||||
//qDebug()<<"strSecretFile"<<strSecretFile;
|
|
||||||
|
|
||||||
importHPGL.BitMapDtat(filePath,strSecretFile);
|
|
||||||
importHPGL.IniPara();
|
|
||||||
importHPGL.ReadSecretFile(strSecretFile,&curFilesInfo.m_marker);
|
|
||||||
//qDebug()<<"importHPGL.IsSecretFile";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
importHPGL.IniPara();
|
|
||||||
importHPGL.Read(filePath,&curFilesInfo.m_marker);
|
|
||||||
}
|
|
||||||
curFilesInfo.m_fileRect = curFilesInfo.m_marker.GetRect();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
curFilesInfo.m_fileType = TYPE_IMAGE;
|
|
||||||
QBitmap pixmap;
|
|
||||||
pixmap.load(filePath);
|
|
||||||
QRect rect;
|
|
||||||
rect.setRect(0,0,pixmap.width()/MMPIXELY*M_IDPMM,pixmap.height()/MMPIXELY*M_IDPMM);
|
|
||||||
|
|
||||||
curFilesInfo.m_pixmap = pixmap;
|
|
||||||
curFilesInfo.m_fileRect = rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
curFilesInfo.m_filePath = filePath;
|
|
||||||
curFilesInfo.m_fileName = fileInfo.fileName();
|
|
||||||
curFilesInfo.m_printNum = 1;
|
|
||||||
curFilesInfo.m_startPoint = 0;
|
|
||||||
curFilesInfo.m_printState = tr("Waitting");
|
|
||||||
curFilesInfo.m_curPrintBlock = 0;//当前打印块数
|
|
||||||
curFilesInfo.m_printedBlockNum = 0;//已打印块数
|
|
||||||
curFilesInfo.m_selectBlockNum = 0;//当前选择块数
|
|
||||||
curFilesInfo.m_creatDataFlag = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPicture CreatPrintBmp::getPicture(Marker marker, int penWidth)
|
|
||||||
{
|
|
||||||
QPicture pic;
|
|
||||||
CBitmapInfo bitmapInfo;
|
|
||||||
QPainterPath painterPath;
|
|
||||||
QRect rect = marker.GetRect();
|
|
||||||
int minX = rect.left();
|
|
||||||
int minY = rect.top();
|
|
||||||
int maxY = rect.bottom();
|
|
||||||
|
|
||||||
int nLineCount = marker.m_listPolyline.size();
|
|
||||||
for(int i = 0; i < nLineCount; i++)
|
|
||||||
{
|
|
||||||
CRPPolyline polyLine = marker.m_listPolyline.at(i);
|
|
||||||
int type = polyLine.m_nDrawingType;
|
|
||||||
|
|
||||||
if(type == 0)//直线
|
|
||||||
{
|
|
||||||
int nPointCount = polyLine.m_listPoint.size();
|
|
||||||
for(int j = 0; j < nPointCount; j++)
|
|
||||||
{
|
|
||||||
double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY;
|
|
||||||
double y = ((0 - (polyLine.m_listPoint.at(j).y() - minY))+(maxY-minY))/(double)M_IDPMM*MMPIXELY;
|
|
||||||
QPointF point(x,y);
|
|
||||||
|
|
||||||
if(j == 0)
|
|
||||||
{
|
|
||||||
painterPath.moveTo(point);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painterPath.lineTo(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(type == 1)//位图
|
|
||||||
{
|
|
||||||
bitmapInfo = polyLine.m_bitmapInfo;
|
|
||||||
int x = bitmapInfo.m_ptAbPostLU.x();
|
|
||||||
int y = bitmapInfo.m_ptAbPostLU.y();
|
|
||||||
|
|
||||||
int nx = (x - minX)/M_IDPMM*MMPIXELY;
|
|
||||||
int ny = ((0 - (y - minY))+(maxY-minY))/M_IDPMM*MMPIXELY;
|
|
||||||
|
|
||||||
bitmapInfo.m_ptAbPostLU.setX(nx);
|
|
||||||
bitmapInfo.m_ptAbPostLU.setY(ny);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(painterPath.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug()<<"painterPath isEmpty";
|
|
||||||
}
|
|
||||||
|
|
||||||
//将路径画在picture上
|
|
||||||
QPen pen;
|
|
||||||
pen.setWidth(penWidth);//设置笔号
|
|
||||||
pen.setColor(QColor(Qt::black));
|
|
||||||
|
|
||||||
QPainter painter;
|
|
||||||
painter.begin(&pic);
|
|
||||||
painter.setPen(pen);
|
|
||||||
painter.drawPath(painterPath);
|
|
||||||
if(bitmapInfo.m_iBytes > 0)//有位图
|
|
||||||
{
|
|
||||||
painter.drawPixmap(bitmapInfo.m_ptAbPostLU.x(),bitmapInfo.m_ptAbPostLU.y(),bitmapInfo.m_pBitmap);
|
|
||||||
}
|
|
||||||
painter.end();
|
|
||||||
return pic;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
||||||
{
|
{
|
||||||
if(idx >= m_mcPrintInfo->m_filesList.size())
|
if(idx >= m_mcPrintInfo->m_filesList.size())
|
||||||
{
|
{
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
McFilesInfo curFilesInfo;
|
McFilesInfo curFilesInfo;
|
||||||
@ -246,7 +92,7 @@ int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
curFilesInfo = m_mcPrintInfo->m_filesList[idx];
|
curFilesInfo = m_mcPrintInfo->m_filesList[idx];
|
||||||
QString filePath = m_printFileDir + QString::number(idx+1);
|
QString filePath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||||||
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
||||||
if(!fileDir.exists())
|
if(!fileDir.exists())
|
||||||
{
|
{
|
||||||
@ -256,7 +102,7 @@ int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
|||||||
|
|
||||||
if(curFilesInfo.m_creatDataFlag < 0)
|
if(curFilesInfo.m_creatDataFlag < 0)
|
||||||
{
|
{
|
||||||
creatMarkerDat(curFilesInfo,m_mcPrintInfo->m_filesList[idx].m_filePath,idx);
|
creatMarkerDat(curFilesInfo,m_printFileDir,m_mcPrintInfo->m_filesList[idx].m_filePath,m_listFileIdx,m_rotateAngle);
|
||||||
m_mcPrintInfo->m_filesList[idx] = curFilesInfo;
|
m_mcPrintInfo->m_filesList[idx] = curFilesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,17 +113,8 @@ int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
|||||||
|
|
||||||
int oft = 0;//起始打印位置的偏移
|
int oft = 0;//起始打印位置的偏移
|
||||||
if(curFilesInfo.m_fileType == TYPE_FILE)
|
if(curFilesInfo.m_fileType == TYPE_FILE)
|
||||||
{
|
|
||||||
//画笔宽度不为1时重画
|
|
||||||
if(PENWIDTH != 1)
|
|
||||||
{
|
|
||||||
pic = getPicture(curFilesInfo.m_marker,PENWIDTH);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
pic = m_mcPrintInfo->m_filesList[idx].m_pic;
|
pic = m_mcPrintInfo->m_filesList[idx].m_pic;
|
||||||
}
|
|
||||||
|
|
||||||
oft = (int)(m_mcPrintInfo->m_filesList[idx].m_startPoint*MMPIXELY);
|
oft = (int)(m_mcPrintInfo->m_filesList[idx].m_startPoint*MMPIXELY);
|
||||||
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
||||||
m_mcPrintInfo->m_totalNums = (pic.width() - oft) / PIXMAPWIDTH;
|
m_mcPrintInfo->m_totalNums = (pic.width() - oft) / PIXMAPWIDTH;
|
||||||
@ -304,34 +141,51 @@ int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
|||||||
m_mcPrintInfo->m_totalNums += 1;
|
m_mcPrintInfo->m_totalNums += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_mcPrintInfo->m_filesList[idx].m_pic = pic;
|
|
||||||
m_mcPrintInfo->m_filesList[idx].m_totalBlocks = (pic.width() - oft)/ PIXMAPWIDTH;
|
m_mcPrintInfo->m_filesList[idx].m_totalBlocks = (pic.width() - oft)/ PIXMAPWIDTH;
|
||||||
|
|
||||||
|
int lwidth = (pic.width() - oft) % PIXMAPWIDTH;
|
||||||
|
if(lwidth != 0)
|
||||||
|
{
|
||||||
|
m_mcPrintInfo->m_filesList[idx].m_totalBlocks += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mcPrintInfo->m_filesList[idx].m_totalBlocks *= m_mcPrintInfo->m_filesList[idx].m_printNum;
|
||||||
|
|
||||||
|
m_mcPrintInfo->m_filesList[idx].m_printState = Printting;
|
||||||
|
|
||||||
//发送文件列表数据
|
//发送文件列表数据
|
||||||
emit siSendFileListDatToMc(idx);
|
emit siSendFileListDatToMc(idx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
int CreatPrintBmp::creatBmpBlockDatAndSend(int fileidx, int idx)
|
||||||
{
|
{
|
||||||
|
if(m_workState == WORK_PAUSE)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setWidth(1);
|
pen.setWidth(1);
|
||||||
pen.setColor(QColor(Qt::black));
|
pen.setColor(QColor(Qt::black));
|
||||||
|
|
||||||
int nextNum = idx / m_mcPrintInfo->m_filesList[m_curFileIdx].m_totalBlocks;
|
if(m_mcPrintInfo->m_filesList[fileidx].m_printNum <= 0)
|
||||||
if((idx % m_mcPrintInfo->m_filesList[m_curFileIdx].m_totalBlocks) == 0)
|
|
||||||
{
|
{
|
||||||
idx = 0;
|
m_mcPrintInfo->m_filesList[fileidx].m_printNum = 1;
|
||||||
}
|
}
|
||||||
|
int oneNumCount = m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks / m_mcPrintInfo->m_filesList[fileidx].m_printNum;
|
||||||
|
|
||||||
QPicture pic = m_mcPrintInfo->m_filesList[m_curFileIdx].m_pic;
|
int nextNum = idx / oneNumCount;
|
||||||
int oft = (int)(m_mcPrintInfo->m_filesList[m_curFileIdx].m_startPoint*MMPIXELY);
|
idx = idx - nextNum * oneNumCount;
|
||||||
|
|
||||||
|
QPicture pic = m_mcPrintInfo->m_filesList[fileidx].m_pic;
|
||||||
|
int oft = (int)(m_mcPrintInfo->m_filesList[fileidx].m_startPoint*MMPIXELY);
|
||||||
|
|
||||||
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
||||||
int num = (pic.width() - oft) / PIXMAPWIDTH;
|
int num = (pic.width() - oft) / PIXMAPWIDTH;
|
||||||
int lwidth = (pic.width() - oft) % PIXMAPWIDTH;
|
int lwidth = (pic.width() - oft) % PIXMAPWIDTH;
|
||||||
int height = pic.height();
|
int height = pic.height();
|
||||||
int offset = 0 - idx * PIXMAPWIDTH + oft;//将picture画在bmp上每次的偏移量,bmp的最大尺寸为u16
|
int offset = 0 - idx * PIXMAPWIDTH - oft;//将picture画在bmp上每次的偏移量,bmp的最大尺寸为u16
|
||||||
|
|
||||||
if(lwidth != 0)
|
if(lwidth != 0)
|
||||||
{
|
{
|
||||||
@ -343,7 +197,7 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
|||||||
pixPainter->begin(pixmap);
|
pixPainter->begin(pixmap);
|
||||||
pixPainter->setPen(pen);
|
pixPainter->setPen(pen);
|
||||||
|
|
||||||
QString filePath = m_printFileDir + QString::number(m_curFileIdx+1);
|
QString filePath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||||||
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
||||||
if(!fileDir.exists())
|
if(!fileDir.exists())
|
||||||
{
|
{
|
||||||
@ -354,7 +208,8 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
|||||||
pixmap->fill(Qt::white);//用白色填充
|
pixmap->fill(Qt::white);//用白色填充
|
||||||
pixPainter->drawPicture(offset,0,pic);
|
pixPainter->drawPicture(offset,0,pic);
|
||||||
|
|
||||||
QString path = filePath+QString::number(idx+nextNum*m_mcPrintInfo->m_filesList[m_curFileIdx].m_totalBlocks+1)+".bmp";
|
int cidx = idx + nextNum*oneNumCount;
|
||||||
|
QString path = filePath+QString::number(cidx+1)+".bmp";
|
||||||
bool bls = pixmap->save(path);
|
bool bls = pixmap->save(path);
|
||||||
while(bls == false)
|
while(bls == false)
|
||||||
{
|
{
|
||||||
@ -372,7 +227,7 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
|||||||
qDebug() << "open file error" << path;
|
qDebug() << "open file error" << path;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rslt = bwBmp.Compress(m_conpressDir);
|
rslt = bwBmp.Compress(cidx,m_conpressDir);
|
||||||
if (rslt != 0)
|
if (rslt != 0)
|
||||||
{
|
{
|
||||||
qDebug() << "Compress error";
|
qDebug() << "Compress error";
|
||||||
@ -386,25 +241,32 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
QByteArray dat = bwBmp.getPrBmpDat();
|
QByteArray dat = bwBmp.getPrBmpDat();
|
||||||
|
emit siSendDatToMc(dat);
|
||||||
|
m_mcPrintInfo->m_filesList[fileidx].m_curPrintBlock = cidx + 1;
|
||||||
|
m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum = cidx;
|
||||||
|
m_mcPrintInfo->m_filesList[fileidx].m_leaveBlockNum = m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks - m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum;
|
||||||
|
|
||||||
//发送文件
|
//计算机器打印进度
|
||||||
BmpDatInfo bmpInfo;
|
int fileNum = m_fileEndIdx - m_fileBegIdx;
|
||||||
memset(&bmpInfo,0,sizeof(BmpDatInfo));
|
int val = 1;
|
||||||
bmpInfo.blkIdx = idx;
|
if(fileNum == 1)//每次只发送一个文件
|
||||||
bmpInfo.biWidth = pixmap->width();
|
|
||||||
bmpInfo.biHeight = pixmap->height();
|
|
||||||
bmpInfo.begPosY = idx * pixmap->width();
|
|
||||||
bmpInfo.endPosY = (idx+1) * pixmap->width();
|
|
||||||
if(m_conpressDir == -1)
|
|
||||||
{
|
{
|
||||||
bmpInfo.compDir = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
else
|
double filePro = (1.0 / (double)fileNum)*m_listFileIdx*val;//发送到第m_listFileIdx个文件的进度
|
||||||
|
double blockPro = (double)m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum / (double)m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks;//发送到第idx个块的进度
|
||||||
|
double fBlockPro = (1.0 / (double)fileNum) * blockPro;//发送到第idx个块的进度
|
||||||
|
double totalPro = filePro + fBlockPro;//发送到第m_listFileIdx个文件的第idx个块的进度
|
||||||
|
m_mcPrintInfo->m_mcSendProgress = totalPro*100.0;
|
||||||
|
|
||||||
|
//单个文件打印完成
|
||||||
|
if(m_mcPrintInfo->m_filesList[fileidx].m_printedBlockNum == m_mcPrintInfo->m_filesList[fileidx].m_totalBlocks)
|
||||||
{
|
{
|
||||||
bmpInfo.compDir = 1;
|
m_mcPrintInfo->m_filesList[m_fileBegIdx].m_printState = Complete;
|
||||||
}
|
}
|
||||||
//qDebug()<<"dat.size()"<<dat.size();
|
|
||||||
emit siSendDatToMc(dat, bmpInfo);
|
emit siRefreshPrintProgress(m_mcPrintInfo->m_mcNum,m_fileBegIdx);
|
||||||
|
|
||||||
m_mcPrintInfo->m_sendedlNums++;
|
m_mcPrintInfo->m_sendedlNums++;
|
||||||
|
|
||||||
pixPainter->end();
|
pixPainter->end();
|
||||||
@ -424,13 +286,14 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
|||||||
void CreatPrintBmp::slotCreatBmp()
|
void CreatPrintBmp::slotCreatBmp()
|
||||||
{
|
{
|
||||||
#if(1)
|
#if(1)
|
||||||
int val = creatFileListMarker();
|
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||||||
|
int val = creatFileListMarker(m_fileBegIdx);
|
||||||
if(val < 0)
|
if(val < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = creatFileListDatAndSend(m_curFileIdx);
|
val = creatFileListDatAndSend(m_fileBegIdx);
|
||||||
if(val < 0)
|
if(val < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -513,82 +376,12 @@ void CreatPrintBmp::slotCreatBmp()
|
|||||||
|
|
||||||
void CreatPrintBmp::slotCreatNextBmpBlockDat()
|
void CreatPrintBmp::slotCreatNextBmpBlockDat()
|
||||||
{
|
{
|
||||||
//非正在打印的文件,正在发送文件时的删除操作
|
if(m_mcPrintInfo->m_filesList.size() <= m_fileBegIdx)
|
||||||
if(m_deleteFileIdx != m_curFileIdx && m_deleteFileIdx != -1)
|
|
||||||
{
|
{
|
||||||
int length = (m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.right() - m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.left())/M_IDPMM;
|
return;
|
||||||
m_mcPrintInfo->m_fileTotalLength -= length;
|
|
||||||
m_mcPrintInfo->m_filesList[m_deleteFileIdx].clear();
|
|
||||||
m_mcPrintInfo->m_filesList.removeAt(m_deleteFileIdx);
|
|
||||||
QString mcFile = m_printFileDir + QString::number(m_deleteFileIdx+1);
|
|
||||||
QDir fileDir(mcFile);
|
|
||||||
if(fileDir.exists())//理论上无此条件
|
|
||||||
{
|
|
||||||
//删除位图文件夹
|
|
||||||
QFileInfoList fileList = fileDir.entryInfoList(QDir::Files);
|
|
||||||
for(int i = 0; i < fileList.size(); i++)
|
|
||||||
{
|
|
||||||
QString fileStr = fileList[i].filePath();
|
|
||||||
QFile::remove(fileStr);
|
|
||||||
}
|
|
||||||
fileDir.rmdir(mcFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_deleteFileIdx < m_curFileIdx)//理论上无此条件
|
m_mcPrintInfo->m_mcWorkState = Busying;
|
||||||
{
|
|
||||||
QString oldName = m_printFileDir + QString::number(m_curFileIdx+1);
|
|
||||||
QDir dir(oldName);
|
|
||||||
m_curFileIdx--;
|
|
||||||
QString newName = m_printFileDir + QString::number(m_curFileIdx+1);
|
|
||||||
dir.rename(oldName,newName);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_mcPrintInfo->m_fileNums = m_mcPrintInfo->m_filesList.size();
|
|
||||||
m_deleteFileIdx = -1;
|
|
||||||
emit siDeleteFileFinish();
|
|
||||||
}
|
|
||||||
|
|
||||||
//非正在打印的文件,正在发送文件时的上下移操作
|
|
||||||
if(m_moveFileIdx != m_curFileIdx && m_moveFileIdx != -1 && m_moveDir != 0)
|
|
||||||
{
|
|
||||||
//交换列表
|
|
||||||
McFilesInfo info = m_mcPrintInfo->m_filesList[m_moveFileIdx];
|
|
||||||
McFilesInfo cInfo;
|
|
||||||
cInfo = m_mcPrintInfo->m_filesList[m_moveFileIdx+m_moveDir];
|
|
||||||
m_mcPrintInfo->m_filesList[m_moveFileIdx+m_moveDir] = info;
|
|
||||||
m_mcPrintInfo->m_filesList[m_moveFileIdx] = cInfo;
|
|
||||||
|
|
||||||
//更换位图文件夹的名称
|
|
||||||
//判断当前交换的文件夹是否存在
|
|
||||||
QString mcFile = m_printFileDir + QString::number(m_moveFileIdx+1);
|
|
||||||
QDir fileDir(mcFile);
|
|
||||||
if(fileDir.exists())//理论上无此条件
|
|
||||||
{
|
|
||||||
//对当前选中文件夹重命名
|
|
||||||
QString oldName = mcFile;
|
|
||||||
QString newName = mcFile.left(mcFile.size()-1);
|
|
||||||
fileDir.rename(oldName,newName);
|
|
||||||
|
|
||||||
int cRow = m_moveFileIdx + m_moveDir;
|
|
||||||
QString mcFile1 = m_printFileDir + QString::number(cRow+1);
|
|
||||||
QDir fileDir1(mcFile1);
|
|
||||||
|
|
||||||
//对要交换的文件夹重命名
|
|
||||||
oldName = mcFile1;
|
|
||||||
newName = mcFile;
|
|
||||||
fileDir1.rename(oldName,newName);
|
|
||||||
|
|
||||||
//再对选中的文件夹重命名
|
|
||||||
QString mcFile2 = mcFile.left(mcFile.size()-1);
|
|
||||||
QDir fileDir2(mcFile1);
|
|
||||||
oldName = mcFile2;
|
|
||||||
newName = mcFile1;
|
|
||||||
fileDir2.rename(oldName,newName);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_moveFileIdx = -1;
|
|
||||||
m_moveDir = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curBmpBlockIdx++;//一个文件可分为若干个位图块,位图块索引++
|
m_curBmpBlockIdx++;//一个文件可分为若干个位图块,位图块索引++
|
||||||
if(m_curBmpBlockIdx < 0)
|
if(m_curBmpBlockIdx < 0)
|
||||||
@ -596,15 +389,65 @@ void CreatPrintBmp::slotCreatNextBmpBlockDat()
|
|||||||
m_curBmpBlockIdx = 0;
|
m_curBmpBlockIdx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_curBmpBlockIdx >= m_mcPrintInfo->m_filesList[m_curFileIdx].m_totalBlocks * m_mcPrintInfo->m_filesList[m_curFileIdx].m_printNum)
|
if(m_curBmpBlockIdx >= m_mcPrintInfo->m_filesList[m_fileBegIdx].m_totalBlocks)
|
||||||
|
{
|
||||||
|
m_listFileIdx++;//文件索引++
|
||||||
|
int flag = 0;
|
||||||
|
if(m_listFileIdx >= m_fileEndIdx)
|
||||||
|
{
|
||||||
|
m_mcPrintInfo->m_mcWorkState = NotBusy;//机器完成打印
|
||||||
|
m_mcPrintInfo->m_filesList[m_fileBegIdx].m_printedBlockNum = m_mcPrintInfo->m_filesList[m_fileBegIdx].m_totalBlocks;
|
||||||
|
m_mcPrintInfo->m_mcSendProgress = 100.0;
|
||||||
|
flag = 1;
|
||||||
|
}
|
||||||
|
emit siOneFilePrintFinished(m_mcPrintInfo->m_mcNum,m_fileBegIdx,flag);
|
||||||
|
//如果为自动绘图目录中的文件,删除自动绘图目录文件夹中已打印完成的文件
|
||||||
|
QString filePath = m_mcPrintInfo->m_filesList[m_fileBegIdx].m_filePath;
|
||||||
|
QDir apppath(qApp->applicationDirPath());
|
||||||
|
QString iniName = "MachineNo" + QString::number(m_mcPrintInfo->m_mcNum) + ".ini";
|
||||||
|
QString iniPath = apppath.path() + apppath.separator() + iniName;
|
||||||
|
QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来
|
||||||
|
QFileInfo info(filePath);
|
||||||
|
QString autoFilePath = setting.value("AutoPrintDir/fileDir").toString() + apppath.separator() + info.fileName();
|
||||||
|
QFile file(autoFilePath);
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
//文件存在
|
||||||
|
QFile::remove(autoFilePath);
|
||||||
|
if(m_fileBegIdx < m_autoDirFilesList.size())
|
||||||
|
{
|
||||||
|
m_autoDirFilesList.removeAt(m_fileBegIdx);//删除自动绘图目录文件列表中的文件
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//m_mcPrintInfo->m_filesList.removeAt(m_fileBegIdx);//删除机器文件列表中已打印完成的文件
|
||||||
|
|
||||||
|
#if(0)
|
||||||
|
//删除此文件的位图存储文件夹
|
||||||
|
QString bmpPath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||||||
|
QDir bmpDir(bmpPath);//对应每台机器的每个文件打印目录
|
||||||
|
if(bmpDir.exists())
|
||||||
|
{
|
||||||
|
bmpDir.removeRecursively();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(m_listFileIdx >= m_fileEndIdx)
|
||||||
{
|
{
|
||||||
m_curFileIdx++;//文件索引++
|
|
||||||
creatFileListDatAndSend(m_curFileIdx);
|
|
||||||
m_curBmpBlockIdx = -1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
creatBmpBlockDatAndSend(m_curBmpBlockIdx);
|
// if(flag == 1)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// creatFileListMarker(m_fileBegIdx);
|
||||||
|
// creatFileListDatAndSend(m_fileBegIdx);
|
||||||
|
// m_curBmpBlockIdx = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
creatBmpBlockDatAndSend(m_fileBegIdx,m_curBmpBlockIdx);
|
||||||
m_conpressDir *= -1;
|
m_conpressDir *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,8 +496,8 @@ void CreatPrintBmp::setMcPrintInfo(int fileIdx, McPrintInfo *printInfo)
|
|||||||
m_fileBegIdx = fileIdx;
|
m_fileBegIdx = fileIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
//自动打印
|
//是否自动打印
|
||||||
int autoPrint = 1;
|
int autoPrint = 0;
|
||||||
|
|
||||||
if(autoPrint == 1)
|
if(autoPrint == 1)
|
||||||
{
|
{
|
||||||
@ -665,75 +508,154 @@ void CreatPrintBmp::setMcPrintInfo(int fileIdx, McPrintInfo *printInfo)
|
|||||||
m_fileEndIdx = m_fileBegIdx + 1;
|
m_fileEndIdx = m_fileBegIdx + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_curFileIdx = m_fileBegIdx;
|
m_listFileIdx = m_fileBegIdx;
|
||||||
|
|
||||||
QDir apppath(qApp->applicationDirPath());
|
QDir apppath(qApp->applicationDirPath());
|
||||||
QString printPath = apppath.path() + apppath.separator() + PRINTDIR;
|
QString printPath = apppath.path() + apppath.separator() + PRINTDIR;
|
||||||
QString mcFile = printPath + apppath.separator() + PRINTMCDIR + QString::number(m_mcPrintInfo->m_mcNum);
|
QString mcFile = printPath + apppath.separator() + PRINTMCDIR + QString::number(m_mcPrintInfo->m_mcNum);
|
||||||
m_printFileDir = mcFile + apppath.separator() + PRINTFILEDIR;
|
m_printFileDir = mcFile + apppath.separator() + PRINTFILEDIR;
|
||||||
|
m_workState = WORK_START;
|
||||||
|
|
||||||
|
m_autoDirFilesList.clear();
|
||||||
|
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||||||
|
{
|
||||||
|
QString iniName = "MachineNo" + QString::number(m_mcPrintInfo->m_mcNum) + ".ini";
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
QStringList filter;
|
||||||
|
filter << QString("*.plt") << QString("*.PLT")
|
||||||
|
<< QString("*.png") << QString("*.PNG")
|
||||||
|
<< QString("*.bmp") << QString("*.BMP")
|
||||||
|
<< QString("*.jpg") << QString("*.JPG");
|
||||||
|
m_autoDirFilesList = dir.entryInfoList(filter, QDir::Files | QDir::NoSymLinks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatPrintBmp::setDeleteFile(int fileIdx)
|
QDir printDir(printPath);//总的打印目录
|
||||||
|
if(!printDir.exists())
|
||||||
{
|
{
|
||||||
if(fileIdx == m_curFileIdx)
|
printDir.mkdir(printPath);
|
||||||
|
}
|
||||||
|
QDir mcDir(mcFile);//对应每台机器打印目录
|
||||||
|
if(!mcDir.exists())
|
||||||
|
{
|
||||||
|
mcDir.mkdir(mcFile);
|
||||||
|
}
|
||||||
|
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatPrintBmp::stopCreatPrintDat()
|
||||||
|
{
|
||||||
|
m_workState = WORK_PAUSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatPrintBmp::setDeleteFile(McPrintInfo *printInfo, int fileIdx)
|
||||||
|
{
|
||||||
|
if(m_mcPrintInfo == NULL)
|
||||||
|
{
|
||||||
|
m_mcPrintInfo = printInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fileIdx == m_fileBegIdx)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_deleteFileIdx = fileIdx;
|
m_deleteFileIdx = fileIdx;
|
||||||
//空闲时的删除文件操作
|
|
||||||
if(m_mcPrintInfo->m_mcWorkState == NotBusy)
|
if(m_deleteFileIdx != m_fileBegIdx && m_deleteFileIdx != -1)
|
||||||
{
|
{
|
||||||
int length = (m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.right() - m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.left())/M_IDPMM;
|
int length = (m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.right() - m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_fileRect.left())/M_IDPMM;
|
||||||
m_mcPrintInfo->m_fileTotalLength -= length;
|
m_mcPrintInfo->m_fileTotalLength -= length;
|
||||||
m_mcPrintInfo->m_filesList[m_deleteFileIdx].clear();
|
|
||||||
m_mcPrintInfo->m_filesList.removeAt(m_deleteFileIdx);
|
|
||||||
QString mcFile = m_printFileDir + QString::number(m_deleteFileIdx+1);
|
QString mcFile = m_printFileDir + QString::number(m_deleteFileIdx+1);
|
||||||
QDir fileDir(mcFile);
|
QDir fileDir(mcFile);
|
||||||
if(fileDir.exists())
|
if(fileDir.exists())
|
||||||
{
|
{
|
||||||
//删除位图文件夹
|
//删除位图文件夹
|
||||||
QFileInfoList fileList = fileDir.entryInfoList(QDir::Files);
|
fileDir.removeRecursively();
|
||||||
for(int i = 0; i < fileList.size(); i++)
|
}
|
||||||
|
|
||||||
|
//如果为自动绘图目录中的文件,删除自动绘图目录文件夹中已打印完成的文件
|
||||||
|
QString filePath = m_mcPrintInfo->m_filesList[m_deleteFileIdx].m_filePath;
|
||||||
|
QDir apppath(qApp->applicationDirPath());
|
||||||
|
QString iniName = "MachineNo" + QString::number(m_mcPrintInfo->m_mcNum) + ".ini";
|
||||||
|
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(filePath))
|
||||||
{
|
{
|
||||||
QString fileStr = fileList[i].filePath();
|
//文件存在
|
||||||
QFile::remove(fileStr);
|
QFile::remove(filePath);
|
||||||
|
if(m_deleteFileIdx < m_autoDirFilesList.size())
|
||||||
|
{
|
||||||
|
m_autoDirFilesList.removeAt(m_deleteFileIdx);//删除自动绘图目录文件列表中的文件
|
||||||
}
|
}
|
||||||
fileDir.rmdir(mcFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_mcPrintInfo->m_filesList[m_deleteFileIdx].clear();
|
||||||
|
m_mcPrintInfo->m_filesList.removeAt(m_deleteFileIdx);
|
||||||
|
|
||||||
m_mcPrintInfo->m_fileNums = m_mcPrintInfo->m_filesList.size();
|
m_mcPrintInfo->m_fileNums = m_mcPrintInfo->m_filesList.size();
|
||||||
m_deleteFileIdx = -1;
|
m_deleteFileIdx = -1;
|
||||||
emit siDeleteFileFinish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatPrintBmp::setMoveFile(int fileIdx, int dir)
|
void CreatPrintBmp::setMoveFile(McPrintInfo *printInfo, int fileIdx, int dir)
|
||||||
{
|
{
|
||||||
if(fileIdx == m_curFileIdx)
|
if(m_mcPrintInfo == NULL)
|
||||||
|
{
|
||||||
|
m_mcPrintInfo = printInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fileIdx == m_fileBegIdx)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_moveFileIdx = fileIdx;//上下移动打印文件索引
|
m_moveFileIdx = fileIdx;//上下移动打印文件索引
|
||||||
m_moveDir = dir;//-1,上移 1,下移
|
m_moveDir = dir;//-1,上移 1,下移
|
||||||
|
|
||||||
//空闲时的移动文件操作
|
//非正在打印的文件,正在发送文件时的上下移操作
|
||||||
if(m_mcPrintInfo->m_mcWorkState == NotBusy)
|
if(m_moveFileIdx != m_fileBegIdx && m_moveFileIdx != -1 && m_moveDir != 0)
|
||||||
{
|
{
|
||||||
//交换列表
|
//交换列表
|
||||||
McFilesInfo info = m_mcPrintInfo->m_filesList[fileIdx];
|
McFilesInfo info = m_mcPrintInfo->m_filesList[fileIdx];
|
||||||
|
QFileInfo fileInfo;
|
||||||
|
if(fileIdx < m_autoDirFilesList.size())
|
||||||
|
{
|
||||||
|
fileInfo = m_autoDirFilesList[fileIdx];
|
||||||
|
}
|
||||||
McFilesInfo cInfo;
|
McFilesInfo cInfo;
|
||||||
|
QFileInfo cFileInfo;
|
||||||
if(dir == -1)
|
if(dir == -1)
|
||||||
{
|
{
|
||||||
cInfo = m_mcPrintInfo->m_filesList[fileIdx-1];
|
cInfo = m_mcPrintInfo->m_filesList[fileIdx-1];
|
||||||
m_mcPrintInfo->m_filesList[fileIdx-1] = info;
|
m_mcPrintInfo->m_filesList[fileIdx-1] = info;
|
||||||
|
|
||||||
|
cFileInfo = m_autoDirFilesList[fileIdx-1];
|
||||||
|
m_autoDirFilesList[fileIdx-1] = fileInfo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cInfo = m_mcPrintInfo->m_filesList[fileIdx+1];
|
cInfo = m_mcPrintInfo->m_filesList[fileIdx+1];
|
||||||
m_mcPrintInfo->m_filesList[fileIdx+1] = info;
|
m_mcPrintInfo->m_filesList[fileIdx+1] = info;
|
||||||
|
|
||||||
|
if(fileIdx+1 < m_autoDirFilesList.size())
|
||||||
|
{
|
||||||
|
cFileInfo = m_autoDirFilesList[fileIdx+1];
|
||||||
|
m_autoDirFilesList[fileIdx+1] = fileInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mcPrintInfo->m_filesList[fileIdx] = cInfo;
|
m_mcPrintInfo->m_filesList[fileIdx] = cInfo;
|
||||||
|
if(fileIdx < m_autoDirFilesList.size())
|
||||||
|
{
|
||||||
|
m_autoDirFilesList[fileIdx] = cFileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
m_moveFileIdx = -1;//上下移动打印文件索引
|
m_moveFileIdx = -1;//上下移动打印文件索引
|
||||||
m_moveDir = 0;//-1,上移 1,下移
|
m_moveDir = 0;//-1,上移 1,下移
|
||||||
|
@ -14,30 +14,15 @@
|
|||||||
#include "bwbmp.h"
|
#include "bwbmp.h"
|
||||||
#include "machine/printinfo/mcfiles.h"
|
#include "machine/printinfo/mcfiles.h"
|
||||||
#include "datafile/hpgl/importhpgl.h"
|
#include "datafile/hpgl/importhpgl.h"
|
||||||
|
#include "datafile/view/drawdata.h"
|
||||||
|
|
||||||
#define TYPE_FILE 0
|
|
||||||
#define TYPE_IMAGE 1
|
|
||||||
#define PIXMAPWIDTH 1200
|
#define PIXMAPWIDTH 1200
|
||||||
#define PENWIDTH 5
|
#define PENWIDTH 5
|
||||||
|
|
||||||
#define START 1
|
|
||||||
#define PAUSE 0
|
|
||||||
|
|
||||||
#define PRINTDIR "print"
|
#define PRINTDIR "print"
|
||||||
#define PRINTMCDIR "mc"
|
#define PRINTMCDIR "mc"
|
||||||
#define PRINTFILEDIR "file"
|
#define PRINTFILEDIR "file"
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u32 blkIdx; // 当前位图块号(位图分块后的编号)
|
|
||||||
u32 biWidth; // 本块位图有效宽度,以像素为单位
|
|
||||||
u32 biHeight; // 本块位图有效高度,以像素为单位
|
|
||||||
u32 begPosY; // 本块起始位置(像素单位)
|
|
||||||
u32 endPosY; // 本块结束位置(像素单位)
|
|
||||||
u8 compType; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩;
|
|
||||||
u8 compDir; // 本块位图压缩方向, =0, 从上到下; =1, 从下到上;(喷墨方向)
|
|
||||||
}__attribute__ ((packed)) BmpDatInfo;
|
|
||||||
|
|
||||||
class CreatPrintBmp : public QObject
|
class CreatPrintBmp : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -49,26 +34,25 @@ private:
|
|||||||
QPicture m_picture;//绘图路径-线段
|
QPicture m_picture;//绘图路径-线段
|
||||||
QString m_savePath;
|
QString m_savePath;
|
||||||
int m_workState;
|
int m_workState;
|
||||||
int m_beginPrintFileIdx;//开始打印文件索引
|
|
||||||
int m_deleteFileIdx;//删除打印文件索引
|
int m_deleteFileIdx;//删除打印文件索引
|
||||||
McPrintInfo *m_mcPrintInfo;//机器信息
|
McPrintInfo *m_mcPrintInfo;//机器信息
|
||||||
int m_fileBegIdx;
|
int m_fileBegIdx;//开始打印和正在打印文件索引(因为打印完成一个就要删掉一个,所以正在打印的文件永远是起始文件索引)
|
||||||
int m_fileEndIdx;
|
int m_fileEndIdx;
|
||||||
int m_curFileIdx;//当前生成数据的文件索引
|
int m_listFileIdx;//初始文件列表时将要生成文件数据的文件索引
|
||||||
int m_curBmpBlockIdx;//当前生成数据的位图块数索引
|
int m_curBmpBlockIdx;//当前生成数据的位图块数索引
|
||||||
int m_conpressDir;//压缩方向
|
int m_conpressDir;//压缩方向
|
||||||
QString m_printFileDir;//打印文件目录
|
QString m_printFileDir;//打印文件目录
|
||||||
|
|
||||||
int m_moveFileIdx;//上下移动打印文件索引
|
int m_moveFileIdx;//上下移动打印文件索引
|
||||||
s16 m_moveDir;//-1,上移 1,下移
|
s16 m_moveDir;//-1,上移 1,下移
|
||||||
|
double m_rotateAngle;
|
||||||
|
|
||||||
|
QFileInfoList m_autoDirFilesList;//自动绘图目录中文件列表
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int creatFileListMarker();//加载文件列表marker数据
|
int creatFileListMarker(int idx);//加载文件列表marker数据
|
||||||
void creatMarkerDat(McFilesInfo &curFilesInfo, QString filePath, int fileIdx);//创建Marker数据
|
|
||||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
|
||||||
|
|
||||||
int creatFileListDatAndSend(int idx);//创建文件列表数据并发送
|
int creatFileListDatAndSend(int idx);//创建文件列表数据并发送
|
||||||
int creatBmpBlockDatAndSend(int idx);//创建位图块数据并发送
|
int creatBmpBlockDatAndSend(int fileidx, int idx);//创建位图块数据并发送
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setPicture(QPicture pic);
|
void setPicture(QPicture pic);
|
||||||
@ -76,14 +60,17 @@ public:
|
|||||||
void setSavePath(QString path);
|
void setSavePath(QString path);
|
||||||
QString getSavePath();
|
QString getSavePath();
|
||||||
void setMcPrintInfo(int fileIdx,McPrintInfo *printInfo);//设置机器信息
|
void setMcPrintInfo(int fileIdx,McPrintInfo *printInfo);//设置机器信息
|
||||||
void setDeleteFile(int fileIdx);//删除文件
|
void stopCreatPrintDat();//停止生成打印数据
|
||||||
void setMoveFile(int fileIdx, int dir = -1);//上下移动文件
|
void setDeleteFile(McPrintInfo *printInfo, int fileIdx);//删除文件
|
||||||
|
void setMoveFile(McPrintInfo *printInfo, int fileIdx, int dir = -1);//上下移动文件
|
||||||
|
inline void setRotateAngle(double angle){m_rotateAngle = angle;}//设置旋转角度
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void siCreatOneBmpFinished(int mcIdx,unsigned char *dat,int datSize);
|
void siCreatOneBmpFinished(int mcIdx,unsigned char *dat,int datSize);
|
||||||
void siSendFileListDatToMc(int idx);
|
void siSendFileListDatToMc(int idx);
|
||||||
void siSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo);
|
void siSendDatToMc(QByteArray dat);
|
||||||
void siDeleteFileFinish();//删除文件完成
|
void siOneFilePrintFinished(int mcNum,int fileIdx,int refreshFlag);//一个文件打印完成
|
||||||
|
void siRefreshPrintProgress(int mcNum,int fileIdx);//刷新打印进度
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotCreatBmp();
|
void slotCreatBmp();
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
#define WORK_START 0x0001 // 启动工作
|
#define WORK_START 0x0001 // 启动工作
|
||||||
#define WORK_PAUSE 0x0002 // 暂停工作
|
#define WORK_PAUSE 0x0002 // 暂停工作
|
||||||
|
|
||||||
|
#pragma pack(1)//设定为1字节对齐
|
||||||
|
|
||||||
// 喷墨图像按照黑白位图的格式存储
|
// 喷墨图像按照黑白位图的格式存储
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ typedef struct
|
|||||||
u32 rev[16-5];
|
u32 rev[16-5];
|
||||||
}__attribute__ ((packed)) PlotFileList;
|
}__attribute__ ((packed)) PlotFileList;
|
||||||
|
|
||||||
// 自定义压缩位图文件头
|
// 压缩位图文件头
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// 0
|
// 0
|
||||||
@ -110,19 +111,57 @@ typedef struct
|
|||||||
u32 biWidth; // 本块位图有效宽度,以像素为单位
|
u32 biWidth; // 本块位图有效宽度,以像素为单位
|
||||||
u32 biHeight; // 本块位图有效高度,以像素为单位
|
u32 biHeight; // 本块位图有效高度,以像素为单位
|
||||||
u32 dataChecksum; // 本块位图数据累加校验和
|
u32 dataChecksum; // 本块位图数据累加校验和
|
||||||
u32 begPosY; // 本块起始位置(像素单位)
|
u32 begPosY; // 本块位图起始位置(像素单位)
|
||||||
u32 endPosY; // 本块结束位置(像素单位)
|
u32 endPosY; // 本块位图结束位置(像素单位)
|
||||||
|
|
||||||
// 32
|
// 32
|
||||||
u8 compType; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩;
|
u16 compDir; // 本块位图压缩方向, =0, 从上到下; =1, 从下到上;(喷墨方向)
|
||||||
u8 compDir; // 本块位图压缩方向, =0, 从上到下; =1, 从下到上;(喷墨方向)
|
u16 compSegWidth; // 分段宽度(0,默认整个宽度,分段宽度必须能被本块位图有效宽度整除)
|
||||||
|
u16 compSegHeight; // 分段高度(0,默认1行的高度)
|
||||||
|
u16 compFillWidth; // 压缩填充位数
|
||||||
|
u8 compType[4]; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩(分段压缩);
|
||||||
|
u32 compSegOffset[4]; // 分段数据起始位置
|
||||||
|
|
||||||
// 34
|
#if (1)
|
||||||
u8 rev[64-2-34]; // 保留
|
// 60
|
||||||
|
u8 rev[128-2-60]; // 保留
|
||||||
|
#else
|
||||||
|
// 保存原图中BMP头文件(算法测试用)
|
||||||
|
// 60
|
||||||
|
u8 rev[64-60]; // 保留
|
||||||
|
|
||||||
// 62
|
// 64
|
||||||
|
u16 identifier; // 类型 一般为 "BM"
|
||||||
|
u32 fileSize; // 文件大小
|
||||||
|
u32 reserved; // 保留
|
||||||
|
u32 bitDatOffset; // 位图数据偏移,一般为 0x3E
|
||||||
|
|
||||||
|
// 78
|
||||||
|
u32 biSize; // 位图信息头大小, 一般为 0x28
|
||||||
|
u32 biWidth2; // 位图宽度,以像素为单位
|
||||||
|
u32 biHeight2; // 位图高度,以像素为单位
|
||||||
|
u16 biPlanes; // 位图的位面数,必须为1
|
||||||
|
|
||||||
|
// 92
|
||||||
|
u16 biBitPerPixel; // 每个像素的位数, =1, 单色位图; =4, 16色; = 8, 256色; = 24 真彩色
|
||||||
|
u32 biCompression; // 位图压缩类型, =0, 不压缩(BI_RGB); =1, BI_RLE8; = 2, BI_RLE4; = 3 BI_BITFIELDS; = 4, BI_JPEG; = 5, BI_PNG
|
||||||
|
u32 biBitmapDatSize;// 位图数据区的大小(字节数), 必须是4的整数倍
|
||||||
|
|
||||||
|
// 102
|
||||||
|
u32 biHResolution; // 水平分辨率, 像素/米
|
||||||
|
u32 biVResolution; // 垂直分辨率, 像素/米
|
||||||
|
u32 biColors; // 颜色数
|
||||||
|
u32 biImpColors; // 重要颜色数
|
||||||
|
|
||||||
|
// 118
|
||||||
|
BmpRgbQuad palette[2]; // 调色板
|
||||||
|
|
||||||
|
// 126
|
||||||
|
//u8 rev2[128-2-126]; // 保留
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// 126
|
||||||
u16 checkCrc; // 前面字段的CRC校验
|
u16 checkCrc; // 前面字段的CRC校验
|
||||||
|
|
||||||
}__attribute__ ((packed)) CompBmpHead;
|
}__attribute__ ((packed)) CompBmpHead;
|
||||||
|
|
||||||
// 机器信息结构定义
|
// 机器信息结构定义
|
||||||
|
@ -99,8 +99,6 @@ Machine::Machine(QObject *parent) : QObject(parent)
|
|||||||
m_pSendTimer->setInterval(100); // 设置定时间隔100毫秒
|
m_pSendTimer->setInterval(100); // 设置定时间隔100毫秒
|
||||||
connect(m_pSendTimer, SIGNAL(timeout()), this, SLOT(onSendTimer()));
|
connect(m_pSendTimer, SIGNAL(timeout()), this, SLOT(onSendTimer()));
|
||||||
initDataExFuns();
|
initDataExFuns();
|
||||||
|
|
||||||
qRegisterMetaType<BmpDatInfo >("BmpDatInfo");//对自定义类型注册
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Machine::~Machine()
|
Machine::~Machine()
|
||||||
@ -400,12 +398,12 @@ void Machine::mcWorkCmd(int workcode, int para1, int para2)
|
|||||||
|
|
||||||
void Machine::deleteFilePrintDat(int fileIdx)
|
void Machine::deleteFilePrintDat(int fileIdx)
|
||||||
{
|
{
|
||||||
m_pCreatPrintDat->setDeleteFile(fileIdx);
|
m_pCreatPrintDat->setDeleteFile(&m_mcPrintInfo,fileIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::moveFilePrintDat(int fileIdx,int dir)
|
void Machine::moveFilePrintDat(int fileIdx,int dir)
|
||||||
{
|
{
|
||||||
m_pCreatPrintDat->setMoveFile(fileIdx,dir);
|
m_pCreatPrintDat->setMoveFile(&m_mcPrintInfo,fileIdx,dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::invalidateWorkFile(int idx)
|
void Machine::invalidateWorkFile(int idx)
|
||||||
@ -413,12 +411,21 @@ void Machine::invalidateWorkFile(int idx)
|
|||||||
setMcStatus(MC_INVALID_FILE, idx);
|
setMcStatus(MC_INVALID_FILE, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::creatPrintDat(int fileIdx)
|
void Machine::creatPrintDat(int fileIdx,int setFlag)
|
||||||
|
{
|
||||||
|
if(setFlag == 1)
|
||||||
{
|
{
|
||||||
m_pCreatPrintDat->setMcPrintInfo(fileIdx,&m_mcPrintInfo);
|
m_pCreatPrintDat->setMcPrintInfo(fileIdx,&m_mcPrintInfo);
|
||||||
|
}
|
||||||
emit siCreatData();
|
emit siCreatData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Machine::stopPrint()
|
||||||
|
{
|
||||||
|
m_pCreatPrintDat->stopCreatPrintDat();
|
||||||
|
m_transBreak = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void Machine::setIpAndPort(QString mcName, QString serverIp, quint16 serverPort, QString localIp, quint16 localPort)
|
void Machine::setIpAndPort(QString mcName, QString serverIp, quint16 serverPort, QString localIp, quint16 localPort)
|
||||||
{
|
{
|
||||||
m_mcName = mcName;
|
m_mcName = mcName;
|
||||||
@ -445,18 +452,21 @@ void Machine::startCommunication()
|
|||||||
m_pCreatPrintDat->moveToThread(m_pTcpBmpThread);
|
m_pCreatPrintDat->moveToThread(m_pTcpBmpThread);
|
||||||
connect(m_pTcpBmpThread, SIGNAL(finished()), m_pCreatPrintDat, SLOT(deleteLater()) ); // 退出删除对象
|
connect(m_pTcpBmpThread, SIGNAL(finished()), m_pCreatPrintDat, SLOT(deleteLater()) ); // 退出删除对象
|
||||||
connect(this, SIGNAL(siCreatData()),
|
connect(this, SIGNAL(siCreatData()),
|
||||||
m_pCreatPrintDat, SLOT(slotCreatBmp()), Qt::QueuedConnection); // 发送数据的槽
|
m_pCreatPrintDat, SLOT(slotCreatBmp()), Qt::QueuedConnection); // 开始创建位图的槽
|
||||||
connect(this, SIGNAL(siSendDataDone()),
|
connect(this, SIGNAL(siSendDataDone()),
|
||||||
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 发送数据的槽
|
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 创建位图块并发送的槽
|
||||||
connect(this, SIGNAL(siCreatBmpBlockDatAndSend()),
|
connect(this, SIGNAL(siCreatBmpBlockDatAndSend()),
|
||||||
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 发送数据的槽
|
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 创建位图块并发送的槽
|
||||||
|
|
||||||
connect(m_pCreatPrintDat, SIGNAL(siSendFileListDatToMc(int)),
|
connect(m_pCreatPrintDat, SIGNAL(siSendFileListDatToMc(int)),
|
||||||
this, SLOT(slotSendPlotFileListToMc(int)), Qt::QueuedConnection); // 发送数据的槽
|
this, SLOT(slotSendPlotFileListToMc(int)), Qt::QueuedConnection); // 发送文件列表的槽
|
||||||
connect(m_pCreatPrintDat, SIGNAL(siSendDatToMc(QByteArray,BmpDatInfo)),
|
connect(m_pCreatPrintDat, SIGNAL(siSendDatToMc(QByteArray)),
|
||||||
this, SLOT(slotSendDatToMc(QByteArray,BmpDatInfo)), Qt::QueuedConnection); // 发送数据的槽
|
this, SLOT(slotSendDatToMc(QByteArray)), Qt::QueuedConnection); // 发送数据的槽
|
||||||
connect(m_pCreatPrintDat, SIGNAL(siDeleteFileFinish()),
|
|
||||||
this, SIGNAL(siDeleteFileFinish())); // 删除文件
|
connect(m_pCreatPrintDat, SIGNAL(siOneFilePrintFinished(int,int,int)),
|
||||||
|
this, SIGNAL(siOneFilePrintFinished(int,int,int)), Qt::AutoConnection); // 完成一个文件的打印
|
||||||
|
connect(m_pCreatPrintDat, SIGNAL(siRefreshPrintProgress(int,int)),
|
||||||
|
this, SIGNAL(siRefreshPrintProgress(int,int)), Qt::AutoConnection); // 刷新打印进度
|
||||||
|
|
||||||
m_pTcpBmpThread->start(); // 启动线程
|
m_pTcpBmpThread->start(); // 启动线程
|
||||||
}
|
}
|
||||||
@ -957,7 +967,7 @@ void Machine::onSendTimer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
void Machine::slotSendDatToMc(QByteArray dat)
|
||||||
{
|
{
|
||||||
if(m_connected == Connected)
|
if(m_connected == Connected)
|
||||||
{
|
{
|
||||||
@ -970,6 +980,11 @@ void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
delayTime.start();
|
delayTime.start();
|
||||||
|
|
||||||
|
if (m_transCtrl.filetransing != 0) // 已经有文件在传输
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (m_transCtrl.filetransing != 0) // 已经有文件在传输
|
while (m_transCtrl.filetransing != 0) // 已经有文件在传输
|
||||||
{
|
{
|
||||||
if (delayTime.elapsed() > 1000)
|
if (delayTime.elapsed() > 1000)
|
||||||
@ -984,18 +999,9 @@ void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
|||||||
|
|
||||||
qDebug()<<"dat.size()"<<dat.size();
|
qDebug()<<"dat.size()"<<dat.size();
|
||||||
|
|
||||||
|
memcpy((u8*)m_pCompBmpHead,(u8*)dat.data(),sizeof(CompBmpHead));
|
||||||
|
|
||||||
m_pCompBmpHead->fileId = m_pPlotFileList->fileId;
|
m_pCompBmpHead->fileId = m_pPlotFileList->fileId;
|
||||||
m_pCompBmpHead->blkIdx = bmpInfo.blkIdx;
|
|
||||||
m_pCompBmpHead->datSize = dat.size();
|
|
||||||
m_pCompBmpHead->biWidth = bmpInfo.biWidth;
|
|
||||||
m_pCompBmpHead->biHeight = bmpInfo.biHeight;
|
|
||||||
m_pCompBmpHead->begPosY = bmpInfo.begPosY;
|
|
||||||
m_pCompBmpHead->endPosY = bmpInfo.endPosY;
|
|
||||||
m_pCompBmpHead->compType = bmpInfo.compType;
|
|
||||||
m_pCompBmpHead->compDir = bmpInfo.compDir;
|
|
||||||
m_pCompBmpHead->dataChecksum = calcCheckSum32((u8*)dat.data() , dat.size()); // 数据累加校验和
|
|
||||||
int len = sizeof(m_pCompBmpHead)-sizeof(m_pCompBmpHead->checkCrc);
|
|
||||||
m_pCompBmpHead->checkCrc = calcCrc16((u8*)m_pCompBmpHead, len); // 前面字段的CRC校验
|
|
||||||
|
|
||||||
if (m_pCompBmpHead->datSize <= 0 || m_pCompBmpHead->datSize > MAX_FILE_SIZE)
|
if (m_pCompBmpHead->datSize <= 0 || m_pCompBmpHead->datSize > MAX_FILE_SIZE)
|
||||||
{
|
{
|
||||||
@ -1008,7 +1014,7 @@ void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
|||||||
m_transCtrl.fileType = (u8)FILE_TYPE_PLOT;
|
m_transCtrl.fileType = (u8)FILE_TYPE_PLOT;
|
||||||
m_transCtrl.fileId = m_pCompBmpHead->fileId;
|
m_transCtrl.fileId = m_pCompBmpHead->fileId;
|
||||||
memcpy(m_transCtrl.pBmpHead, m_pCompBmpHead, sizeof(CompBmpHead));
|
memcpy(m_transCtrl.pBmpHead, m_pCompBmpHead, sizeof(CompBmpHead));
|
||||||
memcpy(m_transCtrl.pDatBuff, dat, m_pCompBmpHead->datSize);
|
memcpy(m_transCtrl.pDatBuff, dat.data()+sizeof(CompBmpHead), m_pCompBmpHead->datSize);
|
||||||
m_transCtrl.packetSize = MAX_EXDP_LEN;
|
m_transCtrl.packetSize = MAX_EXDP_LEN;
|
||||||
m_transCtrl.packetNum = (m_pCompBmpHead->datSize + MAX_EXDP_LEN - 1) / MAX_EXDP_LEN;
|
m_transCtrl.packetNum = (m_pCompBmpHead->datSize + MAX_EXDP_LEN - 1) / MAX_EXDP_LEN;
|
||||||
|
|
||||||
@ -1034,8 +1040,8 @@ void Machine::slotSendPlotFileListToMc(int idx)
|
|||||||
u32 id =qrand() % (UINT16_MAX);//产生0到UINT16_MAX的随机数
|
u32 id =qrand() % (UINT16_MAX);//产生0到UINT16_MAX的随机数
|
||||||
m_pPlotFileList->fileId = id;
|
m_pPlotFileList->fileId = id;
|
||||||
m_pPlotFileList->totalWidth = (m_mcPrintInfo.m_filesList[idx].m_pic.width() - oft) * m_mcPrintInfo.m_filesList[idx].m_printNum;
|
m_pPlotFileList->totalWidth = (m_mcPrintInfo.m_filesList[idx].m_pic.width() - oft) * m_mcPrintInfo.m_filesList[idx].m_printNum;
|
||||||
m_pPlotFileList->totalHeight = m_mcPrintInfo.m_filesList[idx].m_pic.height() * m_mcPrintInfo.m_filesList[idx].m_printNum;
|
m_pPlotFileList->totalHeight = m_mcPrintInfo.m_filesList[idx].m_pic.height();
|
||||||
m_pPlotFileList->blkNums = m_mcPrintInfo.m_filesList[idx].m_totalBlocks * m_mcPrintInfo.m_filesList[idx].m_printNum;
|
m_pPlotFileList->blkNums = m_mcPrintInfo.m_filesList[idx].m_totalBlocks;
|
||||||
m_pPlotFileList->blkWidth = PIXMAPWIDTH;
|
m_pPlotFileList->blkWidth = PIXMAPWIDTH;
|
||||||
|
|
||||||
int rslt;
|
int rslt;
|
||||||
|
@ -104,7 +104,9 @@ public:
|
|||||||
// 机器工作命令
|
// 机器工作命令
|
||||||
void mcWorkCmd(int workcode, int para1 = 0 , int para2 = 0);
|
void mcWorkCmd(int workcode, int para1 = 0 , int para2 = 0);
|
||||||
|
|
||||||
void creatPrintDat(int fileIdx); //生成打印数据
|
void creatPrintDat(int fileIdx,int setFlag = 1); //生成打印数据
|
||||||
|
void stopPrint(); //停止打印
|
||||||
|
|
||||||
void deleteFilePrintDat(int fileIdx);//删除文件打印数据
|
void deleteFilePrintDat(int fileIdx);//删除文件打印数据
|
||||||
void moveFilePrintDat(int fileIdx,int dir = -1);//移动(上下移)文件打印数据
|
void moveFilePrintDat(int fileIdx,int dir = -1);//移动(上下移)文件打印数据
|
||||||
|
|
||||||
@ -122,15 +124,15 @@ signals:
|
|||||||
void siTransProgress(u8 fileType, int send, int total); // 文件传输结果信号
|
void siTransProgress(u8 fileType, int send, int total); // 文件传输结果信号
|
||||||
void siCreatData(); //生成要发送的数据
|
void siCreatData(); //生成要发送的数据
|
||||||
void siCreatBmpBlockDatAndSend();//生成位图数据块数据并发送
|
void siCreatBmpBlockDatAndSend();//生成位图数据块数据并发送
|
||||||
void siDeleteFileFinish();
|
void siOneFilePrintFinished(int mcNum, int fileIdx, int refreshFlag);//完成一个文件的打印
|
||||||
void siMoveFileFinish();
|
void siRefreshPrintProgress(int mcNum, int fileIdx);//刷新打印进度
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotConnectSta(int sta); // 连接状态改变的槽函数
|
void slotConnectSta(int sta); // 连接状态改变的槽函数
|
||||||
void slotConnectErr(QString errinfo); // 接收到通讯错误槽函数
|
void slotConnectErr(QString errinfo); // 接收到通讯错误槽函数
|
||||||
void slotReceiveData(QByteArray dat); // 接收到数据的槽函数
|
void slotReceiveData(QByteArray dat); // 接收到数据的槽函数
|
||||||
void onSendTimer(void);
|
void onSendTimer(void);
|
||||||
void slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo);//发送打印数据
|
void slotSendDatToMc(QByteArray dat);//发送打印数据
|
||||||
void slotSendPlotFileListToMc(int idx);//发送设置文件列表
|
void slotSendPlotFileListToMc(int idx);//发送设置文件列表
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -23,6 +23,16 @@ enum WorkState
|
|||||||
Busying = 1 //工作中
|
Busying = 1 //工作中
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//打印状态
|
||||||
|
enum PrintState
|
||||||
|
{
|
||||||
|
Waitting = 0,//等待打印
|
||||||
|
Printting = 1, //打印中
|
||||||
|
Pause = 2, //暂停打印
|
||||||
|
Complete = 3//打印完成
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class McFilesInfo
|
class McFilesInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -34,8 +44,9 @@ public:
|
|||||||
QRect m_fileRect;//图形被包络的矩形区域
|
QRect m_fileRect;//图形被包络的矩形区域
|
||||||
s16 m_printNum;//打印份数
|
s16 m_printNum;//打印份数
|
||||||
s16 m_startPoint;//打印起始点
|
s16 m_startPoint;//打印起始点
|
||||||
QString m_printState;//打印状态
|
s16 m_printState;//打印状态
|
||||||
QPicture m_pic;//文件-图片
|
QPicture m_pic;//文件-发送的图片-实际笔宽绘制的pic
|
||||||
|
QPainterPath m_drawPath;//文件-数据绘图路径-用MyGraphicsItem画图时如果笔宽不为1,直接画QPicture时线条会很轻,所以用m_drawPath绘制
|
||||||
QBitmap m_pixmap;//图片-图片
|
QBitmap m_pixmap;//图片-图片
|
||||||
s16 m_totalBlocks;//总块数
|
s16 m_totalBlocks;//总块数
|
||||||
s16 m_curPrintBlock;//当前打印块数
|
s16 m_curPrintBlock;//当前打印块数
|
||||||
@ -47,6 +58,7 @@ public:
|
|||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
QPicture pic;
|
QPicture pic;
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
m_creatDataFlag = -1;
|
m_creatDataFlag = -1;
|
||||||
m_creatBmpFlag = -1;//是否已经生成bmp的标志
|
m_creatBmpFlag = -1;//是否已经生成bmp的标志
|
||||||
@ -55,8 +67,9 @@ public:
|
|||||||
m_fileType = 0;//文件类型
|
m_fileType = 0;//文件类型
|
||||||
m_printNum = 0;//打印份数
|
m_printNum = 0;//打印份数
|
||||||
m_startPoint = 0;//打印起始点
|
m_startPoint = 0;//打印起始点
|
||||||
m_printState.clear();//打印状态
|
m_printState = Waitting;//打印状态
|
||||||
m_pic = pic;
|
m_pic = pic;
|
||||||
|
m_drawPath = path;
|
||||||
m_pixmap.clear();
|
m_pixmap.clear();
|
||||||
m_totalBlocks = 0;//总块数
|
m_totalBlocks = 0;//总块数
|
||||||
m_curPrintBlock = 0;//当前打印块数
|
m_curPrintBlock = 0;//当前打印块数
|
||||||
@ -75,7 +88,7 @@ public:
|
|||||||
m_fileType = 0;//文件类型
|
m_fileType = 0;//文件类型
|
||||||
m_printNum = 0;//打印份数
|
m_printNum = 0;//打印份数
|
||||||
m_startPoint = 0;//打印起始点
|
m_startPoint = 0;//打印起始点
|
||||||
m_printState.clear();//打印状态
|
m_printState = Waitting;//打印状态
|
||||||
m_totalBlocks = 0;//总块数
|
m_totalBlocks = 0;//总块数
|
||||||
m_curPrintBlock = 0;//当前打印块数
|
m_curPrintBlock = 0;//当前打印块数
|
||||||
m_printedBlockNum = 0;//已打印块数
|
m_printedBlockNum = 0;//已打印块数
|
||||||
@ -95,6 +108,7 @@ public:
|
|||||||
m_startPoint = item.m_startPoint;//打印起始点
|
m_startPoint = item.m_startPoint;//打印起始点
|
||||||
m_printState = item.m_printState;//打印状态
|
m_printState = item.m_printState;//打印状态
|
||||||
m_pic = item.m_pic;
|
m_pic = item.m_pic;
|
||||||
|
m_drawPath = item.m_drawPath;
|
||||||
m_pixmap = item.m_pixmap;
|
m_pixmap = item.m_pixmap;
|
||||||
m_totalBlocks = item.m_totalBlocks;//总块数
|
m_totalBlocks = item.m_totalBlocks;//总块数
|
||||||
m_curPrintBlock = item.m_curPrintBlock;//当前打印块数
|
m_curPrintBlock = item.m_curPrintBlock;//当前打印块数
|
||||||
@ -116,6 +130,7 @@ public:
|
|||||||
m_startPoint = item.m_startPoint;//打印起始点
|
m_startPoint = item.m_startPoint;//打印起始点
|
||||||
m_printState = item.m_printState;//打印状态
|
m_printState = item.m_printState;//打印状态
|
||||||
m_pic = item.m_pic;
|
m_pic = item.m_pic;
|
||||||
|
m_drawPath = item.m_drawPath;
|
||||||
m_pixmap = item.m_pixmap;
|
m_pixmap = item.m_pixmap;
|
||||||
m_totalBlocks = item.m_totalBlocks;//总块数
|
m_totalBlocks = item.m_totalBlocks;//总块数
|
||||||
m_curPrintBlock = item.m_curPrintBlock;//当前打印块数
|
m_curPrintBlock = item.m_curPrintBlock;//当前打印块数
|
||||||
@ -136,13 +151,12 @@ public:
|
|||||||
QString m_mcName;//机器名称
|
QString m_mcName;//机器名称
|
||||||
int m_mcConnState;//机器连接状态
|
int m_mcConnState;//机器连接状态
|
||||||
int m_mcWorkState;//机器工作状态
|
int m_mcWorkState;//机器工作状态
|
||||||
int m_mcSendProgress;//机器文件发送进度
|
double m_mcSendProgress;//机器打印进度
|
||||||
int m_totalNums;//要发送的总块数
|
int m_totalNums;//要发送的总块数
|
||||||
int m_sendedlNums;//已发送的总块数
|
int m_sendedlNums;//已发送的总块数
|
||||||
QString m_ip;//机器ip
|
QString m_ip;//机器ip
|
||||||
s16 m_port;//机器端口
|
s16 m_port;//机器端口
|
||||||
s16 m_fileNums;//文件数量
|
s16 m_fileNums;//文件数量
|
||||||
s16 m_curCreatPrintDatFileIdx;//当前正在生成打印数据的文件索引
|
|
||||||
long long m_fileTotalLength;//文件总长度
|
long long m_fileTotalLength;//文件总长度
|
||||||
QList<McFilesInfo> m_filesList;//图片列表
|
QList<McFilesInfo> m_filesList;//图片列表
|
||||||
|
|
||||||
@ -160,7 +174,6 @@ public:
|
|||||||
m_port = 0;
|
m_port = 0;
|
||||||
m_fileNums = 0;
|
m_fileNums = 0;
|
||||||
m_fileTotalLength = 0;
|
m_fileTotalLength = 0;
|
||||||
m_curCreatPrintDatFileIdx = -1;
|
|
||||||
for(int i = 0; i < m_filesList.size(); i++)
|
for(int i = 0; i < m_filesList.size(); i++)
|
||||||
{
|
{
|
||||||
m_filesList[i].clear();
|
m_filesList[i].clear();
|
||||||
@ -183,7 +196,6 @@ public:
|
|||||||
m_port = 0;
|
m_port = 0;
|
||||||
m_fileNums = 0;
|
m_fileNums = 0;
|
||||||
m_fileTotalLength = 0;
|
m_fileTotalLength = 0;
|
||||||
m_curCreatPrintDatFileIdx = -1;
|
|
||||||
m_filesList.clear();
|
m_filesList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +213,6 @@ public:
|
|||||||
m_port = item.m_port;
|
m_port = item.m_port;
|
||||||
m_fileNums = item.m_fileNums;
|
m_fileNums = item.m_fileNums;
|
||||||
m_fileTotalLength = item.m_fileTotalLength;
|
m_fileTotalLength = item.m_fileTotalLength;
|
||||||
m_curCreatPrintDatFileIdx = -1;
|
|
||||||
m_filesList = item.m_filesList;
|
m_filesList = item.m_filesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +232,6 @@ public:
|
|||||||
m_port = item.m_port;
|
m_port = item.m_port;
|
||||||
m_fileNums = item.m_fileNums;
|
m_fileNums = item.m_fileNums;
|
||||||
m_fileTotalLength = item.m_fileTotalLength;
|
m_fileTotalLength = item.m_fileTotalLength;
|
||||||
m_curCreatPrintDatFileIdx = -1;
|
|
||||||
m_filesList = item.m_filesList;
|
m_filesList = item.m_filesList;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
35
main.cpp
35
main.cpp
@ -5,6 +5,25 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
QString switchLanguage(int language,QDir appPath)
|
||||||
|
{
|
||||||
|
QString languagePath;
|
||||||
|
switch (language)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return languagePath;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
@ -27,6 +46,14 @@ int main(int argc,char *argv[])
|
|||||||
{
|
{
|
||||||
settings.setValue("Local/ip","192.168.16.41");
|
settings.setValue("Local/ip","192.168.16.41");
|
||||||
settings.setValue("Local/port",5001);
|
settings.setValue("Local/port",5001);
|
||||||
|
|
||||||
|
settings.setValue("DrawSet/rotate90",0);//是否正向旋转90度
|
||||||
|
settings.setValue("DrawSet/vecfont",0);//是否使用矢量字体
|
||||||
|
settings.setValue("DrawSet/linewidth",2);//线宽
|
||||||
|
settings.setValue("DrawSet/paperwidth",2400);//纸张宽度
|
||||||
|
settings.setValue("DrawSet/rightmargin",0);//右边距
|
||||||
|
settings.setValue("DrawSet/markmargin",20);//马克间距
|
||||||
|
settings.setValue("DrawSet/buttmargin",100);//对接符间距
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -64,6 +91,14 @@ int main(int argc,char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//多语言翻译
|
||||||
|
int language = 0;
|
||||||
|
language = settings.value("HMI/language").toInt();
|
||||||
|
QString languageFile = switchLanguage(language,apppath);
|
||||||
|
g_pTranslator = new QTranslator();
|
||||||
|
g_pTranslator->load(languageFile);
|
||||||
|
qApp->installTranslator(g_pTranslator);
|
||||||
|
|
||||||
MainWindow mainWi;
|
MainWindow mainWi;
|
||||||
mainWi.initAllWinForm();
|
mainWi.initAllWinForm();
|
||||||
mainWi.show();
|
mainWi.show();
|
||||||
|
8
main.h
8
main.h
@ -11,16 +11,16 @@
|
|||||||
//语言
|
//语言
|
||||||
enum Language
|
enum Language
|
||||||
{
|
{
|
||||||
LANGUAGE_CHINESE = 1,
|
chinese = 1,
|
||||||
LANGUAGE_ENGLISH = 2
|
english = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _IN_MAIN_CPP
|
#ifdef _IN_MAIN_CPP
|
||||||
QList<Machine*> g_machineList;
|
QList<Machine*> g_machineList;
|
||||||
int g_language;
|
QTranslator *g_pTranslator;
|
||||||
#else
|
#else
|
||||||
extern QList<Machine*> g_machineList;
|
extern QList<Machine*> g_machineList;
|
||||||
extern int g_language;
|
extern QTranslator *g_pTranslator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MAIN_H
|
#endif // MAIN_H
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>MainWidget</class>
|
|
||||||
<widget class="QWidget" name="MainWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>800</width>
|
|
||||||
<height>480</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>III PlotCenter</string>
|
|
||||||
</property>
|
|
||||||
<action name="actionFile_F">
|
|
||||||
<property name="text">
|
|
||||||
<string>File(F)</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
789
mainwindow.cpp
789
mainwindow.cpp
File diff suppressed because it is too large
Load Diff
27
mainwindow.h
27
mainwindow.h
@ -27,20 +27,20 @@
|
|||||||
#include "printinfodialog.h"
|
#include "printinfodialog.h"
|
||||||
#include "addmachinedialog.h"
|
#include "addmachinedialog.h"
|
||||||
#include "datafile/hpgl/importhpgl.h"
|
#include "datafile/hpgl/importhpgl.h"
|
||||||
#include "datafile/dxf/dxfhelper.h"
|
|
||||||
#include "machine/bmp/creatprintbmp.h"
|
#include "machine/bmp/creatprintbmp.h"
|
||||||
|
|
||||||
//文件列表
|
//文件列表
|
||||||
#define COLUMN_NUM 8 //列数
|
#define COLUMN_NUM 9 //列数
|
||||||
#define COLUMN_COLWIDTH 96 //列宽
|
#define COLUMN_COLWIDTH 96 //列宽
|
||||||
#define COLUMN_FILENAME 0 //第1列-文件名称
|
#define COLUMN_FILENAME 0 //第1列-文件名称
|
||||||
#define COLUMN_LENGTH 1 //第2列-文件长度
|
#define COLUMN_LENGTH 1 //第2列-文件长度
|
||||||
#define COLUMN_WIDTH 2 //第3列-文件宽度
|
#define COLUMN_WIDTH 2 //第3列-文件宽度
|
||||||
#define COLUMN_START 3 //第4列-文件起始打印点
|
#define COLUMN_START 3 //第4列-文件起始打印点
|
||||||
#define COLUMN_PRINTEDLENGTH 4 //第5列-文件已打印长度
|
#define COLUMN_PRINTEDLENGTH 4 //第5列-文件已打印长度
|
||||||
#define COLUMN_NUMBERS 5 //第6列-文件打印数量
|
#define COLUMN_PRINTPROGRESS 5 //第6列-文件打印进度
|
||||||
#define COLUMN_STATE 6 //第7列-文件打印状态
|
#define COLUMN_NUMBERS 6 //第7列-文件打印数量
|
||||||
#define COLUMN_FILEPATH 7 //第8列-文件路径
|
#define COLUMN_STATE 7 //第8列-文件打印状态
|
||||||
|
#define COLUMN_FILEPATH 8 //第9列-文件路径
|
||||||
|
|
||||||
//机器连接列表
|
//机器连接列表
|
||||||
#define CONN_COLUMN_NUM 5 //列数
|
#define CONN_COLUMN_NUM 5 //列数
|
||||||
@ -49,7 +49,7 @@
|
|||||||
#define CONN_COLUMN_MCIP 1 //第2列-机器IP
|
#define CONN_COLUMN_MCIP 1 //第2列-机器IP
|
||||||
#define CONN_COLUMN_MCCONSTATE 2 //第3列-机器连接状态
|
#define CONN_COLUMN_MCCONSTATE 2 //第3列-机器连接状态
|
||||||
#define CONN_COLUMN_MCWORKSTATE 3 //第4列-机器工作状态
|
#define CONN_COLUMN_MCWORKSTATE 3 //第4列-机器工作状态
|
||||||
#define CONN_COLUMN_MCPROGRESS 4 //第5列-机器文件发送进度
|
#define CONN_COLUMN_MCPROGRESS 4 //第5列-机器打印进度
|
||||||
|
|
||||||
#define AUTOPRINT 1
|
#define AUTOPRINT 1
|
||||||
#define NOAUTOPRINT 0
|
#define NOAUTOPRINT 0
|
||||||
@ -74,7 +74,6 @@ private:
|
|||||||
PrintViewWindow *m_printViewWi;
|
PrintViewWindow *m_printViewWi;
|
||||||
PrintInfoDialog *m_printInfoDlg;
|
PrintInfoDialog *m_printInfoDlg;
|
||||||
MyGraphicsView *m_preView;
|
MyGraphicsView *m_preView;
|
||||||
QTimer *m_sendTimer;
|
|
||||||
QTimer * m_pTimer;//建立连接的定时器
|
QTimer * m_pTimer;//建立连接的定时器
|
||||||
|
|
||||||
int m_curMcIdx;//列表所选机器索引
|
int m_curMcIdx;//列表所选机器索引
|
||||||
@ -92,6 +91,8 @@ private:
|
|||||||
|
|
||||||
int m_breakAutoLoadThread;//打断自动加载文件线程
|
int m_breakAutoLoadThread;//打断自动加载文件线程
|
||||||
QFuture<void> m_autoPrintLoadThread;//自动绘图目录加载线程
|
QFuture<void> m_autoPrintLoadThread;//自动绘图目录加载线程
|
||||||
|
double m_rotateAngle;
|
||||||
|
QSettings *m_pSettings;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void closeEvent(QCloseEvent *e);
|
void closeEvent(QCloseEvent *e);
|
||||||
@ -99,8 +100,8 @@ private:
|
|||||||
void reflushMcFileInfo();
|
void reflushMcFileInfo();
|
||||||
void changeRowData(int move);
|
void changeRowData(int move);
|
||||||
bool deleteDir(QString path);
|
bool deleteDir(QString path);
|
||||||
void setButtonEnable(bool bl);
|
|
||||||
void startCreatBmpAndSend(int mcIdx = -1);//开始创建位图并发送
|
void startCreatBmpAndSend(int mcIdx = -1);//开始创建位图并发送
|
||||||
|
void stopPrint(int mcIdx = -1);//停止打印
|
||||||
QPicture creatFilePicture(McFilesInfo & mcFileInfo, s16 penWidth = 1);
|
QPicture creatFilePicture(McFilesInfo & mcFileInfo, s16 penWidth = 1);
|
||||||
//刷新连接状态
|
//刷新连接状态
|
||||||
void refConnectUi();//刷新连接状态(1秒)
|
void refConnectUi();//刷新连接状态(1秒)
|
||||||
@ -108,7 +109,8 @@ private:
|
|||||||
void refreshMcListShow();//刷新机器列表显示
|
void refreshMcListShow();//刷新机器列表显示
|
||||||
void refreshOneMcShow(int row,int idx);//刷新单个机器信息显示
|
void refreshOneMcShow(int row,int idx);//刷新单个机器信息显示
|
||||||
int refreshMcFileListShow(int idx);
|
int refreshMcFileListShow(int idx);
|
||||||
void creatMarkerDat(McFilesInfo &curFilesInfo, QString filePath);//创建Marker数据
|
void refreshBtnEnable();//刷新按钮可按状态
|
||||||
|
void switchLanguage(s16 languageType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initAllWinForm();
|
void initAllWinForm();
|
||||||
@ -124,11 +126,11 @@ private slots:
|
|||||||
void slotStartSetDlgShow();
|
void slotStartSetDlgShow();
|
||||||
void slotViewPrintInfo();
|
void slotViewPrintInfo();
|
||||||
void slotDeleteFile();//删除文件
|
void slotDeleteFile();//删除文件
|
||||||
void slotDeleteFileFinish();//删除文件完成并刷新
|
|
||||||
void slotDeleteMc();//删除机器
|
void slotDeleteMc();//删除机器
|
||||||
void onSendTimer(void);
|
|
||||||
void slotLoadAutoPrintFiles();
|
void slotLoadAutoPrintFiles();
|
||||||
void onOneSecondTimer();//1秒定时器
|
void onOneSecondTimer();//1秒定时器
|
||||||
|
void slotDeleteFileFromList(int mcNum, int fileIdx, int refreshFlag = 0);//从列表中删除已打印完成的文件
|
||||||
|
void slotRefreshPrintProgress(int mcNum, int fileIdx); //刷新打印进度
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionDrawing_Setting_triggered();
|
void on_actionDrawing_Setting_triggered();
|
||||||
@ -143,7 +145,6 @@ private slots:
|
|||||||
void on_actionOpenFileIcon_triggered();
|
void on_actionOpenFileIcon_triggered();
|
||||||
void on_actionOpen_Image_triggered();
|
void on_actionOpen_Image_triggered();
|
||||||
void on_actionOpenImageIcon_triggered();
|
void on_actionOpenImageIcon_triggered();
|
||||||
void on_actionDelete_triggered();
|
|
||||||
void on_actionAuto_Print_Dir_triggered();
|
void on_actionAuto_Print_Dir_triggered();
|
||||||
void on_actionStart_triggered();
|
void on_actionStart_triggered();
|
||||||
void on_actionStartIcon_triggered();
|
void on_actionStartIcon_triggered();
|
||||||
@ -152,6 +153,8 @@ private slots:
|
|||||||
void on_actionAddMachine_triggered();
|
void on_actionAddMachine_triggered();
|
||||||
void on_actionDeletMachine_triggered();
|
void on_actionDeletMachine_triggered();
|
||||||
void on_tableView_Connection_clicked(const QModelIndex &index);
|
void on_tableView_Connection_clicked(const QModelIndex &index);
|
||||||
|
void on_actionChinese_triggered();
|
||||||
|
void on_actionEnglish_triggered();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -259,7 +259,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1024</width>
|
<width>1024</width>
|
||||||
<height>23</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile_F">
|
<widget class="QMenu" name="menuFile_F">
|
||||||
@ -277,10 +277,8 @@
|
|||||||
<addaction name="menuTesting"/>
|
<addaction name="menuTesting"/>
|
||||||
<addaction name="actionStart"/>
|
<addaction name="actionStart"/>
|
||||||
<addaction name="actionPause"/>
|
<addaction name="actionPause"/>
|
||||||
<addaction name="actionDelete"/>
|
|
||||||
<addaction name="actionAuto_Print_Dir"/>
|
<addaction name="actionAuto_Print_Dir"/>
|
||||||
<addaction name="actionlog"/>
|
<addaction name="actionlog"/>
|
||||||
<addaction name="actionExit"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuConnect_Manage_C">
|
<widget class="QMenu" name="menuConnect_Manage_C">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -349,12 +347,12 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionStart">
|
<action name="actionStart">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start</string>
|
<string extracomment="启动所有">Start All</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPause">
|
<action name="actionPause">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pause</string>
|
<string extracomment="暂停所有">Pause All</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionDelete">
|
<action name="actionDelete">
|
||||||
@ -488,7 +486,7 @@
|
|||||||
<string>DrawingSetIcon</string>
|
<string>DrawingSetIcon</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>DrawingSetting</string>
|
<string extracomment="图形设置">DrawingSetting</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAddMachine">
|
<action name="actionAddMachine">
|
||||||
|
@ -14,3 +14,13 @@ PlotterSetDialog::~PlotterSetDialog()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlotterSetDialog::refreshLanguage()
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlotterSetDialog::on_pushButton_cancel_clicked()
|
||||||
|
{
|
||||||
|
done(0);
|
||||||
|
}
|
||||||
|
@ -14,6 +14,10 @@ class PlotterSetDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit PlotterSetDialog(QWidget *parent = 0);
|
explicit PlotterSetDialog(QWidget *parent = 0);
|
||||||
~PlotterSetDialog();
|
~PlotterSetDialog();
|
||||||
|
void refreshLanguage();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_cancel_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PlotterSetDialog *ui;
|
Ui::PlotterSetDialog *ui;
|
||||||
|
@ -23,19 +23,19 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Print startup mode selection</string>
|
<string extracomment="打印启动方式选择">Print startup mode selection</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QCheckBox" name="checkBox_auto">
|
<widget class="QCheckBox" name="checkBox_auto">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>241</width>
|
<width>241</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto Print</string>
|
<string extracomment="自动打印">Auto Print</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -49,32 +49,32 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Print mode selection</string>
|
<string extracomment="打印模式选择">Print mode selection</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QRadioButton" name="radioButton_single">
|
<widget class="QRadioButton" name="radioButton_single">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>89</width>
|
<width>89</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Single</string>
|
<string extracomment="单向">Single</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QRadioButton" name="radioButton_double">
|
<widget class="QRadioButton" name="radioButton_double">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>200</x>
|
<x>200</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>89</width>
|
<width>89</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Double</string>
|
<string extracomment="双向">Double</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -88,13 +88,13 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Graphic error correction</string>
|
<string extracomment="图形误差修正">Graphic error correction</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLineEdit" name="lineEdit_outputW">
|
<widget class="QLineEdit" name="lineEdit_outputW">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>26</y>
|
<y>28</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -107,7 +107,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>30</y>
|
<y>32</y>
|
||||||
<width>30</width>
|
<width>30</width>
|
||||||
<height>12</height>
|
<height>12</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -120,20 +120,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>53</x>
|
<x>53</x>
|
||||||
<y>26</y>
|
<y>28</y>
|
||||||
<width>181</width>
|
<width>181</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>1 meter actual output:</string>
|
<string extracomment="1米实际输出:">1 meter actual output:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_outputHUnit">
|
<widget class="QLabel" name="label_outputHUnit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>60</y>
|
<y>62</y>
|
||||||
<width>30</width>
|
<width>30</width>
|
||||||
<height>12</height>
|
<height>12</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -146,20 +146,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>53</x>
|
<x>53</x>
|
||||||
<y>56</y>
|
<y>58</y>
|
||||||
<width>181</width>
|
<width>181</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>1 meter actual output:</string>
|
<string extracomment="1米实际输出:">1 meter actual output:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_outputH">
|
<widget class="QLineEdit" name="lineEdit_outputH">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>56</y>
|
<y>58</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -172,20 +172,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>340</x>
|
<x>340</x>
|
||||||
<y>38</y>
|
<y>40</y>
|
||||||
<width>201</width>
|
<width>201</width>
|
||||||
<height>26</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Drawing 1 meter Square</string>
|
<string extracomment="绘1米正方形">Drawing 1 meter Square</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_outputWIcon">
|
<widget class="QLabel" name="label_outputWIcon">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
<y>26</y>
|
<y>28</y>
|
||||||
<width>42</width>
|
<width>42</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -201,7 +201,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>6</x>
|
<x>6</x>
|
||||||
<y>55</y>
|
<y>57</y>
|
||||||
<width>42</width>
|
<width>42</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -224,7 +224,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Two way print error setting</string>
|
<string extracomment="双向打印误差设置">Two way print error setting</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLineEdit" name="lineEdit_twowayError">
|
<widget class="QLineEdit" name="lineEdit_twowayError">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -262,7 +262,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Two way print error:</string>
|
<string extracomment="双向打印错位误差:">Two way print error:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_drawWUnit">
|
<widget class="QLabel" name="label_drawWUnit">
|
||||||
@ -288,7 +288,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Print drawing width:</string>
|
<string extracomment="打印图形宽度:">Print drawing width:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_drawW">
|
<widget class="QLineEdit" name="lineEdit_drawW">
|
||||||
@ -314,7 +314,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Print Error Correction</string>
|
<string extracomment="打印误差修正图">Print Error Correction</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -328,15 +328,15 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Error setting between nozzles</string>
|
<string extracomment="喷头间误差设置">Error setting between nozzles</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QGroupBox" name="groupBox_nozzleError">
|
<widget class="QGroupBox" name="groupBox_nozzleError">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>21</y>
|
<y>10</y>
|
||||||
<width>501</width>
|
<width>501</width>
|
||||||
<height>94</height>
|
<height>106</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -346,7 +346,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>8</y>
|
<y>24</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -359,59 +359,59 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>8</y>
|
<y>24</y>
|
||||||
<width>51</width>
|
<width>51</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_12Error">
|
<widget class="QLabel" name="label_12Error">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>8</y>
|
<y>24</y>
|
||||||
<width>221</width>
|
<width>221</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>1、2 error between nozzles:</string>
|
<string extracomment="1、2喷头间错误误差:">1、2 error between nozzles:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_23ErrorUnit">
|
<widget class="QLabel" name="label_23ErrorUnit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>36</y>
|
<y>52</y>
|
||||||
<width>51</width>
|
<width>51</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_23Error">
|
<widget class="QLabel" name="label_23Error">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>36</y>
|
<y>52</y>
|
||||||
<width>221</width>
|
<width>221</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>2、3 error between nozzles:</string>
|
<string extracomment="2、3喷头间错误误差:">2、3 error between nozzles:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_23Error">
|
<widget class="QLineEdit" name="lineEdit_23Error">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>36</y>
|
<y>52</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -424,20 +424,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>64</y>
|
<y>80</y>
|
||||||
<width>221</width>
|
<width>221</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>3、4 error between nozzles:</string>
|
<string extracomment="3、4喷头间错误误差:">3、4 error between nozzles:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_34Error">
|
<widget class="QLineEdit" name="lineEdit_34Error">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>64</y>
|
<y>80</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -450,20 +450,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>64</y>
|
<y>80</y>
|
||||||
<width>51</width>
|
<width>51</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_errorIcon">
|
<widget class="QLabel" name="label_errorIcon">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>390</x>
|
<x>390</x>
|
||||||
<y>23</y>
|
<y>39</y>
|
||||||
<width>65</width>
|
<width>65</width>
|
||||||
<height>48</height>
|
<height>48</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -480,9 +480,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>122</y>
|
<y>105</y>
|
||||||
<width>501</width>
|
<width>501</width>
|
||||||
<height>94</height>
|
<height>106</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -492,7 +492,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>8</y>
|
<y>25</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -505,59 +505,59 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>8</y>
|
<y>25</y>
|
||||||
<width>51</width>
|
<width>51</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_12Overlap">
|
<widget class="QLabel" name="label_12Overlap">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>8</y>
|
<y>25</y>
|
||||||
<width>221</width>
|
<width>221</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>1、2 overlap between nozzles:</string>
|
<string extracomment="1、2喷头间重叠误差:">1、2 overlap between nozzles:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_23OverlapUnit">
|
<widget class="QLabel" name="label_23OverlapUnit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>36</y>
|
<y>53</y>
|
||||||
<width>51</width>
|
<width>51</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_23Overlap">
|
<widget class="QLabel" name="label_23Overlap">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>36</y>
|
<y>53</y>
|
||||||
<width>221</width>
|
<width>221</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>2、3 overlap between nozzles:</string>
|
<string extracomment="2、3喷头间重叠误差:">2、3 overlap between nozzles:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_23Overlap">
|
<widget class="QLineEdit" name="lineEdit_23Overlap">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>36</y>
|
<y>53</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -570,20 +570,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>13</x>
|
<x>13</x>
|
||||||
<y>64</y>
|
<y>81</y>
|
||||||
<width>221</width>
|
<width>221</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>3、4 overlap between nozzles:</string>
|
<string extracomment="3、4喷头间重叠误差:">3、4 overlap between nozzles:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_34Overlap">
|
<widget class="QLineEdit" name="lineEdit_34Overlap">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>64</y>
|
<y>81</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -596,20 +596,20 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>64</y>
|
<y>81</y>
|
||||||
<width>51</width>
|
<width>51</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pixel</string>
|
<string extracomment="像素">pixel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_overlapIcon">
|
<widget class="QLabel" name="label_overlapIcon">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>390</x>
|
<x>390</x>
|
||||||
<y>23</y>
|
<y>40</y>
|
||||||
<width>65</width>
|
<width>65</width>
|
||||||
<height>48</height>
|
<height>48</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -632,7 +632,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Correction diagram between nozzles</string>
|
<string extracomment="打印喷头间误差修正图">Correction diagram between nozzles</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -646,13 +646,13 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Paper feeding error correction</string>
|
<string extracomment="走纸误差修正">Paper feeding error correction</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLineEdit" name="lineEdit_paperFeedingSet">
|
<widget class="QLineEdit" name="lineEdit_paperFeedingSet">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>26</y>
|
<y>31</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -665,7 +665,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>30</y>
|
<y>35</y>
|
||||||
<width>30</width>
|
<width>30</width>
|
||||||
<height>12</height>
|
<height>12</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -678,26 +678,26 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>36</x>
|
<x>36</x>
|
||||||
<y>26</y>
|
<y>31</y>
|
||||||
<width>201</width>
|
<width>201</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Paper feeding error set:</string>
|
<string extracomment="走纸误差设置:">Paper feeding error set:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_printPaperFeeding">
|
<widget class="QPushButton" name="pushButton_printPaperFeeding">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>340</x>
|
<x>340</x>
|
||||||
<y>22</y>
|
<y>27</y>
|
||||||
<width>201</width>
|
<width>201</width>
|
||||||
<height>26</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Print paper feed error</string>
|
<string extracomment="打印走纸误差">Print paper feed error</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -711,7 +711,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ok</string>
|
<string extracomment="确定">Ok</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_cancel">
|
<widget class="QPushButton" name="pushButton_cancel">
|
||||||
@ -724,7 +724,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cancel</string>
|
<string extracomment="取消">Cancel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QGroupBox" name="groupBox_SprinklerSelect">
|
<widget class="QGroupBox" name="groupBox_SprinklerSelect">
|
||||||
@ -737,58 +737,58 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Sprinkler selection</string>
|
<string extracomment="喷头选择">Sprinkler selection</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QCheckBox" name="checkBox_nozzle1">
|
<widget class="QCheckBox" name="checkBox_nozzle1">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Nozzle 1</string>
|
<string extracomment="1号喷头">Nozzle 1</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox" name="checkBox_nozzle2">
|
<widget class="QCheckBox" name="checkBox_nozzle2">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>130</x>
|
<x>130</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Nozzle 2</string>
|
<string extracomment="2号喷头">Nozzle 2</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox" name="checkBox_nozzle3">
|
<widget class="QCheckBox" name="checkBox_nozzle3">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>240</x>
|
<x>240</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Nozzle 3</string>
|
<string extracomment="3号喷头">Nozzle 3</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox" name="checkBox_nozzle4">
|
<widget class="QCheckBox" name="checkBox_nozzle4">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>350</x>
|
<x>350</x>
|
||||||
<y>22</y>
|
<y>25</y>
|
||||||
<width>91</width>
|
<width>91</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Nozzle 4</string>
|
<string extracomment="4号喷头">Nozzle 4</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -11,6 +11,8 @@ PrintInfoDialog::PrintInfoDialog(QWidget *parent) :
|
|||||||
|
|
||||||
//QListView
|
//QListView
|
||||||
ui->listView_blockList->setDragEnabled(false); //控件不允许拖动
|
ui->listView_blockList->setDragEnabled(false); //控件不允许拖动
|
||||||
|
// 设置listView为不可编辑状态
|
||||||
|
ui->listView_blockList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
m_listViewModel = new QStringListModel(ui->listView_blockList);
|
m_listViewModel = new QStringListModel(ui->listView_blockList);
|
||||||
ui->listView_blockList->setModel(m_listViewModel);
|
ui->listView_blockList->setModel(m_listViewModel);
|
||||||
|
|
||||||
@ -24,6 +26,11 @@ PrintInfoDialog::~PrintInfoDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintInfoDialog::refreshLanguage()
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
void PrintInfoDialog::on_listView_blockList_clicked(const QModelIndex &index)
|
void PrintInfoDialog::on_listView_blockList_clicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QString str = "0 - ";
|
QString str = "0 - ";
|
||||||
@ -101,11 +108,11 @@ void PrintInfoDialog::setFilesInfo(McFilesInfo info)
|
|||||||
m_preView->cleanView();
|
m_preView->cleanView();
|
||||||
if(m_curFilesInfo.m_fileType == TYPE_FILE)
|
if(m_curFilesInfo.m_fileType == TYPE_FILE)
|
||||||
{
|
{
|
||||||
m_preView->creatView(m_curFilesInfo.m_marker);//刷新显示
|
m_preView->creatViewPathAndPic(m_curFilesInfo.m_drawPath,m_curFilesInfo.m_pic);//刷新显示
|
||||||
}
|
}
|
||||||
else if(m_curFilesInfo.m_fileType == TYPE_IMAGE)
|
else if(m_curFilesInfo.m_fileType == TYPE_IMAGE)
|
||||||
{
|
{
|
||||||
m_preView->creatView(m_curFilesInfo.m_pixmap);//刷新显示
|
m_preView->swithViewByPic(m_curFilesInfo.m_pic);//刷新显示
|
||||||
}
|
}
|
||||||
|
|
||||||
reflushFileInfo();
|
reflushFileInfo();
|
||||||
|
@ -18,6 +18,7 @@ class PrintInfoDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit PrintInfoDialog(QWidget *parent = 0);
|
explicit PrintInfoDialog(QWidget *parent = 0);
|
||||||
~PrintInfoDialog();
|
~PrintInfoDialog();
|
||||||
|
void refreshLanguage();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_listView_blockList_clicked(const QModelIndex &index);
|
void on_listView_blockList_clicked(const QModelIndex &index);
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Number:</string>
|
<string extracomment="份数:">Number:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_ok">
|
<widget class="QPushButton" name="pushButton_ok">
|
||||||
|
@ -32,7 +32,12 @@ PrintViewWindow::~PrintViewWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintViewWindow::refreshShow(McFilesInfo mcFilesInfo,int flag)
|
void PrintViewWindow::refreshLanguage()
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintViewWindow::refreshShow(McFilesInfo &mcFilesInfo,int penWidth,int flag)
|
||||||
{
|
{
|
||||||
m_startPoint = 0;
|
m_startPoint = 0;
|
||||||
m_printNumber = 1;
|
m_printNumber = 1;
|
||||||
@ -56,11 +61,12 @@ void PrintViewWindow::refreshShow(McFilesInfo mcFilesInfo,int flag)
|
|||||||
m_view->cleanView();
|
m_view->cleanView();
|
||||||
if(mcFilesInfo.m_fileType == TYPE_FILE)
|
if(mcFilesInfo.m_fileType == TYPE_FILE)
|
||||||
{
|
{
|
||||||
m_view->creatView(mcFilesInfo.m_marker);
|
mcFilesInfo.m_pic = m_view->getPictureByDat(mcFilesInfo.m_marker,penWidth);
|
||||||
|
mcFilesInfo.m_drawPath = m_view->getDrawPath();
|
||||||
}
|
}
|
||||||
else if(mcFilesInfo.m_fileType == TYPE_IMAGE)
|
else if(mcFilesInfo.m_fileType == TYPE_IMAGE)
|
||||||
{
|
{
|
||||||
m_view->creatView(mcFilesInfo.m_pixmap);
|
mcFilesInfo.m_pic = m_view->getPictureByBmp(mcFilesInfo.m_pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果是最大化变为正常大小
|
//如果是最大化变为正常大小
|
||||||
@ -104,6 +110,6 @@ void PrintViewWindow::on_pushButton_draw_clicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
siAddNewFile(m_addNewFileFlag);
|
emit siAddNewFile(m_addNewFileFlag);
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ class PrintViewWindow : public QMainWindow
|
|||||||
public:
|
public:
|
||||||
explicit PrintViewWindow(QWidget *parent = 0);
|
explicit PrintViewWindow(QWidget *parent = 0);
|
||||||
~PrintViewWindow();
|
~PrintViewWindow();
|
||||||
|
void refreshLanguage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PrintViewWindow *ui;
|
Ui::PrintViewWindow *ui;
|
||||||
@ -32,7 +33,7 @@ private:
|
|||||||
int m_length;
|
int m_length;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void refreshShow(McFilesInfo mcFilesInfo,int flag = 0);
|
void refreshShow(McFilesInfo &mcFilesInfo,int penWidth,int flag = 0);
|
||||||
void setStartLineText(QString str);
|
void setStartLineText(QString str);
|
||||||
void setNumberLineText(QString str);
|
void setNumberLineText(QString str);
|
||||||
inline int getStartPoint(){return m_startPoint;}
|
inline int getStartPoint(){return m_startPoint;}
|
||||||
|
Loading…
Reference in New Issue
Block a user