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