Import upstream version 0.99.2
[fmit.git] / src / modules / GLErrorHistory.h
1 // Copyright 2004 "Gilles Degottex"
2
3 // This file is part of "fmit"
4
5 // "fmit" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // "fmit" is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
20
21 #ifndef _GLErrorHistory_h_
22 #define _GLErrorHistory_h_
23
24 #include <deque>
25 using namespace std;
26 #include <qgl.h>
27 #include <qspinbox.h>
28 #include <qsettings.h>
29 #include <qaction.h>
30 class QTimer;
31 #include <Music/Music.h>
32 #include "View.h"
33
34 class GLErrorHistory : public QGLWidget, public View
35 {
36         Q_OBJECT
37
38         virtual void mouseReleaseEvent(QMouseEvent* e){View::mouseReleaseEvent(e);}
39
40         void drawTicksCent(int r, int ticks_size);
41         void drawTextTickCent(int r, int dy);
42
43   public:
44         GLErrorHistory(QWidget* parent);
45
46         struct Note
47         {
48                 int ht;
49                 QString factor;
50                 float min_err;
51                 float max_err;
52                 float avg_err;
53                 deque<float> errors;
54                 void init();
55                 Note(int h);
56                 Note(int h, int num, int den);
57                 Note(int h, float cents);
58                 void addError(float err);
59                 QString getName() const;
60         };
61         deque<Note> m_notes;
62         void addNote(GLErrorHistory::Note note);
63         void addError(float err);
64
65         // settings
66         QAction* setting_keep;
67         QAction* setting_useCents;
68         QSpinBox* setting_spinScale;
69         virtual void save();
70         virtual void load();
71         virtual void clearSettings();
72
73   public slots:
74         void initializeGL();
75         void paintGL();
76         void resizeGL( int w, int h );
77         void keepPreviousNotes(bool keep);
78 };
79
80 #endif // _GLErrorHistory_h_
81