00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef CPUPLOT_H
00026 #define CPUPLOT_H
00027
00028 #include <QApplication>
00029 #include <QTimer>
00030 #include <QTableView>
00031
00032 #include <qpainter.h>
00033 #include <qwt_plot.h>
00034 #include <qwt_plot_curve.h>
00035 #include <qvutils/cpustat.h>
00036
00037 #define MAX_HISTORY 60 // seconds
00038
00040 class QVCpuPlot : public QwtPlot
00041 {
00042 Q_OBJECT
00043 public:
00044 QVCpuPlot(CpuStat *, bool decorations = true, QWidget * = 0);
00045
00046 public slots:
00047 void update();
00048
00049 private:
00050 bool decorations;
00051 QwtPlotCurve **curve;
00052 double **data;
00053 double timeData[MAX_HISTORY];
00054 int dataCount, nFlags;
00055 CpuStat *cpuStat;
00056 QTimer timer;
00057
00058 void initPlot();
00059 void timerEvent(QTimerEvent *e);
00060 const double curveValue(int curve) const
00061 {
00062 if (curve == 0)
00063 return data[curve][0];
00064 else
00065 return data[curve][0] - data[curve-1][0];
00066 }
00067
00068 friend class CpuPieMarker;
00069 class CpuPieMarker: public QwtPlotItem
00070 {
00071 public:
00072 CpuPieMarker(unsigned int nFlags, QwtPlotCurve **curves);
00073 virtual int rtti() const;
00074 virtual void draw(QPainter *p, const QwtScaleMap &, const QwtScaleMap &, const QRect &rect) const;
00075
00076 private:
00077 unsigned int nCpuFlags;
00078 QwtPlotCurve **cpuCurve;
00079 };
00080 };
00081
00082 class QVCpuTableView: public QTableView
00083 {
00084 Q_OBJECT
00085 public:
00086 QVCpuTableView(CpuStat *cpuStat): QTableView()
00087 {
00088 this->cpuStat = cpuStat;
00089 }
00090
00091 void update()
00092 {
00093 if (!cpuStat->isActive())
00094 return;
00095
00096 QStringList timeFlags = cpuStat->getFlagNames();
00097
00098 }
00099
00100 private:
00101 CpuStat *cpuStat;
00102 };
00103
00105 #endif