136 lines
4.1 KiB
C++
136 lines
4.1 KiB
C++
#ifndef VECTORSQRT_H
|
||
#define VECTORSQRT_H
|
||
|
||
#include <QObject>
|
||
#include <QFile>
|
||
#include "config/config.h"
|
||
#include "comm/datadef.h"
|
||
|
||
|
||
class VSqrtItem : public QObject
|
||
{
|
||
Q_OBJECT
|
||
|
||
|
||
public:
|
||
explicit VSqrtItem(QObject *parent = NULL);
|
||
VSqrtItem(const VSqrtItem & item);
|
||
public:
|
||
VSqrtItem& operator=(const VSqrtItem & item);
|
||
private:
|
||
void CopyData(const VSqrtItem & item);
|
||
|
||
public:
|
||
void InitVSItem();
|
||
|
||
public:
|
||
int m_sqrttype; // 图形类型, 1, 直线, 2, 圆弧; 3, 三次贝塞尔
|
||
|
||
double m_begx;
|
||
double m_begy; // 起点
|
||
double m_midx;
|
||
double m_midy; // 中间点1
|
||
double m_midx2;
|
||
double m_midy2; // 中间点2
|
||
double m_endx;
|
||
double m_endy; // 终点
|
||
|
||
public:
|
||
u32 m_code; // 数据类型
|
||
|
||
public:
|
||
int m_ownsteplock; // 专有步长和回针标志, != 0, 使用一下的步长和锁针参数. 否则,使用公共的参数
|
||
|
||
u32 m_stepSize; // 步长
|
||
u32 m_blockNum; // 起始锁针针数
|
||
u32 m_blockTimes; // 起始锁针次数
|
||
u32 m_blockjumps; // 起始跳过针数
|
||
u32 m_elockNum; // 结束锁针针数
|
||
u32 m_elockTimes; // 结束锁针次数
|
||
u32 m_elockjumps; // 结束跳过针数
|
||
};
|
||
|
||
class VectorSqrt : public QObject
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
DataFileHead m_fileHead; // 数据文件头描述
|
||
|
||
explicit VectorSqrt(QObject *parent = NULL);
|
||
~VectorSqrt();
|
||
VectorSqrt(const VectorSqrt & item);
|
||
|
||
public:
|
||
VectorSqrt& operator=(const VectorSqrt & item);
|
||
|
||
private:
|
||
void CopyData(const VectorSqrt & item);
|
||
|
||
public:
|
||
void InitVSqrt(QString name = QString());
|
||
|
||
public:
|
||
QString m_filename; // 名称
|
||
int m_anchorSel; // 定位点选择; 0, 和起点重合; 1,图形的左下角; 2, 图形的右下角; 3, 图形的右上角; 4, 图形的左上角; 5, 图形的中心
|
||
|
||
public:
|
||
QList<VSqrtItem> m_vSqitItemList; // 图形列表
|
||
public:
|
||
// 针步和回针参数
|
||
u32 m_para_stepSize ; // 步长
|
||
u32 m_para_blockNum ; // 起始锁针针数
|
||
u32 m_para_blockTimes ; // 起始锁针次数
|
||
u32 m_para_blockjumps ; // 起始跳过针数
|
||
u32 m_para_elockNum ; // 结束锁针针数
|
||
u32 m_para_elockTimes ; // 结束锁针次数
|
||
u32 m_para_elockjumps ; // 结束跳过针数
|
||
|
||
public:
|
||
//这个过程应该放在不同的文件实现中而不是放在 VectorSqrt 这里生成数据中应该分离开
|
||
int CreateDs16FromSqrt(QByteArray & ds16Ary);
|
||
int CreateDs8FromDs16(const QByteArray & ds16Ary, QByteArray & ds8Ary);
|
||
|
||
int CreateDs4FromSqrt(QByteArray & ds4Ary);
|
||
int CreateDs2FromDs4(const QByteArray & ds4Ary, QByteArray & ds2Ary);
|
||
|
||
public:
|
||
void SetAnchor(int nX,int nY);
|
||
void SetBegin(int nX,int nY);
|
||
|
||
private:
|
||
int m_anchorX;//定位点X
|
||
int m_anchorY;//定位点Y
|
||
int m_beginX;//数据起点坐标X
|
||
int m_beginY;//数据起点坐标Y
|
||
|
||
|
||
|
||
signals:
|
||
|
||
public slots:
|
||
};
|
||
|
||
int GetDataMinMax(DataItem * pData, int nums, s32 & minx, s32 & miny, s32 & maxx, s32 & maxy);
|
||
|
||
|
||
// 图形算法
|
||
// 直线
|
||
int CalcLine(double x0, double y0, double x1, double y1, int * pactx, int * pacty, int stepSize, DataItem * pData, u8 type, s16 dr);
|
||
|
||
// 三点圆弧
|
||
int CalcCurve(double threex[], double threey[], int * pactx, int * pacty, int * pActAng, int stepSize, DataItem * pData, u8 type);
|
||
|
||
void Rotatec(double xin, double yin, double * px, double * py, double angle);
|
||
int ArcDir(const double x[], const double y[]);
|
||
int IsThreePointOnALine(const double threex[], const double threey[]);
|
||
int GetArcCenter(const double x[], const double y[], double * pxc, double * pyc, double * pr);
|
||
int GetArcRectAndAngle(const double x[], const double y[], double * minx, double * maxx, double * miny, double * maxy, double * startangle, double * endangle);
|
||
int GetArcMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy);
|
||
s16 GetAngle(const double bx, const double by, const double ex, const double ey, int * pActAng);
|
||
|
||
// 三次贝塞尔
|
||
int GetBezierMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy);
|
||
|
||
|
||
#endif // VECTORSQRT_H
|