1 // Maintainer: Max Howell <max.howell@methylblue.com>, (C) 2004
2 // Copyright: See COPYING file that comes with this distribution
8 #include "config-amarok.h" //HAVE_QGLWIDGET
11 #include <sys/types.h>
14 #include "fht.h" //stack allocated and convenience
15 #include <QPixmap> //stack allocated and convenience
16 #include <QTimer> //stack allocated
17 #include <qwidget.h> //baseclass
19 #include <QResizeEvent>
21 #include <QPaintEvent>
22 #include <vector> //included for convenience
25 #include <qgl.h> //baseclass
27 #include <OpenGL/gl.h> //included for convenience
28 #include <OpenGL/glu.h> //included for convenience
30 #include <GL/gl.h> //included for convenience
31 #include <GL/glu.h> //included for convenience
34 //this is a workaround for compile problems due to moc
35 #define QGLWidget QWidget
38 #include <qimage.h> //for bitBlt
47 typedef std::vector
<float> Scope
;
49 template<class W
> class Base
: public W
52 uint
timeout() const { return m_timeout
; }
55 Base( QWidget
*, uint
, uint
= 7 );
56 ~Base() { delete m_fht
; }
59 int resizeExponent( int );
60 int resizeForBands( int );
61 virtual void transform( Scope
& );
62 virtual void analyze( const Scope
& ) = 0;
63 virtual void paused();
66 void changeTimeout( uint newTimeout
)
68 m_timer
.start( newTimeout
);
69 m_timeout
= newTimeout
;
73 bool event( QEvent
* );
82 class Base2D
: public Base
<QWidget
>
86 const QPixmap
*background() const { return &m_background
; }
89 void draw() { drawFrame(); }
92 void set50fps() { changeTimeout( 50 ); }
93 void set33fps() { changeTimeout( 33 ); }
94 void set25fps() { changeTimeout( 25 ); }
95 void set20fps() { changeTimeout( 20 ); }
96 void set10fps() { changeTimeout( 10 ); }
99 Base2D( QWidget
*, uint timeout
, uint scopeSize
= 7 );
101 virtual void init() {}
103 QPixmap
*background() { return &m_background
; }
105 void resizeEvent( QResizeEvent
* );
110 QPixmap m_background
;
115 //This mess is because moc generates an entry for this class despite the #if block
116 //1. the Q_OBJECT macro must be exposed
117 //2. we have to define the class
118 //3. we have to declare a ctor (to satisfy the inheritance)
119 //4. the slot must also by visible (!)
120 //TODO find out how to stop moc generating a metaobject for this class
121 class Base3D
: public Base
<QGLWidget
>
124 #ifdef HAVE_QGLWIDGET
126 Base3D( QWidget
*, uint
, uint
= 7 );
128 void draw() { drawFrame(); }
131 Base3D( QWidget
*w
, uint i1
, uint i2
) : Base
<QGLWidget
>( w
, i1
, i2
) {}
140 //Currently this is a rather small class, its only purpose
141 //to ensure that making changes to analyzers will not require
142 //rebuilding the world!
144 //eventually it would be better to make analyzers pluggable
145 //but I can't be arsed, nor can I see much reason to do so
148 static QWidget
* createAnalyzer( QWidget
* );
149 static QWidget
* createPlaylistAnalyzer( QWidget
*);
153 void interpolate( const Scope
&, Scope
& );
154 void initSin( Scope
&, const uint
= 6000 );
156 } //END namespace Analyzer
158 using Analyzer::Scope
;