UtiLite
0.3.1
A lite utilities library
|
00001 /* 00002 * utilite is a cross-platform library with 00003 * useful utilities for fast and small developing. 00004 * Copyright (C) 2010 Mathieu Labbe 00005 * 00006 * utilite is free library: you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * utilite is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef AUDIOWIDGET_H_ 00021 #define AUDIOWIDGET_H_ 00022 00023 #include "utilite/UtiLiteQtExp.h" // DLL export/import defines 00024 00025 #include <QtGui/QWidget> 00026 00027 class QGraphicsView; 00028 class QGraphicsPixmapItem; 00029 class UOrientableLabel; 00030 class QAction; 00031 class QMenu; 00032 class QImage; 00033 class QLabel; 00034 class QGridLayout; 00035 00070 class UTILITEQT_EXP USpectrogram : public QWidget 00071 { 00072 Q_OBJECT; 00073 00074 public: 00078 USpectrogram(QWidget * parent = 0); 00082 USpectrogram(int fs, QWidget * parent = 0); 00083 virtual ~USpectrogram(); 00084 void setScaled(bool freqScaled, bool timeScaled); 00085 void setZoomed(bool zoomed); 00086 void setAxesSwitched(bool axesSwitched); 00087 void setOnlyLastFramesDrawn(bool onlyLastFramesDrawn); 00088 void setAllDataKept(bool allDataKept); 00089 void setHorizontalScrollBarValue(int value); 00090 void setVerticalScrollBarValue(int value); 00091 void setDBRelative(bool dBRelative); 00092 void setDBGain(float value); 00093 void setDBMin(float value); 00094 int samplingRate() const {return _fs;} 00095 bool isScaledTime() const; 00096 bool isScaledFreq() const; 00097 bool isAxesSwitched() const; 00098 bool isZoomed() const; 00099 bool isOnlyLastFramesDrawn() const; 00100 bool isAllDataKept() const; 00101 bool isDBRelative() const; 00105 void setData(const QList<QVector<float> > & data); 00106 USpectrogram * clone() const; 00107 00108 public slots: 00112 void clear(); 00117 void push(const std::vector<float> & frame); 00122 void push(const QVector<float> & frame); 00126 void setSamplingRate(int fs); 00127 00128 protected: 00129 virtual void resizeEvent(QResizeEvent * event); 00130 virtual void showEvent(QShowEvent * event); 00131 virtual void mouseMoveEvent(QMouseEvent * event); 00132 virtual void contextMenuEvent(QContextMenuEvent * event); 00133 00134 private: 00135 void setupUi(); 00136 void updateView(); 00137 void push(const float frame[], int frameLength); 00138 00139 private: 00140 QGraphicsView * _view; 00141 QList<QVector<QRgb> > _rgbData; 00142 QList<QVector<QRgb> > _rgbLogData; 00143 QList<QVector<float> > _data; 00144 QList<QVector<float> > _dataLog; 00145 int _fs; 00146 QGraphicsPixmapItem * _imageItem; 00147 UOrientableLabel * _xLabel; 00148 UOrientableLabel * _yLabel; 00149 bool _axesSwitched; 00150 QGridLayout * _gridLayout; 00151 int _nbSubOctave; 00152 int _minLogSample; 00153 float _dBGain; 00154 float _dBMin; 00155 00156 QMenu * _menu; 00157 QAction * _aClear; 00158 QAction * _aOnlyLastFramesDrawn; 00159 QAction * _aAllDataKept; 00160 QAction * _aScaledFreq; 00161 QAction * _aScaledTime; 00162 QAction * _aZoom2x; 00163 QAction * _aSwitchAxes; 00164 QAction * _aOpenNewWindow; 00165 QAction * _aLogFrequency; 00166 QAction * _aSaveTo; 00167 QAction * _aCopyFrame; 00168 QAction * _aPlotFrame; 00169 QAction * _aDBRelative; 00170 QAction * _aDBMin; 00171 QAction * _aDBGain; 00172 }; 00173 00174 #endif /* AUDIOWIDGET_H_ */