src/qvgui/qvcpuplot.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
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

Generated on Wed Jan 16 18:41:29 2008 for QVision by  doxygen 1.5.3