annotate base/ZoomConstraint.h @ 497:b6dc6c7f402c

Various fixes: * Fix handling of HTTP redirects (avoiding crashes... I hope) * Fix failure to delete FFT models when a feature extraction model transformer was abandoned (also a cause of crashes in the past) * Fix deadlock when said transform was abandoned before its source model was ready because the session was being cleared (and so the source model would never be ready)
author Chris Cannam
date Fri, 28 Nov 2008 13:36:13 +0000
parents abaf3d7195ce
children 6a94bb528e9d
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _ZOOM_CONSTRAINT_H_
Chris@0 17 #define _ZOOM_CONSTRAINT_H_
Chris@0 18
Chris@0 19 #include <stdlib.h>
Chris@0 20
Chris@0 21 /**
Chris@0 22 * ZoomConstraint is a simple interface that describes a limitation on
Chris@0 23 * the available zoom sizes for a view, for example based on cache
Chris@0 24 * strategy or a (processing) window-size limitation.
Chris@0 25 *
Chris@12 26 * The default ZoomConstraint imposes no actual constraint except for
Chris@12 27 * a nominal maximum.
Chris@0 28 */
Chris@0 29
Chris@0 30 class ZoomConstraint
Chris@0 31 {
Chris@0 32 public:
Chris@27 33 virtual ~ZoomConstraint() { }
Chris@27 34
Chris@0 35 enum RoundingDirection {
Chris@0 36 RoundDown,
Chris@0 37 RoundUp,
Chris@0 38 RoundNearest
Chris@0 39 };
Chris@0 40
Chris@0 41 /**
Chris@0 42 * Given the "ideal" block size (frames per pixel) for a given
Chris@0 43 * zoom level, return the nearest viable block size for this
Chris@0 44 * constraint.
Chris@0 45 *
Chris@0 46 * For example, if a block size of 1523 frames per pixel is
Chris@0 47 * requested but the underlying model only supports value
Chris@0 48 * summaries at powers-of-two block sizes, return 1024 or 2048
Chris@0 49 * depending on the rounding direction supplied.
Chris@0 50 */
Chris@0 51 virtual size_t getNearestBlockSize(size_t requestedBlockSize,
Chris@0 52 RoundingDirection = RoundNearest)
Chris@0 53 const
Chris@0 54 {
Chris@12 55 if (requestedBlockSize > getMaxZoomLevel()) return getMaxZoomLevel();
Chris@12 56 else return requestedBlockSize;
Chris@0 57 }
Chris@12 58
Chris@160 59 /**
Chris@160 60 * Return the maximum zoom level within range for this constraint.
Chris@160 61 */
Chris@12 62 virtual size_t getMaxZoomLevel() const { return 262144; }
Chris@0 63 };
Chris@0 64
Chris@0 65 #endif
Chris@0 66