131 lines
6.5 KiB
C
131 lines
6.5 KiB
C
|
#ifndef DATAFILEQUI_H
|
|||
|
#define DATAFILEQUI_H
|
|||
|
|
|||
|
#include <QFileInfo>
|
|||
|
#include <QFile>
|
|||
|
#include <QString>
|
|||
|
#include <QByteArray>
|
|||
|
#include <QImage>
|
|||
|
#include <QDebug>
|
|||
|
#include <QPainter>
|
|||
|
#include <QRgb>
|
|||
|
#include "math.h"
|
|||
|
#include <QBrush>
|
|||
|
#include "stdint.h"
|
|||
|
|
|||
|
//#include "vectorsqrt.h"
|
|||
|
#include "machine/comm/datadef.h"
|
|||
|
#include "machine/comm/crc16.h"
|
|||
|
#include "datafile/dataoperat.h"
|
|||
|
|
|||
|
#define QUI_DATADIRX (1) // X向数据坐标与下位机坐标系统的差异
|
|||
|
#define QUI_DATADIRY (-1) // Y向数据坐标与下位机坐标系统的差异
|
|||
|
#define QUI_DATADIRR (-1) // R向数据坐标与下位机坐标系统的差异
|
|||
|
|
|||
|
#define QUI_SHOWDIRX (1) // X向显示坐标和数据坐标的差异
|
|||
|
#define QUI_SHOWDIRY (-1) // Y向显示坐标和数据坐标的差异
|
|||
|
|
|||
|
#define QUI_PREVIEW_SIDE (15) // 留边大小
|
|||
|
#define QUI_PREVIEW_WIDTH (156) // 默认预览图区域宽度
|
|||
|
#define QUI_PREVIEW_HEIGHT (164) // 默认预览图区域高度
|
|||
|
|
|||
|
typedef struct tagQuiltingFileHead
|
|||
|
{
|
|||
|
char id[4]; // 0x00—0x03; 标志:=="RICH"
|
|||
|
char name[8]; // 0x04—0x07; 文件名
|
|||
|
unsigned char reserve1[4]; // 0x0C—0x0F; 保留
|
|||
|
unsigned char ver; // 0x10; 版本号
|
|||
|
unsigned char unit; // 0x11; 单位 0x00: 0.1mm; 0x01: 1/1000inch; 0x02: 0.04mm;0x03: 0.01mm
|
|||
|
unsigned char type; // 0x12; 类型, 0x00: 多针机英制; 0x01: 多针机公制; 0x10: 单头机英制; 0x11:单头机公制
|
|||
|
unsigned char reserve2[11]; // 0x13—0x1D; 保留
|
|||
|
unsigned short HStep; // 0x1E—0x1F; 水平方向针距 单位:0.1mm(绘制用,多针机)
|
|||
|
unsigned short leftRightLen; // 0x20—0x21; 左针右针距离 单位:0.1mm(绘制用,多针机)
|
|||
|
unsigned short VStep12; // 0x22—0x23; 第1 2排针距 单位:0.1mm(绘制用,多针机)
|
|||
|
unsigned short VStep23; // 0x24—0x25; 第2 3排针距 单位:0.1mm(绘制用,多针机)
|
|||
|
|
|||
|
// 排针每个字节:XXXX XXXX
|
|||
|
// 针位n (0x00:无针,0x01:右针, 0x10:左针,0x11:左右针)
|
|||
|
unsigned char arrayNeedle1[48]; // 0x26—0x55; 第1排排针(绘制用,多针机)
|
|||
|
unsigned char arrayNeedle2[48]; // 0x56—0x85; 第2排排针(绘制用,多针机)
|
|||
|
unsigned char arrayNeedle3[48]; // 0x86—0xB5; 第3排排针(绘制用,多针机)
|
|||
|
unsigned char rotateStyle; // 0xB6; 旋转式样
|
|||
|
unsigned char rotateAngle; // 0xB7; 旋转角度
|
|||
|
unsigned char reinMode; // 0xB8; 加固方式
|
|||
|
unsigned char reinNum; // 0xB9; 次数
|
|||
|
unsigned char reserve3[4]; // 0xBA—0xBD; 保留
|
|||
|
unsigned short angleCorrOffset; // 0xBE ; 角度修正量 (中间数据后,可以修改,拐角补偿,单针机和多针机,新加-hhy)
|
|||
|
unsigned char angleCorrPosX; // 0xC0 ; 角度修正x正(中间数据后,可以修改,拐角补偿,单针机和多针机)
|
|||
|
unsigned char angleCorrPosY; // 0xC1 ; 角度修正y正(中间数据后,可以修改,拐角补偿,单针机和多针机)
|
|||
|
unsigned char angleCorrNegX; // 0xC2 ; 角度修正x负(中间数据后,可以修改,拐角补偿,单针机和多针机)
|
|||
|
unsigned char angleCorrNegY; // 0xC3 ; 角度修正y负(中间数据后,可以修改,拐角补偿,单针机和多针机)
|
|||
|
unsigned char stepQui[2]; // 0xC4—0xC5; 跨步绗缝
|
|||
|
unsigned char reinNeedles; // 0xC6; 加固绗缝针数(中间数据后,可以修改,终点有跨步的才加,单针机和多针机)
|
|||
|
unsigned char rollaYUpDn; // 0xC7; 罗拉补偿y上下(中间数据后,让图形闭合,可以修改,多针机)
|
|||
|
unsigned char rollaYRev; // 0xC8; 罗拉补偿y预留
|
|||
|
unsigned char normalStep; // 0xC9; 针步大小(中间数据前,可以修改,单针机和多针机)
|
|||
|
unsigned char miniStep; // 0xCA; 最小针步
|
|||
|
unsigned char reserve4[4]; // 0xCB—0xCE; 保留
|
|||
|
unsigned char saddleRatio[2]; // 0xCF—0xD0; 鞍架比例
|
|||
|
unsigned char rollaRatio[2]; // 0xD1—0xD2; 罗拉比例
|
|||
|
unsigned char reinQuiNeedleHigh; // 0xD3; 加固绗缝针数高字节
|
|||
|
unsigned short left; // 0xD4—0xD5; 左边 (中间数据后,可以修改,改变起始点,单针机)
|
|||
|
unsigned short front; // 0xD6—0xD7; 前边 (中间数据后,可以修改,改变起始点,单针机)
|
|||
|
unsigned short scanX; // 0xD8—0xD9; 缩放X (中间数据前,可以修改,单针机和多针机)
|
|||
|
unsigned short scanY; // 0xDA—0xDB; 缩放Y (中间数据前,可以修改,单针机和多针机)
|
|||
|
unsigned short totalOutput; // 0xDC—0xDD; 本花样累计总产量
|
|||
|
unsigned short currentOutput; // 0xDE—0xDF; 本花样当次产量
|
|||
|
unsigned short serWorkLa; // 0xE0-0xE1; 连续作业前留边
|
|||
|
unsigned short serWorkLb; // 0xE2-0xE3; 连续作业后留边
|
|||
|
unsigned char stepCompUpDn; // 0xE4; 跨步补偿y上下(多针机专业)(中间数据后,可以修改,多针机)
|
|||
|
|
|||
|
unsigned char reserve6[27]; // 0xE5—0xFF; 保留
|
|||
|
|
|||
|
} __attribute__ ((packed)) QuiFileHead;
|
|||
|
|
|||
|
class DataFileQui
|
|||
|
{
|
|||
|
public:
|
|||
|
DataFileQui();
|
|||
|
|
|||
|
protected:
|
|||
|
QString m_fileFullPathName; // 文件路径
|
|||
|
QByteArray m_absData; // 转换后的绝对坐标数据
|
|||
|
QByteArray m_quiFileData;// 文件数据内容(原始数据)
|
|||
|
|
|||
|
private:
|
|||
|
double m_minX;
|
|||
|
double m_maxX;
|
|||
|
double m_minY;
|
|||
|
double m_maxY;
|
|||
|
QuiPoint m_firstPoint;
|
|||
|
|
|||
|
private:
|
|||
|
void creatAbsHeadAndAr();//生成绝对坐标数据文件头及ar
|
|||
|
void getQuiMinMax();
|
|||
|
int checkFileHead();
|
|||
|
double getMutiUnit(int unit);
|
|||
|
|
|||
|
public:
|
|||
|
void initFile(const QString & fullPathName);
|
|||
|
void clear();
|
|||
|
void loadFile();
|
|||
|
void convertDataToEmbAbs(s16 flag = 1);
|
|||
|
int createPreviewImage(QImage * pImg = NULL, int saveflag = 0, int penwidth = 1, int reDraw = 0); // 生成预览文件
|
|||
|
inline const QString & getFileFullPathName() const {return m_fileFullPathName;} // 文件路径名称
|
|||
|
inline QByteArray & getEmbAbsData() {return m_absData;} // 得到转换后的数据
|
|||
|
QuiFileHead *getQuiHead();
|
|||
|
void writePatternParaToFile(QuiFileHead *head);//将花样参数配置写到文件中
|
|||
|
void moveDataBeginPonit(s32 left, s32 front);//移动数据起始点
|
|||
|
|
|||
|
public:
|
|||
|
int getStitchNums();//得到数据的针数
|
|||
|
int getDatWidth();//得到数据的图形宽度
|
|||
|
int getDatHeight();//得到数据的图形高度
|
|||
|
int getMaxX();//得到数据最大X+
|
|||
|
int getMinX();//得到数据最小X-
|
|||
|
int getMaxY();//得到数据最大Y+
|
|||
|
int getMinY();//得到数据最小Y-
|
|||
|
};
|
|||
|
|
|||
|
#endif // DATAFILEQUI_H
|