#ifndef CCTRLMIMG_OPENGL_CAM_H
#define CCTRLMIMG_OPENGL_CAM_H

#include "cctrlmimg_opengl.h"
#include "cctrlgraphbutton.h"
class CCtrlMImg_OPenGL_Cam : public CCtrlMImg_OPenGL
{
    Q_OBJECT
public:
    explicit CCtrlMImg_OPenGL_Cam(QWidget *parent = 0);

    CCam* m_pCam;
    void mouseReleaseEvent(QMouseEvent *pEvent);
    void mousePressEvent(QMouseEvent *pEvent);
    void resizeEvent(QResizeEvent* e);
    void showEvent(QShowEvent *pEvent);
    void MTimeFresh();
    void refreshPixmap();
    void timerEvent(QTimerEvent *pEvent);

    void DrawButton(QPainter& painter);
    void ResizeButtonPos();

    void ZoomFit();
    void ZoomOrginal();
    GRAPHBTNMAP m_ButtonMap;

    enum BtnID
    {
        BTN_RESERVE=0,
        BTN_LIVE,
        BTN_CLEAR,
        BTN_ENABLEMOVE,
        BTN_ENABLEZOOM,
        BTN_HLINEH_ADD,
        BTN_HLINEH_REDUCE,
        BTN_HLINEV_ADD,
        BTN_HLINEV_REDUCE,

        BTN_LEFT_1UM,
        BTN_RIGHT_1UM,

        BTN_LEFT_STEP,
        BTN_RIGHT_STEP,

        BTN_TOP_1UM,
        BTN_BOTTOM_1UM,

        BTN_TOP_STEP,
        BTN_BOTTOM_STEP,

        STR_HLINE_H,
        STR_HLINE_V,

        STR_DIS_X,
        STR_DIS_Y,

		BTN_LOCKMOVE_X,
		BTN_LOCKMOVE_Y,
		BTN_HIDESHOW,
    };

    int BtnHitIn(QPoint& pt);
    int m_iCaptureBtnID;

    void BtnClick(int iBtnID);
    void BtnPress(int iBtnID);
    void BtnRelease(int iBtnID);

public:
    void GetStepMoveDis(double &dX, double &dY);
    void MotorStepMove(bool bX,bool bJOG,int iButtonType,int iDirect);
    void MotorStop();
    void StartJogTimer(bool bX, int iButtonType, int iDirect);
    void StopTimer();
    enum movebuttonType
    {
        STEPMOVE_BTN,
        UMMOVE_BTN,
    };
    bool m_bJogMove;
    bool m_bX;
    int m_iButtonType;
    int m_iDirect;
    int m_iJogTimerID;
	bool m_bBtnHide;
	bool m_bLockAxisX;
	bool m_bLockAxisY;

    void on_pushButton_LeftStep_clicked();
    void on_pushButton_RightStep_clicked();
    void on_pushButton_Left1um_clicked();
    void on_pushButton_Right1um_clicked();

    void on_pushButton_LeftStep_pressed();
    void on_pushButton_RightStep_pressed();
    void on_pushButton_Left1um_pressed();
    void on_pushButton_Right1um_pressed();

    void on_pushButton_LeftStep_released();
    void on_pushButton_RightStep_released();
    void on_pushButton_Left1um_released();
    void on_pushButton_Right1um_released();

    void on_pushButton_UpStep_clicked();
    void on_pushButton_DownStep_clicked();
    void on_pushButton_Up1um_clicked();
    void on_pushButton_Down1um_clicked();

    void on_pushButton_UpStep_pressed();
    void on_pushButton_DownStep_pressed();
    void on_pushButton_Up1um_pressed();
    void on_pushButton_Down1um_pressed();

    void on_pushButton_UpStep_released();
    void on_pushButton_Up1um_released();
    void on_pushButton_Down1um_released();
    void on_pushButton_DownStep_released();

    void on_pushButton_HLineV_add_clicked();
    void on_pushButton_HLineH_add_clicked();

    void on_pushButton_HLineV_add_pressed();
    void on_pushButton_HLineH_add_pressed();

    void on_pushButton_HLineV_add_released();
    void on_pushButton_HLineH_add_released();


    void on_pushButton_HLineV_reduce_clicked();
    void on_pushButton_HLineH_reduce_clicked();

    void on_pushButton_HLineV_reduce_pressed();
    void on_pushButton_HLineH_reduce_pressed();

    void on_pushButton_HLineV_reduce_released();
    void on_pushButton_HLineH_reduce_released();

	void on_pushButton_DisX_pressed();
	void on_pushButton_DisY_pressed();
	void on_pushButton_LineV_pressed();
	void on_pushButton_LineH_pressed();

    int m_iJogHLine;
    bool m_bVHLine;
    int m_iDirectHLine;
    int m_iJogHLineTimerID;


    void MoveHLine(bool bV, int iStep);
    void StartHLineTimer(bool bV, int iDirect);
    void StopHLineTimer();


    QRect rectPictureX;
    QRect rectPictureY;

	int m_iStepValueX;
	int m_iStepValueY;
	int m_iStepValueH;
	int m_iStepValueV;
};

#endif // CCTRLMIMG_OPENGL_CAM_H
