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/creatprintbmp.cpp \
|
||||
machine/tcp/qbindtcpsocket.cpp \
|
||||
machine/tcp/tcpclient.cpp
|
||||
machine/tcp/tcpclient.cpp \
|
||||
datafile/view/drawdata.cpp
|
||||
|
||||
FORMS += \
|
||||
mainwidget.ui \
|
||||
mainwindow.ui \
|
||||
printviewwindow.ui \
|
||||
printnumbersetdialog.ui \
|
||||
@ -135,7 +135,11 @@ HEADERS += \
|
||||
machine/bmp/creatprintbmp.h \
|
||||
machine/tcp/qbindtcpsocket.h \
|
||||
machine/tcp/tcpclient.h \
|
||||
machine/printinfo/mcfiles.h
|
||||
machine/printinfo/mcfiles.h \
|
||||
datafile/view/drawdata.h
|
||||
|
||||
TRANSLATIONS += chinese.ts\
|
||||
english.ts
|
||||
|
||||
RESOURCES += \
|
||||
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_dScale=(double)1.0;
|
||||
m_rotateAngle = 0;
|
||||
|
||||
m_chTerminator = 3;
|
||||
m_nTerminatorMode = 1;
|
||||
@ -242,7 +243,7 @@ void ImportHPGL::creatPolylinePainterPath()
|
||||
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;
|
||||
double y = (maxY - polyLine.m_listPoint.at(j).y())/(double)M_IDPMM*MMPIXELY;
|
||||
QPointF point(x,y);
|
||||
|
||||
if(j == 0)
|
||||
@ -629,6 +630,11 @@ bool ImportHPGL::MoveToNextEnglishChar()
|
||||
//将m_listXY加入到m_pMarker中,并将m_listXY清空
|
||||
void ImportHPGL::AddPolylineToMarker()
|
||||
{
|
||||
if(m_listXY.size() <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//长度<0.2mm为钻孔
|
||||
CRPPolyline RPPolyline1;
|
||||
QPoint pt1,pt2;
|
||||
@ -679,15 +685,44 @@ void ImportHPGL::AddPolylineToMarker()
|
||||
}
|
||||
}
|
||||
m_listXY.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1145,8 +1180,6 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
||||
int notchOffsetX,notchOffsetY;
|
||||
notchOffsetX = notchOffsetY = 0;
|
||||
|
||||
IniPara();
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
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.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_iBKColor = bitDispStyle[1];
|
||||
|
||||
bitmapInfo.m_iWidth = bitGDIInfo[0];
|
||||
bitmapInfo.m_iHeight = bitGDIInfo[1];
|
||||
|
||||
bitmapInfo.m_iStride = bitGDIInfo[2];
|
||||
bitmapInfo.m_iPixelFormat = bitGDIInfo[3];
|
||||
|
||||
@ -1510,12 +1565,15 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
||||
unBmpArr.append(pBmpData[nCount]);
|
||||
}
|
||||
QByteArray pUnCompressData;
|
||||
pUnCompressData.clear();
|
||||
|
||||
//解压缩
|
||||
// 文件路径
|
||||
QDir apppath(qApp->applicationDirPath());
|
||||
QString zipPath = apppath.path();
|
||||
QString zipFile = stePathName + "bfile.zip";
|
||||
QFileInfo fileInfo(stePathName);
|
||||
QString zipPath = fileInfo.absolutePath();//获取Secret.plt所在的目录
|
||||
QString cpstePathName = stePathName;
|
||||
QString zipFile = cpstePathName.remove(cpstePathName.length()-3,3) + "zip";
|
||||
QFile file(zipFile);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
@ -1525,25 +1583,81 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
||||
file.write(unBmpArr);
|
||||
file.close();
|
||||
|
||||
QZipReader reader(zipFile);
|
||||
if(!reader.exists())
|
||||
//判断zip文件是否存在
|
||||
if (!QFile::exists(zipFile))
|
||||
{
|
||||
qDebug() << "The zip file does not exist";
|
||||
return false;
|
||||
}
|
||||
|
||||
reader.extractAll(zipFile);
|
||||
//QVector<QZipReader::FileInfo> list = reader.fileInfoList();
|
||||
QZipReader::FileInfo fileInfo = reader.entryInfoAt(0);//文件夹名称
|
||||
pUnCompressData = reader.fileData(fileInfo.filePath);
|
||||
QZipReader reader(zipFile);
|
||||
|
||||
//解压到当前unzipfile文件夹目录
|
||||
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();
|
||||
|
||||
// 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());
|
||||
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_iStride,bitmapInfo.m_iPixelFormat, 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(unzipFilePath);
|
||||
|
||||
delete pBmpData;
|
||||
|
||||
RPPolyline.m_nDrawingType = 1;
|
||||
@ -1650,6 +1764,20 @@ bool ImportHPGL::ReadSecretFile(QString stePathName, Marker *pMarker)
|
||||
//qrPixmap.save("D:\\1.bmp");
|
||||
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)
|
||||
{
|
||||
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.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_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(siMoveTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint)));
|
||||
|
||||
CRPPolyline crppolylineTemp;
|
||||
|
||||
bOk=GetChar(&cCh1);
|
||||
if (bOk)
|
||||
{
|
||||
@ -2094,6 +2240,8 @@ bool ImportHPGL::L_Code()
|
||||
break;
|
||||
case 'B':
|
||||
case 'b':
|
||||
{
|
||||
CRPPolyline crppolylineTemp;
|
||||
AddPolylineToMarker();
|
||||
bOk = SearchChar(m_chTerminator,strText);
|
||||
m_ptCurrentPos = GetTextOrigin(m_ptCurrentPos,strText);
|
||||
@ -2118,7 +2266,7 @@ bool ImportHPGL::L_Code()
|
||||
|
||||
//qDebug()<<crppolylineTemp.m_text.m_strText;
|
||||
//m_pMarker->m_listPolyline.append(crppolylineTemp);//用文本方法绘制
|
||||
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
case 'o':
|
||||
|
@ -13,13 +13,14 @@
|
||||
#include <QImage>
|
||||
#include <QBitmap>
|
||||
#include <qtextcodec.h>
|
||||
#include <QByteArray>
|
||||
#include "marker.h"
|
||||
#include "plotbitmap.h"
|
||||
#include "QtGui/private/qzipreader_p.h"
|
||||
//#include "QtGui/private/qzipwriter_p.h"
|
||||
#include "datafile/qrencode/qrencode.h"
|
||||
|
||||
#define DEFCMD_IN 0x8A //IN
|
||||
#define DEFCMD_IN 0x8A //IN
|
||||
#define DEFCMD_SP 0x7C //SP
|
||||
#define DEFCMD_LT 0xE6 //LT 0:PS_SOLID; 1:PS_DASH; 2:PS_DOT; 3:PS_DASHDOT
|
||||
#define DEFCMD_PG 0x97 //PG
|
||||
@ -50,6 +51,8 @@
|
||||
#define PixelFormatGDI 0x00020000 // Is a GDI-supported format
|
||||
#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
|
||||
|
||||
#pragma pack(1) //设定为1字节对齐
|
||||
|
||||
struct SC
|
||||
{
|
||||
double dXMin;
|
||||
@ -205,6 +208,7 @@ protected:
|
||||
|
||||
Marker *m_pMarker; //当前使用的唛架,仅能在读文件时使用
|
||||
double m_dScale; //读入文件时将切割数据文件的单位转换成内部数据单位时的比例
|
||||
double m_rotateAngle;//旋转角度
|
||||
QPen m_penPen;//笔绘画笔
|
||||
QPen m_cutPen;//切割画笔
|
||||
QPen m_halfCutPen;//半透切割画笔
|
||||
@ -250,6 +254,7 @@ public:
|
||||
|
||||
//初始化参数,读取参数前,需将参数值重置,避免造成参数值读取错误
|
||||
void IniPara();
|
||||
inline void setRotateAngle(double angle){m_rotateAngle = angle;}
|
||||
|
||||
QPoint GetTextOrigin(QPoint pt,QString strText);
|
||||
double GetTextAngle(double dX,double dY);
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#define CONST_PI 3.14159265359
|
||||
|
||||
#pragma pack(1) //设定为1字节对齐
|
||||
|
||||
struct LineType
|
||||
{
|
||||
//具体参照HPGL英文版手册216页 当LT没有设置值时,线型为实线
|
||||
@ -21,7 +23,6 @@ struct LineType
|
||||
int nMode;//0相对模式 缺省值 解释为P1、P2距离的百分比 1绝对模式,以毫米解释图案长度
|
||||
};
|
||||
|
||||
|
||||
class CBitmapInfo
|
||||
{
|
||||
public:
|
||||
|
@ -18,7 +18,7 @@ QBitmap PlotBitmap::Create1BPPBitmap(int iWidth,int iHeight,unsigned char *pBmp
|
||||
pen.setColor(QColor(Qt::black));
|
||||
|
||||
//QImage::Format_RGBA8888 代表彩色图
|
||||
QImage image = QImage(pBmpData, iWidth, iHeight, QImage::Format_RGBA8888);
|
||||
QImage image = QImage(pBmpData, iWidth, iHeight,QImage::Format_RGBA8888);
|
||||
//image.save("D:\\1.png");
|
||||
|
||||
QBitmap pixmap = QBitmap(iWidth,iHeight);
|
||||
|
@ -118,7 +118,6 @@ void VectorFont::IniVectorFont()
|
||||
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);
|
||||
|
||||
|
||||
m_pChinese_char[nCharCount_C-nCountChar] = Chinese_char1;
|
||||
//m_aChinese_char.append(Chinese_char1);
|
||||
nCountChar--;
|
||||
@ -129,7 +128,6 @@ void VectorFont::IniVectorFont()
|
||||
m_dFontHeight = 0.375 * 10 * m_iDPMM;
|
||||
}
|
||||
|
||||
|
||||
//输入参数:
|
||||
// ptPointLU 显示字符串的左上角坐标(即TextOut(...)的x,y值)
|
||||
// pbyData 字符的描述数据
|
||||
@ -411,12 +409,15 @@ void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,i
|
||||
if (bPenUp) MoveTo(ptPoint1);
|
||||
else LineTo(ptPoint1);
|
||||
}
|
||||
else {
|
||||
if (bClockwise) {
|
||||
else
|
||||
{
|
||||
if (bClockwise)
|
||||
{
|
||||
dx2=-dy1;
|
||||
dy2=dx1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
dx2=dy1;
|
||||
dy2=-dx1;
|
||||
}
|
||||
@ -459,10 +460,12 @@ void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,i
|
||||
bVerTextCommand=false;
|
||||
break;
|
||||
case 0xD:
|
||||
if (bVerTextCommand) {
|
||||
if (bVerTextCommand)
|
||||
{
|
||||
wIndex1=wIndex1+4;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
wIndex1++;
|
||||
while ((pbyData[wIndex1] != 0) || (pbyData[wIndex1+1] != 0)) {
|
||||
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);
|
||||
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.setY(ptCurrentPos.y() - (int)dy1);
|
||||
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
|
||||
LineTo(ptPoint1);
|
||||
}
|
||||
else {
|
||||
if (bClockwise) {
|
||||
else
|
||||
{
|
||||
if (bClockwise)
|
||||
{
|
||||
dx2=-dy1;
|
||||
dy2=dx1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
dx2=dy1;
|
||||
dy2=-dx1;
|
||||
}
|
||||
@ -571,6 +578,7 @@ QPoint VectorFont::CPToLP(QPoint ptCP,int nHeight,QPoint ptPointLU,double dSin,d
|
||||
|
||||
return ptPoint1;
|
||||
}
|
||||
|
||||
//抬笔移动到点(x,y)
|
||||
void VectorFont::MoveTo(long x, long y)
|
||||
{
|
||||
@ -584,7 +592,6 @@ void VectorFont::MoveTo(QPoint ptPoint)
|
||||
emit siMoveTo(true,ptPoint);
|
||||
}
|
||||
|
||||
|
||||
//从当前位置画线到点(x,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();
|
||||
fileChinese.close();
|
||||
}
|
||||
|
||||
//画弧,从Start逆时针画到End
|
||||
void VectorFont::Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,
|
||||
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;
|
||||
LineTo(dx+0.5,dy+0.5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QPoint VectorFont::GetNextCoodinate(WORD wDirection,WORD wLength,QPoint ptPoint)
|
||||
{
|
||||
QPoint ptPoint1;
|
||||
|
||||
switch (wDirection) {
|
||||
switch (wDirection)
|
||||
{
|
||||
case 0:
|
||||
ptPoint1.setX( ptPoint.x() + (int)wLength);
|
||||
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.setY(0);
|
||||
m_fileType = TYPE_FILE;
|
||||
|
||||
//使item可以被选择
|
||||
//this->setFlag(QGraphicsItem::ItemIsSelectable);
|
||||
@ -32,89 +33,58 @@ void MyGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *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)
|
||||
{
|
||||
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();
|
||||
pic = creatPictureByData(marker,m_drawPath,penWidth);
|
||||
m_boundingRect = pic.boundingRect();
|
||||
return pic;
|
||||
}
|
||||
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)
|
||||
{
|
||||
m_fileType = TYPE_IMAGE;
|
||||
m_picture = pic;
|
||||
// 外矩形
|
||||
m_boundingRect = m_picture.boundingRect();
|
||||
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)
|
||||
{
|
||||
m_point = p;
|
||||
@ -145,7 +115,12 @@ void MyGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
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;
|
||||
pen.setWidthF(width); // 线段保持原来的线宽
|
||||
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::SmoothPixmapTransform, true);
|
||||
|
||||
painter->drawPicture(0,0,m_picture);
|
||||
//用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->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 <QtGui>
|
||||
#include "machine/bmp/creatprintbmp.h"
|
||||
#include "datafile/hpgl/importhpgl.h"
|
||||
#include "datafile/view/drawdata.h"
|
||||
|
||||
class MyGraphicsItem : public QObject, public QGraphicsItem
|
||||
{
|
||||
@ -29,9 +29,6 @@ public:
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = 0);
|
||||
|
||||
void creatPicture(Marker marker);
|
||||
void creatPicture(QPixmap pixmap);
|
||||
|
||||
protected: //事件
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||
@ -39,13 +36,19 @@ protected: //事件
|
||||
|
||||
private:
|
||||
QPicture m_picture;
|
||||
QPainterPath m_drawPath;
|
||||
QPixmap m_blockPixmap;
|
||||
QPoint m_point;
|
||||
QRectF m_boundingRect;//返回形状
|
||||
int m_fileType;
|
||||
|
||||
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 setPaintPath(QPainterPath path);
|
||||
void setPaintPathAndPic(QPainterPath path,QPicture pic);
|
||||
void reflushBlockPos(QPoint p);//更显打印块位置
|
||||
|
||||
public slots:
|
||||
|
@ -29,19 +29,18 @@ void MyGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||
return QGraphicsScene::mouseReleaseEvent(mouseEvent);
|
||||
}
|
||||
|
||||
void MyGraphicsScene::createScene(Marker marker)
|
||||
void MyGraphicsScene::createScenePathAndPic(QPainterPath path, QPicture pic)
|
||||
{
|
||||
m_myGraphicsItem->creatPicture(marker);
|
||||
//绘制留边
|
||||
this->setSceneRect(0,0,m_myGraphicsItem->boundingRect().width()+DRAWMARGINS,m_myGraphicsItem->boundingRect().height()+DRAWMARGINS);
|
||||
//如果scene未超过graphicsView的范围,图形就是居中显示的
|
||||
this->addItem(m_myGraphicsItem);
|
||||
m_myGraphicsItem->moveBy(DRAWMARGINS/2.0,DRAWMARGINS/2.0);//item居中显示
|
||||
if(m_myGraphicsItem != NULL)
|
||||
{
|
||||
this->clear();
|
||||
m_myGraphicsItem->setPaintPathAndPic(path,pic);
|
||||
this->addItem(m_myGraphicsItem);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
//如果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;
|
||||
if(m_myGraphicsItem != NULL)
|
||||
{
|
||||
pic = m_myGraphicsItem->getPicture(marker,penWidth);
|
||||
pic = m_myGraphicsItem->getPictureByDat(marker,penWidth);
|
||||
}
|
||||
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)
|
||||
{
|
||||
this->clear();
|
||||
m_myGraphicsItem->setPicture(pic);
|
||||
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)
|
||||
{
|
||||
if(m_myGraphicsItem != NULL)
|
||||
|
@ -23,11 +23,14 @@ private:
|
||||
MyGraphicsItem *m_myGraphicsItem;
|
||||
|
||||
public:
|
||||
void createScene(Marker marker);
|
||||
void createScene(QPixmap pixmap);
|
||||
void createScenePathAndPic(QPainterPath path,QPicture pic);
|
||||
void addItemToScene();
|
||||
void cleanScene();
|
||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
||||
void swithScene(QPicture pic);
|
||||
QPicture getPictureByDat(Marker marker,int penWidth = 1);
|
||||
QPicture getPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
||||
QPainterPath getDrawPath();
|
||||
void swithSceneByPic(QPicture pic);
|
||||
void swithSceneByPath(QPainterPath path);
|
||||
void ReflushBlockScene(QPoint p);
|
||||
|
||||
signals:
|
||||
|
@ -120,8 +120,12 @@ void MyGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
||||
QPoint viewPoint = event->pos();
|
||||
//QGraphicsScene坐标
|
||||
QPointF scenePoint = mapToScene(viewPoint);
|
||||
double x = scenePoint.x() / MMPIXELY;
|
||||
double y = abs(abs(scenePoint.y()) - m_scene->itemsBoundingRect().height()) / MMPIXELY;
|
||||
// double x = scenePoint.x() / 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.setY(y);
|
||||
setMouseTracking(true);
|
||||
@ -179,31 +183,47 @@ void MyGraphicsView::wheelEvent(QWheelEvent *event)
|
||||
verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
|
||||
}
|
||||
|
||||
QPicture MyGraphicsView::getPicture(Marker marker,int penWidth)
|
||||
QPicture MyGraphicsView::getPictureByDat(Marker marker,int penWidth)
|
||||
{
|
||||
QPicture pic;
|
||||
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;
|
||||
}
|
||||
|
||||
void MyGraphicsView::creatView(Marker marker)
|
||||
QPicture MyGraphicsView::getPictureByBmp(QPixmap pixmap,int penWidth)
|
||||
{
|
||||
QPicture pic;
|
||||
if(m_scene != NULL)
|
||||
{
|
||||
m_scene->createScene(marker);
|
||||
pic = m_scene->getPictureByBmp(pixmap,penWidth);
|
||||
m_scene->addItemToScene();
|
||||
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||
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)
|
||||
{
|
||||
m_scene->createScene(pixmap);
|
||||
m_scene->createScenePathAndPic(path,pic);
|
||||
QRectF rectItem = m_scene->itemsBoundingRect();
|
||||
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)
|
||||
{
|
||||
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();
|
||||
this->fitInView(rectItem, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
@ -34,11 +34,13 @@ protected:
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
public:
|
||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
||||
void creatView(Marker marker);
|
||||
void creatView(QPixmap pixmap);
|
||||
QPicture getPictureByDat(Marker marker,int penWidth = 1);
|
||||
QPicture getPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
||||
QPainterPath getDrawPath();
|
||||
void creatViewPathAndPic(QPainterPath path,QPicture pic);
|
||||
void cleanView();
|
||||
void swithView(QPicture pic);
|
||||
void swithViewByPic(QPicture pic);
|
||||
void swithViewByPath(QPainterPath path);
|
||||
void reflushBlockView(QPoint p);
|
||||
|
||||
signals:
|
||||
|
@ -8,9 +8,90 @@ DrawingSetDialog::DrawingSetDialog(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
setWindowModality(Qt::ApplicationModal);
|
||||
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()
|
||||
{
|
||||
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
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
|
||||
namespace Ui {
|
||||
class DrawingSetDialog;
|
||||
@ -14,9 +16,18 @@ class DrawingSetDialog : public QDialog
|
||||
public:
|
||||
explicit DrawingSetDialog(QWidget *parent = 0);
|
||||
~DrawingSetDialog();
|
||||
void refreshLanguage();
|
||||
void refreshConfigPara(QString filePath);//刷新配置参数
|
||||
double getRotateAngle();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_pushButton_ok_clicked();
|
||||
|
||||
private:
|
||||
Ui::DrawingSetDialog *ui;
|
||||
QString m_configfile;
|
||||
|
||||
};
|
||||
|
||||
#endif // DRAWINGSETDIALOG_H
|
||||
|
@ -23,7 +23,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use vector fonts</string>
|
||||
<string extracomment="使用矢量字体">Use vector fonts</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_angle">
|
||||
@ -36,7 +36,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Graph positive rotation angle</string>
|
||||
<string extracomment="图形正向旋转90度">Graph positive rotation 90 angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_ok">
|
||||
@ -62,7 +62,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Boundary and alignment spacing</string>
|
||||
<string extracomment="边界及对位间距">Boundary and alignment spacing</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_rightUnit">
|
||||
<property name="geometry">
|
||||
@ -100,7 +100,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Right margin:</string>
|
||||
<string extracomment="右边距:">Right margin:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_mark">
|
||||
@ -139,7 +139,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mark margin:</string>
|
||||
<string extracomment="马克间距:">Mark margin:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_butt">
|
||||
@ -152,7 +152,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Butt joint margin:</string>
|
||||
<string extracomment="对接符间距:">Butt joint margin:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_buttUnit">
|
||||
@ -240,13 +240,13 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Paper Width</string>
|
||||
<string extracomment="纸张宽度">Paper Width</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_paperWidthUnit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>24</y>
|
||||
<y>28</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
@ -259,7 +259,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>20</y>
|
||||
<y>25</y>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -272,7 +272,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<y>24</y>
|
||||
<width>42</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -308,26 +308,26 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Lineweight settings</string>
|
||||
<string extracomment="线宽设置">Lineweight settings</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_lineWidth">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>20</y>
|
||||
<y>24</y>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Lineweight:</string>
|
||||
<string extracomment="线宽:">Lineweight:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_lineWidth">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>20</y>
|
||||
<y>24</y>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -340,13 +340,13 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>19</y>
|
||||
<y>24</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</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;
|
||||
}
|
||||
|
||||
void HistoryDialog::refreshLanguage()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ class HistoryDialog : public QDialog
|
||||
public:
|
||||
explicit HistoryDialog(QWidget *parent = 0);
|
||||
~HistoryDialog();
|
||||
void refreshLanguage();
|
||||
|
||||
private:
|
||||
Ui::HistoryDialog *ui;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#include "machine/comm/protocol.h"
|
||||
|
||||
#pragma pack(1) //设定为1字节对齐
|
||||
|
||||
@ -37,8 +38,6 @@ typedef struct
|
||||
BmpRgbQuad palette[2]; // 调色板
|
||||
}__attribute__ ((packed)) BitmapHead;
|
||||
|
||||
#pragma pack(4)
|
||||
|
||||
|
||||
class BWBmp
|
||||
{
|
||||
@ -48,26 +47,30 @@ public:
|
||||
public:
|
||||
int LoadBiBmp(QString filename);
|
||||
int SavePrBmp(QString filename);
|
||||
int Compress(int dir = 1);
|
||||
|
||||
int LoadPrBmp(QString filename);
|
||||
int Unpress();
|
||||
int SaveBiBmp(QString filename);
|
||||
|
||||
int Compress(int idx = 0, int dir = 1, int segWidth = 300, int segHeight = 50);
|
||||
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:
|
||||
|
||||
QByteArray m_bwDdat;
|
||||
QByteArray m_bwDdat; // 单色BMP
|
||||
QByteArray m_prDdat;
|
||||
|
||||
QByteArray m_rbwDdat;
|
||||
QString m_fileName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // BWBMP_H
|
||||
|
@ -3,18 +3,19 @@
|
||||
CreatPrintBmp::CreatPrintBmp(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_savePath.clear();
|
||||
m_workState = PAUSE;
|
||||
m_beginPrintFileIdx = -1;
|
||||
m_workState = WORK_PAUSE;
|
||||
m_fileBegIdx = -1;
|
||||
m_fileEndIdx = -1;
|
||||
m_deleteFileIdx = -1;
|
||||
m_curFileIdx = -1;//当前生成数据的文件索引
|
||||
m_listFileIdx = -1;//当前生成数据的文件索引
|
||||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||||
m_mcPrintInfo = NULL;
|
||||
m_conpressDir = 1;
|
||||
m_printFileDir.clear();
|
||||
m_moveFileIdx = -1;//上下移动打印文件索引
|
||||
m_moveDir = 0;//-1,上移 1,下移
|
||||
m_rotateAngle = 0;
|
||||
m_autoDirFilesList.clear();
|
||||
}
|
||||
|
||||
CreatPrintBmp::~CreatPrintBmp()
|
||||
@ -26,216 +27,61 @@ CreatPrintBmp::~CreatPrintBmp()
|
||||
}
|
||||
}
|
||||
|
||||
int CreatPrintBmp::creatFileListMarker()
|
||||
int CreatPrintBmp::creatFileListMarker(int idx)
|
||||
{
|
||||
if(m_workState == WORK_PAUSE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
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())
|
||||
if(idx >= m_autoDirFilesList.size())
|
||||
{
|
||||
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);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(int i = 0; i < fileList.size(); i++)
|
||||
QFileInfo fileInfo(m_autoDirFilesList[idx]);
|
||||
QString filePath = fileInfo.filePath();
|
||||
|
||||
int creatDataFlag = 0;//是否已经生成Marker数据的标志
|
||||
if(idx < m_mcPrintInfo->m_filesList.size())
|
||||
{
|
||||
if(m_mcPrintInfo->m_filesList[idx].m_creatDataFlag != 0)
|
||||
{
|
||||
if(m_workState == WORK_PAUSE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//QCoreApplication::processEvents(QEventLoop::AllEvents);
|
||||
|
||||
QFileInfo fileInfo(fileList[i]);
|
||||
QString filePath = fileInfo.filePath();
|
||||
|
||||
if(m_mcPrintInfo->m_filesList.size() > i)
|
||||
{
|
||||
//已经生成数据的跳过
|
||||
if(m_mcPrintInfo->m_filesList[i].m_creatDataFlag != 1)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
creatDataFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//已经生成数据的跳过
|
||||
if(creatDataFlag == 0)
|
||||
{
|
||||
McFilesInfo curFilesInfo;//当前文件信息
|
||||
creatMarkerDat(curFilesInfo,m_printFileDir,filePath,m_listFileIdx,m_rotateAngle);
|
||||
long long fileTotalLength = (curFilesInfo.m_fileRect.right() - curFilesInfo.m_fileRect.left())/M_IDPMM;
|
||||
m_mcPrintInfo->m_fileNums += 1;
|
||||
m_mcPrintInfo->m_fileTotalLength += fileTotalLength;
|
||||
m_mcPrintInfo->m_filesList.append(curFilesInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_mcPrintInfo->m_loadFileFinishFlag < 0)
|
||||
{
|
||||
//全部文件Marker数据加载完成
|
||||
if(m_mcPrintInfo->m_filesList.size() == m_autoDirFilesList.size())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if(idx >= m_mcPrintInfo->m_filesList.size())
|
||||
{
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
McFilesInfo curFilesInfo;
|
||||
@ -246,7 +92,7 @@ int CreatPrintBmp::creatFileListDatAndSend(int 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);//对应每台机器的每个文件打印目录
|
||||
if(!fileDir.exists())
|
||||
{
|
||||
@ -256,7 +102,7 @@ int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -268,16 +114,7 @@ int CreatPrintBmp::creatFileListDatAndSend(int idx)
|
||||
int oft = 0;//起始打印位置的偏移
|
||||
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);
|
||||
//将picture保存为多个宽度为PIXMAPWIDTH像素的bmp
|
||||
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_filesList[idx].m_pic = pic;
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
||||
int CreatPrintBmp::creatBmpBlockDatAndSend(int fileidx, int idx)
|
||||
{
|
||||
if(m_workState == WORK_PAUSE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setColor(QColor(Qt::black));
|
||||
|
||||
int nextNum = idx / m_mcPrintInfo->m_filesList[m_curFileIdx].m_totalBlocks;
|
||||
if((idx % m_mcPrintInfo->m_filesList[m_curFileIdx].m_totalBlocks) == 0)
|
||||
if(m_mcPrintInfo->m_filesList[fileidx].m_printNum <= 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 oft = (int)(m_mcPrintInfo->m_filesList[m_curFileIdx].m_startPoint*MMPIXELY);
|
||||
int nextNum = idx / oneNumCount;
|
||||
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
|
||||
int num = (pic.width() - oft) / PIXMAPWIDTH;
|
||||
int lwidth = (pic.width() - oft) % PIXMAPWIDTH;
|
||||
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)
|
||||
{
|
||||
@ -343,7 +197,7 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
||||
pixPainter->begin(pixmap);
|
||||
pixPainter->setPen(pen);
|
||||
|
||||
QString filePath = m_printFileDir + QString::number(m_curFileIdx+1);
|
||||
QString filePath = m_printFileDir + QString::number(m_listFileIdx+1);
|
||||
QDir fileDir(filePath);//对应每台机器的每个文件打印目录
|
||||
if(!fileDir.exists())
|
||||
{
|
||||
@ -354,7 +208,8 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
||||
pixmap->fill(Qt::white);//用白色填充
|
||||
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);
|
||||
while(bls == false)
|
||||
{
|
||||
@ -372,7 +227,7 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
||||
qDebug() << "open file error" << path;
|
||||
return -1;
|
||||
}
|
||||
rslt = bwBmp.Compress(m_conpressDir);
|
||||
rslt = bwBmp.Compress(cidx,m_conpressDir);
|
||||
if (rslt != 0)
|
||||
{
|
||||
qDebug() << "Compress error";
|
||||
@ -386,25 +241,32 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
||||
return -1;
|
||||
}
|
||||
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;
|
||||
memset(&bmpInfo,0,sizeof(BmpDatInfo));
|
||||
bmpInfo.blkIdx = idx;
|
||||
bmpInfo.biWidth = pixmap->width();
|
||||
bmpInfo.biHeight = pixmap->height();
|
||||
bmpInfo.begPosY = idx * pixmap->width();
|
||||
bmpInfo.endPosY = (idx+1) * pixmap->width();
|
||||
if(m_conpressDir == -1)
|
||||
//计算机器打印进度
|
||||
int fileNum = m_fileEndIdx - m_fileBegIdx;
|
||||
int val = 1;
|
||||
if(fileNum == 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++;
|
||||
|
||||
pixPainter->end();
|
||||
@ -424,13 +286,14 @@ int CreatPrintBmp::creatBmpBlockDatAndSend(int idx)
|
||||
void CreatPrintBmp::slotCreatBmp()
|
||||
{
|
||||
#if(1)
|
||||
int val = creatFileListMarker();
|
||||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||||
int val = creatFileListMarker(m_fileBegIdx);
|
||||
if(val < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
val = creatFileListDatAndSend(m_curFileIdx);
|
||||
val = creatFileListDatAndSend(m_fileBegIdx);
|
||||
if(val < 0)
|
||||
{
|
||||
return;
|
||||
@ -513,82 +376,12 @@ void CreatPrintBmp::slotCreatBmp()
|
||||
|
||||
void CreatPrintBmp::slotCreatNextBmpBlockDat()
|
||||
{
|
||||
//非正在打印的文件,正在发送文件时的删除操作
|
||||
if(m_deleteFileIdx != m_curFileIdx && m_deleteFileIdx != -1)
|
||||
if(m_mcPrintInfo->m_filesList.size() <= m_fileBegIdx)
|
||||
{
|
||||
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_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)//理论上无此条件
|
||||
{
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
||||
//非正在打印的文件,正在发送文件时的上下移操作
|
||||
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_mcPrintInfo->m_mcWorkState = Busying;
|
||||
|
||||
m_curBmpBlockIdx++;//一个文件可分为若干个位图块,位图块索引++
|
||||
if(m_curBmpBlockIdx < 0)
|
||||
@ -596,15 +389,65 @@ void CreatPrintBmp::slotCreatNextBmpBlockDat()
|
||||
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_curFileIdx++;//文件索引++
|
||||
creatFileListDatAndSend(m_curFileIdx);
|
||||
m_curBmpBlockIdx = -1;
|
||||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if(flag == 1)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// creatFileListMarker(m_fileBegIdx);
|
||||
// creatFileListDatAndSend(m_fileBegIdx);
|
||||
// m_curBmpBlockIdx = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
creatBmpBlockDatAndSend(m_curBmpBlockIdx);
|
||||
creatBmpBlockDatAndSend(m_fileBegIdx,m_curBmpBlockIdx);
|
||||
m_conpressDir *= -1;
|
||||
}
|
||||
|
||||
@ -653,8 +496,8 @@ void CreatPrintBmp::setMcPrintInfo(int fileIdx, McPrintInfo *printInfo)
|
||||
m_fileBegIdx = fileIdx;
|
||||
}
|
||||
|
||||
//自动打印
|
||||
int autoPrint = 1;
|
||||
//是否自动打印
|
||||
int autoPrint = 0;
|
||||
|
||||
if(autoPrint == 1)
|
||||
{
|
||||
@ -665,75 +508,154 @@ void CreatPrintBmp::setMcPrintInfo(int fileIdx, McPrintInfo *printInfo)
|
||||
m_fileEndIdx = m_fileBegIdx + 1;
|
||||
}
|
||||
|
||||
m_curFileIdx = m_fileBegIdx;
|
||||
m_listFileIdx = m_fileBegIdx;
|
||||
|
||||
QDir apppath(qApp->applicationDirPath());
|
||||
QString printPath = apppath.path() + apppath.separator() + PRINTDIR;
|
||||
QString mcFile = printPath + apppath.separator() + PRINTMCDIR + QString::number(m_mcPrintInfo->m_mcNum);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
QDir printDir(printPath);//总的打印目录
|
||||
if(!printDir.exists())
|
||||
{
|
||||
printDir.mkdir(printPath);
|
||||
}
|
||||
QDir mcDir(mcFile);//对应每台机器打印目录
|
||||
if(!mcDir.exists())
|
||||
{
|
||||
mcDir.mkdir(mcFile);
|
||||
}
|
||||
m_curBmpBlockIdx = -1;//当前生成数据的位图块数索引
|
||||
}
|
||||
|
||||
void CreatPrintBmp::setDeleteFile(int fileIdx)
|
||||
void CreatPrintBmp::stopCreatPrintDat()
|
||||
{
|
||||
if(fileIdx == m_curFileIdx)
|
||||
m_workState = WORK_PAUSE;
|
||||
}
|
||||
|
||||
void CreatPrintBmp::setDeleteFile(McPrintInfo *printInfo, int fileIdx)
|
||||
{
|
||||
if(m_mcPrintInfo == NULL)
|
||||
{
|
||||
m_mcPrintInfo = printInfo;
|
||||
}
|
||||
|
||||
if(fileIdx == m_fileBegIdx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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;
|
||||
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);
|
||||
fileDir.removeRecursively();
|
||||
}
|
||||
|
||||
//如果为自动绘图目录中的文件,删除自动绘图目录文件夹中已打印完成的文件
|
||||
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))
|
||||
{
|
||||
//文件存在
|
||||
QFile::remove(filePath);
|
||||
if(m_deleteFileIdx < m_autoDirFilesList.size())
|
||||
{
|
||||
m_autoDirFilesList.removeAt(m_deleteFileIdx);//删除自动绘图目录文件列表中的文件
|
||||
}
|
||||
}
|
||||
|
||||
m_mcPrintInfo->m_filesList[m_deleteFileIdx].clear();
|
||||
m_mcPrintInfo->m_filesList.removeAt(m_deleteFileIdx);
|
||||
|
||||
m_mcPrintInfo->m_fileNums = m_mcPrintInfo->m_filesList.size();
|
||||
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;
|
||||
}
|
||||
m_moveFileIdx = fileIdx;//上下移动打印文件索引
|
||||
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];
|
||||
QFileInfo fileInfo;
|
||||
if(fileIdx < m_autoDirFilesList.size())
|
||||
{
|
||||
fileInfo = m_autoDirFilesList[fileIdx];
|
||||
}
|
||||
McFilesInfo cInfo;
|
||||
QFileInfo cFileInfo;
|
||||
if(dir == -1)
|
||||
{
|
||||
cInfo = m_mcPrintInfo->m_filesList[fileIdx-1];
|
||||
m_mcPrintInfo->m_filesList[fileIdx-1] = info;
|
||||
|
||||
cFileInfo = m_autoDirFilesList[fileIdx-1];
|
||||
m_autoDirFilesList[fileIdx-1] = fileInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
cInfo = m_mcPrintInfo->m_filesList[fileIdx+1];
|
||||
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;
|
||||
if(fileIdx < m_autoDirFilesList.size())
|
||||
{
|
||||
m_autoDirFilesList[fileIdx] = cFileInfo;
|
||||
}
|
||||
|
||||
m_moveFileIdx = -1;//上下移动打印文件索引
|
||||
m_moveDir = 0;//-1,上移 1,下移
|
||||
|
@ -14,30 +14,15 @@
|
||||
#include "bwbmp.h"
|
||||
#include "machine/printinfo/mcfiles.h"
|
||||
#include "datafile/hpgl/importhpgl.h"
|
||||
#include "datafile/view/drawdata.h"
|
||||
|
||||
#define TYPE_FILE 0
|
||||
#define TYPE_IMAGE 1
|
||||
#define PIXMAPWIDTH 1200
|
||||
#define PENWIDTH 5
|
||||
|
||||
#define START 1
|
||||
#define PAUSE 0
|
||||
|
||||
#define PRINTDIR "print"
|
||||
#define PRINTMCDIR "mc"
|
||||
#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
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -49,26 +34,25 @@ private:
|
||||
QPicture m_picture;//绘图路径-线段
|
||||
QString m_savePath;
|
||||
int m_workState;
|
||||
int m_beginPrintFileIdx;//开始打印文件索引
|
||||
int m_deleteFileIdx;//删除打印文件索引
|
||||
McPrintInfo *m_mcPrintInfo;//机器信息
|
||||
int m_fileBegIdx;
|
||||
int m_fileBegIdx;//开始打印和正在打印文件索引(因为打印完成一个就要删掉一个,所以正在打印的文件永远是起始文件索引)
|
||||
int m_fileEndIdx;
|
||||
int m_curFileIdx;//当前生成数据的文件索引
|
||||
int m_listFileIdx;//初始文件列表时将要生成文件数据的文件索引
|
||||
int m_curBmpBlockIdx;//当前生成数据的位图块数索引
|
||||
int m_conpressDir;//压缩方向
|
||||
QString m_printFileDir;//打印文件目录
|
||||
|
||||
int m_moveFileIdx;//上下移动打印文件索引
|
||||
s16 m_moveDir;//-1,上移 1,下移
|
||||
double m_rotateAngle;
|
||||
|
||||
QFileInfoList m_autoDirFilesList;//自动绘图目录中文件列表
|
||||
|
||||
private:
|
||||
int creatFileListMarker();//加载文件列表marker数据
|
||||
void creatMarkerDat(McFilesInfo &curFilesInfo, QString filePath, int fileIdx);//创建Marker数据
|
||||
QPicture getPicture(Marker marker,int penWidth = 1);
|
||||
|
||||
int creatFileListMarker(int idx);//加载文件列表marker数据
|
||||
int creatFileListDatAndSend(int idx);//创建文件列表数据并发送
|
||||
int creatBmpBlockDatAndSend(int idx);//创建位图块数据并发送
|
||||
int creatBmpBlockDatAndSend(int fileidx, int idx);//创建位图块数据并发送
|
||||
|
||||
public:
|
||||
void setPicture(QPicture pic);
|
||||
@ -76,14 +60,17 @@ public:
|
||||
void setSavePath(QString path);
|
||||
QString getSavePath();
|
||||
void setMcPrintInfo(int fileIdx,McPrintInfo *printInfo);//设置机器信息
|
||||
void setDeleteFile(int fileIdx);//删除文件
|
||||
void setMoveFile(int fileIdx, int dir = -1);//上下移动文件
|
||||
void stopCreatPrintDat();//停止生成打印数据
|
||||
void setDeleteFile(McPrintInfo *printInfo, int fileIdx);//删除文件
|
||||
void setMoveFile(McPrintInfo *printInfo, int fileIdx, int dir = -1);//上下移动文件
|
||||
inline void setRotateAngle(double angle){m_rotateAngle = angle;}//设置旋转角度
|
||||
|
||||
signals:
|
||||
void siCreatOneBmpFinished(int mcIdx,unsigned char *dat,int datSize);
|
||||
void siSendFileListDatToMc(int idx);
|
||||
void siSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo);
|
||||
void siDeleteFileFinish();//删除文件完成
|
||||
void siSendDatToMc(QByteArray dat);
|
||||
void siOneFilePrintFinished(int mcNum,int fileIdx,int refreshFlag);//一个文件打印完成
|
||||
void siRefreshPrintProgress(int mcNum,int fileIdx);//刷新打印进度
|
||||
|
||||
public slots:
|
||||
void slotCreatBmp();
|
||||
|
@ -76,6 +76,7 @@
|
||||
#define WORK_START 0x0001 // 启动工作
|
||||
#define WORK_PAUSE 0x0002 // 暂停工作
|
||||
|
||||
#pragma pack(1)//设定为1字节对齐
|
||||
|
||||
// 喷墨图像按照黑白位图的格式存储
|
||||
|
||||
@ -100,39 +101,77 @@ typedef struct
|
||||
u32 rev[16-5];
|
||||
}__attribute__ ((packed)) PlotFileList;
|
||||
|
||||
// 自定义压缩位图文件头
|
||||
// 压缩位图文件头
|
||||
typedef struct
|
||||
{
|
||||
// 0
|
||||
u32 fileId; // 整个位图文件标识
|
||||
u32 blkIdx; // 当前位图块号(位图分块后的编号)
|
||||
u32 datSize; // 本块位图数据区的大小(字节数)
|
||||
u32 biWidth; // 本块位图有效宽度,以像素为单位
|
||||
u32 biHeight; // 本块位图有效高度,以像素为单位
|
||||
u32 dataChecksum; // 本块位图数据累加校验和
|
||||
u32 begPosY; // 本块起始位置(像素单位)
|
||||
u32 endPosY; // 本块结束位置(像素单位)
|
||||
u32 fileId; // 整个位图文件标识
|
||||
u32 blkIdx; // 当前位图块号(位图分块后的编号)
|
||||
u32 datSize; // 本块位图数据区的大小(字节数)
|
||||
u32 biWidth; // 本块位图有效宽度,以像素为单位
|
||||
u32 biHeight; // 本块位图有效高度,以像素为单位
|
||||
u32 dataChecksum; // 本块位图数据累加校验和
|
||||
u32 begPosY; // 本块位图起始位置(像素单位)
|
||||
u32 endPosY; // 本块位图结束位置(像素单位)
|
||||
|
||||
// 32
|
||||
u8 compType; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩;
|
||||
u8 compDir; // 本块位图压缩方向, =0, 从上到下; =1, 从下到上;(喷墨方向)
|
||||
u16 compDir; // 本块位图压缩方向, =0, 从上到下; =1, 从下到上;(喷墨方向)
|
||||
u16 compSegWidth; // 分段宽度(0,默认整个宽度,分段宽度必须能被本块位图有效宽度整除)
|
||||
u16 compSegHeight; // 分段高度(0,默认1行的高度)
|
||||
u16 compFillWidth; // 压缩填充位数
|
||||
u8 compType[4]; // 本块位图压缩类型, =0, 不压缩; =1, 按字节压缩(分段压缩);
|
||||
u32 compSegOffset[4]; // 分段数据起始位置
|
||||
|
||||
// 34
|
||||
u8 rev[64-2-34]; // 保留
|
||||
#if (1)
|
||||
// 60
|
||||
u8 rev[128-2-60]; // 保留
|
||||
#else
|
||||
// 保存原图中BMP头文件(算法测试用)
|
||||
// 60
|
||||
u8 rev[64-60]; // 保留
|
||||
|
||||
// 62
|
||||
u16 checkCrc; // 前面字段的CRC校验
|
||||
// 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校验
|
||||
}__attribute__ ((packed)) CompBmpHead;
|
||||
|
||||
// 机器信息结构定义
|
||||
typedef struct
|
||||
{
|
||||
// 0
|
||||
char softwareVerStr[32]; // 软件版本
|
||||
char softwareVerStr[32]; // 软件版本
|
||||
|
||||
// 32
|
||||
char rev[1024-32];
|
||||
char rev[1024-32];
|
||||
|
||||
} __attribute__ ((packed)) MCInfo;
|
||||
|
||||
@ -190,29 +229,29 @@ typedef struct
|
||||
{
|
||||
// 0
|
||||
u32 workStatus; // 工作状态位图
|
||||
// .0 允许时限。=0,使用时限已到,不允许下位机工作;=1,允许下位机工作;
|
||||
// .1 允许状态。=0,界面钳制,不允许下位机工作;=1,允许下位机工作;
|
||||
// .2 机器状态。=0,手动工作状态; =1,自动工作状态
|
||||
// .3 钥匙状态。=0,关闭状态; =1,打开状态
|
||||
// .4 文件接收标志。= 0,初始状态。= 1,收到了文件
|
||||
// .5 参数接收标志。= 0,初始状态。= 1,收到了参数
|
||||
// .6 正在忙标志。= 0,空闲(可以接收文件和参数)。= 1,工作中(不会接收文件和参数)
|
||||
// .7 上料状态。=0,手动上料状态; =1,自动上料状态
|
||||
// .8 参数更新标志。 =1,下位机更新了参数
|
||||
// .9 模拟工作标志。=1, 处于模拟工作状态
|
||||
// .10 允许扫描条码状态。=1, 允许
|
||||
// .11 允许拍照状态。=1, 允许
|
||||
// .12 正在工作标志
|
||||
// .13 传感信号扫描中标志
|
||||
// .14 相机校准模式中标志
|
||||
// .15
|
||||
// .16
|
||||
// .17
|
||||
// .18
|
||||
// .19 取模板框状态
|
||||
// .20 放模板框状态
|
||||
// .21 匹绣, 0:退出匹绣,主轴归零 1:进入匹绣,扎针,允许移框
|
||||
// .22 断线检测, 0:退出断线检测状态, 1:进入断线检测状态
|
||||
// .0 允许时限。=0,使用时限已到,不允许下位机工作;=1,允许下位机工作;
|
||||
// .1 允许状态。=0,界面钳制,不允许下位机工作;=1,允许下位机工作;
|
||||
// .2 机器状态。=0,手动工作状态; =1,自动工作状态
|
||||
// .3 钥匙状态。=0,关闭状态; =1,打开状态
|
||||
// .4 文件接收标志。= 0,初始状态。= 1,收到了文件
|
||||
// .5 参数接收标志。= 0,初始状态。= 1,收到了参数
|
||||
// .6 正在忙标志。= 0,空闲(可以接收文件和参数)。= 1,工作中(不会接收文件和参数)
|
||||
// .7 上料状态。=0,手动上料状态; =1,自动上料状态
|
||||
// .8 参数更新标志。 =1,下位机更新了参数
|
||||
// .9 模拟工作标志。=1, 处于模拟工作状态
|
||||
// .10 允许扫描条码状态。=1, 允许
|
||||
// .11 允许拍照状态。=1, 允许
|
||||
// .12 正在工作标志
|
||||
// .13 传感信号扫描中标志
|
||||
// .14 相机校准模式中标志
|
||||
// .15
|
||||
// .16
|
||||
// .17
|
||||
// .18
|
||||
// .19 取模板框状态
|
||||
// .20 放模板框状态
|
||||
// .21 匹绣, 0:退出匹绣,主轴归零 1:进入匹绣,扎针,允许移框
|
||||
// .22 断线检测, 0:退出断线检测状态, 1:进入断线检测状态
|
||||
|
||||
// 1
|
||||
u32 errorCode; // 错误代码
|
||||
|
@ -99,8 +99,6 @@ Machine::Machine(QObject *parent) : QObject(parent)
|
||||
m_pSendTimer->setInterval(100); // 设置定时间隔100毫秒
|
||||
connect(m_pSendTimer, SIGNAL(timeout()), this, SLOT(onSendTimer()));
|
||||
initDataExFuns();
|
||||
|
||||
qRegisterMetaType<BmpDatInfo >("BmpDatInfo");//对自定义类型注册
|
||||
}
|
||||
|
||||
Machine::~Machine()
|
||||
@ -400,12 +398,12 @@ void Machine::mcWorkCmd(int workcode, int para1, int para2)
|
||||
|
||||
void Machine::deleteFilePrintDat(int fileIdx)
|
||||
{
|
||||
m_pCreatPrintDat->setDeleteFile(fileIdx);
|
||||
m_pCreatPrintDat->setDeleteFile(&m_mcPrintInfo,fileIdx);
|
||||
}
|
||||
|
||||
void Machine::moveFilePrintDat(int fileIdx,int dir)
|
||||
{
|
||||
m_pCreatPrintDat->setMoveFile(fileIdx,dir);
|
||||
m_pCreatPrintDat->setMoveFile(&m_mcPrintInfo,fileIdx,dir);
|
||||
}
|
||||
|
||||
void Machine::invalidateWorkFile(int idx)
|
||||
@ -413,12 +411,21 @@ void Machine::invalidateWorkFile(int idx)
|
||||
setMcStatus(MC_INVALID_FILE, idx);
|
||||
}
|
||||
|
||||
void Machine::creatPrintDat(int fileIdx)
|
||||
void Machine::creatPrintDat(int fileIdx,int setFlag)
|
||||
{
|
||||
m_pCreatPrintDat->setMcPrintInfo(fileIdx,&m_mcPrintInfo);
|
||||
if(setFlag == 1)
|
||||
{
|
||||
m_pCreatPrintDat->setMcPrintInfo(fileIdx,&m_mcPrintInfo);
|
||||
}
|
||||
emit siCreatData();
|
||||
}
|
||||
|
||||
void Machine::stopPrint()
|
||||
{
|
||||
m_pCreatPrintDat->stopCreatPrintDat();
|
||||
m_transBreak = 1;
|
||||
}
|
||||
|
||||
void Machine::setIpAndPort(QString mcName, QString serverIp, quint16 serverPort, QString localIp, quint16 localPort)
|
||||
{
|
||||
m_mcName = mcName;
|
||||
@ -445,18 +452,21 @@ void Machine::startCommunication()
|
||||
m_pCreatPrintDat->moveToThread(m_pTcpBmpThread);
|
||||
connect(m_pTcpBmpThread, SIGNAL(finished()), m_pCreatPrintDat, SLOT(deleteLater()) ); // 退出删除对象
|
||||
connect(this, SIGNAL(siCreatData()),
|
||||
m_pCreatPrintDat, SLOT(slotCreatBmp()), Qt::QueuedConnection); // 发送数据的槽
|
||||
m_pCreatPrintDat, SLOT(slotCreatBmp()), Qt::QueuedConnection); // 开始创建位图的槽
|
||||
connect(this, SIGNAL(siSendDataDone()),
|
||||
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 发送数据的槽
|
||||
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 创建位图块并发送的槽
|
||||
connect(this, SIGNAL(siCreatBmpBlockDatAndSend()),
|
||||
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 发送数据的槽
|
||||
m_pCreatPrintDat, SLOT(slotCreatNextBmpBlockDat()), Qt::QueuedConnection); // 创建位图块并发送的槽
|
||||
|
||||
connect(m_pCreatPrintDat, SIGNAL(siSendFileListDatToMc(int)),
|
||||
this, SLOT(slotSendPlotFileListToMc(int)), Qt::QueuedConnection); // 发送数据的槽
|
||||
connect(m_pCreatPrintDat, SIGNAL(siSendDatToMc(QByteArray,BmpDatInfo)),
|
||||
this, SLOT(slotSendDatToMc(QByteArray,BmpDatInfo)), Qt::QueuedConnection); // 发送数据的槽
|
||||
connect(m_pCreatPrintDat, SIGNAL(siDeleteFileFinish()),
|
||||
this, SIGNAL(siDeleteFileFinish())); // 删除文件
|
||||
this, SLOT(slotSendPlotFileListToMc(int)), Qt::QueuedConnection); // 发送文件列表的槽
|
||||
connect(m_pCreatPrintDat, SIGNAL(siSendDatToMc(QByteArray)),
|
||||
this, SLOT(slotSendDatToMc(QByteArray)), Qt::QueuedConnection); // 发送数据的槽
|
||||
|
||||
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(); // 启动线程
|
||||
}
|
||||
@ -957,7 +967,7 @@ void Machine::onSendTimer()
|
||||
}
|
||||
}
|
||||
|
||||
void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
||||
void Machine::slotSendDatToMc(QByteArray dat)
|
||||
{
|
||||
if(m_connected == Connected)
|
||||
{
|
||||
@ -970,6 +980,11 @@ void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
||||
int counter = 0;
|
||||
delayTime.start();
|
||||
|
||||
if (m_transCtrl.filetransing != 0) // 已经有文件在传输
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (m_transCtrl.filetransing != 0) // 已经有文件在传输
|
||||
{
|
||||
if (delayTime.elapsed() > 1000)
|
||||
@ -984,18 +999,9 @@ void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
||||
|
||||
qDebug()<<"dat.size()"<<dat.size();
|
||||
|
||||
memcpy((u8*)m_pCompBmpHead,(u8*)dat.data(),sizeof(CompBmpHead));
|
||||
|
||||
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)
|
||||
{
|
||||
@ -1008,7 +1014,7 @@ void Machine::slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo)
|
||||
m_transCtrl.fileType = (u8)FILE_TYPE_PLOT;
|
||||
m_transCtrl.fileId = m_pCompBmpHead->fileId;
|
||||
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.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的随机数
|
||||
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->totalHeight = m_mcPrintInfo.m_filesList[idx].m_pic.height() * m_mcPrintInfo.m_filesList[idx].m_printNum;
|
||||
m_pPlotFileList->blkNums = m_mcPrintInfo.m_filesList[idx].m_totalBlocks * 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_pPlotFileList->blkWidth = PIXMAPWIDTH;
|
||||
|
||||
int rslt;
|
||||
|
@ -104,7 +104,9 @@ public:
|
||||
// 机器工作命令
|
||||
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 moveFilePrintDat(int fileIdx,int dir = -1);//移动(上下移)文件打印数据
|
||||
|
||||
@ -122,15 +124,15 @@ signals:
|
||||
void siTransProgress(u8 fileType, int send, int total); // 文件传输结果信号
|
||||
void siCreatData(); //生成要发送的数据
|
||||
void siCreatBmpBlockDatAndSend();//生成位图数据块数据并发送
|
||||
void siDeleteFileFinish();
|
||||
void siMoveFileFinish();
|
||||
void siOneFilePrintFinished(int mcNum, int fileIdx, int refreshFlag);//完成一个文件的打印
|
||||
void siRefreshPrintProgress(int mcNum, int fileIdx);//刷新打印进度
|
||||
|
||||
private slots:
|
||||
void slotConnectSta(int sta); // 连接状态改变的槽函数
|
||||
void slotConnectErr(QString errinfo); // 接收到通讯错误槽函数
|
||||
void slotReceiveData(QByteArray dat); // 接收到数据的槽函数
|
||||
void onSendTimer(void);
|
||||
void slotSendDatToMc(QByteArray dat, BmpDatInfo bmpInfo);//发送打印数据
|
||||
void slotSendDatToMc(QByteArray dat);//发送打印数据
|
||||
void slotSendPlotFileListToMc(int idx);//发送设置文件列表
|
||||
|
||||
public slots:
|
||||
|
@ -23,6 +23,16 @@ enum WorkState
|
||||
Busying = 1 //工作中
|
||||
};
|
||||
|
||||
//打印状态
|
||||
enum PrintState
|
||||
{
|
||||
Waitting = 0,//等待打印
|
||||
Printting = 1, //打印中
|
||||
Pause = 2, //暂停打印
|
||||
Complete = 3//打印完成
|
||||
};
|
||||
|
||||
|
||||
class McFilesInfo
|
||||
{
|
||||
public:
|
||||
@ -34,8 +44,9 @@ public:
|
||||
QRect m_fileRect;//图形被包络的矩形区域
|
||||
s16 m_printNum;//打印份数
|
||||
s16 m_startPoint;//打印起始点
|
||||
QString m_printState;//打印状态
|
||||
QPicture m_pic;//文件-图片
|
||||
s16 m_printState;//打印状态
|
||||
QPicture m_pic;//文件-发送的图片-实际笔宽绘制的pic
|
||||
QPainterPath m_drawPath;//文件-数据绘图路径-用MyGraphicsItem画图时如果笔宽不为1,直接画QPicture时线条会很轻,所以用m_drawPath绘制
|
||||
QBitmap m_pixmap;//图片-图片
|
||||
s16 m_totalBlocks;//总块数
|
||||
s16 m_curPrintBlock;//当前打印块数
|
||||
@ -47,6 +58,7 @@ public:
|
||||
void clear()
|
||||
{
|
||||
QPicture pic;
|
||||
QPainterPath path;
|
||||
|
||||
m_creatDataFlag = -1;
|
||||
m_creatBmpFlag = -1;//是否已经生成bmp的标志
|
||||
@ -55,8 +67,9 @@ public:
|
||||
m_fileType = 0;//文件类型
|
||||
m_printNum = 0;//打印份数
|
||||
m_startPoint = 0;//打印起始点
|
||||
m_printState.clear();//打印状态
|
||||
m_printState = Waitting;//打印状态
|
||||
m_pic = pic;
|
||||
m_drawPath = path;
|
||||
m_pixmap.clear();
|
||||
m_totalBlocks = 0;//总块数
|
||||
m_curPrintBlock = 0;//当前打印块数
|
||||
@ -75,7 +88,7 @@ public:
|
||||
m_fileType = 0;//文件类型
|
||||
m_printNum = 0;//打印份数
|
||||
m_startPoint = 0;//打印起始点
|
||||
m_printState.clear();//打印状态
|
||||
m_printState = Waitting;//打印状态
|
||||
m_totalBlocks = 0;//总块数
|
||||
m_curPrintBlock = 0;//当前打印块数
|
||||
m_printedBlockNum = 0;//已打印块数
|
||||
@ -95,6 +108,7 @@ public:
|
||||
m_startPoint = item.m_startPoint;//打印起始点
|
||||
m_printState = item.m_printState;//打印状态
|
||||
m_pic = item.m_pic;
|
||||
m_drawPath = item.m_drawPath;
|
||||
m_pixmap = item.m_pixmap;
|
||||
m_totalBlocks = item.m_totalBlocks;//总块数
|
||||
m_curPrintBlock = item.m_curPrintBlock;//当前打印块数
|
||||
@ -116,6 +130,7 @@ public:
|
||||
m_startPoint = item.m_startPoint;//打印起始点
|
||||
m_printState = item.m_printState;//打印状态
|
||||
m_pic = item.m_pic;
|
||||
m_drawPath = item.m_drawPath;
|
||||
m_pixmap = item.m_pixmap;
|
||||
m_totalBlocks = item.m_totalBlocks;//总块数
|
||||
m_curPrintBlock = item.m_curPrintBlock;//当前打印块数
|
||||
@ -136,13 +151,12 @@ public:
|
||||
QString m_mcName;//机器名称
|
||||
int m_mcConnState;//机器连接状态
|
||||
int m_mcWorkState;//机器工作状态
|
||||
int m_mcSendProgress;//机器文件发送进度
|
||||
double m_mcSendProgress;//机器打印进度
|
||||
int m_totalNums;//要发送的总块数
|
||||
int m_sendedlNums;//已发送的总块数
|
||||
QString m_ip;//机器ip
|
||||
s16 m_port;//机器端口
|
||||
s16 m_fileNums;//文件数量
|
||||
s16 m_curCreatPrintDatFileIdx;//当前正在生成打印数据的文件索引
|
||||
long long m_fileTotalLength;//文件总长度
|
||||
QList<McFilesInfo> m_filesList;//图片列表
|
||||
|
||||
@ -160,7 +174,6 @@ public:
|
||||
m_port = 0;
|
||||
m_fileNums = 0;
|
||||
m_fileTotalLength = 0;
|
||||
m_curCreatPrintDatFileIdx = -1;
|
||||
for(int i = 0; i < m_filesList.size(); i++)
|
||||
{
|
||||
m_filesList[i].clear();
|
||||
@ -183,7 +196,6 @@ public:
|
||||
m_port = 0;
|
||||
m_fileNums = 0;
|
||||
m_fileTotalLength = 0;
|
||||
m_curCreatPrintDatFileIdx = -1;
|
||||
m_filesList.clear();
|
||||
}
|
||||
|
||||
@ -201,7 +213,6 @@ public:
|
||||
m_port = item.m_port;
|
||||
m_fileNums = item.m_fileNums;
|
||||
m_fileTotalLength = item.m_fileTotalLength;
|
||||
m_curCreatPrintDatFileIdx = -1;
|
||||
m_filesList = item.m_filesList;
|
||||
}
|
||||
|
||||
@ -221,7 +232,6 @@ public:
|
||||
m_port = item.m_port;
|
||||
m_fileNums = item.m_fileNums;
|
||||
m_fileTotalLength = item.m_fileTotalLength;
|
||||
m_curCreatPrintDatFileIdx = -1;
|
||||
m_filesList = item.m_filesList;
|
||||
return *this;
|
||||
}
|
||||
|
35
main.cpp
35
main.cpp
@ -5,6 +5,25 @@
|
||||
#include "main.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[])
|
||||
{
|
||||
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/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
|
||||
{
|
||||
@ -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;
|
||||
mainWi.initAllWinForm();
|
||||
mainWi.show();
|
||||
|
8
main.h
8
main.h
@ -11,16 +11,16 @@
|
||||
//语言
|
||||
enum Language
|
||||
{
|
||||
LANGUAGE_CHINESE = 1,
|
||||
LANGUAGE_ENGLISH = 2
|
||||
chinese = 1,
|
||||
english = 2
|
||||
};
|
||||
|
||||
#ifdef _IN_MAIN_CPP
|
||||
QList<Machine*> g_machineList;
|
||||
int g_language;
|
||||
QTranslator *g_pTranslator;
|
||||
#else
|
||||
extern QList<Machine*> g_machineList;
|
||||
extern int g_language;
|
||||
extern QTranslator *g_pTranslator;
|
||||
#endif
|
||||
|
||||
#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>
|
811
mainwindow.cpp
811
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 "addmachinedialog.h"
|
||||
#include "datafile/hpgl/importhpgl.h"
|
||||
#include "datafile/dxf/dxfhelper.h"
|
||||
#include "machine/bmp/creatprintbmp.h"
|
||||
|
||||
//文件列表
|
||||
#define COLUMN_NUM 8 //列数
|
||||
#define COLUMN_NUM 9 //列数
|
||||
#define COLUMN_COLWIDTH 96 //列宽
|
||||
#define COLUMN_FILENAME 0 //第1列-文件名称
|
||||
#define COLUMN_LENGTH 1 //第2列-文件长度
|
||||
#define COLUMN_WIDTH 2 //第3列-文件宽度
|
||||
#define COLUMN_START 3 //第4列-文件起始打印点
|
||||
#define COLUMN_PRINTEDLENGTH 4 //第5列-文件已打印长度
|
||||
#define COLUMN_NUMBERS 5 //第6列-文件打印数量
|
||||
#define COLUMN_STATE 6 //第7列-文件打印状态
|
||||
#define COLUMN_FILEPATH 7 //第8列-文件路径
|
||||
#define COLUMN_PRINTPROGRESS 5 //第6列-文件打印进度
|
||||
#define COLUMN_NUMBERS 6 //第7列-文件打印数量
|
||||
#define COLUMN_STATE 7 //第8列-文件打印状态
|
||||
#define COLUMN_FILEPATH 8 //第9列-文件路径
|
||||
|
||||
//机器连接列表
|
||||
#define CONN_COLUMN_NUM 5 //列数
|
||||
@ -49,7 +49,7 @@
|
||||
#define CONN_COLUMN_MCIP 1 //第2列-机器IP
|
||||
#define CONN_COLUMN_MCCONSTATE 2 //第3列-机器连接状态
|
||||
#define CONN_COLUMN_MCWORKSTATE 3 //第4列-机器工作状态
|
||||
#define CONN_COLUMN_MCPROGRESS 4 //第5列-机器文件发送进度
|
||||
#define CONN_COLUMN_MCPROGRESS 4 //第5列-机器打印进度
|
||||
|
||||
#define AUTOPRINT 1
|
||||
#define NOAUTOPRINT 0
|
||||
@ -74,7 +74,6 @@ private:
|
||||
PrintViewWindow *m_printViewWi;
|
||||
PrintInfoDialog *m_printInfoDlg;
|
||||
MyGraphicsView *m_preView;
|
||||
QTimer *m_sendTimer;
|
||||
QTimer * m_pTimer;//建立连接的定时器
|
||||
|
||||
int m_curMcIdx;//列表所选机器索引
|
||||
@ -92,6 +91,8 @@ private:
|
||||
|
||||
int m_breakAutoLoadThread;//打断自动加载文件线程
|
||||
QFuture<void> m_autoPrintLoadThread;//自动绘图目录加载线程
|
||||
double m_rotateAngle;
|
||||
QSettings *m_pSettings;
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent *e);
|
||||
@ -99,8 +100,8 @@ private:
|
||||
void reflushMcFileInfo();
|
||||
void changeRowData(int move);
|
||||
bool deleteDir(QString path);
|
||||
void setButtonEnable(bool bl);
|
||||
void startCreatBmpAndSend(int mcIdx = -1);//开始创建位图并发送
|
||||
void stopPrint(int mcIdx = -1);//停止打印
|
||||
QPicture creatFilePicture(McFilesInfo & mcFileInfo, s16 penWidth = 1);
|
||||
//刷新连接状态
|
||||
void refConnectUi();//刷新连接状态(1秒)
|
||||
@ -108,7 +109,8 @@ private:
|
||||
void refreshMcListShow();//刷新机器列表显示
|
||||
void refreshOneMcShow(int row,int idx);//刷新单个机器信息显示
|
||||
int refreshMcFileListShow(int idx);
|
||||
void creatMarkerDat(McFilesInfo &curFilesInfo, QString filePath);//创建Marker数据
|
||||
void refreshBtnEnable();//刷新按钮可按状态
|
||||
void switchLanguage(s16 languageType);
|
||||
|
||||
public:
|
||||
void initAllWinForm();
|
||||
@ -124,11 +126,11 @@ private slots:
|
||||
void slotStartSetDlgShow();
|
||||
void slotViewPrintInfo();
|
||||
void slotDeleteFile();//删除文件
|
||||
void slotDeleteFileFinish();//删除文件完成并刷新
|
||||
void slotDeleteMc();//删除机器
|
||||
void onSendTimer(void);
|
||||
void slotLoadAutoPrintFiles();
|
||||
void onOneSecondTimer();//1秒定时器
|
||||
void slotDeleteFileFromList(int mcNum, int fileIdx, int refreshFlag = 0);//从列表中删除已打印完成的文件
|
||||
void slotRefreshPrintProgress(int mcNum, int fileIdx); //刷新打印进度
|
||||
|
||||
private slots:
|
||||
void on_actionDrawing_Setting_triggered();
|
||||
@ -143,7 +145,6 @@ private slots:
|
||||
void on_actionOpenFileIcon_triggered();
|
||||
void on_actionOpen_Image_triggered();
|
||||
void on_actionOpenImageIcon_triggered();
|
||||
void on_actionDelete_triggered();
|
||||
void on_actionAuto_Print_Dir_triggered();
|
||||
void on_actionStart_triggered();
|
||||
void on_actionStartIcon_triggered();
|
||||
@ -152,6 +153,8 @@ private slots:
|
||||
void on_actionAddMachine_triggered();
|
||||
void on_actionDeletMachine_triggered();
|
||||
void on_tableView_Connection_clicked(const QModelIndex &index);
|
||||
void on_actionChinese_triggered();
|
||||
void on_actionEnglish_triggered();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -259,7 +259,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>23</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile_F">
|
||||
@ -277,10 +277,8 @@
|
||||
<addaction name="menuTesting"/>
|
||||
<addaction name="actionStart"/>
|
||||
<addaction name="actionPause"/>
|
||||
<addaction name="actionDelete"/>
|
||||
<addaction name="actionAuto_Print_Dir"/>
|
||||
<addaction name="actionlog"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuConnect_Manage_C">
|
||||
<property name="title">
|
||||
@ -349,12 +347,12 @@
|
||||
</action>
|
||||
<action name="actionStart">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
<string extracomment="启动所有">Start All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPause">
|
||||
<property name="text">
|
||||
<string>Pause</string>
|
||||
<string extracomment="暂停所有">Pause All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDelete">
|
||||
@ -488,7 +486,7 @@
|
||||
<string>DrawingSetIcon</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>DrawingSetting</string>
|
||||
<string extracomment="图形设置">DrawingSetting</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAddMachine">
|
||||
|
@ -14,3 +14,13 @@ PlotterSetDialog::~PlotterSetDialog()
|
||||
{
|
||||
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:
|
||||
explicit PlotterSetDialog(QWidget *parent = 0);
|
||||
~PlotterSetDialog();
|
||||
void refreshLanguage();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::PlotterSetDialog *ui;
|
||||
|
@ -23,19 +23,19 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Print startup mode selection</string>
|
||||
<string extracomment="打印启动方式选择">Print startup mode selection</string>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="checkBox_auto">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>241</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto Print</string>
|
||||
<string extracomment="自动打印">Auto Print</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -49,32 +49,32 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Print mode selection</string>
|
||||
<string extracomment="打印模式选择">Print mode selection</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_single">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Single</string>
|
||||
<string extracomment="单向">Single</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_double">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Double</string>
|
||||
<string extracomment="双向">Double</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -88,13 +88,13 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Graphic error correction</string>
|
||||
<string extracomment="图形误差修正">Graphic error correction</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit_outputW">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>26</y>
|
||||
<y>28</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -107,7 +107,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>30</y>
|
||||
<y>32</y>
|
||||
<width>30</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
@ -120,20 +120,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>53</x>
|
||||
<y>26</y>
|
||||
<y>28</y>
|
||||
<width>181</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 meter actual output:</string>
|
||||
<string extracomment="1米实际输出:">1 meter actual output:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_outputHUnit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>60</y>
|
||||
<y>62</y>
|
||||
<width>30</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
@ -146,20 +146,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>53</x>
|
||||
<y>56</y>
|
||||
<y>58</y>
|
||||
<width>181</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 meter actual output:</string>
|
||||
<string extracomment="1米实际输出:">1 meter actual output:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_outputH">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>56</y>
|
||||
<y>58</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -172,20 +172,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>38</y>
|
||||
<y>40</y>
|
||||
<width>201</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Drawing 1 meter Square</string>
|
||||
<string extracomment="绘1米正方形">Drawing 1 meter Square</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_outputWIcon">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>6</x>
|
||||
<y>26</y>
|
||||
<y>28</y>
|
||||
<width>42</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -201,7 +201,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>6</x>
|
||||
<y>55</y>
|
||||
<y>57</y>
|
||||
<width>42</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -224,7 +224,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Two way print error setting</string>
|
||||
<string extracomment="双向打印误差设置">Two way print error setting</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit_twowayError">
|
||||
<property name="geometry">
|
||||
@ -262,7 +262,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Two way print error:</string>
|
||||
<string extracomment="双向打印错位误差:">Two way print error:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_drawWUnit">
|
||||
@ -288,7 +288,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print drawing width:</string>
|
||||
<string extracomment="打印图形宽度:">Print drawing width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_drawW">
|
||||
@ -314,7 +314,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print Error Correction</string>
|
||||
<string extracomment="打印误差修正图">Print Error Correction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -328,15 +328,15 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Error setting between nozzles</string>
|
||||
<string extracomment="喷头间误差设置">Error setting between nozzles</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_nozzleError">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>21</y>
|
||||
<y>10</y>
|
||||
<width>501</width>
|
||||
<height>94</height>
|
||||
<height>106</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
@ -346,7 +346,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>8</y>
|
||||
<y>24</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -359,59 +359,59 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>8</y>
|
||||
<y>24</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_12Error">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>8</y>
|
||||
<y>24</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1、2 error between nozzles:</string>
|
||||
<string extracomment="1、2喷头间错误误差:">1、2 error between nozzles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_23ErrorUnit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>36</y>
|
||||
<y>52</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_23Error">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>36</y>
|
||||
<y>52</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2、3 error between nozzles:</string>
|
||||
<string extracomment="2、3喷头间错误误差:">2、3 error between nozzles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_23Error">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>36</y>
|
||||
<y>52</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -424,20 +424,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>64</y>
|
||||
<y>80</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>3、4 error between nozzles:</string>
|
||||
<string extracomment="3、4喷头间错误误差:">3、4 error between nozzles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_34Error">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>64</y>
|
||||
<y>80</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -450,20 +450,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>64</y>
|
||||
<y>80</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_errorIcon">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>390</x>
|
||||
<y>23</y>
|
||||
<y>39</y>
|
||||
<width>65</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
@ -480,9 +480,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>122</y>
|
||||
<y>105</y>
|
||||
<width>501</width>
|
||||
<height>94</height>
|
||||
<height>106</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
@ -492,7 +492,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>8</y>
|
||||
<y>25</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -505,59 +505,59 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>8</y>
|
||||
<y>25</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_12Overlap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>8</y>
|
||||
<y>25</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1、2 overlap between nozzles:</string>
|
||||
<string extracomment="1、2喷头间重叠误差:">1、2 overlap between nozzles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_23OverlapUnit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>36</y>
|
||||
<y>53</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_23Overlap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>36</y>
|
||||
<y>53</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2、3 overlap between nozzles:</string>
|
||||
<string extracomment="2、3喷头间重叠误差:">2、3 overlap between nozzles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_23Overlap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>36</y>
|
||||
<y>53</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -570,20 +570,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>64</y>
|
||||
<y>81</y>
|
||||
<width>221</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>3、4 overlap between nozzles:</string>
|
||||
<string extracomment="3、4喷头间重叠误差:">3、4 overlap between nozzles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_34Overlap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>64</y>
|
||||
<y>81</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -596,20 +596,20 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>64</y>
|
||||
<y>81</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pixel</string>
|
||||
<string extracomment="像素">pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_overlapIcon">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>390</x>
|
||||
<y>23</y>
|
||||
<y>40</y>
|
||||
<width>65</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
@ -632,7 +632,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Correction diagram between nozzles</string>
|
||||
<string extracomment="打印喷头间误差修正图">Correction diagram between nozzles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -646,13 +646,13 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Paper feeding error correction</string>
|
||||
<string extracomment="走纸误差修正">Paper feeding error correction</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit_paperFeedingSet">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>26</y>
|
||||
<y>31</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -665,7 +665,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>30</y>
|
||||
<y>35</y>
|
||||
<width>30</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
@ -678,26 +678,26 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>36</x>
|
||||
<y>26</y>
|
||||
<y>31</y>
|
||||
<width>201</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Paper feeding error set:</string>
|
||||
<string extracomment="走纸误差设置:">Paper feeding error set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_printPaperFeeding">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>22</y>
|
||||
<y>27</y>
|
||||
<width>201</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print paper feed error</string>
|
||||
<string extracomment="打印走纸误差">Print paper feed error</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -711,7 +711,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
<string extracomment="确定">Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
@ -724,7 +724,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
<string extracomment="取消">Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_SprinklerSelect">
|
||||
@ -737,58 +737,58 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Sprinkler selection</string>
|
||||
<string extracomment="喷头选择">Sprinkler selection</string>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="checkBox_nozzle1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Nozzle 1</string>
|
||||
<string extracomment="1号喷头">Nozzle 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_nozzle2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Nozzle 2</string>
|
||||
<string extracomment="2号喷头">Nozzle 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_nozzle3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Nozzle 3</string>
|
||||
<string extracomment="3号喷头">Nozzle 3</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_nozzle4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>22</y>
|
||||
<y>25</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Nozzle 4</string>
|
||||
<string extracomment="4号喷头">Nozzle 4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -11,6 +11,8 @@ PrintInfoDialog::PrintInfoDialog(QWidget *parent) :
|
||||
|
||||
//QListView
|
||||
ui->listView_blockList->setDragEnabled(false); //控件不允许拖动
|
||||
// 设置listView为不可编辑状态
|
||||
ui->listView_blockList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
m_listViewModel = new QStringListModel(ui->listView_blockList);
|
||||
ui->listView_blockList->setModel(m_listViewModel);
|
||||
|
||||
@ -24,6 +26,11 @@ PrintInfoDialog::~PrintInfoDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrintInfoDialog::refreshLanguage()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void PrintInfoDialog::on_listView_blockList_clicked(const QModelIndex &index)
|
||||
{
|
||||
QString str = "0 - ";
|
||||
@ -101,11 +108,11 @@ void PrintInfoDialog::setFilesInfo(McFilesInfo info)
|
||||
m_preView->cleanView();
|
||||
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)
|
||||
{
|
||||
m_preView->creatView(m_curFilesInfo.m_pixmap);//刷新显示
|
||||
m_preView->swithViewByPic(m_curFilesInfo.m_pic);//刷新显示
|
||||
}
|
||||
|
||||
reflushFileInfo();
|
||||
|
@ -18,6 +18,7 @@ class PrintInfoDialog : public QDialog
|
||||
public:
|
||||
explicit PrintInfoDialog(QWidget *parent = 0);
|
||||
~PrintInfoDialog();
|
||||
void refreshLanguage();
|
||||
|
||||
private slots:
|
||||
void on_listView_blockList_clicked(const QModelIndex &index);
|
||||
|
@ -49,7 +49,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number:</string>
|
||||
<string extracomment="份数:">Number:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_ok">
|
||||
|
@ -32,7 +32,12 @@ PrintViewWindow::~PrintViewWindow()
|
||||
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_printNumber = 1;
|
||||
@ -56,11 +61,12 @@ void PrintViewWindow::refreshShow(McFilesInfo mcFilesInfo,int flag)
|
||||
m_view->cleanView();
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
siAddNewFile(m_addNewFileFlag);
|
||||
emit siAddNewFile(m_addNewFileFlag);
|
||||
this->close();
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class PrintViewWindow : public QMainWindow
|
||||
public:
|
||||
explicit PrintViewWindow(QWidget *parent = 0);
|
||||
~PrintViewWindow();
|
||||
void refreshLanguage();
|
||||
|
||||
private:
|
||||
Ui::PrintViewWindow *ui;
|
||||
@ -32,7 +33,7 @@ private:
|
||||
int m_length;
|
||||
|
||||
public:
|
||||
void refreshShow(McFilesInfo mcFilesInfo,int flag = 0);
|
||||
void refreshShow(McFilesInfo &mcFilesInfo,int penWidth,int flag = 0);
|
||||
void setStartLineText(QString str);
|
||||
void setNumberLineText(QString str);
|
||||
inline int getStartPoint(){return m_startPoint;}
|
||||
|
Loading…
Reference in New Issue
Block a user