Diffstat (limited to 'noncore/net/wellenreiter/gui/graphwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/graphwindow.cpp | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/noncore/net/wellenreiter/gui/graphwindow.cpp b/noncore/net/wellenreiter/gui/graphwindow.cpp index 7e1f378..b116b91 100644 --- a/noncore/net/wellenreiter/gui/graphwindow.cpp +++ b/noncore/net/wellenreiter/gui/graphwindow.cpp | |||
@@ -31,3 +31,3 @@ MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const cha | |||
31 | 31 | ||
32 | // we draw everything alone | 32 | // we draw everything on our own |
33 | setBackgroundMode( QWidget::NoBackground ); | 33 | setBackgroundMode( QWidget::NoBackground ); |
@@ -36,2 +36,16 @@ MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const cha | |||
36 | 36 | ||
37 | void MFrequencySpectrum::drawTopLine( QPainter* p, int x, int y, int width, const QColor& c ) | ||
38 | { | ||
39 | p->setPen( c.light() ); | ||
40 | p->drawLine( x, y, x+width-1, y ); | ||
41 | } | ||
42 | |||
43 | |||
44 | void MFrequencySpectrum::drawBottomLine( QPainter* p, int x, int y, int width, const QColor& c ) | ||
45 | { | ||
46 | p->setPen( c.dark() ); | ||
47 | p->drawLine( x, y, x+width-1, y ); | ||
48 | } | ||
49 | |||
50 | |||
37 | void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c ) | 51 | void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c ) |
@@ -63,8 +77,9 @@ void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int heig | |||
63 | int v = (v2-v1)*i/maxheight + v1; | 77 | int v = (v2-v1)*i/maxheight + v1; |
64 | drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); | 78 | if ( i == 0 ) |
79 | drawBottomLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); | ||
80 | else if ( i == height-1 ) | ||
81 | drawTopLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); | ||
82 | else | ||
83 | drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); | ||
65 | } | 84 | } |
66 | |||
67 | /*for ( int i = height; i < maxheight; ++i ) | ||
68 | drawLine( p, x, y-i, width, QColor( 47, 68, 76 ) );*/ | ||
69 | |||
70 | } | 85 | } |
@@ -100,2 +115,18 @@ void MFrequencySpectrum::paintEvent( QPaintEvent* e ) | |||
100 | 115 | ||
116 | void MFrequencySpectrum::mousePressEvent( QMouseEvent* e ) | ||
117 | { | ||
118 | int xmargin = 5; | ||
119 | int ymargin = 2; | ||
120 | int y = size().height() - 2 * ymargin; | ||
121 | int x = 0; | ||
122 | int width = ( size().width() - 2 * xmargin ) / _channels; | ||
123 | |||
124 | QPoint pos = e->pos(); | ||
125 | int channel = ( pos.x()-xmargin ) / width; | ||
126 | int height = 100 - ( pos.y()-ymargin )*100/y; | ||
127 | if ( channel < 15 ) _values[channel] = height; | ||
128 | |||
129 | } | ||
130 | |||
131 | |||
101 | Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f ) | 132 | Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f ) |
@@ -127,6 +158,3 @@ MGraphWindow::MGraphWindow( QWidget* parent, const char* name, WFlags f ) | |||
127 | legende = new Legende( 14, this ); | 158 | legende = new Legende( 14, this ); |
128 | startTimer( 50 ); //FIXME: tweak | 159 | startTimer( 50 ); |
129 | |||
130 | //testGraph(); | ||
131 | |||
132 | }; | 160 | }; |
@@ -148,3 +176,3 @@ void MGraphWindow::timerEvent( QTimerEvent* e ) | |||
148 | { | 176 | { |
149 | spectrum->decrease( i, 1 ); //TODO: make this customizable? | 177 | spectrum->decrease( i, 1 ); |
150 | } | 178 | } |