Mercurial > hg > svgui
changeset 916:94e4952a6774 osx-retina
Start trying to introduce LayerGeometryProvider as proxyable interface for View methods that the Layer wants to use
author | Chris Cannam |
---|---|
date | Tue, 17 Mar 2015 15:05:25 +0000 |
parents | f6d9f28f37cb |
children | 77a1d42353ce |
files | layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/FlexiNoteLayer.cpp layer/FlexiNoteLayer.h layer/ImageLayer.cpp layer/ImageLayer.h layer/Layer.h layer/LinearNumericalScale.h layer/NoteLayer.cpp layer/NoteLayer.h layer/RegionLayer.cpp layer/RegionLayer.h layer/SliceLayer.cpp layer/SliceLayer.h layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/SpectrumLayer.cpp layer/SpectrumLayer.h layer/TextLayer.cpp layer/TextLayer.h layer/TimeInstantLayer.cpp layer/TimeInstantLayer.h layer/TimeRulerLayer.cpp layer/TimeRulerLayer.h layer/TimeValueLayer.cpp layer/TimeValueLayer.h layer/VerticalScaleLayer.h layer/WaveformLayer.cpp layer/WaveformLayer.h view/LayerGeometryProvider.h view/View.h |
diffstat | 31 files changed, 320 insertions(+), 202 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/Colour3DPlotLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -506,7 +506,7 @@ } void -Colour3DPlotLayer::setLayerDormant(const View *v, bool dormant) +Colour3DPlotLayer::setLayerDormant(const LayerGeometryProvider *v, bool dormant) { if (dormant) { @@ -530,7 +530,7 @@ } bool -Colour3DPlotLayer::isLayerScrollable(const View *v) const +Colour3DPlotLayer::isLayerScrollable(const LayerGeometryProvider *v) const { if (m_normalizeVisibleArea) { return false; @@ -589,7 +589,7 @@ } bool -Colour3DPlotLayer::getYScaleValue(const View *, int, +Colour3DPlotLayer::getYScaleValue(const LayerGeometryProvider *, int, double &, QString &) const { return false;//!!! @@ -645,13 +645,13 @@ } double -Colour3DPlotLayer::getYForBin(View *v, double bin) const +Colour3DPlotLayer::getYForBin(LayerGeometryProvider *v, double bin) const { double y = bin; if (!m_model) return y; double mn = 0, mx = m_model->getHeight(); getDisplayExtents(mn, mx); - double h = v->height(); + double h = v->getPaintHeight(); if (m_binScale == LinearBinScale) { y = h - (((bin - mn) * h) / (mx - mn)); } else { @@ -663,19 +663,19 @@ } int -Colour3DPlotLayer::getIYForBin(View *v, int bin) const +Colour3DPlotLayer::getIYForBin(LayerGeometryProvider *v, int bin) const { return int(round(getYForBin(v, bin))); } double -Colour3DPlotLayer::getBinForY(View *v, double y) const +Colour3DPlotLayer::getBinForY(LayerGeometryProvider *v, double y) const { double bin = y; if (!m_model) return bin; double mn = 0, mx = m_model->getHeight(); getDisplayExtents(mn, mx); - double h = v->height(); + double h = v->getPaintHeight(); if (m_binScale == LinearBinScale) { bin = mn + ((h - y) * (mx - mn)) / h; } else { @@ -687,13 +687,13 @@ } int -Colour3DPlotLayer::getIBinForY(View *v, int y) const +Colour3DPlotLayer::getIBinForY(LayerGeometryProvider *v, int y) const { return int(floor(getBinForY(v, y))); } QString -Colour3DPlotLayer::getFeatureDescription(View *v, QPoint &pos) const +Colour3DPlotLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const { if (!m_model) return ""; @@ -724,8 +724,8 @@ if (symin < 0) symin = 0; if (symax > sh) symax = sh; - // double binHeight = double(v->height()) / (symax - symin); -// int sy = int((v->height() - y) / binHeight) + symin; + // double binHeight = double(v->getPaintHeight()) / (symax - symin); +// int sy = int((v->getPaintHeight() - y) / binHeight) + symin; int sy = getIBinForY(v, y); @@ -762,7 +762,7 @@ } int -Colour3DPlotLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const +Colour3DPlotLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const { if (!m_model) return 0; @@ -784,7 +784,7 @@ } void -Colour3DPlotLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const +Colour3DPlotLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const { if (!m_model) return; @@ -1246,7 +1246,7 @@ } bool -Colour3DPlotLayer::shouldPaintDenseIn(const View *v) const +Colour3DPlotLayer::shouldPaintDenseIn(const LayerGeometryProvider *v) const { if (!m_model || !v || !(v->getViewManager())) { return false; @@ -1255,7 +1255,7 @@ v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate(); if (m_opaque || m_smooth || - m_model->getHeight() >= v->height() || + m_model->getHeight() >= v->getPaintHeight() || ((m_model->getResolution() * srRatio) / v->getZoomLevel()) < 2) { return true; } @@ -1263,7 +1263,7 @@ } void -Colour3DPlotLayer::paint(View *v, QPainter &paint, QRect rect) const +Colour3DPlotLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { /* if (m_model) { @@ -1278,13 +1278,13 @@ int completion = 0; if (!m_model || !m_model->isOK() || !m_model->isReady(&completion)) { if (completion > 0) { - paint.fillRect(0, 10, v->width() * completion / 100, + paint.fillRect(0, 10, v->getPaintWidth() * completion / 100, 10, QColor(120, 120, 120)); } return; } - if (m_normalizeVisibleArea && !m_normalizeColumns) rect = v->rect(); + if (m_normalizeVisibleArea && !m_normalizeColumns) rect = v->getPaintRect(); sv_frame_t modelStart = m_model->getStartFrame(); sv_frame_t modelEnd = m_model->getEndFrame(); @@ -1302,7 +1302,7 @@ int x0 = rect.left(); int x1 = rect.right() + 1; - int h = v->height(); + int h = v->getPaintHeight(); double srRatio = v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate(); @@ -1424,7 +1424,7 @@ } void -Colour3DPlotLayer::paintDense(View *v, QPainter &paint, QRect rect) const +Colour3DPlotLayer::paintDense(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { Profiler profiler("Colour3DPlotLayer::paintDense", true); if (!m_cache) return; @@ -1440,7 +1440,7 @@ int x1 = rect.right() + 1; const int w = x1 - x0; // const so it can be used as array size below - int h = v->height(); // we always paint full height + int h = v->getPaintHeight(); // we always paint full height int sh = m_model->getHeight(); int symin = m_miny; @@ -1655,7 +1655,7 @@ } bool -Colour3DPlotLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, +Colour3DPlotLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const {
--- a/layer/Colour3DPlotLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/Colour3DPlotLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -49,20 +49,20 @@ return m_model ? m_model->getZoomConstraint() : 0; } virtual const Model *getModel() const { return m_model; } - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; - virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; - virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; + virtual int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const; + virtual void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const; - virtual QString getFeatureDescription(View *v, QPoint &) const; + virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, + virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const; - virtual void setLayerDormant(const View *v, bool dormant); + virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant); - virtual bool isLayerScrollable(const View *v) const; + virtual bool isLayerScrollable(const LayerGeometryProvider *v) const; virtual ColourSignificance getLayerColourSignificance() const { return ColourHasMeaningfulValue; @@ -70,7 +70,7 @@ void setModel(const DenseThreeDimensionalModel *model); - virtual int getCompletion(View *) const { return m_model->getCompletion(); } + virtual int getCompletion(LayerGeometryProvider *) const { return m_model->getCompletion(); } virtual PropertyList getProperties() const; virtual PropertyType getPropertyType(const PropertyName &) const; @@ -151,7 +151,7 @@ virtual bool getDisplayExtents(double &min, double &max) const; virtual bool setDisplayExtents(double min, double max); - virtual bool getYScaleValue(const View *, int /* y */, + virtual bool getYScaleValue(const LayerGeometryProvider *, int /* y */, double &/* value */, QString &/* unit */) const; virtual int getVerticalZoomSteps(int &defaultStep) const; @@ -202,12 +202,12 @@ * and the vertical scale is the usual way up). Bin number may be * fractional, to obtain a position part-way through a bin. */ - double getYForBin(View *, double bin) const; + double getYForBin(LayerGeometryProvider *, double bin) const; /** * As getYForBin, but rounding to integer values. */ - int getIYForBin(View *, int bin) const; + int getIYForBin(LayerGeometryProvider *, int bin) const; /** * Return the bin number, possibly fractional, at the given y @@ -215,12 +215,12 @@ * at which the bins "start" (i.e. the bottom of the visible bin, * if the vertical scale is the usual way up). */ - double getBinForY(View *, double y) const; + double getBinForY(LayerGeometryProvider *, double y) const; /** * As getBinForY, but rounding to integer values. */ - int getIBinForY(View *, int y) const; + int getIBinForY(LayerGeometryProvider *, int y) const; DenseThreeDimensionalModel::Column getColumn(int col) const; @@ -229,11 +229,11 @@ * are so small you can't see their borders. False for big, * translucent cells. */ - bool shouldPaintDenseIn(const View *) const; + bool shouldPaintDenseIn(const LayerGeometryProvider *) const; int getColourScaleWidth(QPainter &) const; void fillCache(int firstBin, int lastBin) const; - void paintDense(View *v, QPainter &paint, QRect rect) const; + void paintDense(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; }; #endif
--- a/layer/FlexiNoteLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/FlexiNoteLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -204,7 +204,7 @@ } bool -FlexiNoteLayer::isLayerScrollable(const View *v) const +FlexiNoteLayer::isLayerScrollable(const LayerGeometryProvider *v) const { QPoint discard; return !v->shouldIlluminateLocalFeatures(this, discard); @@ -405,7 +405,7 @@ } FlexiNoteModel::PointList -FlexiNoteLayer::getLocalPoints(View *v, int x) const +FlexiNoteLayer::getLocalPoints(LayerGeometryProvider *v, int x) const { if (!m_model) return FlexiNoteModel::PointList(); @@ -448,7 +448,7 @@ } bool -FlexiNoteLayer::getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &p) const +FlexiNoteLayer::getPointToDrag(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &p) const { if (!m_model) return false; @@ -476,7 +476,7 @@ } bool -FlexiNoteLayer::getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &p) const +FlexiNoteLayer::getNoteToEdit(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &p) const { // GF: find the note that is closest to the cursor if (!m_model) return false; @@ -505,7 +505,7 @@ } QString -FlexiNoteLayer::getFeatureDescription(View *v, QPoint &pos) const +FlexiNoteLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const { int x = pos.x(); @@ -593,7 +593,7 @@ } bool -FlexiNoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, +FlexiNoteLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -673,7 +673,7 @@ } void -FlexiNoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const +FlexiNoteLayer::getScaleExtents(LayerGeometryProvider *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -730,11 +730,11 @@ } int -FlexiNoteLayer::getYForValue(View *v, double val) const +FlexiNoteLayer::getYForValue(LayerGeometryProvider *v, double val) const { double min = 0.0, max = 0.0; bool logarithmic = false; - int h = v->height(); + int h = v->getPaintHeight(); getScaleExtents(v, min, max, logarithmic); @@ -765,11 +765,11 @@ } double -FlexiNoteLayer::getValueForY(View *v, int y) const +FlexiNoteLayer::getValueForY(LayerGeometryProvider *v, int y) const { double min = 0.0, max = 0.0; bool logarithmic = false; - int h = v->height(); + int h = v->getPaintHeight(); getScaleExtents(v, min, max, logarithmic); @@ -794,7 +794,7 @@ } void -FlexiNoteLayer::paint(View *v, QPainter &paint, QRect rect) const +FlexiNoteLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return; @@ -860,8 +860,8 @@ !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { - paint.drawLine(x, -1, x, v->height() + 1); - paint.drawLine(x+w, -1, x+w, v->height() + 1); + paint.drawLine(x, -1, x, v->getPaintHeight() + 1); + paint.drawLine(x+w, -1, x+w, v->getPaintHeight() + 1); paint.setPen(v->getForeground()); // paint.setBrush(v->getForeground()); @@ -904,7 +904,7 @@ } int -FlexiNoteLayer::getVerticalScaleWidth(View *v, bool, QPainter &paint) const +FlexiNoteLayer::getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &paint) const { if (!m_model || shouldAutoAlign()) { return 0; @@ -918,7 +918,7 @@ } void -FlexiNoteLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const +FlexiNoteLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect) const { if (!m_model || m_model->getPoints().empty()) return; @@ -927,7 +927,7 @@ bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); - int h = v->height(); + int h = v->getPaintHeight(); getScaleExtents(v, min, max, logarithmic); @@ -956,7 +956,7 @@ } void -FlexiNoteLayer::drawStart(View *v, QMouseEvent *e) +FlexiNoteLayer::drawStart(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; @@ -980,7 +980,7 @@ } void -FlexiNoteLayer::drawDrag(View *v, QMouseEvent *e) +FlexiNoteLayer::drawDrag(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; @@ -1009,7 +1009,7 @@ } void -FlexiNoteLayer::drawEnd(View *, QMouseEvent *) +FlexiNoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) { // SVDEBUG << "FlexiNoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; if (!m_model || !m_editing) return; @@ -1019,7 +1019,7 @@ } void -FlexiNoteLayer::eraseStart(View *v, QMouseEvent *e) +FlexiNoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) { if (!m_model) return; @@ -1034,12 +1034,12 @@ } void -FlexiNoteLayer::eraseDrag(View *, QMouseEvent *) +FlexiNoteLayer::eraseDrag(LayerGeometryProvider *, QMouseEvent *) { } void -FlexiNoteLayer::eraseEnd(View *v, QMouseEvent *e) +FlexiNoteLayer::eraseEnd(LayerGeometryProvider *v, QMouseEvent *e) { if (!m_model || !m_editing) return; @@ -1059,7 +1059,7 @@ } void -FlexiNoteLayer::editStart(View *v, QMouseEvent *e) +FlexiNoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; std::cerr << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; @@ -1110,7 +1110,7 @@ } void -FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) +FlexiNoteLayer::editDrag(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; std::cerr << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << std::endl; @@ -1177,7 +1177,7 @@ } void -FlexiNoteLayer::editEnd(View *, QMouseEvent *e) +FlexiNoteLayer::editEnd(LayerGeometryProvider *, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; @@ -1207,7 +1207,7 @@ } void -FlexiNoteLayer::splitStart(View *v, QMouseEvent *e) +FlexiNoteLayer::splitStart(LayerGeometryProvider *v, QMouseEvent *e) { // GF: note splitting starts (!! remove printing soon) std::cerr << "splitStart" << std::endl; @@ -1231,7 +1231,7 @@ } void -FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) +FlexiNoteLayer::splitEnd(LayerGeometryProvider *v, QMouseEvent *e) { // GF: note splitting ends. (!! remove printing soon) std::cerr << "splitEnd" << std::endl; @@ -1250,13 +1250,13 @@ } void -FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame) +FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame) { splitNotesAt(v, frame, 0); } void -FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e) +FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame, QMouseEvent *e) { FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return; @@ -1296,7 +1296,7 @@ } void -FlexiNoteLayer::addNote(View *v, QMouseEvent *e) +FlexiNoteLayer::addNote(LayerGeometryProvider *v, QMouseEvent *e) { std::cerr << "addNote" << std::endl; if (!m_model) return; @@ -1335,7 +1335,7 @@ } SparseTimeValueModel * -FlexiNoteLayer::getAssociatedPitchModel(View *v) const +FlexiNoteLayer::getAssociatedPitchModel(LayerGeometryProvider *v) const { // Better than we used to do, but still not very satisfactory @@ -1359,7 +1359,7 @@ } void -FlexiNoteLayer::snapSelectedNotesToPitchTrack(View *v, Selection s) +FlexiNoteLayer::snapSelectedNotesToPitchTrack(LayerGeometryProvider *v, Selection s) { if (!m_model) return; @@ -1397,7 +1397,7 @@ } void -FlexiNoteLayer::mergeNotes(View *v, Selection s, bool inclusive) +FlexiNoteLayer::mergeNotes(LayerGeometryProvider *v, Selection s, bool inclusive) { FlexiNoteModel::PointList points = m_model->getPoints(s.getStartFrame(), s.getEndFrame()); @@ -1440,7 +1440,7 @@ } bool -FlexiNoteLayer::updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const +FlexiNoteLayer::updateNoteValue(LayerGeometryProvider *v, FlexiNoteModel::Point ¬e) const { SparseTimeValueModel *model = getAssociatedPitchModel(v); if (!model) return false; @@ -1482,7 +1482,7 @@ } void -FlexiNoteLayer::mouseMoveEvent(View *v, QMouseEvent *e) +FlexiNoteLayer::mouseMoveEvent(LayerGeometryProvider *v, QMouseEvent *e) { // GF: context sensitive cursors // v->setCursor(Qt::ArrowCursor); @@ -1510,7 +1510,7 @@ } void -FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const +FlexiNoteLayer::getRelativeMousePosition(LayerGeometryProvider *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const { // GF: TODO: consoloidate the tolerance values if (!m_model) return; @@ -1539,7 +1539,7 @@ bool -FlexiNoteLayer::editOpen(View *v, QMouseEvent *e) +FlexiNoteLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) { std::cerr << "Opening note editor dialog" << std::endl; if (!m_model) return false; @@ -1693,7 +1693,7 @@ } void -FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) +FlexiNoteLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to) { if (!m_model) return; @@ -1711,7 +1711,7 @@ } bool -FlexiNoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) +FlexiNoteLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -1722,7 +1722,7 @@ if (clipboardHasDifferentAlignment(v, from)) { QMessageBox::StandardButton button = - QMessageBox::question(v, tr("Re-align pasted items?"), + QMessageBox::question(v->getWidget(), tr("Re-align pasted items?"), tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes); @@ -1859,7 +1859,7 @@ } void -FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) +FlexiNoteLayer::setVerticalRangeToNoteRange(LayerGeometryProvider *v) { double minf = std::numeric_limits<double>::max(); double maxf = 0;
--- a/layer/FlexiNoteLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/FlexiNoteLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -38,50 +38,50 @@ public: FlexiNoteLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; - virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; - virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; + virtual int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const; + virtual void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const; - virtual QString getFeatureDescription(View *v, QPoint &) const; + virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, + virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const; - virtual void drawStart(View *v, QMouseEvent *); - virtual void drawDrag(View *v, QMouseEvent *); - virtual void drawEnd(View *v, QMouseEvent *); + virtual void drawStart(LayerGeometryProvider *v, QMouseEvent *); + virtual void drawDrag(LayerGeometryProvider *v, QMouseEvent *); + virtual void drawEnd(LayerGeometryProvider *v, QMouseEvent *); - virtual void eraseStart(View *v, QMouseEvent *); - virtual void eraseDrag(View *v, QMouseEvent *); - virtual void eraseEnd(View *v, QMouseEvent *); + virtual void eraseStart(LayerGeometryProvider *v, QMouseEvent *); + virtual void eraseDrag(LayerGeometryProvider *v, QMouseEvent *); + virtual void eraseEnd(LayerGeometryProvider *v, QMouseEvent *); - virtual void editStart(View *v, QMouseEvent *); - virtual void editDrag(View *v, QMouseEvent *); - virtual void editEnd(View *v, QMouseEvent *); + virtual void editStart(LayerGeometryProvider *v, QMouseEvent *); + virtual void editDrag(LayerGeometryProvider *v, QMouseEvent *); + virtual void editEnd(LayerGeometryProvider *v, QMouseEvent *); - virtual void splitStart(View *v, QMouseEvent *); - virtual void splitEnd(View *v, QMouseEvent *); + virtual void splitStart(LayerGeometryProvider *v, QMouseEvent *); + virtual void splitEnd(LayerGeometryProvider *v, QMouseEvent *); - virtual void addNote(View *v, QMouseEvent *e); + virtual void addNote(LayerGeometryProvider *v, QMouseEvent *e); - virtual void mouseMoveEvent(View *v, QMouseEvent *); + virtual void mouseMoveEvent(LayerGeometryProvider *v, QMouseEvent *); - virtual bool editOpen(View *v, QMouseEvent *); + virtual bool editOpen(LayerGeometryProvider *v, QMouseEvent *); virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void deleteSelectionInclusive(Selection s); - virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, + virtual void copy(LayerGeometryProvider *v, Selection s, Clipboard &to); + virtual bool paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); - void splitNotesAt(View *v, sv_frame_t frame); - void snapSelectedNotesToPitchTrack(View *v, Selection s); - void mergeNotes(View *v, Selection s, bool inclusive); + void splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame); + void snapSelectedNotesToPitchTrack(LayerGeometryProvider *v, Selection s); + void mergeNotes(LayerGeometryProvider *v, Selection s, bool inclusive); virtual const Model *getModel() const { return m_model; } void setModel(FlexiNoteModel *model); @@ -116,11 +116,11 @@ void setVerticalScale(VerticalScale scale); VerticalScale getVerticalScale() const { return m_verticalScale; } - virtual bool isLayerScrollable(const View *v) const; + virtual bool isLayerScrollable(const LayerGeometryProvider *v) const; virtual bool isLayerEditable() const { return true; } - virtual int getCompletion(View *) const { return m_model->getCompletion(); } + virtual int getCompletion(LayerGeometryProvider *) const { return m_model->getCompletion(); } virtual bool getValueExtents(double &min, double &max, bool &log, QString &unit) const; @@ -156,27 +156,27 @@ void setProperties(const QXmlAttributes &attributes); - void setVerticalRangeToNoteRange(View *v); + void setVerticalRangeToNoteRange(LayerGeometryProvider *v); /// VerticalScaleLayer methods - virtual int getYForValue(View *v, double value) const; - virtual double getValueForY(View *v, int y) const; + virtual int getYForValue(LayerGeometryProvider *v, double value) const; + virtual double getValueForY(LayerGeometryProvider *v, int y) const; virtual QString getScaleUnits() const; protected: - void getScaleExtents(View *, double &min, double &max, bool &log) const; + void getScaleExtents(LayerGeometryProvider *, double &min, double &max, bool &log) const; bool shouldConvertMIDIToHz() const; virtual int getDefaultColourHint(bool dark, bool &impose); - FlexiNoteModel::PointList getLocalPoints(View *v, int) const; + FlexiNoteModel::PointList getLocalPoints(LayerGeometryProvider *v, int) const; - bool getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &) const; - bool getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &) const; - void getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const; - SparseTimeValueModel *getAssociatedPitchModel(View *v) const; - bool updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const; - void splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e); + bool getPointToDrag(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &) const; + bool getNoteToEdit(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &) const; + void getRelativeMousePosition(LayerGeometryProvider *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const; + SparseTimeValueModel *getAssociatedPitchModel(LayerGeometryProvider *v) const; + bool updateNoteValue(LayerGeometryProvider *v, FlexiNoteModel::Point ¬e) const; + void splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame, QMouseEvent *e); FlexiNoteModel *m_model; bool m_editing;
--- a/layer/ImageLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/ImageLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -280,7 +280,7 @@ } void -ImageLayer::paint(View *v, QPainter &paint, QRect rect) const +ImageLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return;
--- a/layer/ImageLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/ImageLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -38,7 +38,7 @@ ImageLayer(); virtual ~ImageLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual QString getFeatureDescription(View *v, QPoint &) const;
--- a/layer/Layer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/Layer.h Tue Mar 17 15:05:25 2015 +0000 @@ -39,6 +39,7 @@ class Model; class QPainter; class View; +class LayerGeometryProvider; class QMouseEvent; class Clipboard; class RangeMapper; @@ -83,12 +84,13 @@ /** * Paint the given rectangle of this layer onto the given view * using the given painter, superimposing it on top of any - * existing material in that view. The view is provided here - * because it is possible for one layer to exist in more than one - * view, so the dimensions of the view may vary from one paint - * call to another (without any view having been resized). + * existing material in that view. The LayerGeometryProvider (an + * interface implemented by View) is provided here because it is + * possible for one layer to exist in more than one view, so the + * dimensions of the view may vary from one paint call to another + * (without any view having been resized). */ - virtual void paint(View *, QPainter &, QRect) const = 0; + virtual void paint(LayerGeometryProvider *, QPainter &, QRect) const = 0; /** * Enable or disable synchronous painting. If synchronous @@ -128,25 +130,25 @@ virtual QString getLayerPresentationName() const; virtual QPixmap getLayerPresentationPixmap(QSize) const { return QPixmap(); } - virtual int getVerticalScaleWidth(View *, bool detailed, + virtual int getVerticalScaleWidth(LayerGeometryProvider *, bool detailed, QPainter &) const = 0; - virtual void paintVerticalScale(View *, bool /* detailed */, + virtual void paintVerticalScale(LayerGeometryProvider *, bool /* detailed */, QPainter &, QRect) const { } - virtual bool getCrosshairExtents(View *, QPainter &, QPoint /* cursorPos */, + virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint /* cursorPos */, std::vector<QRect> &) const { return false; } - virtual void paintCrosshairs(View *, QPainter &, QPoint) const { } + virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const { } - virtual void paintMeasurementRects(View *, QPainter &, + virtual void paintMeasurementRects(LayerGeometryProvider *, QPainter &, bool showFocus, QPoint focusPoint) const; - virtual bool nearestMeasurementRectChanged(View *, QPoint prev, + virtual bool nearestMeasurementRectChanged(LayerGeometryProvider *, QPoint prev, QPoint now) const; - virtual QString getFeatureDescription(View *, QPoint &) const { + virtual QString getFeatureDescription(LayerGeometryProvider *, QPoint &) const { return ""; } @@ -180,7 +182,7 @@ * (and leave frame unmodified). If returning true, also return * the resolution of the model in this layer in sample frames. */ - virtual bool snapToFeatureFrame(View * /* v */, + virtual bool snapToFeatureFrame(LayerGeometryProvider * /* v */, sv_frame_t & /* frame */, int &resolution, SnapType /* snap */) const { @@ -204,7 +206,7 @@ * (and leave frame unmodified). If returning true, also return * the resolution of the model in this layer in sample frames. */ - virtual bool snapToSimilarFeature(View * /* v */, + virtual bool snapToSimilarFeature(LayerGeometryProvider * /* v */, sv_frame_t & /* source frame */, int &resolution, SnapType /* snap */) const { @@ -217,30 +219,30 @@ // Layer needs to get actual mouse events, I guess. Draw mode is // probably the easier. - virtual void drawStart(View *, QMouseEvent *) { } - virtual void drawDrag(View *, QMouseEvent *) { } - virtual void drawEnd(View *, QMouseEvent *) { } + virtual void drawStart(LayerGeometryProvider *, QMouseEvent *) { } + virtual void drawDrag(LayerGeometryProvider *, QMouseEvent *) { } + virtual void drawEnd(LayerGeometryProvider *, QMouseEvent *) { } - virtual void eraseStart(View *, QMouseEvent *) { } - virtual void eraseDrag(View *, QMouseEvent *) { } - virtual void eraseEnd(View *, QMouseEvent *) { } + virtual void eraseStart(LayerGeometryProvider *, QMouseEvent *) { } + virtual void eraseDrag(LayerGeometryProvider *, QMouseEvent *) { } + virtual void eraseEnd(LayerGeometryProvider *, QMouseEvent *) { } - virtual void editStart(View *, QMouseEvent *) { } - virtual void editDrag(View *, QMouseEvent *) { } - virtual void editEnd(View *, QMouseEvent *) { } + virtual void editStart(LayerGeometryProvider *, QMouseEvent *) { } + virtual void editDrag(LayerGeometryProvider *, QMouseEvent *) { } + virtual void editEnd(LayerGeometryProvider *, QMouseEvent *) { } - virtual void splitStart(View *, QMouseEvent *) { } - virtual void splitEnd(View *, QMouseEvent *) { } - virtual void addNote(View *, QMouseEvent *) { }; + virtual void splitStart(LayerGeometryProvider *, QMouseEvent *) { } + virtual void splitEnd(LayerGeometryProvider *, QMouseEvent *) { } + virtual void addNote(LayerGeometryProvider *, QMouseEvent *) { }; // Measurement rectangle (or equivalent). Unlike draw and edit, // the base Layer class can provide working implementations of // these for most situations. // - virtual void measureStart(View *, QMouseEvent *); - virtual void measureDrag(View *, QMouseEvent *); - virtual void measureEnd(View *, QMouseEvent *); - virtual void measureDoubleClick(View *, QMouseEvent *); + virtual void measureStart(LayerGeometryProvider *, QMouseEvent *); + virtual void measureDrag(LayerGeometryProvider *, QMouseEvent *); + virtual void measureEnd(LayerGeometryProvider *, QMouseEvent *); + virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *); virtual bool haveCurrentMeasureRect() const { return m_haveCurrentMeasureRect; @@ -252,13 +254,13 @@ * double-click). If there is no item or editing is not * supported, return false. */ - virtual bool editOpen(View *, QMouseEvent *) { return false; } + virtual bool editOpen(LayerGeometryProvider *, QMouseEvent *) { return false; } virtual void moveSelection(Selection, sv_frame_t /* newStartFrame */) { } virtual void resizeSelection(Selection, Selection /* newSize */) { } virtual void deleteSelection(Selection) { } - virtual void copy(View *, Selection, Clipboard & /* to */) { } + virtual void copy(LayerGeometryProvider *, Selection, Clipboard & /* to */) { } /** * Paste from the given clipboard onto the layer at the given @@ -267,7 +269,7 @@ * return false if the user cancelled the paste operation. This * function should return true if a paste actually occurred. */ - virtual bool paste(View *, + virtual bool paste(LayerGeometryProvider *, const Clipboard & /* from */, sv_frame_t /* frameOffset */, bool /* interactive */) { return false; } @@ -289,7 +291,7 @@ * scrolling better if it is known that individual views can be * scrolled safely in this way. */ - virtual bool isLayerScrollable(const View *) const { return true; } + virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return true; } /** * This should return true if the layer completely obscures any @@ -344,14 +346,14 @@ * isReady(int *) call. The view may choose to show a progress * meter if it finds that this returns < 100 at any given moment. */ - virtual int getCompletion(View *) const { return 100; } + virtual int getCompletion(LayerGeometryProvider *) const { return 100; } /** * Return an error string if any errors have occurred while * loading or processing data for the given view. Return the * empty string if no error has occurred. */ - virtual QString getError(View *) const { return ""; } + virtual QString getError(LayerGeometryProvider *) const { return ""; } virtual void setObjectName(const QString &name); @@ -400,13 +402,13 @@ * A layer class that overrides this function must also call this * class's implementation. */ - virtual void setLayerDormant(const View *v, bool dormant); + virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant); /** * Return whether the layer is dormant (i.e. hidden) in the given * view. */ - virtual bool isLayerDormant(const View *v) const; + virtual bool isLayerDormant(const LayerGeometryProvider *v) const; virtual PlayParameters *getPlayParameters(); @@ -457,14 +459,14 @@ * measurement tool. The default implementation works correctly * if the layer hasTimeXAxis(). */ - virtual bool getXScaleValue(const View *v, int x, + virtual bool getXScaleValue(const LayerGeometryProvider *v, int x, double &value, QString &unit) const; /** * Return the value and unit at the given y coordinate in the * given view. */ - virtual bool getYScaleValue(const View *, int /* y */, + virtual bool getYScaleValue(const LayerGeometryProvider *, int /* y */, double &/* value */, QString &/* unit */) const { return false; } @@ -475,7 +477,7 @@ * The default implementation just calls getYScaleValue twice and * returns the difference, with the same unit. */ - virtual bool getYScaleDifference(const View *v, int y0, int y1, + virtual bool getYScaleDifference(const LayerGeometryProvider *v, int y0, int y1, double &diff, QString &unit) const; /** @@ -519,7 +521,7 @@ virtual RangeMapper *getNewVerticalZoomRangeMapper() const { return 0; } public slots: - void showLayer(View *, bool show); + void showLayer(LayerGeometryProvider *, bool show); signals: void modelChanged(); @@ -538,9 +540,9 @@ protected: void connectSignals(const Model *); - virtual sv_frame_t alignToReference(View *v, sv_frame_t frame) const; - virtual sv_frame_t alignFromReference(View *v, sv_frame_t frame) const; - bool clipboardHasDifferentAlignment(View *v, const Clipboard &clip) const; + virtual sv_frame_t alignToReference(LayerGeometryProvider *v, sv_frame_t frame) const; + virtual sv_frame_t alignFromReference(LayerGeometryProvider *v, sv_frame_t frame) const; + bool clipboardHasDifferentAlignment(LayerGeometryProvider *v, const Clipboard &clip) const; struct MeasureRect { @@ -605,16 +607,16 @@ // Note that pixrects are only correct for a single view. // So we should update them at the start of the paint procedure // (painting is single threaded) and only use them after that. - void updateMeasurePixrects(View *v) const; + void updateMeasurePixrects(LayerGeometryProvider *v) const; - virtual void updateMeasureRectYCoords(View *v, const MeasureRect &r) const; - virtual void setMeasureRectYCoord(View *v, MeasureRect &r, bool start, int y) const; - virtual void setMeasureRectFromPixrect(View *v, MeasureRect &r, QRect pixrect) const; + virtual void updateMeasureRectYCoords(LayerGeometryProvider *v, const MeasureRect &r) const; + virtual void setMeasureRectYCoord(LayerGeometryProvider *v, MeasureRect &r, bool start, int y) const; + virtual void setMeasureRectFromPixrect(LayerGeometryProvider *v, MeasureRect &r, QRect pixrect) const; // This assumes updateMeasurementPixrects has been called MeasureRectSet::const_iterator findFocusedMeasureRect(QPoint) const; - void paintMeasurementRect(View *v, QPainter &paint, + void paintMeasurementRect(LayerGeometryProvider *v, QPainter &paint, const MeasureRect &r, bool focus) const; QString m_presentationName;
--- a/layer/LinearNumericalScale.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/LinearNumericalScale.h Tue Mar 17 15:05:25 2015 +0000 @@ -19,17 +19,17 @@ #include <QRect> class QPainter; -class View; +class LayerGeometryProvider; class VerticalScaleLayer; class LinearNumericalScale { public: - int getWidth(View *v, QPainter &paint); + int getWidth(LayerGeometryProvider *v, QPainter &paint); void paintVertical - (View *v, const VerticalScaleLayer *layer, QPainter &paint, int x0, - double minf, double maxf); + (LayerGeometryProvider *v, const VerticalScaleLayer *layer, + QPainter &paint, int x0, double minf, double maxf); }; #endif
--- a/layer/NoteLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/NoteLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -741,7 +741,7 @@ } void -NoteLayer::paint(View *v, QPainter &paint, QRect rect) const +NoteLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return;
--- a/layer/NoteLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/NoteLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -35,7 +35,7 @@ public: NoteLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
--- a/layer/RegionLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/RegionLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -866,7 +866,7 @@ } void -RegionLayer::paint(View *v, QPainter &paint, QRect rect) const +RegionLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return;
--- a/layer/RegionLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/RegionLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -39,7 +39,7 @@ public: RegionLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
--- a/layer/SliceLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/SliceLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -313,7 +313,7 @@ } void -SliceLayer::paint(View *v, QPainter &paint, QRect rect) const +SliceLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_sliceableModel || !m_sliceableModel->isOK() || !m_sliceableModel->isReady()) return;
--- a/layer/SliceLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/SliceLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -38,7 +38,7 @@ void setSliceableModel(const Model *model); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual QString getFeatureDescription(View *v, QPoint &) const;
--- a/layer/SpectrogramLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/SpectrogramLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -1767,7 +1767,7 @@ } void -SpectrogramLayer::paint(View *v, QPainter &paint, QRect rect) const +SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { // What a lovely, old-fashioned function this is. // It's practically FORTRAN 77 in its clarity and linearity.
--- a/layer/SpectrogramLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/SpectrogramLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -57,7 +57,7 @@ virtual const ZoomConstraint *getZoomConstraint() const { return this; } virtual const Model *getModel() const { return m_model; } - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual void setSynchronousPainting(bool synchronous); virtual int getVerticalScaleWidth(View *v, bool detailed, QPainter &) const;
--- a/layer/SpectrumLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/SpectrumLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -650,7 +650,7 @@ } void -SpectrumLayer::paint(View *v, QPainter &paint, QRect rect) const +SpectrumLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_originModel || !m_originModel->isOK() || !m_originModel->isReady()) {
--- a/layer/SpectrumLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/SpectrumLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -45,7 +45,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual VerticalPosition getPreferredFrameCountPosition() const { return PositionTop;
--- a/layer/TextLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TextLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -306,7 +306,7 @@ } void -TextLayer::paint(View *v, QPainter &paint, QRect rect) const +TextLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return;
--- a/layer/TextLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TextLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -32,7 +32,7 @@ public: TextLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual QString getFeatureDescription(View *v, QPoint &) const;
--- a/layer/TimeInstantLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TimeInstantLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -321,7 +321,7 @@ } void -TimeInstantLayer::paint(View *v, QPainter &paint, QRect rect) const +TimeInstantLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return;
--- a/layer/TimeInstantLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TimeInstantLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -33,7 +33,7 @@ TimeInstantLayer(); virtual ~TimeInstantLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual QString getLabelPreceding(sv_frame_t) const; virtual QString getFeatureDescription(View *v, QPoint &) const;
--- a/layer/TimeRulerLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TimeRulerLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -192,7 +192,7 @@ } void -TimeRulerLayer::paint(View *v, QPainter &paint, QRect rect) const +TimeRulerLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { #ifdef DEBUG_TIME_RULER_LAYER SVDEBUG << "TimeRulerLayer::paint (" << rect.x() << "," << rect.y()
--- a/layer/TimeRulerLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TimeRulerLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -32,7 +32,7 @@ public: TimeRulerLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; void setModel(Model *); virtual const Model *getModel() const { return m_model; }
--- a/layer/TimeValueLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TimeValueLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -896,7 +896,7 @@ } void -TimeValueLayer::paint(View *v, QPainter &paint, QRect rect) const +TimeValueLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return;
--- a/layer/TimeValueLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/TimeValueLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -37,7 +37,7 @@ public: TimeValueLayer(); - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
--- a/layer/VerticalScaleLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/VerticalScaleLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -19,8 +19,8 @@ class VerticalScaleLayer { public: - virtual int getYForValue(View *, double value) const = 0; - virtual double getValueForY(View *, int y) const = 0; + virtual int getYForValue(LayerGeometryProvider *, double value) const = 0; + virtual double getValueForY(LayerGeometryProvider *, int y) const = 0; virtual QString getScaleUnits() const = 0; };
--- a/layer/WaveformLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/WaveformLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -473,7 +473,7 @@ } void -WaveformLayer::paint(View *v, QPainter &viewPainter, QRect rect) const +WaveformLayer::paint(LayerGeometryProvider *v, QPainter &viewPainter, QRect rect) const { if (!m_model || !m_model->isOK()) { return;
--- a/layer/WaveformLayer.h Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/WaveformLayer.h Tue Mar 17 15:05:25 2015 +0000 @@ -38,7 +38,7 @@ return m_model ? m_model->getZoomConstraint() : 0; } virtual const Model *getModel() const { return m_model; } - virtual void paint(View *v, QPainter &paint, QRect rect) const; + virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; virtual QString getFeatureDescription(View *v, QPoint &) const;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/view/LayerGeometryProvider.h Tue Mar 17 15:05:25 2015 +0000 @@ -0,0 +1,119 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef LAYER_GEOMETRY_PROVIDER_H +#define LAYER_GEOMETRY_PROVIDER_H + +#include "base/BaseTypes.h" + +class ViewManager; +class Layer; + +class LayerGeometryProvider +{ +public: + /** + * Retrieve the first visible sample frame on the widget. + * This is a calculated value based on the centre-frame, widget + * width and zoom level. The result may be negative. + */ + virtual sv_frame_t getStartFrame() const = 0; + + /** + * Return the centre frame of the visible widget. This is an + * exact value that does not depend on the zoom block size. Other + * frame values (start, end) are calculated from this based on the + * zoom and other factors. + */ + virtual sv_frame_t getCentreFrame() const = 0; + + /** + * Retrieve the last visible sample frame on the widget. + * This is a calculated value based on the centre-frame, widget + * width and zoom level. + */ + virtual sv_frame_t getEndFrame() const = 0; + + /** + * Return the pixel x-coordinate corresponding to a given sample + * frame (which may be negative). + */ + virtual int getXForFrame(sv_frame_t frame) const = 0; + + /** + * Return the closest frame to the given pixel x-coordinate. + */ + virtual sv_frame_t getFrameForX(int x) const = 0; + + /** + * Return the pixel y-coordinate corresponding to a given + * frequency, if the frequency range is as specified. This does + * not imply any policy about layer frequency ranges, but it might + * be useful for layers to match theirs up if desired. + * + * Not thread-safe in logarithmic mode. Call only from GUI thread. + */ + virtual double getYForFrequency(double frequency, double minFreq, double maxFreq, + bool logarithmic) const = 0; + + /** + * Return the closest frequency to the given pixel y-coordinate, + * if the frequency range is as specified. + * + * Not thread-safe in logarithmic mode. Call only from GUI thread. + */ + virtual double getFrequencyForY(int y, double minFreq, double maxFreq, + bool logarithmic) const = 0; + + /** + * Return the zoom level, i.e. the number of frames per pixel + */ + virtual int getZoomLevel() const = 0; + + /** + * To be called from a layer, to obtain the extent of the surface + * that the layer is currently painting to. This may be the extent + * of the view (if 1x display scaling is in effect) or of a larger + * cached pixmap (if greater display scaling is in effect). + */ + virtual QRect getPaintRect() const = 0; + + virtual QSize getPaintSize() const { return getPaintRect().size(); } + virtual int getPaintWidth() const { return getPaintRect().width(); } + virtual int getPaintHeight() const { return getPaintRect().height(); } + + virtual bool hasLightBackground() const = 0; + virtual QColor getForeground() const = 0; + virtual QColor getBackground() const = 0; + + virtual ViewManager *getViewManager() const = 0; + + virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const = 0; + + enum TextStyle { + BoxedText, + OutlinedText, + OutlinedItalicText + }; + + virtual void drawVisibleText(QPainter &p, int x, int y, + QString text, TextStyle style) const = 0; + + virtual void drawMeasurementRect(QPainter &p, const Layer *, + QRect rect, bool focus) const = 0; + + virtual QWidget *getWidget() const = 0; +}; + +#endif
--- a/view/View.h Wed Mar 11 15:35:20 2015 +0000 +++ b/view/View.h Tue Mar 17 15:05:25 2015 +0000 @@ -19,6 +19,8 @@ #include <QFrame> #include <QProgressBar> +#include "LayerGeometryProvider.h" + #include "base/ZoomConstraint.h" #include "base/PropertyContainer.h" #include "ViewManager.h" @@ -49,7 +51,8 @@ */ class View : public QFrame, - public XmlExportable + public XmlExportable, + public LayerGeometryProvider { Q_OBJECT @@ -243,12 +246,6 @@ virtual QColor getForeground() const; virtual QColor getBackground() const; - enum TextStyle { - BoxedText, - OutlinedText, - OutlinedItalicText - }; - virtual void drawVisibleText(QPainter &p, int x, int y, QString text, TextStyle style) const;