#ifndef CCTRLGRAPHPIOPENGL_H
#define CCTRLGRAPHPIOPENGL_H

#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QPixmap>
#include <QPainter>
#include <QMutex>
#include "export_ctrls_graph.h"
typedef struct _PI_Graph_Data
{
    double dData;
    QString name;
    QColor color;
    QString unit;
    _PI_Graph_Data()
    {
       dData=0;
       color=QRgb(0);
    }
    _PI_Graph_Data(QString name1,double data1,
                   QColor color1,QString unit1)
    {
        name=name1;
        dData=data1;
        color=color1;
        unit=unit1;
    }

}PI_Graph_Data;
typedef QList<PI_Graph_Data> LPI_Graph_Data;
class CTRLS_GRAPH_EXPORT CCtrlGraph_PI : public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT
public:
    explicit CCtrlGraph_PI(QWidget *parent = 0);
    void initializeGL() Q_DECL_OVERRIDE;
    void resizeGL(int w, int h) Q_DECL_OVERRIDE;
    void paintGL() Q_DECL_OVERRIDE;

    virtual void MInit();
    virtual void MTimeFresh();
    virtual void MFresh();

    virtual void showEvent(QShowEvent * pEvent);
public:
    virtual void refreshPixmap(bool bupdate=true);
    QPixmap m_Pixmap;
    LPI_Graph_Data m_dataList;
    void SetString(QStringList& extraString);
    QMutex m_mutex;
private:
    QStringList m_ExtraString;
    QRectF  Get_Graph_rect();
    QRectF  Get_PI_rect();
    QRectF  Get_Text_rect();
    void DrawPI(QPainter &painter, PI_Graph_Data& data);
    void DrawDataText(QPainter &painter);

    float m_dCurAngle;
    double m_dTotal;
public:
    QString m_sName;
    QColor m_BKColor;
    int m_pPrecise;
signals:

public slots:
};

#endif // CCTRLGRAPHPIOPENGL_H
