summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib/TimeDomainDisplayPlot.cc
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-02-06 19:51:11 -0500
committerTom Rondeau <trondeau@vt.edu>2013-02-06 19:51:11 -0500
commit15664543675da132f825a4e8e372d2c6b9f3aec4 (patch)
tree3c509aab1988a705868c0f378c2bd10f877cd792 /gr-qtgui/lib/TimeDomainDisplayPlot.cc
parentb6f0e19eec09066f16c6f4f91ae872985c0f34ba (diff)
qtgui: adding auto scaling to other plotters.
Diffstat (limited to 'gr-qtgui/lib/TimeDomainDisplayPlot.cc')
-rw-r--r--gr-qtgui/lib/TimeDomainDisplayPlot.cc29
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)
{