#ifndef ROUNDPLOT_H
#define ROUNDPLOT_H


#include <QWidget>

class RoundPlot : public QWidget
{
	Q_OBJECT
public:
	RoundPlot(QWidget *parent = 0);
	~RoundPlot();

protected:
	void paintEvent(QPaintEvent *);
	void drawDial(QPainter *painter);
	void drawBgOut(QPainter *painter);
	void drawBgRound(QPainter *painter);
	void drawBgCenter(QPainter *painter);
	void drawText(QPainter *painter);

private:
	double minValue;            //Сֵ
	double maxValue;            //ֵ
	double value;               //Ŀֵ
	double angle;               //ʼתǶ
    int precision;              //ȷ,С㼸λ
	QString unit;               //λ

	double currentPercent;      //ǰѴİٷֱ
	double valuePercent;        //Ŀֵٷֱ

	QColor usedColor;           //ʹðٷֱɫ
	QColor freeColor;           //δʹðٷֱɫ

	QColor rangeTextColor;      //Χֵɫ
	QColor valueTextColor;      //Ŀֵɫ

	QColor valueBgColor;        //Ŀֵɫ
	QColor outBgColor;          //߿򱳾ɫ
	QColor centerBgColorStart;  //мԲ䱳ʼɫ
	QColor centerBgColorEnd;    //мԲ䱳ɫ

    QTimer *timer;              //ƶʱ

private slots:
	void updateValue();

public:
	//ȡСֵ
	double getMinValue()const
	{
		return minValue;
	}

	//ȡֵ
	double getMaxValue()const
	{
		return maxValue;
	}

	//ȡĿֵ
	double getValue()const
	{
		return value;
	}

	//ȡתǶ
	double getAngle()const
	{
		return angle;
	}

	//ȡСλ
    int getPrecision()const
	{
        return precision;
	}

	//ȡλ
	QString getUnit()const
	{
		return unit;
	}

public slots:
	//Сֵ-Χֵ
	void setRange(double minValue, double maxValue);
	void setRange(int minValue, int maxValue);

	//Ŀֵ
	void setValue(double value);
	void setValue(int value);

	//תǶ
	void setAngle(double angle);

	//Сλ
    void setPrecision(int precision);

	//ֺĵλ
	void setUnit(QString unit);

	//ʹðٷֱɫ
	void setUsedColor(QColor usedColor);
	//δʹðٷֱɫ
	void setFreeColor(QColor freeColor);

	//÷Χֵɫ
	void setRangeTextColor(QColor rangeTextColor);
	//Ŀֵɫ
	void setValueTextColor(QColor valueTextColor);

	//Ŀֵɫ
	void setValueBgColor(QColor valueBgColor);
	//߿򱳾ɫ
	void setOutBgColor(QColor outBgColor);
	//Բɫ
	void setCenterBgColor(QColor centerBgColorStart, QColor centerBgColorEnd);

signals:
	void valueChanged(double value);
};

#endif // ROUNDPLOT_H
