Mercurial > hg > easaier-soundaccess
comparison layer/TimeValueLayer.h @ 0:fc9323a41f5a
start base : Sonic Visualiser sv1-1.0rc1
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 09:08:14 +0000 |
parents | |
children | d8e6709e9075 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fc9323a41f5a |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _TIME_VALUE_LAYER_H_ | |
17 #define _TIME_VALUE_LAYER_H_ | |
18 | |
19 #include "Layer.h" | |
20 #include "data/model/SparseTimeValueModel.h" | |
21 | |
22 #include <QObject> | |
23 #include <QColor> | |
24 | |
25 class View; | |
26 class QPainter; | |
27 | |
28 class TimeValueLayer : public Layer | |
29 { | |
30 Q_OBJECT | |
31 | |
32 public: | |
33 TimeValueLayer(); | |
34 | |
35 virtual void paint(View *v, QPainter &paint, QRect rect) const; | |
36 | |
37 virtual int getVerticalScaleWidth(View *v, QPainter &) const; | |
38 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const; | |
39 | |
40 virtual QString getFeatureDescription(View *v, QPoint &) const; | |
41 | |
42 virtual bool snapToFeatureFrame(View *v, int &frame, | |
43 size_t &resolution, | |
44 SnapType snap) const; | |
45 | |
46 virtual void drawStart(View *v, QMouseEvent *); | |
47 virtual void drawDrag(View *v, QMouseEvent *); | |
48 virtual void drawEnd(View *v, QMouseEvent *); | |
49 | |
50 virtual void editStart(View *v, QMouseEvent *); | |
51 virtual void editDrag(View *v, QMouseEvent *); | |
52 virtual void editEnd(View *v, QMouseEvent *); | |
53 | |
54 virtual void editOpen(View *v, QMouseEvent *); | |
55 | |
56 virtual void moveSelection(Selection s, size_t newStartFrame); | |
57 virtual void resizeSelection(Selection s, Selection newSize); | |
58 virtual void deleteSelection(Selection s); | |
59 | |
60 virtual void copy(Selection s, Clipboard &to); | |
61 virtual bool paste(const Clipboard &from, int frameOffset, | |
62 bool interactive); | |
63 | |
64 virtual const Model *getModel() const { return m_model; } | |
65 void setModel(SparseTimeValueModel *model); | |
66 | |
67 virtual PropertyList getProperties() const; | |
68 virtual QString getPropertyLabel(const PropertyName &) const; | |
69 virtual PropertyType getPropertyType(const PropertyName &) const; | |
70 virtual QString getPropertyGroupName(const PropertyName &) const; | |
71 virtual int getPropertyRangeAndValue(const PropertyName &, | |
72 int *min, int *max, int *deflt) const; | |
73 virtual QString getPropertyValueLabel(const PropertyName &, | |
74 int value) const; | |
75 virtual void setProperty(const PropertyName &, int value); | |
76 | |
77 void setBaseColour(QColor); | |
78 QColor getBaseColour() const { return m_colour; } | |
79 | |
80 void setFillColourMap(int); | |
81 int getFillColourMap() const { return m_colourMap; } | |
82 | |
83 enum PlotStyle { | |
84 PlotPoints, | |
85 PlotStems, | |
86 PlotConnectedPoints, | |
87 PlotLines, | |
88 PlotCurve, | |
89 PlotSegmentation | |
90 }; | |
91 | |
92 void setPlotStyle(PlotStyle style); | |
93 PlotStyle getPlotStyle() const { return m_plotStyle; } | |
94 | |
95 enum VerticalScale { | |
96 AutoAlignScale, | |
97 LinearScale, | |
98 LogScale, | |
99 PlusMinusOneScale | |
100 }; | |
101 | |
102 void setVerticalScale(VerticalScale scale); | |
103 VerticalScale getVerticalScale() const { return m_verticalScale; } | |
104 | |
105 virtual bool isLayerScrollable(const View *v) const; | |
106 | |
107 virtual bool isLayerEditable() const { return true; } | |
108 | |
109 virtual int getCompletion(View *) const { return m_model->getCompletion(); } | |
110 | |
111 virtual bool needsTextLabelHeight() const { | |
112 return m_plotStyle == PlotSegmentation && m_model->hasTextLabels(); | |
113 } | |
114 | |
115 virtual bool getValueExtents(float &min, float &max, | |
116 bool &logarithmic, QString &unit) const; | |
117 | |
118 virtual bool getDisplayExtents(float &min, float &max) const; | |
119 | |
120 virtual QString toXmlString(QString indent = "", | |
121 QString extraAttributes = "") const; | |
122 | |
123 void setProperties(const QXmlAttributes &attributes); | |
124 | |
125 protected: | |
126 void getScaleExtents(View *, float &min, float &max, bool &log) const; | |
127 int getYForValue(View *, float value) const; | |
128 float getValueForY(View *, int y) const; | |
129 QColor getColourForValue(View *v, float value) const; | |
130 | |
131 SparseTimeValueModel::PointList getLocalPoints(View *v, int) const; | |
132 | |
133 SparseTimeValueModel *m_model; | |
134 bool m_editing; | |
135 SparseTimeValueModel::Point m_originalPoint; | |
136 SparseTimeValueModel::Point m_editingPoint; | |
137 SparseTimeValueModel::EditCommand *m_editingCommand; | |
138 QColor m_colour; | |
139 int m_colourMap; | |
140 PlotStyle m_plotStyle; | |
141 VerticalScale m_verticalScale; | |
142 }; | |
143 | |
144 #endif | |
145 |