annotate layer/PaintAssistant.h @ 1394:4a36f6130056 spectrogramparam

Various tweaks & fixes to log-scale handling in spectrum. We can't easily preserve the nice behaviour where peaks stay in place as fft size changes, without potentially losing a bit of low-frequency information
author Chris Cannam
date Wed, 14 Nov 2018 14:17:06 +0000
parents cca66ce390e0
children 28075cc658c9
rev   line source
Chris@195 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@195 2
Chris@195 3 /*
Chris@195 4 Sonic Visualiser
Chris@195 5 An audio file viewer and annotation editor.
Chris@195 6 Centre for Digital Music, Queen Mary, University of London.
Chris@195 7 This file copyright 2006-2007 Chris Cannam and QMUL.
Chris@195 8
Chris@195 9 This program is free software; you can redistribute it and/or
Chris@195 10 modify it under the terms of the GNU General Public License as
Chris@195 11 published by the Free Software Foundation; either version 2 of the
Chris@195 12 License, or (at your option) any later version. See the file
Chris@195 13 COPYING included with this distribution for more information.
Chris@195 14 */
Chris@195 15
Chris@1228 16 #ifndef SV_PAINT_ASSISTANT_H
Chris@1228 17 #define SV_PAINT_ASSISTANT_H
Chris@195 18
Chris@195 19 #include <QRect>
Chris@1228 20 #include <QPen>
Chris@195 21 #include <vector>
Chris@195 22
Chris@195 23 class QPainter;
Chris@1078 24 class Layer;
Chris@1078 25 class LayerGeometryProvider;
Chris@195 26
Chris@195 27 class PaintAssistant
Chris@195 28 {
Chris@195 29 public:
Chris@195 30 enum Scale { LinearScale, MeterScale, dBScale };
Chris@195 31
Chris@195 32 static void paintVerticalLevelScale(QPainter &p, QRect rect,
Chris@905 33 double minVal, double maxVal,
Chris@220 34 Scale scale, int &multRtn,
Chris@195 35 std::vector<int> *markCoordRtns = 0);
Chris@195 36
Chris@905 37 static int getYForValue(Scale scale, double value,
Chris@905 38 double minVal, double maxVal,
Chris@195 39 int minY, int height);
Chris@1078 40
Chris@1078 41 enum TextStyle {
Chris@1266 42 BoxedText,
Chris@1266 43 OutlinedText,
Chris@1078 44 OutlinedItalicText
Chris@1078 45 };
Chris@1078 46
Chris@1078 47 static void drawVisibleText(const LayerGeometryProvider *,
Chris@1078 48 QPainter &p, int x, int y,
Chris@1078 49 QString text, TextStyle style);
Chris@1228 50
Chris@1228 51 /**
Chris@1373 52 * Scale up a size in pixels for a hi-dpi display without pixel
Chris@1373 53 * doubling. This is like ViewManager::scalePixelSize, but taking
Chris@1373 54 * and returning floating-point values rather than integer
Chris@1373 55 * pixels. It is also a little more conservative - it never
Chris@1373 56 * shrinks the size, it can only increase or leave it unchanged.
Chris@1373 57 */
Chris@1373 58 static double scaleSize(double size);
Chris@1373 59
Chris@1373 60 /**
Chris@1228 61 * Scale up pen width for a hi-dpi display without pixel doubling.
Chris@1373 62 * This is like scaleSize except that it also scales the
Chris@1373 63 * zero-width case.
Chris@1228 64 */
Chris@1228 65 static double scalePenWidth(double width);
Chris@1228 66
Chris@1228 67 /**
Chris@1228 68 * Apply scalePenWidth to a pen.
Chris@1228 69 */
Chris@1228 70 static QPen scalePen(QPen pen);
Chris@195 71 };
Chris@195 72
Chris@195 73 #endif