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 GRAPHPARAMGLOBAL_H 26 #define GRAPHPARAMGLOBAL_H 27 28 #include "qcustomplot.h" 29 30 class GraphParamGlobal : public QCustomPlot 31 { 32 Q_OBJECT 33 34 public: 35 enum TypeForme 36 { 37 FORME_MANUELLE, 38 FORME_LINEAIRE_ASC, 39 FORME_LINEAIRE_DESC, 40 FORME_EXP_ASC, 41 FORME_EXP_DESC, 42 FORME_ALEATOIRE 43 }; 44 45 explicit GraphParamGlobal(QWidget *parent = nullptr); 46 ~GraphParamGlobal(); 47 eventFilter(QObject * o,QEvent * e)48 bool eventFilter(QObject* o, QEvent* e) 49 { 50 if ((e->type() == QEvent::MouseMove || 51 e->type() == QEvent::MouseButtonPress || 52 e->type() == QEvent::MouseButtonRelease || 53 e->type() == QEvent::Leave) 54 && o == this) 55 { 56 QMouseEvent * mouseEvent = static_cast<QMouseEvent *>(e); 57 QPoint pos = mouseEvent->pos(); 58 if (mouseEvent->type() == QEvent::MouseMove) 59 this->mouseMoved(pos); 60 else if (mouseEvent->type() == QEvent::Leave) 61 this->mouseLeft(); 62 else if (mouseEvent->button() == Qt::LeftButton) 63 { 64 if (mouseEvent->type() == QEvent::MouseButtonPress) 65 this->mousePressed(pos); 66 else if (mouseEvent->type() == QEvent::MouseButtonRelease) 67 this->mouseReleased(pos); 68 } 69 else if (mouseEvent->button() == Qt::RightButton) 70 { 71 if (mouseEvent->type() == QEvent::MouseButtonPress) 72 this->mouseRightPressed(pos); 73 else if (mouseEvent->type() == QEvent::MouseButtonRelease) 74 this->mouseRightReleased(pos); 75 } 76 return true; 77 } 78 return false; 79 } 80 81 void indexMotifChanged(int index); 82 void raideurChanged(double value); 83 void setHighlightedRange(int minKey, int maxKey); setMinMax(double min,double max)84 void setMinMax(double min, double max) { yMin = qMin(min, max); yMax = qMax(min, max); } setMinMaxX(int min,int max)85 void setMinMaxX(int min, int max) { xMin = qMin(min, max); xMax = qMax(min, max); } 86 QVector<double> getValues(); 87 void setValues(QVector<double> val); getXmin()88 int getXmin() { return xMin; } getXmax()89 int getXmax() { return xMax; } 90 91 private: 92 TypeForme forme; 93 QVector<double> dValues; 94 bool flagEdit; 95 int limitEdit; 96 void replot(); 97 int nbPoints; 98 double raideurExp; 99 double yMin, yMax; 100 int xMin, xMax; 101 QCPItemText * labelCoord; 102 int previousX; 103 double previousY; 104 105 void mousePressed(QPoint pos); 106 void mouseRightPressed(QPoint pos); 107 void mouseReleased(QPoint pos); 108 void mouseRightReleased(QPoint pos); 109 void mouseMoved(QPoint pos); 110 void mouseLeft(); 111 void writeMotif(); 112 void write(QPoint pos); 113 void afficheCoord(double x, double y); 114 }; 115 116 #endif // GRAPHPARAMGLOBAL_H 117