Chris@916
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@916
|
2
|
Chris@916
|
3 /*
|
Chris@916
|
4 Sonic Visualiser
|
Chris@916
|
5 An audio file viewer and annotation editor.
|
Chris@916
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@916
|
7
|
Chris@916
|
8 This program is free software; you can redistribute it and/or
|
Chris@916
|
9 modify it under the terms of the GNU General Public License as
|
Chris@916
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@916
|
11 License, or (at your option) any later version. See the file
|
Chris@916
|
12 COPYING included with this distribution for more information.
|
Chris@916
|
13 */
|
Chris@916
|
14
|
Chris@916
|
15 #ifndef LAYER_GEOMETRY_PROVIDER_H
|
Chris@916
|
16 #define LAYER_GEOMETRY_PROVIDER_H
|
Chris@916
|
17
|
Chris@916
|
18 #include "base/BaseTypes.h"
|
Chris@916
|
19
|
Chris@916
|
20 class ViewManager;
|
Chris@916
|
21 class Layer;
|
Chris@916
|
22
|
Chris@916
|
23 class LayerGeometryProvider
|
Chris@916
|
24 {
|
Chris@916
|
25 public:
|
Chris@916
|
26 /**
|
Chris@916
|
27 * Retrieve the first visible sample frame on the widget.
|
Chris@916
|
28 * This is a calculated value based on the centre-frame, widget
|
Chris@916
|
29 * width and zoom level. The result may be negative.
|
Chris@916
|
30 */
|
Chris@916
|
31 virtual sv_frame_t getStartFrame() const = 0;
|
Chris@916
|
32
|
Chris@916
|
33 /**
|
Chris@916
|
34 * Return the centre frame of the visible widget. This is an
|
Chris@916
|
35 * exact value that does not depend on the zoom block size. Other
|
Chris@916
|
36 * frame values (start, end) are calculated from this based on the
|
Chris@916
|
37 * zoom and other factors.
|
Chris@916
|
38 */
|
Chris@916
|
39 virtual sv_frame_t getCentreFrame() const = 0;
|
Chris@916
|
40
|
Chris@916
|
41 /**
|
Chris@916
|
42 * Retrieve the last visible sample frame on the widget.
|
Chris@916
|
43 * This is a calculated value based on the centre-frame, widget
|
Chris@916
|
44 * width and zoom level.
|
Chris@916
|
45 */
|
Chris@916
|
46 virtual sv_frame_t getEndFrame() const = 0;
|
Chris@916
|
47
|
Chris@916
|
48 /**
|
Chris@916
|
49 * Return the pixel x-coordinate corresponding to a given sample
|
Chris@916
|
50 * frame (which may be negative).
|
Chris@916
|
51 */
|
Chris@916
|
52 virtual int getXForFrame(sv_frame_t frame) const = 0;
|
Chris@916
|
53
|
Chris@916
|
54 /**
|
Chris@916
|
55 * Return the closest frame to the given pixel x-coordinate.
|
Chris@916
|
56 */
|
Chris@916
|
57 virtual sv_frame_t getFrameForX(int x) const = 0;
|
Chris@916
|
58
|
Chris@916
|
59 /**
|
Chris@916
|
60 * Return the pixel y-coordinate corresponding to a given
|
Chris@916
|
61 * frequency, if the frequency range is as specified. This does
|
Chris@916
|
62 * not imply any policy about layer frequency ranges, but it might
|
Chris@916
|
63 * be useful for layers to match theirs up if desired.
|
Chris@916
|
64 *
|
Chris@916
|
65 * Not thread-safe in logarithmic mode. Call only from GUI thread.
|
Chris@916
|
66 */
|
Chris@916
|
67 virtual double getYForFrequency(double frequency, double minFreq, double maxFreq,
|
Chris@916
|
68 bool logarithmic) const = 0;
|
Chris@916
|
69
|
Chris@916
|
70 /**
|
Chris@916
|
71 * Return the closest frequency to the given pixel y-coordinate,
|
Chris@916
|
72 * if the frequency range is as specified.
|
Chris@916
|
73 *
|
Chris@916
|
74 * Not thread-safe in logarithmic mode. Call only from GUI thread.
|
Chris@916
|
75 */
|
Chris@916
|
76 virtual double getFrequencyForY(int y, double minFreq, double maxFreq,
|
Chris@916
|
77 bool logarithmic) const = 0;
|
Chris@916
|
78
|
Chris@916
|
79 /**
|
Chris@916
|
80 * Return the zoom level, i.e. the number of frames per pixel
|
Chris@916
|
81 */
|
Chris@916
|
82 virtual int getZoomLevel() const = 0;
|
Chris@916
|
83
|
Chris@916
|
84 /**
|
Chris@916
|
85 * To be called from a layer, to obtain the extent of the surface
|
Chris@916
|
86 * that the layer is currently painting to. This may be the extent
|
Chris@916
|
87 * of the view (if 1x display scaling is in effect) or of a larger
|
Chris@916
|
88 * cached pixmap (if greater display scaling is in effect).
|
Chris@916
|
89 */
|
Chris@916
|
90 virtual QRect getPaintRect() const = 0;
|
Chris@916
|
91
|
Chris@916
|
92 virtual QSize getPaintSize() const { return getPaintRect().size(); }
|
Chris@916
|
93 virtual int getPaintWidth() const { return getPaintRect().width(); }
|
Chris@916
|
94 virtual int getPaintHeight() const { return getPaintRect().height(); }
|
Chris@916
|
95
|
Chris@916
|
96 virtual bool hasLightBackground() const = 0;
|
Chris@916
|
97 virtual QColor getForeground() const = 0;
|
Chris@916
|
98 virtual QColor getBackground() const = 0;
|
Chris@916
|
99
|
Chris@916
|
100 virtual ViewManager *getViewManager() const = 0;
|
Chris@916
|
101
|
Chris@916
|
102 virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const = 0;
|
Chris@916
|
103
|
Chris@916
|
104 enum TextStyle {
|
Chris@916
|
105 BoxedText,
|
Chris@916
|
106 OutlinedText,
|
Chris@916
|
107 OutlinedItalicText
|
Chris@916
|
108 };
|
Chris@916
|
109
|
Chris@916
|
110 virtual void drawVisibleText(QPainter &p, int x, int y,
|
Chris@916
|
111 QString text, TextStyle style) const = 0;
|
Chris@916
|
112
|
Chris@916
|
113 virtual void drawMeasurementRect(QPainter &p, const Layer *,
|
Chris@916
|
114 QRect rect, bool focus) const = 0;
|
Chris@916
|
115
|
Chris@916
|
116 virtual QWidget *getWidget() const = 0;
|
Chris@916
|
117 };
|
Chris@916
|
118
|
Chris@916
|
119 #endif
|