Mercurial > hg > svgui
changeset 1078:ee01a4062747 spectrogram-minor-refactor
Move drawVisibleText to PaintAssistant
author | Chris Cannam |
---|---|
date | Thu, 30 Jun 2016 12:40:22 +0100 |
parents | 5144d7185fb5 |
children | 7ebfb61b1701 |
files | layer/Colour3DPlotLayer.cpp layer/FlexiNoteLayer.cpp layer/LayerGeometryProvider.h layer/NoteLayer.cpp layer/PaintAssistant.cpp layer/PaintAssistant.h layer/RegionLayer.cpp layer/SliceLayer.cpp layer/SpectrogramLayer.cpp layer/SpectrumLayer.cpp layer/TimeInstantLayer.cpp layer/TimeRulerLayer.cpp layer/TimeValueLayer.cpp layer/WaveformLayer.cpp view/Pane.cpp view/View.cpp view/View.h view/ViewProxy.h |
diffstat | 18 files changed, 161 insertions(+), 143 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/Colour3DPlotLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -21,6 +21,7 @@ #include "ColourMapper.h" #include "LayerGeometryProvider.h" +#include "PaintAssistant.h" #include "view/ViewManager.h" @@ -867,12 +868,12 @@ paint.setWorldMatrix(m); - v->drawVisibleText(paint, 2, 0, minstr, LayerGeometryProvider::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, 2, 0, minstr, PaintAssistant::OutlinedText); m.translate(ch - msw - 2, 0); paint.setWorldMatrix(m); - v->drawVisibleText(paint, 0, 0, maxstr, LayerGeometryProvider::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, 0, 0, maxstr, PaintAssistant::OutlinedText); paint.restore(); } @@ -1440,12 +1441,13 @@ double value = m_model->getValueAt(sx, sy); snprintf(labelbuf, buflen, "%06f", value); QString text(labelbuf); - v->drawVisibleText - (paint, + PaintAssistant::drawVisibleText + (v, + paint, rx0 + 2, ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), text, - LayerGeometryProvider::OutlinedText); + PaintAssistant::OutlinedText); } } }
--- a/layer/FlexiNoteLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/FlexiNoteLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -22,12 +22,13 @@ #include "base/Pitch.h" #include "base/LogRange.h" #include "base/RangeMapper.h" + #include "ColourDatabase.h" #include "LayerGeometryProvider.h" - #include "PianoScale.h" #include "LinearNumericalScale.h" #include "LogNumericalScale.h" +#include "PaintAssistant.h" #include "data/model/FlexiNoteModel.h" @@ -869,34 +870,34 @@ // paint.setBrush(v->getForeground()); QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits()); - // v->drawVisibleText(paint, + // PaintAssistant::drawVisibleText(v, paint, // x - paint.fontMetrics().width(vlabel) - 2, // y + paint.fontMetrics().height()/2 // - paint.fontMetrics().descent(), - // vlabel, LayerGeometryProvider::OutlinedText); - v->drawVisibleText(paint, + // vlabel, PaintAssistant::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, x, y - h/2 - 2 - paint.fontMetrics().height() - paint.fontMetrics().descent(), - vlabel, LayerGeometryProvider::OutlinedText); + vlabel, PaintAssistant::OutlinedText); QString hlabel = "dur: " + QString(RealTime::frame2RealTime (p.duration, m_model->getSampleRate()).toText(true).c_str()); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x, y - h/2 - paint.fontMetrics().descent() - 2, - hlabel, LayerGeometryProvider::OutlinedText); + hlabel, PaintAssistant::OutlinedText); QString llabel = QString("%1").arg(p.label); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x, y + h + 2 + paint.fontMetrics().descent(), - llabel, LayerGeometryProvider::OutlinedText); + llabel, PaintAssistant::OutlinedText); QString nlabel = QString("%1").arg(noteNumber); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x + paint.fontMetrics().averageCharWidth() / 2, y + h/2 - paint.fontMetrics().descent(), - nlabel, LayerGeometryProvider::OutlinedText); + nlabel, PaintAssistant::OutlinedText); } paint.drawRect(x, y - h/2, w, h);
--- a/layer/LayerGeometryProvider.h Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/LayerGeometryProvider.h Thu Jun 30 12:40:22 2016 +0100 @@ -153,15 +153,6 @@ virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const = 0; virtual bool shouldShowFeatureLabels() 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;
--- a/layer/NoteLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/NoteLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -21,12 +21,13 @@ #include "base/Pitch.h" #include "base/LogRange.h" #include "base/RangeMapper.h" -#include "ColourDatabase.h" #include "view/View.h" +#include "ColourDatabase.h" #include "PianoScale.h" #include "LinearNumericalScale.h" #include "LogNumericalScale.h" +#include "PaintAssistant.h" #include "data/model/NoteModel.h" @@ -809,18 +810,18 @@ paint.setBrush(v->getForeground()); QString vlabel = QString("%1%2").arg(p.value).arg(getScaleUnits()); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x - paint.fontMetrics().width(vlabel) - 2, y + paint.fontMetrics().height()/2 - paint.fontMetrics().descent(), - vlabel, LayerGeometryProvider::OutlinedText); + vlabel, PaintAssistant::OutlinedText); QString hlabel = RealTime::frame2RealTime (p.frame, m_model->getSampleRate()).toText(true).c_str(); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x, y - h/2 - paint.fontMetrics().descent() - 2, - hlabel, LayerGeometryProvider::OutlinedText); + hlabel, PaintAssistant::OutlinedText); } paint.drawRect(x, y - h/2, w, h);
--- a/layer/PaintAssistant.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/PaintAssistant.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -15,6 +15,8 @@ #include "PaintAssistant.h" +#include "LayerGeometryProvider.h" + #include "base/AudioLevel.h" #include <QPaintDevice> @@ -207,3 +209,55 @@ return vy; } + +void +PaintAssistant::drawVisibleText(const LayerGeometryProvider *v, + QPainter &paint, int x, int y, + QString text, TextStyle style) +{ + 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 = v->getForeground(); + surroundColour = v->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 { + + std::cerr << "ERROR: PaintAssistant::drawVisibleText: Boxed style not yet implemented!" << std::endl; + } +}
--- a/layer/PaintAssistant.h Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/PaintAssistant.h Thu Jun 30 12:40:22 2016 +0100 @@ -13,13 +13,15 @@ COPYING included with this distribution for more information. */ -#ifndef _PAINT_ASSISTANT_H_ -#define _PAINT_ASSISTANT_H_ +#ifndef PAINT_ASSISTANT_H +#define PAINT_ASSISTANT_H #include <QRect> #include <vector> class QPainter; +class Layer; +class LayerGeometryProvider; class PaintAssistant { @@ -34,6 +36,16 @@ static int getYForValue(Scale scale, double value, double minVal, double maxVal, int minY, int height); + + enum TextStyle { + BoxedText, + OutlinedText, + OutlinedItalicText + }; + + static void drawVisibleText(const LayerGeometryProvider *, + QPainter &p, int x, int y, + QString text, TextStyle style); }; #endif
--- a/layer/RegionLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/RegionLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -19,13 +19,14 @@ #include "base/RealTime.h" #include "base/Profiler.h" #include "base/LogRange.h" + #include "ColourDatabase.h" - #include "ColourMapper.h" #include "LinearNumericalScale.h" #include "LogNumericalScale.h" #include "LinearColourScale.h" #include "LogColourScale.h" +#include "PaintAssistant.h" #include "view/View.h" @@ -979,18 +980,18 @@ paint.setBrush(v->getForeground()); QString vlabel = QString("%1%2").arg(p.value).arg(getScaleUnits()); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x - paint.fontMetrics().width(vlabel) - 2, y + paint.fontMetrics().height()/2 - paint.fontMetrics().descent(), - vlabel, LayerGeometryProvider::OutlinedText); + vlabel, PaintAssistant::OutlinedText); QString hlabel = RealTime::frame2RealTime (p.frame, m_model->getSampleRate()).toText(true).c_str(); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, x, y - h/2 - paint.fontMetrics().descent() - 2, - hlabel, LayerGeometryProvider::OutlinedText); + hlabel, PaintAssistant::OutlinedText); } paint.drawLine(x, y-1, x + w, y-1); @@ -1048,7 +1049,7 @@ nextLabelMinX = labelX + paint.fontMetrics().width(label); } - v->drawVisibleText(paint, labelX, labelY, label, LayerGeometryProvider::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, labelX, labelY, label, PaintAssistant::OutlinedText); } }
--- a/layer/SliceLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/SliceLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -485,17 +485,17 @@ v->drawVisibleText (paint, xorigin + 5, paint.fontMetrics().ascent() + 5, - startText, View::OutlinedText); + startText, PaintAssistant::OutlinedText); v->drawVisibleText (paint, xorigin + 5, paint.fontMetrics().ascent() + paint.fontMetrics().height() + 10, - endText, View::OutlinedText); + endText, PaintAssistant::OutlinedText); v->drawVisibleText (paint, xorigin + 5, paint.fontMetrics().ascent() + 2*paint.fontMetrics().height() + 15, - durationText, View::OutlinedText); + durationText, PaintAssistant::OutlinedText); } */ }
--- a/layer/SpectrogramLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -25,10 +25,12 @@ #include "base/LogRange.h" #include "base/ColumnOp.h" #include "widgets/CommandHistory.h" +#include "data/model/Dense3DModelPeakCache.h" + #include "ColourMapper.h" #include "ImageRegionFinder.h" -#include "data/model/Dense3DModelPeakCache.h" #include "PianoScale.h" +#include "PaintAssistant.h" #include <QPainter> #include <QImage> @@ -2850,35 +2852,35 @@ double fundamental = getFrequencyForY(v, cursorPos.y()); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, sw + 2, cursorPos.y() - 2, QString("%1 Hz").arg(fundamental), - View::OutlinedText); + PaintAssistant::OutlinedText); if (Pitch::isFrequencyInMidiRange(fundamental)) { QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, sw + 2, cursorPos.y() + paint.fontMetrics().ascent() + 2, pitchLabel, - View::OutlinedText); + PaintAssistant::OutlinedText); } sv_frame_t frame = v->getFrameForX(cursorPos.x()); RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate()); QString rtLabel = QString("%1 s").arg(rt.toText(true).c_str()); QString frameLabel = QString("%1").arg(frame); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, cursorPos.x() - paint.fontMetrics().width(frameLabel) - 2, v->getPaintHeight() - 2, frameLabel, - View::OutlinedText); - v->drawVisibleText(paint, + PaintAssistant::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, cursorPos.x() + 2, v->getPaintHeight() - 2, rtLabel, - View::OutlinedText); + PaintAssistant::OutlinedText); int harmonic = 2;
--- a/layer/SpectrumLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/SpectrumLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -21,7 +21,9 @@ #include "base/Preferences.h" #include "base/RangeMapper.h" #include "base/Pitch.h" + #include "ColourMapper.h" +#include "PaintAssistant.h" #include <QPainter> #include <QTextStream> @@ -491,19 +493,19 @@ int hoffset = 2; if (m_binScale == LogBins) hoffset = 13; - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, cursorPos.x() + 2, v->getPaintHeight() - 2 - hoffset, QString("%1 Hz").arg(fundamental), - View::OutlinedText); + PaintAssistant::OutlinedText); if (Pitch::isFrequencyInMidiRange(fundamental)) { QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, cursorPos.x() - paint.fontMetrics().width(pitchLabel) - 2, v->getPaintHeight() - 2 - hoffset, pitchLabel, - View::OutlinedText); + PaintAssistant::OutlinedText); } double value = getValueForY(cursorPos.y(), v); @@ -512,17 +514,17 @@ if (value > 0.0) db = 10.0 * log10(value); if (db < thresh) db = thresh; - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, xorigin + 2, cursorPos.y() - 2, QString("%1 V").arg(value), - View::OutlinedText); + PaintAssistant::OutlinedText); - v->drawVisibleText(paint, + PaintAssistant::drawVisibleText(v, paint, xorigin + 2, cursorPos.y() + 2 + paint.fontMetrics().ascent(), QString("%1 dBV").arg(db), - View::OutlinedText); + PaintAssistant::OutlinedText); int harmonic = 2;
--- a/layer/TimeInstantLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/TimeInstantLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -20,7 +20,9 @@ #include "view/View.h" #include "base/Profiler.h" #include "base/Clipboard.h" + #include "ColourDatabase.h" +#include "PaintAssistant.h" #include "data/model/SparseOneDimensionalModel.h" @@ -456,7 +458,7 @@ } if (good) { - v->drawVisibleText(paint, x + iw + 2, textY, p.label, View::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, x + iw + 2, textY, p.label, PaintAssistant::OutlinedText); // paint.drawText(x + iw + 2, textY, p.label); } }
--- a/layer/TimeRulerLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/TimeRulerLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -19,8 +19,10 @@ #include "data/model/Model.h" #include "base/RealTime.h" +#include "view/View.h" + #include "ColourDatabase.h" -#include "view/View.h" +#include "PaintAssistant.h" #include <QPainter> @@ -324,7 +326,7 @@ // backmost layer, don't worry about outlining the text paint.drawText(x+2 - tw/2, y, text); } else { - v->drawVisibleText(paint, x+2 - tw/2, y, text, View::OutlinedText); + PaintAssistant::drawVisibleText(v, paint, x+2 - tw/2, y, text, PaintAssistant::OutlinedText); } } }
--- a/layer/TimeValueLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/TimeValueLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -21,7 +21,6 @@ #include "base/LogRange.h" #include "base/RangeMapper.h" #include "base/Pitch.h" -#include "ColourDatabase.h" #include "view/View.h" #include "data/model/SparseTimeValueModel.h" @@ -31,12 +30,14 @@ #include "widgets/ListInputDialog.h" #include "widgets/TextAbbrev.h" +#include "ColourDatabase.h" #include "ColourMapper.h" #include "PianoScale.h" #include "LinearNumericalScale.h" #include "LogNumericalScale.h" #include "LinearColourScale.h" #include "LogColourScale.h" +#include "PaintAssistant.h" #include <QPainter> #include <QPainterPath> @@ -1214,10 +1215,10 @@ if (haveRoom || (!haveNext && (pointCount == 0 || !italic))) { - v->drawVisibleText(paint, x + 5, textY, label, + PaintAssistant::drawVisibleText(v, paint, x + 5, textY, label, italic ? - View::OutlinedItalicText : - View::OutlinedText); + PaintAssistant::OutlinedItalicText : + PaintAssistant::OutlinedText); } } }
--- a/layer/WaveformLayer.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/layer/WaveformLayer.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -19,7 +19,9 @@ #include "view/View.h" #include "base/Profiler.h" #include "base/RangeMapper.h" + #include "ColourDatabase.h" +#include "PaintAssistant.h" #include <QPainter> #include <QPixmap>
--- a/view/Pane.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/view/Pane.cpp Thu Jun 30 12:40:22 2016 +0100 @@ -25,6 +25,7 @@ #include "base/Preferences.h" #include "layer/WaveformLayer.h" #include "layer/TimeRulerLayer.h" +#include "layer/PaintAssistant.h" // GF: added so we can propagate the mouse move event to the note layer for context handling. #include "layer/LayerFactory.h" @@ -777,14 +778,14 @@ int tw = paint.fontMetrics().width(text); int x = width()/2 - 4 - tw; - drawVisibleText(paint, x, y, text, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, x, y, text, PaintAssistant::OutlinedText); } QString text = QString("%1").arg(m_centreFrame); int x = width()/2 + 4; - drawVisibleText(paint, x, y, text, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, x, y, text, PaintAssistant::OutlinedText); } } @@ -866,8 +867,8 @@ return; } - drawVisibleText(paint, m_scaleWidth + 5, - paint.fontMetrics().ascent() + y, text, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, m_scaleWidth + 5, + paint.fontMetrics().ascent() + y, text, PaintAssistant::OutlinedText); paint.restore(); } @@ -905,8 +906,8 @@ return; } - drawVisibleText(paint, m_scaleWidth + 5, - paint.fontMetrics().ascent() + y, text, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, m_scaleWidth + 5, + paint.fontMetrics().ascent() + y, text, PaintAssistant::OutlinedText); paint.restore(); } @@ -954,9 +955,9 @@ paint.setPen(getForeground()); } - drawVisibleText(paint, llx, + PaintAssistant::drawVisibleText(this, paint, llx, lly - fontHeight + fontAscent, - texts[i], OutlinedText); + texts[i], PaintAssistant::OutlinedText); if (!pixmaps[i].isNull()) { paint.drawPixmap(llx - fontAscent - 3, @@ -1018,10 +1019,10 @@ offsetText = tr("+%1").arg(offsetText); } } - drawVisibleText(paint, p0 + 2, fontAscent + fontHeight + 4, startText, OutlinedText); - drawVisibleText(paint, p1 + 2, fontAscent + fontHeight + 4, endText, OutlinedText); - drawVisibleText(paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); - drawVisibleText(paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); + PaintAssistant::drawVisibleText(this, paint, p0 + 2, fontAscent + fontHeight + 4, startText, PaintAssistant::OutlinedText); + PaintAssistant::drawVisibleText(this, paint, p1 + 2, fontAscent + fontHeight + 4, endText, PaintAssistant::OutlinedText); + PaintAssistant::drawVisibleText(this, paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, PaintAssistant::OutlinedText); + PaintAssistant::drawVisibleText(this, paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, PaintAssistant::OutlinedText); //!!! duplicating display policy with View::drawSelections @@ -1084,9 +1085,9 @@ if (x < pbw + 5) x = pbw + 5; if (r.x() < x + paint.fontMetrics().width(desc)) { - drawVisibleText(paint, x, + PaintAssistant::drawVisibleText(this, paint, x, height() - fontHeight + fontAscent - 6, - desc, OutlinedText); + desc, PaintAssistant::OutlinedText); } }
--- a/view/View.cpp Thu Jun 30 10:59:11 2016 +0100 +++ b/view/View.cpp Thu Jun 30 12:40:22 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" @@ -810,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; @@ -2369,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; }
--- a/view/View.h Thu Jun 30 10:59:11 2016 +0100 +++ b/view/View.h Thu Jun 30 12:40:22 2016 +0100 @@ -266,9 +266,6 @@ virtual QColor getForeground() const; virtual QColor getBackground() const; - virtual void drawVisibleText(QPainter &p, int x, int y, - QString text, TextStyle style) const; - virtual void drawMeasurementRect(QPainter &p, const Layer *, QRect rect, bool focus) const;
--- a/view/ViewProxy.h Thu Jun 30 10:59:11 2016 +0100 +++ b/view/ViewProxy.h Thu Jun 30 12:40:22 2016 +0100 @@ -128,11 +128,6 @@ return m_view->shouldShowFeatureLabels(); } - virtual void drawVisibleText(QPainter &p, int x, int y, - QString text, TextStyle style) const { - m_view->drawVisibleText(p, x, y, text, style); - } - virtual void drawMeasurementRect(QPainter &p, const Layer *layer, QRect rect, bool focus) const { m_view->drawMeasurementRect(p, layer, rect, focus);