Chris@916: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@916: Chris@916: /* Chris@916: Sonic Visualiser Chris@916: An audio file viewer and annotation editor. Chris@916: Centre for Digital Music, Queen Mary, University of London. Chris@916: Chris@916: This program is free software; you can redistribute it and/or Chris@916: modify it under the terms of the GNU General Public License as Chris@916: published by the Free Software Foundation; either version 2 of the Chris@916: License, or (at your option) any later version. See the file Chris@916: COPYING included with this distribution for more information. Chris@916: */ Chris@916: Chris@916: #ifndef LAYER_GEOMETRY_PROVIDER_H Chris@916: #define LAYER_GEOMETRY_PROVIDER_H Chris@916: Chris@916: #include "base/BaseTypes.h" Chris@916: Chris@916: class ViewManager; Chris@918: class View; Chris@916: class Layer; Chris@916: Chris@916: class LayerGeometryProvider Chris@916: { Chris@916: public: Chris@916: /** Chris@916: * Retrieve the first visible sample frame on the widget. Chris@916: * This is a calculated value based on the centre-frame, widget Chris@916: * width and zoom level. The result may be negative. Chris@916: */ Chris@916: virtual sv_frame_t getStartFrame() const = 0; Chris@916: Chris@916: /** Chris@916: * Return the centre frame of the visible widget. This is an Chris@916: * exact value that does not depend on the zoom block size. Other Chris@916: * frame values (start, end) are calculated from this based on the Chris@916: * zoom and other factors. Chris@916: */ Chris@916: virtual sv_frame_t getCentreFrame() const = 0; Chris@916: Chris@916: /** Chris@916: * Retrieve the last visible sample frame on the widget. Chris@916: * This is a calculated value based on the centre-frame, widget Chris@916: * width and zoom level. Chris@916: */ Chris@916: virtual sv_frame_t getEndFrame() const = 0; Chris@916: Chris@916: /** Chris@916: * Return the pixel x-coordinate corresponding to a given sample Chris@916: * frame (which may be negative). Chris@916: */ Chris@916: virtual int getXForFrame(sv_frame_t frame) const = 0; Chris@916: Chris@916: /** Chris@916: * Return the closest frame to the given pixel x-coordinate. Chris@916: */ Chris@916: virtual sv_frame_t getFrameForX(int x) const = 0; Chris@916: Chris@919: virtual sv_frame_t getModelsStartFrame() const = 0; Chris@919: virtual sv_frame_t getModelsEndFrame() const = 0; Chris@919: Chris@916: /** Chris@916: * Return the pixel y-coordinate corresponding to a given Chris@916: * frequency, if the frequency range is as specified. This does Chris@916: * not imply any policy about layer frequency ranges, but it might Chris@916: * be useful for layers to match theirs up if desired. Chris@916: * Chris@916: * Not thread-safe in logarithmic mode. Call only from GUI thread. Chris@916: */ Chris@916: virtual double getYForFrequency(double frequency, double minFreq, double maxFreq, Chris@916: bool logarithmic) const = 0; Chris@916: Chris@916: /** Chris@916: * Return the closest frequency to the given pixel y-coordinate, Chris@916: * if the frequency range is as specified. Chris@916: * Chris@916: * Not thread-safe in logarithmic mode. Call only from GUI thread. Chris@916: */ Chris@916: virtual double getFrequencyForY(int y, double minFreq, double maxFreq, Chris@916: bool logarithmic) const = 0; Chris@916: Chris@918: virtual int getTextLabelHeight(const Layer *layer, QPainter &) const = 0; Chris@918: Chris@918: virtual bool getValueExtents(QString unit, double &min, double &max, Chris@918: bool &log) const = 0; Chris@918: Chris@916: /** Chris@916: * Return the zoom level, i.e. the number of frames per pixel Chris@916: */ Chris@916: virtual int getZoomLevel() const = 0; Chris@916: Chris@916: /** Chris@916: * To be called from a layer, to obtain the extent of the surface Chris@916: * that the layer is currently painting to. This may be the extent Chris@916: * of the view (if 1x display scaling is in effect) or of a larger Chris@916: * cached pixmap (if greater display scaling is in effect). Chris@916: */ Chris@916: virtual QRect getPaintRect() const = 0; Chris@916: Chris@916: virtual QSize getPaintSize() const { return getPaintRect().size(); } Chris@916: virtual int getPaintWidth() const { return getPaintRect().width(); } Chris@916: virtual int getPaintHeight() const { return getPaintRect().height(); } Chris@916: Chris@916: virtual bool hasLightBackground() const = 0; Chris@916: virtual QColor getForeground() const = 0; Chris@916: virtual QColor getBackground() const = 0; Chris@916: Chris@916: virtual ViewManager *getViewManager() const = 0; Chris@916: Chris@916: virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const = 0; Chris@919: virtual bool shouldShowFeatureLabels() const = 0; Chris@916: Chris@916: enum TextStyle { Chris@916: BoxedText, Chris@916: OutlinedText, Chris@916: OutlinedItalicText Chris@916: }; Chris@916: Chris@916: virtual void drawVisibleText(QPainter &p, int x, int y, Chris@916: QString text, TextStyle style) const = 0; Chris@916: Chris@916: virtual void drawMeasurementRect(QPainter &p, const Layer *, Chris@916: QRect rect, bool focus) const = 0; Chris@916: Chris@918: virtual View *getView() = 0; Chris@918: virtual const View *getView() const = 0; Chris@916: }; Chris@916: Chris@916: #endif