comparison layer/NoteLayer.h @ 30:ea6fe8cfcdd5

* Add the Note layer for pianoroll-type display of note-type data * Complete the MIDI file importer (well, nearly -- it would be nice to be able to import the non-note data as other sorts of models, and that's not done yet). * Minor refactoring in RealTime etc
author Chris Cannam
date Fri, 10 Feb 2006 17:51:36 +0000
parents
children 78515b1e29eb
comparison
equal deleted inserted replaced
29:9f55af9676b4 30:ea6fe8cfcdd5
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 A waveform viewer and audio annotation editor.
5 Chris Cannam, Queen Mary University of London, 2005-2006
6
7 This is experimental software. Not for distribution.
8 */
9
10 #ifndef _NOTE_LAYER_H_
11 #define _NOTE_LAYER_H_
12
13 #include "base/Layer.h"
14 #include "model/NoteModel.h"
15
16 #include <QObject>
17 #include <QColor>
18
19 class View;
20 class QPainter;
21
22 class NoteLayer : public Layer
23 {
24 Q_OBJECT
25
26 public:
27 NoteLayer(View *w);
28
29 virtual void paint(QPainter &paint, QRect rect) const;
30
31 virtual QString getFeatureDescription(QPoint &) const;
32
33 virtual bool snapToFeatureFrame(int &frame,
34 size_t &resolution,
35 SnapType snap) const;
36
37 virtual void drawStart(QMouseEvent *);
38 virtual void drawDrag(QMouseEvent *);
39 virtual void drawEnd(QMouseEvent *);
40
41 virtual void editStart(QMouseEvent *);
42 virtual void editDrag(QMouseEvent *);
43 virtual void editEnd(QMouseEvent *);
44
45 virtual const Model *getModel() const { return m_model; }
46 void setModel(NoteModel *model);
47
48 virtual PropertyList getProperties() const;
49 virtual PropertyType getPropertyType(const PropertyName &) const;
50 virtual int getPropertyRangeAndValue(const PropertyName &,
51 int *min, int *max) const;
52 virtual QString getPropertyValueLabel(const PropertyName &,
53 int value) const;
54 virtual void setProperty(const PropertyName &, int value);
55
56 void setBaseColour(QColor);
57 QColor getBaseColour() const { return m_colour; }
58
59 enum VerticalScale {
60 MinMaxRangeScale,
61 MIDIRangeScale,
62 FrequencyScale
63 };
64
65 void setVerticalScale(VerticalScale scale);
66 VerticalScale getVerticalScale() const { return m_verticalScale; }
67
68 virtual bool isLayerScrollable() const;
69
70 virtual bool isLayerEditable() const { return true; }
71
72 virtual int getCompletion() const { return m_model->getCompletion(); }
73
74 virtual QString toXmlString(QString indent = "",
75 QString extraAttributes = "") const;
76
77 void setProperties(const QXmlAttributes &attributes);
78
79 protected:
80 int getYForValue(float value) const;
81 float getValueForY(int y) const;
82
83 NoteModel::PointList getLocalPoints(int) const;
84
85 NoteModel *m_model;
86 bool m_editing;
87 NoteModel::Point m_originalPoint;
88 NoteModel::Point m_editingPoint;
89 NoteModel::EditCommand *m_editingCommand;
90 QColor m_colour;
91 VerticalScale m_verticalScale;
92 };
93
94 #endif
95