cursors: Move cursors to keep a constant symbol rate when changing symbol count

This commit is contained in:
Mike Walters
2016-05-02 00:02:18 +01:00
parent 8c2394df77
commit ecdc01986b
2 changed files with 15 additions and 3 deletions

View File

@@ -102,10 +102,15 @@ void PlotView::cursorsMoved()
horizontalScrollBar()->value() + cursors.selection().maximum * samplesPerLine()
};
emitTimeSelection();
viewport()->update();
}
void PlotView::emitTimeSelection()
{
off_t sampleCount = selectedSamples.length();
float selectionTime = sampleCount / (float)mainSampleSource->rate();
emit timeSelectionChanged(selectionTime);
viewport()->update();
}
void PlotView::enableCursors(bool enabled)
@@ -196,9 +201,15 @@ void PlotView::repaint()
void PlotView::setCursorSegments(int segments)
{
// Calculate number of samples per segment
float sampPerSeg = (float)selectedSamples.length() / cursors.segments();
// Alter selection to keep samples per segment the same
selectedSamples.maximum = selectedSamples.minimum + (segments * sampPerSeg + 0.5f);
cursors.setSegments(segments);
cursorsMoved();
viewport()->update();
updateView();
emitTimeSelection();
}
void PlotView::setFFTAndZoom(int size, int zoom)