Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / QtCollider / widgets / QcScope.h
blobe5e3c7e99221a5e481754cc1d0b1001cd18d3e29
1 /************************************************************************
3 * Copyright 2010 Jakob Leben (jakob.leben@gmail.com)
5 * This file is part of SuperCollider Qt GUI.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ************************************************************************/
22 #ifndef QC_SCOPE_H
23 #define QC_SCOPE_H
25 #include "../QcHelper.h"
27 #include <SC_Types.h>
28 #include <SC_SndBuf.h>
30 #include <QWidget>
32 class QcScope : public QWidget, QcHelper
34 Q_OBJECT
35 Q_PROPERTY( int bufferNumber READ dummyInt WRITE setBufferNumber );
36 Q_PROPERTY( float xOffset READ dummyFloat WRITE setXOffset );
37 Q_PROPERTY( float yOffset READ dummyFloat WRITE setYOffset );
38 Q_PROPERTY( float xZoom READ dummyFloat WRITE setXZoom );
39 Q_PROPERTY( float yZoom READ dummyFloat WRITE setYZoom );
40 Q_PROPERTY( int style READ dummyInt WRITE setStyle );
41 Q_PROPERTY( VariantList waveColors READ dummyVariantList WRITE setWaveColors );
42 Q_PROPERTY( QColor background READ background WRITE setBackground );
43 Q_PROPERTY( int updateInterval READ updateInterval WRITE setUpdateInterval );
45 public:
46 QcScope();
47 ~QcScope();
48 void setBufferNumber( int );
49 void setXOffset( float f ) { xOffset = f; }
50 void setYOffset( float f ) { yOffset = f; }
51 void setXZoom( float f ) { xZoom = f; }
52 void setYZoom( float f ) { yZoom = f; }
53 void setStyle( int i ) { style = i; }
54 void setWaveColors( const VariantList & colors );
55 QColor background() const { return _bkg; }
56 void setBackground( const QColor &c ) { _bkg = c; update(); }
57 int updateInterval() const;
58 void setUpdateInterval( int i );
59 QSize sizeHint() const { return QSize( 500, 300 ); }
60 QSize minimumSizeHint() const { return QSize( 50, 50 ); }
61 private Q_SLOTS:
62 void updateScope();
63 private:
64 void paintEvent ( QPaintEvent * event );
65 void setPoint( QPointF& pt,
66 float frame, float data, float xRatio, float yRatio,
67 int xStart, int yStart );
68 void paint1D( bool overlapped, QPainter & );
69 void paint2D( QPainter & );
71 int bufNum;
72 SndBuf buffer;
73 QTimer *timer;
74 float xOffset;
75 float yOffset;
76 float xZoom;
77 float yZoom;
78 int style;
79 QList<QColor> colors;
80 QColor _bkg;
83 #endif