Mercurial > hg > svgui
diff view/View.cpp @ 1148:c0d841cb8ab9 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | 179ea8a2f650 |
children | 0edfed2c8482 |
line wrap: on
line diff
--- a/view/View.cpp Tue Oct 20 12:55:09 2015 +0100 +++ b/view/View.cpp Fri Aug 19 15:58:57 2016 +0100 @@ -24,6 +24,8 @@ #include "layer/TimeRulerLayer.h" #include "layer/SingleColourLayer.h" +#include "layer/PaintAssistant.h" + #include "data/model/PowerOfSqrtTwoZoomConstraint.h" #include "data/model/RangeSummarisableTimeValueModel.h" @@ -49,9 +51,9 @@ //#define DEBUG_VIEW 1 //#define DEBUG_VIEW_WIDGET_PAINT 1 - View::View(QWidget *w, bool showProgress) : QFrame(w), + m_id(getNextId()), m_centreFrame(0), m_zoomLevel(1024), m_followPan(true), @@ -365,15 +367,17 @@ sv_frame_t View::getFrameForX(int x) const { - int z = m_zoomLevel; + sv_frame_t z = m_zoomLevel; // nb not just int, or multiplication may overflow sv_frame_t frame = m_centreFrame - (width()/2) * z; + frame = (frame / z) * z; // this is start frame + frame = frame + x * z; + #ifdef DEBUG_VIEW_WIDGET_PAINT - SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; + cerr << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; #endif - frame = (frame / z) * z; // this is start frame - return frame + x * z; + return frame; } double @@ -411,12 +415,12 @@ } double -View::getFrequencyForY(int y, +View::getFrequencyForY(double y, double minf, double maxf, bool logarithmic) const { - int h = height(); + double h = height(); if (logarithmic) { @@ -808,56 +812,6 @@ } void -View::drawVisibleText(QPainter &paint, int x, int y, QString text, TextStyle style) const -{ - if (style == OutlinedText || style == OutlinedItalicText) { - - paint.save(); - - if (style == OutlinedItalicText) { - QFont f(paint.font()); - f.setItalic(true); - paint.setFont(f); - } - - QColor penColour, surroundColour, boxColour; - - penColour = getForeground(); - surroundColour = getBackground(); - boxColour = surroundColour; - boxColour.setAlpha(127); - - paint.setPen(Qt::NoPen); - paint.setBrush(boxColour); - - QRect r = paint.fontMetrics().boundingRect(text); - r.translate(QPoint(x, y)); -// cerr << "drawVisibleText: r = " << r.x() << "," <<r.y() << " " << r.width() << "x" << r.height() << endl; - paint.drawRect(r); - paint.setBrush(Qt::NoBrush); - - paint.setPen(surroundColour); - - for (int dx = -1; dx <= 1; ++dx) { - for (int dy = -1; dy <= 1; ++dy) { - if (!(dx || dy)) continue; - paint.drawText(x + dx, y + dy, text); - } - } - - paint.setPen(penColour); - - paint.drawText(x, y, text); - - paint.restore(); - - } else { - - cerr << "ERROR: View::drawVisibleText: Boxed style not yet implemented!" << endl; - } -} - -void View::setPlaybackFollow(PlaybackFollowMode m) { m_followPlay = m; @@ -2367,32 +2321,32 @@ } if (axs != "") { - drawVisibleText(paint, axx, axy, axs, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, axx, axy, axs, PaintAssistant::OutlinedText); axy += fontHeight; } if (ays != "") { - drawVisibleText(paint, axx, axy, ays, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, axx, axy, ays, PaintAssistant::OutlinedText); axy += fontHeight; } if (bxs != "") { - drawVisibleText(paint, bxx, bxy, bxs, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, bxx, bxy, bxs, PaintAssistant::OutlinedText); bxy += fontHeight; } if (bys != "") { - drawVisibleText(paint, bxx, bxy, bys, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, bxx, bxy, bys, PaintAssistant::OutlinedText); bxy += fontHeight; } if (dxs != "") { - drawVisibleText(paint, dxx, dxy, dxs, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, dxx, dxy, dxs, PaintAssistant::OutlinedText); dxy += fontHeight; } if (dys != "") { - drawVisibleText(paint, dxx, dxy, dys, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, dxx, dxy, dys, PaintAssistant::OutlinedText); dxy += fontHeight; }