summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/graphwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/graphwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/graphwindow.cpp50
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
@@ -29,11 +29,25 @@ MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const cha
29 _dirty[i] = true; 29 _dirty[i] = true;
30 } 30 }
31 31
32 // we draw everything alone 32 // we draw everything on our own
33 setBackgroundMode( QWidget::NoBackground ); 33 setBackgroundMode( QWidget::NoBackground );
34} 34}
35 35
36 36
37void 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
44void 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
37void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c ) 51void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c )
38{ 52{
39 p->setPen( c.light() ); 53 p->setPen( c.light() );
@@ -61,12 +75,13 @@ void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int heig
61 int h = (h2-h1)*i/maxheight + h1; 75 int h = (h2-h1)*i/maxheight + h1;
62 int s = (s2-s1)*i/maxheight + s1; 76 int s = (s2-s1)*i/maxheight + s1;
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}
71 86
72 87
@@ -98,6 +113,22 @@ void MFrequencySpectrum::paintEvent( QPaintEvent* e )
98} 113}
99 114
100 115
116void 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
101Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f ) 132Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f )
102 :QFrame( parent, name, f ), _channels( channels ) 133 :QFrame( parent, name, f ), _channels( channels )
103{ 134{
@@ -125,10 +156,7 @@ MGraphWindow::MGraphWindow( QWidget* parent, const char* name, WFlags f )
125{ 156{
126 spectrum = new MFrequencySpectrum( 14, this ); 157 spectrum = new MFrequencySpectrum( 14, this );
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};
133 161
134 162
@@ -146,7 +174,7 @@ void MGraphWindow::timerEvent( QTimerEvent* e )
146{ 174{
147 for ( int i = 0; i < 14; i++ ) 175 for ( int i = 0; i < 14; i++ )
148 { 176 {
149 spectrum->decrease( i, 1 ); //TODO: make this customizable? 177 spectrum->decrease( i, 1 );
150 } 178 }
151 spectrum->repaint(); 179 spectrum->repaint();
152} 180}