File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -434,13 +434,17 @@ void PlotView::setCursorSegments(int segments)
434434 selectedSamples.maximum = selectedSamples.minimum + (segments * sampPerSeg + 0 .5f );
435435
436436 cursors.setSegments (segments);
437+
437438 updateView ();
438439 emitTimeSelection ();
439440}
440441
441442void PlotView::setFFTAndZoom (int size, int zoom)
442443{
443444 auto oldSamplesPerColumn = samplesPerColumn ();
445+ float oldPlotCenter = (verticalScrollBar ()->value () + viewport ()->height () / 2.0 ) / plotsHeight ();
446+ if (verticalScrollBar ()->maximum () == 0 )
447+ oldPlotCenter = 0.5 ;
444448
445449 // Set new FFT size
446450 fftSize = size;
@@ -457,6 +461,10 @@ void PlotView::setFFTAndZoom(int size, int zoom)
457461 horizontalScrollBar ()->setPageStep (100 );
458462
459463 updateView (true , samplesPerColumn () < oldSamplesPerColumn);
464+
465+ // maintain the relative position of the vertical scroll bar
466+ if (verticalScrollBar ()->maximum ())
467+ verticalScrollBar ()->setValue ((int )(oldPlotCenter * plotsHeight () - viewport ()->height () / 2.0 + 0 .5f ));
460468}
461469
462470void PlotView::setPowerMin (int power)
@@ -613,6 +621,7 @@ void PlotView::updateView(bool reCenter, bool expanding)
613621 }
614622 horizontalScrollBar ()->setMaximum (std::max (0 , sampleToColumn (mainSampleSource->count ()) - width ()));
615623 verticalScrollBar ()->setMaximum (std::max (0 , plotsHeight () - viewport ()->height ()));
624+
616625 if (expanding) {
617626 updateViewRange (reCenter);
618627 }
You can’t perform that action at this time.
0 commit comments