comparison layer/VerticalBinLayer.h @ 1082:5b4fe7bb9430 spectrogram-minor-refactor

VerticalBinLayer for vertical mapping abstraction. Not totally sure about this
author Chris Cannam
date Fri, 01 Jul 2016 09:55:48 +0100
parents
children 7122aae95a88
comparison
equal deleted inserted replaced
1081:cbc7c8675706 1082:5b4fe7bb9430
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 /**
20 * Interface for layers in which the Y axis corresponds to bin number
21 * rather than scale value. Colour3DPlotLayer is the obvious example.
22 */
23 class VerticalBinLayer
24 {
25 public:
26 /**
27 * Return the y coordinate at which the given bin "starts"
28 * (i.e. at the bottom of the bin, if the given bin is an integer
29 * and the vertical scale is the usual way up). Bin number may be
30 * fractional, to obtain a position part-way through a bin.
31 */
32 virtual double getYForBin(LayerGeometryProvider *, double bin) const = 0;
33
34 /**
35 * As getYForBin, but rounding to integer values.
36 */
37 virtual int getIYForBin(LayerGeometryProvider *, int bin) const = 0;
38
39 /**
40 * Return the bin number, possibly fractional, at the given y
41 * coordinate. Note that the whole numbers occur at the positions
42 * at which the bins "start" (i.e. the bottom of the visible bin,
43 * if the vertical scale is the usual way up).
44 */
45 virtual double getBinForY(LayerGeometryProvider *, double y) const = 0;
46
47 /**
48 * As getBinForY, but rounding to integer values.
49 */
50 virtual int getIBinForY(LayerGeometryProvider *, int y) const = 0;
51 };
52
53 #endif
54