#ifndef CJIGDRIVER_H
#define CJIGDRIVER_H

#include <cdrivercard.h>
#include "ckerf_base.h"
#include "mark_area.h"
#include <QReadWriteLock>
#include "export_laser_cali_driver.h"

class LASER_CALI_DRIVER_EXPORT CJigDriver :
    public CDriverCard
{
    enum msg_id
    {
        CJIGDRIVER_MSG_ID = MAX_DRIVER_MSG_ID,
        MEASURE_THICKNESS,		//<测量CellArea的焦点补偿，如果没有切割会进行一次切割
        REPLACE_MARKPANEL,		//<更换打码的板子
        MAX_JIGDRIVER_MSG_ID,
    };
public:
    CJigDriver(const QString& name, int32_t id);
public:
    //高倍相机看到时，坐标的位置
    //CMPointd m_CenterPt;
    double m_dFocusOffset;
    //double m_dZPosOffset;
    //double m_dOffsetY;
    //当前的区域Index
    int m_iCurPosIdx;

    int m_iKerfCamID;

    QReadWriteLock m_Lock;
    //! 每个区域左上角区域的位置坐标
    std::vector<_Mark_Area> m_MarkListTopLeft;
    CMPointd m_CheckPos;    //检查的点位

public:
    int ReplaceMarkPanel();
    void InitalPosVector(std::vector<_Mark_Area>& areaListTopLeft, int& iIndex);

    void SaveCutData(bool bWrite);
    void LoadMarkData(bool bRead);

    int MeasureThickness(int iCellIndex = -1, bool bOnlyMeasure = false);
    int CalcuMeasurePos(double& dStartPosX, double& dEndPosX, double& dPosY, int iCellIndex = -1);
    double MeasTargetThick(int iCellIndex);
    void SetMeasureCamParam();
    bool IsNeedMeasure();
    bool IsNeedMeasureCut(int iCellIndex = -1);


    bool PosIndexIncrease();
    void SetMeasureCuttedMark(int idx, bool bCutted);
    bool CellAreaHasLine(const _Mark_Area& markArea, int& iLine);
};

#endif // CJIGDRIVER_H