1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2020 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #ifndef GRAPHICSWAVEPAINTER_H 26 #define GRAPHICSWAVEPAINTER_H 27 28 #include <QWidget> 29 30 class GraphicsWavePainter 31 { 32 public: 33 GraphicsWavePainter(QWidget * widget); 34 ~GraphicsWavePainter(); 35 36 // Configure the painter with data 37 void setData(QByteArray baData); 38 39 // Draw data 40 void paint(quint32 start, quint32 end, float zoomY); 41 42 // Get data around a central point 43 QPointF * getDataAround(quint32 position, quint32 desiredLength, quint32 &pointNumber); 44 45 private: 46 void prepareImage(); 47 float getValueX(float pos1, float value1, float pos2, float value2, float posX); 48 static QRgb mergeRgb(QRgb color1, QRgb color2, float x); 49 50 // Target widget 51 QWidget * _widget; 52 53 // Input data 54 quint32 _sampleSize; 55 qint16 * _sampleData; 56 57 // Buffered image and associated parameters 58 QRgb * _pixels; 59 QImage * _image; 60 QPointF * _samplePlotMean; 61 quint32 _start, _end; 62 float _zoomY; 63 64 // Colors 65 QRgb _backgroundColor, _waveColor, _gridColor, _greenColor, _redColor; 66 }; 67 68 #endif // GRAPHICSWAVEPAINTER_H 69