2 * graph.h - a QT widget for displaying and manipulating waveforms
4 * Copyright (c) 2006-2007 Andreas Brandmaier <andy/at/brandmaier/dot/de>
5 * 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
7 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
30 #include <QtGui/QWidget>
31 #include <QtGui/QPixmap>
32 #include <QtGui/QCursor>
35 #include "ModelView.h"
36 #include "lmms_basics.h"
41 class EXPORT graph
: public QWidget
, public ModelView
52 graph( QWidget
* _parent
, graphStyle _style
= graph::LinearStyle
);
55 void setForeground( const QPixmap
& _pixmap
);
57 void setGraphColor( const QColor
);
59 inline graphModel
* model()
61 return castModel
<graphModel
>();
64 inline graphStyle
getGraphStyle()
69 inline void setGraphStyle( graphStyle _s
)
77 virtual void paintEvent( QPaintEvent
* _pe
);
78 virtual void dropEvent( QDropEvent
* _de
);
79 virtual void dragEnterEvent( QDragEnterEvent
* _dee
);
80 virtual void mousePressEvent( QMouseEvent
* _me
);
81 virtual void mouseMoveEvent( QMouseEvent
* _me
);
82 virtual void mouseReleaseEvent( QMouseEvent
* _me
);
85 void updateGraph( int _startPos
, int _endPos
);
89 virtual void modelChanged();
91 void changeSampleAt(int _x
, int _y
);
97 graphModel
* m_graphModel
;
98 graphStyle m_graphStyle
;
106 class EXPORT graphModel
: public Model
110 graphModel( float _min
,
114 bool _default_constructed
= false,
117 virtual ~graphModel();
119 // TODO: saveSettings, loadSettings?
121 inline float minValue() const
123 return( m_minValue
);
126 inline float maxValue() const
128 return( m_maxValue
);
131 inline int length() const
133 return( m_samples
.count() );
136 inline const float * samples() const
138 return( m_samples
.data() );
142 void setRange( float _min
, float _max
);
144 void setLength( int _size
);
146 void setSampleAt( int _samplePos
, float _value
);
147 void setSamples( const float * _value
);
149 void setWaveToSine();
150 void setWaveToTriangle();
152 void setWaveToSquare();
153 void setWaveToNoise();
154 //void setWaveToUser( );
160 void lengthChanged();
161 void samplesChanged( int startPos
, int endPos
);
166 QVector
<float> m_samples
;