comparison layer/VerticalBinLayer.h @ 1148:c0d841cb8ab9 tony-2.0-integration

Merge latest SV 3.0 branch code
author Chris Cannam
date Fri, 19 Aug 2016 15:58:57 +0100
parents 261a00010918
children 4eafe5a1b655
comparison
equal deleted inserted replaced
1009:96cf499fad62 1148:c0d841cb8ab9
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-2016 Chris Cannam and QMUL.
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 VERTICAL_BIN_LAYER_H
17 #define VERTICAL_BIN_LAYER_H
18
19 #include "SliceableLayer.h"
20
21 /**
22 * Interface for layers in which the Y axis corresponds to bin number
23 * rather than scale value. Colour3DPlotLayer is the obvious example.
24 * Conceptually these are always SliceableLayers as well, and this
25 * subclasses from SliceableLayer to avoid a big inheritance mess.
26 */
27 class VerticalBinLayer : public SliceableLayer
28 {
29 public:
30 /**
31 * Return the y coordinate at which the given bin "starts"
32 * (i.e. at the bottom of the bin, if the given bin is an integer
33 * and the vertical scale is the usual way up). Bin number may be
34 * fractional, to obtain a position part-way through a bin.
35 */
36 virtual double getYForBin(const LayerGeometryProvider *, double bin) const = 0;
37
38 /**
39 * As getYForBin, but rounding to integer values.
40 */
41 virtual int getIYForBin(const LayerGeometryProvider *v, int bin) const {
42 return int(round(getYForBin(v, bin)));
43 }
44
45 /**
46 * Return the bin number, possibly fractional, at the given y
47 * coordinate. Note that the whole numbers occur at the positions
48 * at which the bins "start" (i.e. the bottom of the visible bin,
49 * if the vertical scale is the usual way up).
50 */
51 virtual double getBinForY(const LayerGeometryProvider *, double y) const = 0;
52
53 /**
54 * As getBinForY, but rounding to integer values.
55 */
56 virtual int getIBinForY(const LayerGeometryProvider *v, int y) const {
57 return int(floor(getBinForY(v, y)));
58 }
59 };
60
61 #endif
62