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