#ifndef CCTRLGRAPH_H
#define CCTRLGRAPH_H
#include "base.h"
#include "cmwidget.h"
#include <QRectF>
#include <QList>
#include <QPainter>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QPixmap>
#include "cshapelogic.h"
#include "export_ctrls_graph.h"
class CTRLS_GRAPH_EXPORT CCtrlGraph : public CMWidget
{
    Q_OBJECT

public:
    explicit CCtrlGraph(QWidget *parent = 0);
    ~CCtrlGraph();

    virtual void MInit();
    virtual void MTimeFresh();
    virtual void MFresh();
    virtual void MApply();
	virtual void paintEvent(QPaintEvent *pEvent);

	virtual void showEvent(QShowEvent * pEvent);
    virtual void mousePressEvent(QMouseEvent *pEvent);
    virtual void mouseReleaseEvent(QMouseEvent *pEvent);
    virtual void mouseMoveEvent(QMouseEvent *pEvent);
    virtual void wheelEvent(QWheelEvent *pEvent);
    virtual void resizeEvent(QResizeEvent *);
public:
	CRect_logic m_rectWindow;
	int32_t m_iMargin;
	bool m_bISOTROPIC;
public:
	double m_dRangeXMin;
    double m_dRangeXMax;
	QList<double> lUnitsX;
	QString m_strUnitX;
	double m_dCurUnitX;

	double m_dRangeYMin;
    double m_dRangeYMax;
	QList<double> lUnitsY;
	QString m_strUnitY;
	double m_dCurUnitY;
public:
	QTransform m_trans_LP2DP;
	QTransform m_trans_DP2LP;
	void CalcuTransfrom();
    void ZoomIn();
	void ZoomOut();
    void ZoomFit();
public:
    virtual void refreshPixmap(bool bupdate=true);
	QPixmap m_Pixmap;

	QRectF get_rectClip();
    void  adjust_rectWindow(bool bresetZero);
    virtual void  init_rectWindow();
    void draw_Coord(QPainter& painter);
protected:
    QRect m_rubberBandRect;
    bool m_bCapture;
    virtual void updaterubberBandRect();
public:
    enum ZeroPos
    {
        CENTER_POS,
        LEFT_BOTTOM,

        LEFT_CENTER,
        LEFT_TOP,

        BOTTOM_CENTER,
        BOTTOM_RIGHT,
    };
    int  m_iZeroPos;
    int m_iPenWidth;
	bool m_bEnableZoom;
    bool m_bEnbleDrawText;
protected:
    bool m_bInit;
    QColor m_BKColor;
};

#endif // CCTRLGRAPH_H
