comparison view/LayerGeometryProvider.h @ 978:64c2b3a4435a 3.0-integration

Merge from branch osx-retina
author Chris Cannam
date Fri, 26 Jun 2015 14:10:40 +0100
parents a5488775f880
children 0be17aafa935
comparison
equal deleted inserted replaced
977:f40ccbf228c2 978:64c2b3a4435a
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 LAYER_GEOMETRY_PROVIDER_H
16 #define LAYER_GEOMETRY_PROVIDER_H
17
18 #include "base/BaseTypes.h"
19
20 class ViewManager;
21 class View;
22 class Layer;
23
24 class LayerGeometryProvider
25 {
26 public:
27 /**
28 * Retrieve the first visible sample frame on the widget.
29 * This is a calculated value based on the centre-frame, widget
30 * width and zoom level. The result may be negative.
31 */
32 virtual sv_frame_t getStartFrame() const = 0;
33
34 /**
35 * Return the centre frame of the visible widget. This is an
36 * exact value that does not depend on the zoom block size. Other
37 * frame values (start, end) are calculated from this based on the
38 * zoom and other factors.
39 */
40 virtual sv_frame_t getCentreFrame() const = 0;
41
42 /**
43 * Retrieve the last visible sample frame on the widget.
44 * This is a calculated value based on the centre-frame, widget
45 * width and zoom level.
46 */
47 virtual sv_frame_t getEndFrame() const = 0;
48
49 /**
50 * Return the pixel x-coordinate corresponding to a given sample
51 * frame (which may be negative).
52 */
53 virtual int getXForFrame(sv_frame_t frame) const = 0;
54
55 /**
56 * Return the closest frame to the given pixel x-coordinate.
57 */
58 virtual sv_frame_t getFrameForX(int x) const = 0;
59
60 virtual sv_frame_t getModelsStartFrame() const = 0;
61 virtual sv_frame_t getModelsEndFrame() const = 0;
62
63 /**
64 * Return the pixel y-coordinate corresponding to a given
65 * frequency, if the frequency range is as specified. This does
66 * not imply any policy about layer frequency ranges, but it might
67 * be useful for layers to match theirs up if desired.
68 *
69 * Not thread-safe in logarithmic mode. Call only from GUI thread.
70 */
71 virtual double getYForFrequency(double frequency, double minFreq, double maxFreq,
72 bool logarithmic) const = 0;
73
74 /**
75 * Return the closest frequency to the given pixel y-coordinate,
76 * if the frequency range is as specified.
77 *
78 * Not thread-safe in logarithmic mode. Call only from GUI thread.
79 */
80 virtual double getFrequencyForY(int y, double minFreq, double maxFreq,
81 bool logarithmic) const = 0;
82
83 virtual int getTextLabelHeight(const Layer *layer, QPainter &) const = 0;
84
85 virtual bool getValueExtents(QString unit, double &min, double &max,
86 bool &log) const = 0;
87
88 /**
89 * Return the zoom level, i.e. the number of frames per pixel
90 */
91 virtual int getZoomLevel() const = 0;
92
93 /**
94 * To be called from a layer, to obtain the extent of the surface
95 * that the layer is currently painting to. This may be the extent
96 * of the view (if 1x display scaling is in effect) or of a larger
97 * cached pixmap (if greater display scaling is in effect).
98 */
99 virtual QRect getPaintRect() const = 0;
100
101 virtual QSize getPaintSize() const { return getPaintRect().size(); }
102 virtual int getPaintWidth() const { return getPaintRect().width(); }
103 virtual int getPaintHeight() const { return getPaintRect().height(); }
104
105 virtual bool hasLightBackground() const = 0;
106 virtual QColor getForeground() const = 0;
107 virtual QColor getBackground() const = 0;
108
109 virtual ViewManager *getViewManager() const = 0;
110
111 virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const = 0;
112 virtual bool shouldShowFeatureLabels() const = 0;
113
114 enum TextStyle {
115 BoxedText,
116 OutlinedText,
117 OutlinedItalicText
118 };
119
120 virtual void drawVisibleText(QPainter &p, int x, int y,
121 QString text, TextStyle style) const = 0;
122
123 virtual void drawMeasurementRect(QPainter &p, const Layer *,
124 QRect rect, bool focus) const = 0;
125
126 virtual View *getView() = 0;
127 virtual const View *getView() const = 0;
128 };
129
130 #endif