diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-02-06 19:51:11 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-02-06 19:51:11 -0500 |
commit | 15664543675da132f825a4e8e372d2c6b9f3aec4 (patch) | |
tree | 3c509aab1988a705868c0f378c2bd10f877cd792 /gr-qtgui/lib/TimeDomainDisplayPlot.cc | |
parent | b6f0e19eec09066f16c6f4f91ae872985c0f34ba (diff) |
qtgui: adding auto scaling to other plotters.
Diffstat (limited to 'gr-qtgui/lib/TimeDomainDisplayPlot.cc')
-rw-r--r-- | gr-qtgui/lib/TimeDomainDisplayPlot.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 1f63b43abd..0e0b691eea 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -207,6 +207,22 @@ TimeDomainDisplayPlot::plotNewData(const std::vector<double*> dataPoints, memcpy(_dataPoints[i], dataPoints[i], numDataPoints*sizeof(double)); } + + if(_autoscale_state) { + double bottom=1e20, top=-1e20; + for(int n = 0; n < _nplots; n++) { + for(int64_t point = 0; point < numDataPoints; point++) { + if(dataPoints[n][point] < bottom) { + bottom = dataPoints[n][point]; + } + if(dataPoints[n][point] > top) { + top = dataPoints[n][point]; + } + } + } + _autoScale(bottom, top); + } + replot(); } } @@ -231,6 +247,19 @@ void TimeDomainDisplayPlot::_resetXAxisPoints() } void +TimeDomainDisplayPlot::_autoScale(double bottom, double top) +{ + // Auto scale the y-axis with a margin of 20% + setYaxis(bottom - fabs(bottom)*0.20, top + fabs(top)*0.20); +} + +void +TimeDomainDisplayPlot::setAutoScale(bool state) +{ + _autoscale_state = state; +} + +void TimeDomainDisplayPlot::setSampleRate(double sr, double units, const std::string &strunits) { |