Mercurial > hg > easaier-soundaccess
comparison base/ZoomConstraint.h @ 0:fc9323a41f5a
start base : Sonic Visualiser sv1-1.0rc1
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 09:08:14 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fc9323a41f5a |
---|---|
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 Chris Cannam. | |
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 _ZOOM_CONSTRAINT_H_ | |
17 #define _ZOOM_CONSTRAINT_H_ | |
18 | |
19 #include <stdlib.h> | |
20 | |
21 /** | |
22 * ZoomConstraint is a simple interface that describes a limitation on | |
23 * the available zoom sizes for a view, for example based on cache | |
24 * strategy or a (processing) window-size limitation. | |
25 * | |
26 * The default ZoomConstraint imposes no actual constraint except for | |
27 * a nominal maximum. | |
28 */ | |
29 | |
30 class ZoomConstraint | |
31 { | |
32 public: | |
33 virtual ~ZoomConstraint() { } | |
34 | |
35 enum RoundingDirection { | |
36 RoundDown, | |
37 RoundUp, | |
38 RoundNearest | |
39 }; | |
40 | |
41 /** | |
42 * Given the "ideal" block size (frames per pixel) for a given | |
43 * zoom level, return the nearest viable block size for this | |
44 * constraint. | |
45 * | |
46 * For example, if a block size of 1523 frames per pixel is | |
47 * requested but the underlying model only supports value | |
48 * summaries at powers-of-two block sizes, return 1024 or 2048 | |
49 * depending on the rounding direction supplied. | |
50 */ | |
51 virtual size_t getNearestBlockSize(size_t requestedBlockSize, | |
52 RoundingDirection = RoundNearest) | |
53 const | |
54 { | |
55 if (requestedBlockSize > getMaxZoomLevel()) return getMaxZoomLevel(); | |
56 else return requestedBlockSize; | |
57 } | |
58 | |
59 /** | |
60 * Return the maximum zoom level within range for this constraint. | |
61 */ | |
62 virtual size_t getMaxZoomLevel() const { return 262144; } | |
63 }; | |
64 | |
65 #endif | |
66 |