feat(spectrogramplot): Draw a frequency scale

This commit is contained in:
schneider
2016-09-06 00:08:07 +02:00
parent 25b01a19b8
commit ed31017f2c
7 changed files with 112 additions and 10 deletions

View File

@@ -39,12 +39,13 @@ PlotView::PlotView(InputSource *input) : cursors(this), viewRange({0, 0})
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setMouseTracking(true);
enableCursors(false);
enableTimeScale(true);
connect(&cursors, SIGNAL(cursorsMoved()), this, SLOT(cursorsMoved()));
spectrogramPlot = new SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float>>>(mainSampleSource));
auto tunerOutput = std::dynamic_pointer_cast<SampleSource<std::complex<float>>>(spectrogramPlot->output());
enableScales(true);
addPlot(spectrogramPlot);
viewport()->installEventFilter(this);
@@ -373,8 +374,10 @@ void PlotView::paintEvent(QPaintEvent *event)
if (cursorsEnabled)
cursors.paintFront(painter, rect, viewRange);
if (timeScaleEnabled)
if (timeScaleEnabled) {
paintTimeScale(painter, rect, viewRange);
}
#undef PLOT_LAYER
}
@@ -429,7 +432,6 @@ void PlotView::paintTimeScale(QPainter &painter, QRect &rect, range_t<off_t> sam
painter.restore();
}
int PlotView::plotsHeight()
{
int height = 0;
@@ -491,12 +493,20 @@ void PlotView::updateView(bool reCenter)
void PlotView::setSampleRate(off_t rate)
{
sampleRate = rate;
if (spectrogramPlot != nullptr)
spectrogramPlot->setSampleRate(rate);
emitTimeSelection();
}
void PlotView::enableTimeScale(bool enabled)
void PlotView::enableScales(bool enabled)
{
timeScaleEnabled = enabled;
if (spectrogramPlot != nullptr)
spectrogramPlot->enableScales(enabled);
viewport()->update();
}