Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1078:ee01a4062747 spectrogram-minor-refactor
Move drawVisibleText to PaintAssistant
author | Chris Cannam |
---|---|
date | Thu, 30 Jun 2016 12:40:22 +0100 |
parents | 85e49aa7fe77 |
children | 179ea8a2f650 |
comparison
equal
deleted
inserted
replaced
1077:5144d7185fb5 | 1078:ee01a4062747 |
---|---|
23 #include "base/Preferences.h" | 23 #include "base/Preferences.h" |
24 #include "base/RangeMapper.h" | 24 #include "base/RangeMapper.h" |
25 #include "base/LogRange.h" | 25 #include "base/LogRange.h" |
26 #include "base/ColumnOp.h" | 26 #include "base/ColumnOp.h" |
27 #include "widgets/CommandHistory.h" | 27 #include "widgets/CommandHistory.h" |
28 #include "data/model/Dense3DModelPeakCache.h" | |
29 | |
28 #include "ColourMapper.h" | 30 #include "ColourMapper.h" |
29 #include "ImageRegionFinder.h" | 31 #include "ImageRegionFinder.h" |
30 #include "data/model/Dense3DModelPeakCache.h" | |
31 #include "PianoScale.h" | 32 #include "PianoScale.h" |
33 #include "PaintAssistant.h" | |
32 | 34 |
33 #include <QPainter> | 35 #include <QPainter> |
34 #include <QImage> | 36 #include <QImage> |
35 #include <QPixmap> | 37 #include <QPixmap> |
36 #include <QRect> | 38 #include <QRect> |
2848 paint.drawLine(0, cursorPos.y(), cursorPos.x() - 1, cursorPos.y()); | 2850 paint.drawLine(0, cursorPos.y(), cursorPos.x() - 1, cursorPos.y()); |
2849 paint.drawLine(cursorPos.x(), 0, cursorPos.x(), v->getPaintHeight()); | 2851 paint.drawLine(cursorPos.x(), 0, cursorPos.x(), v->getPaintHeight()); |
2850 | 2852 |
2851 double fundamental = getFrequencyForY(v, cursorPos.y()); | 2853 double fundamental = getFrequencyForY(v, cursorPos.y()); |
2852 | 2854 |
2853 v->drawVisibleText(paint, | 2855 PaintAssistant::drawVisibleText(v, paint, |
2854 sw + 2, | 2856 sw + 2, |
2855 cursorPos.y() - 2, | 2857 cursorPos.y() - 2, |
2856 QString("%1 Hz").arg(fundamental), | 2858 QString("%1 Hz").arg(fundamental), |
2857 View::OutlinedText); | 2859 PaintAssistant::OutlinedText); |
2858 | 2860 |
2859 if (Pitch::isFrequencyInMidiRange(fundamental)) { | 2861 if (Pitch::isFrequencyInMidiRange(fundamental)) { |
2860 QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental); | 2862 QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental); |
2861 v->drawVisibleText(paint, | 2863 PaintAssistant::drawVisibleText(v, paint, |
2862 sw + 2, | 2864 sw + 2, |
2863 cursorPos.y() + paint.fontMetrics().ascent() + 2, | 2865 cursorPos.y() + paint.fontMetrics().ascent() + 2, |
2864 pitchLabel, | 2866 pitchLabel, |
2865 View::OutlinedText); | 2867 PaintAssistant::OutlinedText); |
2866 } | 2868 } |
2867 | 2869 |
2868 sv_frame_t frame = v->getFrameForX(cursorPos.x()); | 2870 sv_frame_t frame = v->getFrameForX(cursorPos.x()); |
2869 RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate()); | 2871 RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate()); |
2870 QString rtLabel = QString("%1 s").arg(rt.toText(true).c_str()); | 2872 QString rtLabel = QString("%1 s").arg(rt.toText(true).c_str()); |
2871 QString frameLabel = QString("%1").arg(frame); | 2873 QString frameLabel = QString("%1").arg(frame); |
2872 v->drawVisibleText(paint, | 2874 PaintAssistant::drawVisibleText(v, paint, |
2873 cursorPos.x() - paint.fontMetrics().width(frameLabel) - 2, | 2875 cursorPos.x() - paint.fontMetrics().width(frameLabel) - 2, |
2874 v->getPaintHeight() - 2, | 2876 v->getPaintHeight() - 2, |
2875 frameLabel, | 2877 frameLabel, |
2876 View::OutlinedText); | 2878 PaintAssistant::OutlinedText); |
2877 v->drawVisibleText(paint, | 2879 PaintAssistant::drawVisibleText(v, paint, |
2878 cursorPos.x() + 2, | 2880 cursorPos.x() + 2, |
2879 v->getPaintHeight() - 2, | 2881 v->getPaintHeight() - 2, |
2880 rtLabel, | 2882 rtLabel, |
2881 View::OutlinedText); | 2883 PaintAssistant::OutlinedText); |
2882 | 2884 |
2883 int harmonic = 2; | 2885 int harmonic = 2; |
2884 | 2886 |
2885 while (harmonic < 100) { | 2887 while (harmonic < 100) { |
2886 | 2888 |