summaryrefslogtreecommitdiffstats
path: root/src/app/analyzer.h
blob: edd526ec2036eda853c62558c18fa9424a4db977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// (c) 2004 Max Howell (max.howell@methylblue.com)
// See COPYING file for licensing information

#ifndef ANALYZER_H
#define ANALYZER_H

#ifdef __FreeBSD__
   #include <sys/types.h>
#endif

#include <ntqpixmap.h> //stack allocated and convenience
#include <ntqtimer.h>  //stack allocated
#include <ntqwidget.h> //baseclass
#include <vector>    //included for convenience

namespace Analyzer
{
   typedef std::vector<float> Scope;

   template<class W> class Base : public W
   {
   public:
      uint timeout() const { return m_timeout; }

   protected:
      Base( TQWidget*, uint );

      virtual void transform( Scope& ) = 0;
      virtual void analyze( const Scope& ) = 0;

   private:
      virtual bool event( TQEvent* );

   protected:
      TQTimer m_timer;
      uint   m_timeout;
   };

   class Base2D : public Base<TQWidget>
   {
   Q_OBJECT
   public:
      const TQPixmap *canvas() const { return &m_canvas; }

   private slots:
      void draw();

   protected:
      Base2D( TQWidget*, uint timeout );

      TQPixmap *canvas() { return &m_canvas; }

      void paintEvent( TQPaintEvent* ) { if( !m_canvas.isNull() ) bitBlt( this, 0, 0, canvas() ); }
      void resizeEvent( TQResizeEvent* );

   private:
      TQPixmap m_canvas;
   };

   class Block : public Analyzer::Base2D
   {
   public:
      Block( TQWidget* );

   protected:
      virtual void transform( Analyzer::Scope& );
      virtual void analyze( const Analyzer::Scope& );

      virtual int heightForWidth( int ) const;

      virtual void show() {} //TODO temporary as the scope plugin causes freezes
   };
}

#endif