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.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/graphwindow.cpp b/noncore/net/wellenreiter/gui/graphwindow.cpp
index b4174d3..d53421c 100644
--- a/noncore/net/wellenreiter/gui/graphwindow.cpp
+++ b/noncore/net/wellenreiter/gui/graphwindow.cpp
@@ -16,12 +16,39 @@
16#include "graphwindow.h" 16#include "graphwindow.h"
17 17
18#include <qpainter.h> 18#include <qpainter.h>
19#include <qpixmap.h> 19#include <qpixmap.h>
20#include <qtimer.h> 20#include <qtimer.h>
21 21
22/* XPM */
23static char * background[] = {
24"16 16 6 1",
25 " c None",
26 ".c #52676E",
27 "+c #3F545B",
28 "@c #394E56",
29 "#c #2F454C",
30 "$c #364B52",
31".+++++++++++++++",
32"@###############",
33"+$$$$$$$$$$$$$$$",
34"@###############",
35"+$$$$$$$$$$$$$$$",
36"@###############",
37"+$$$$$$$$$$$$$$$",
38"@###############",
39"+$$$$$$$$$$$$$$$",
40"@###############",
41"+$$$$$$$$$$$$$$$",
42"@###############",
43"+$$$$$$$$$$$$$$$",
44"@###############",
45"+$$$$$$$$$$$$$$$",
46"@###############"};
47
48
22MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const char* name, WFlags f) 49MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const char* name, WFlags f)
23 :QWidget( parent, name,f ), _channels( channels ) 50 :QWidget( parent, name,f ), _channels( channels )
24{ 51{
25 _values = new int[_channels]; 52 _values = new int[_channels];
26 _dirty = new bool[_channels]; 53 _dirty = new bool[_channels];
27 for ( int i = 0; i < channels; ++i ) 54 for ( int i = 0; i < channels; ++i )
@@ -82,13 +109,13 @@ void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int heig
82 else 109 else
83 drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); 110 drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) );
84 } 111 }
85} 112}
86 113
87 114
88void MFrequencySpectrum::paintEvent( QPaintEvent* e ) 115void MFrequencySpectrum::paintEvent( QPaintEvent* )
89{ 116{
90 QPixmap pm( size() ); 117 QPixmap pm( size() );
91 QPainter p; 118 QPainter p;
92 p.begin( &pm ); 119 p.begin( &pm );
93 p.drawTiledPixmap( 0, 0, size().width(), size().height(), QPixmap( (const char**) &background ) ); 120 p.drawTiledPixmap( 0, 0, size().width(), size().height(), QPixmap( (const char**) &background ) );
94 121
@@ -115,13 +142,12 @@ void MFrequencySpectrum::paintEvent( QPaintEvent* e )
115 142
116void MFrequencySpectrum::mousePressEvent( QMouseEvent* e ) 143void MFrequencySpectrum::mousePressEvent( QMouseEvent* e )
117{ 144{
118 int xmargin = 5; 145 int xmargin = 5;
119 int ymargin = 2; 146 int ymargin = 2;
120 int y = size().height() - 2 * ymargin; 147 int y = size().height() - 2 * ymargin;
121 int x = 0;
122 int width = ( size().width() - 2 * xmargin ) / _channels; 148 int width = ( size().width() - 2 * xmargin ) / _channels;
123 149
124 QPoint pos = e->pos(); 150 QPoint pos = e->pos();
125 int channel = ( pos.x()-xmargin ) / width; 151 int channel = ( pos.x()-xmargin ) / width;
126 int height = 100 - ( pos.y()-ymargin )*100/y; 152 int height = 100 - ( pos.y()-ymargin )*100/y;
127 if ( channel < 15 ) _values[channel] = height; 153 if ( channel < 15 ) _values[channel] = height;
@@ -139,14 +165,12 @@ Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f )
139} 165}
140 166
141 167
142void Legende::drawContents( QPainter* p ) 168void Legende::drawContents( QPainter* p )
143{ 169{
144 int xmargin = 5; 170 int xmargin = 5;
145 int ymargin = 2;
146 int x = 0;
147 int width = ( contentsRect().width() - 2 * xmargin ) / _channels; 171 int width = ( contentsRect().width() - 2 * xmargin ) / _channels;
148 172
149 for ( int i = 0; i < _channels; ++i ) 173 for ( int i = 0; i < _channels; ++i )
150 p->drawText( xmargin + (width*i), 12, QString().sprintf( "%02d", i+1 ) ); 174 p->drawText( xmargin + (width*i), 12, QString().sprintf( "%02d", i+1 ) );
151} 175}
152 176
@@ -167,13 +191,13 @@ void MGraphWindow::testGraph()
167 if ( i == 14 ) i = 0; 191 if ( i == 14 ) i = 0;
168 QTimer::singleShot( 2000, this, SLOT( testGraph() ) ); 192 QTimer::singleShot( 2000, this, SLOT( testGraph() ) );
169 193
170} 194}
171 195
172 196
173void MGraphWindow::timerEvent( QTimerEvent* e ) 197void MGraphWindow::timerEvent( QTimerEvent* )
174{ 198{
175 for ( int i = 0; i < 14; i++ ) 199 for ( int i = 0; i < 14; i++ )
176 { 200 {
177 spectrum->decrease( i, 1 ); 201 spectrum->decrease( i, 1 );
178 } 202 }
179 spectrum->repaint(); 203 spectrum->repaint();