Chris@1511
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1511
|
2
|
Chris@1511
|
3 /*
|
Chris@1511
|
4 Sonic Visualiser
|
Chris@1511
|
5 An audio file viewer and annotation editor.
|
Chris@1511
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1511
|
7
|
Chris@1511
|
8 This program is free software; you can redistribute it and/or
|
Chris@1511
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1511
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1511
|
11 License, or (at your option) any later version. See the file
|
Chris@1511
|
12 COPYING included with this distribution for more information.
|
Chris@1511
|
13 */
|
Chris@1511
|
14
|
Chris@1518
|
15 #ifndef SV_BOX_LAYER_H
|
Chris@1518
|
16 #define SV_BOX_LAYER_H
|
Chris@1511
|
17
|
Chris@1511
|
18 #include "SingleColourLayer.h"
|
Chris@1511
|
19 #include "VerticalScaleLayer.h"
|
Chris@1511
|
20
|
Chris@1518
|
21 #include "data/model/BoxModel.h"
|
Chris@1511
|
22
|
Chris@1511
|
23 #include <QObject>
|
Chris@1511
|
24 #include <QColor>
|
Chris@1511
|
25
|
Chris@1511
|
26 #include <map>
|
Chris@1511
|
27
|
Chris@1511
|
28 class View;
|
Chris@1511
|
29 class QPainter;
|
Chris@1511
|
30
|
Chris@1518
|
31 class BoxLayer : public SingleColourLayer,
|
Chris@1511
|
32 public VerticalScaleLayer
|
Chris@1511
|
33 {
|
Chris@1511
|
34 Q_OBJECT
|
Chris@1511
|
35
|
Chris@1511
|
36 public:
|
Chris@1518
|
37 BoxLayer();
|
Chris@1511
|
38
|
Chris@1511
|
39 void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override;
|
Chris@1511
|
40
|
Chris@1511
|
41 int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const override;
|
Chris@1511
|
42 void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const override;
|
Chris@1511
|
43
|
Chris@1511
|
44 QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override;
|
Chris@1511
|
45 QString getLabelPreceding(sv_frame_t) const override;
|
Chris@1511
|
46
|
Chris@1511
|
47 bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame,
|
Chris@1511
|
48 int &resolution,
|
Chris@1511
|
49 SnapType snap) const override;
|
Chris@1511
|
50
|
Chris@1511
|
51 void drawStart(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
52 void drawDrag(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
53 void drawEnd(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
54
|
Chris@1511
|
55 void eraseStart(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
56 void eraseDrag(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
57 void eraseEnd(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
58
|
Chris@1511
|
59 void editStart(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
60 void editDrag(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
61 void editEnd(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
62
|
Chris@1511
|
63 bool editOpen(LayerGeometryProvider *v, QMouseEvent *) override;
|
Chris@1511
|
64
|
Chris@1511
|
65 void moveSelection(Selection s, sv_frame_t newStartFrame) override;
|
Chris@1511
|
66 void resizeSelection(Selection s, Selection newSize) override;
|
Chris@1511
|
67 void deleteSelection(Selection s) override;
|
Chris@1511
|
68
|
Chris@1511
|
69 void copy(LayerGeometryProvider *v, Selection s, Clipboard &to) override;
|
Chris@1511
|
70 bool paste(LayerGeometryProvider *v, const Clipboard &from,
|
Chris@1511
|
71 sv_frame_t frameOffset, bool interactive) override;
|
Chris@1511
|
72
|
Chris@1511
|
73 ModelId getModel() const override { return m_model; }
|
Chris@1518
|
74 void setModel(ModelId model); // a BoxModel
|
Chris@1511
|
75
|
Chris@1511
|
76 PropertyList getProperties() const override;
|
Chris@1511
|
77 QString getPropertyLabel(const PropertyName &) const override;
|
Chris@1511
|
78 PropertyType getPropertyType(const PropertyName &) const override;
|
Chris@1511
|
79 QString getPropertyGroupName(const PropertyName &) const override;
|
Chris@1511
|
80 int getPropertyRangeAndValue(const PropertyName &,
|
Chris@1511
|
81 int *min, int *max, int *deflt) const override;
|
Chris@1511
|
82 QString getPropertyValueLabel(const PropertyName &,
|
Chris@1511
|
83 int value) const override;
|
Chris@1511
|
84 void setProperty(const PropertyName &, int value) override;
|
Chris@1511
|
85
|
Chris@1511
|
86 enum VerticalScale {
|
Chris@1511
|
87 AutoAlignScale,
|
Chris@1511
|
88 LinearScale,
|
Chris@1511
|
89 LogScale,
|
Chris@1511
|
90 };
|
Chris@1511
|
91
|
Chris@1511
|
92 void setVerticalScale(VerticalScale scale);
|
Chris@1511
|
93 VerticalScale getVerticalScale() const { return m_verticalScale; }
|
Chris@1511
|
94
|
Chris@1511
|
95 bool isLayerScrollable(const LayerGeometryProvider *v) const override;
|
Chris@1511
|
96
|
Chris@1511
|
97 bool isLayerEditable() const override { return true; }
|
Chris@1511
|
98
|
Chris@1511
|
99 int getCompletion(LayerGeometryProvider *) const override;
|
Chris@1511
|
100
|
Chris@1511
|
101 bool getValueExtents(double &min, double &max,
|
Chris@1511
|
102 bool &log, QString &unit) const override;
|
Chris@1511
|
103
|
Chris@1511
|
104 bool getDisplayExtents(double &min, double &max) const override;
|
Chris@1511
|
105
|
Chris@1518
|
106 bool adoptExtents(double min, double max, QString unit) override;
|
Chris@1518
|
107
|
Chris@1511
|
108 void toXml(QTextStream &stream, QString indent = "",
|
Chris@1511
|
109 QString extraAttributes = "") const override;
|
Chris@1511
|
110
|
Chris@1511
|
111 void setProperties(const QXmlAttributes &attributes) override;
|
Chris@1511
|
112
|
Chris@1511
|
113 /// VerticalScaleLayer methods
|
Chris@1511
|
114 int getYForValue(LayerGeometryProvider *v, double value) const override;
|
Chris@1511
|
115 double getValueForY(LayerGeometryProvider *v, int y) const override;
|
Chris@1511
|
116 QString getScaleUnits() const override;
|
Chris@1511
|
117
|
Chris@1511
|
118 protected:
|
Chris@1511
|
119 void getScaleExtents(LayerGeometryProvider *, double &min, double &max, bool &log) const;
|
Chris@1511
|
120
|
Chris@1511
|
121 EventVector getLocalPoints(LayerGeometryProvider *v, int x) const;
|
Chris@1511
|
122
|
Chris@1511
|
123 bool getPointToDrag(LayerGeometryProvider *v, int x, int y, Event &) const;
|
Chris@1511
|
124
|
Chris@1511
|
125 ModelId m_model;
|
Chris@1511
|
126 bool m_editing;
|
Chris@1511
|
127 int m_dragPointX;
|
Chris@1511
|
128 int m_dragPointY;
|
Chris@1511
|
129 int m_dragStartX;
|
Chris@1511
|
130 int m_dragStartY;
|
Chris@1511
|
131 Event m_originalPoint;
|
Chris@1511
|
132 Event m_editingPoint;
|
Chris@1511
|
133 ChangeEventsCommand *m_editingCommand;
|
Chris@1511
|
134 VerticalScale m_verticalScale;
|
Chris@1511
|
135
|
Chris@1511
|
136 void finish(ChangeEventsCommand *command) {
|
Chris@1511
|
137 Command *c = command->finish();
|
Chris@1511
|
138 if (c) CommandHistory::getInstance()->addCommand(c, false);
|
Chris@1511
|
139 }
|
Chris@1511
|
140 };
|
Chris@1511
|
141
|
Chris@1511
|
142 #endif
|
Chris@1511
|
143
|