00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GRAPHWINDOW_H
00017 #define GRAPHWINDOW_H
00018
00019 #include <qwidget.h>
00020 #include <qvbox.h>
00021
00022 class MFrequencySpectrum : public QWidget
00023 {
00024 public:
00025 MFrequencySpectrum( int channels, QWidget* parent = 0, const char* name = "MFrequencySpectrum", WFlags f = 0 );
00026 int value( int channel ) const { return _values[channel]; };
00027 void setValue( int channel, int value )
00028 {
00029 if ( value > _values[channel] )
00030 {
00031 _values[channel] = value;
00032 _dirty[channel] = true;
00033 }
00034 };
00035 void decrease( int channel, int amount )
00036 {
00037 if ( _values[channel] >= amount )
00038 {
00039 _values[channel] -= amount;
00040 _dirty[channel] = true;
00041 }
00042 };
00043
00044 protected:
00045 virtual void paintEvent( QPaintEvent* );
00046 virtual void mousePressEvent( QMouseEvent* );
00047
00048 void drawLine( QPainter* p, int x, int y, int width, const QColor& c );
00049 void drawTopLine( QPainter* p, int x, int y, int width, const QColor& c );
00050 void drawBottomLine( QPainter* p, int x, int y, int width, const QColor& c );
00051 void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight );
00052
00053 private:
00054 int _channels;
00055 int* _values;
00056 bool* _dirty;
00057 };
00058
00059
00060 class Legende : public QFrame
00061 {
00062 public:
00063 Legende( int channels, QWidget* parent = 0, const char* name = "Legende", WFlags f = 0 );
00064
00065 protected:
00066 virtual void drawContents( QPainter* );
00067
00068 private:
00069 int _channels;
00070 };
00071
00072
00073 class MGraphWindow : public QVBox
00074 {
00075 Q_OBJECT
00076
00077 public:
00078 MGraphWindow( QWidget* parent = 0, const char* name = "MGraphWindow", WFlags f = 0 );
00079 void traffic( int channel, int signal );
00080
00081 protected:
00082 virtual void timerEvent( QTimerEvent* e );
00083
00084 protected slots:
00085 virtual void testGraph();
00086
00087 protected:
00088 MFrequencySpectrum* spectrum;
00089 Legende* legende;
00090
00091 };
00092
00093
00094 #endif
00095