From ff8cce37b69c8ea48399e42a7a36485eaf83e420 Mon Sep 17 00:00:00 2001 From: Bjorn Terelius Date: Thu, 11 Apr 2019 18:34:01 +0200 Subject: [PATCH] Add flag to enable shared x-axis for local event log visualization. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: None Change-Id: I4aea047c905aa8acbe25fd325bc92bb65b8d0826 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132557 Reviewed-by: Mirko Bonadei Commit-Queue: Björn Terelius Cr-Commit-Position: refs/heads/master@{#27583} --- rtc_tools/event_log_visualizer/main.cc | 8 +++++++- rtc_tools/event_log_visualizer/plot_python.cc | 15 +++++++++------ rtc_tools/event_log_visualizer/plot_python.h | 5 ++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/rtc_tools/event_log_visualizer/main.cc b/rtc_tools/event_log_visualizer/main.cc index 7992b1c9aa..25e5bfb19b 100644 --- a/rtc_tools/event_log_visualizer/main.cc +++ b/rtc_tools/event_log_visualizer/main.cc @@ -214,6 +214,12 @@ WEBRTC_DEFINE_bool( true, "Normalize the log timestamps so that the call starts at time 0."); +WEBRTC_DEFINE_bool(shared_xaxis, + false, + "Share x-axis between all plots so that zooming in one plot " + "updates all the others too. A downside is that certain " + "operations like panning become much slower."); + WEBRTC_DEFINE_bool(protobuf_output, false, "Output charts as protobuf instead of python code."); @@ -294,7 +300,7 @@ int main(int argc, char* argv[]) { if (FLAG_protobuf_output) { collection.reset(new webrtc::ProtobufPlotCollection()); } else { - collection.reset(new webrtc::PythonPlotCollection()); + collection.reset(new webrtc::PythonPlotCollection(FLAG_shared_xaxis)); } if (FLAG_plot_incoming_packet_sizes) { diff --git a/rtc_tools/event_log_visualizer/plot_python.cc b/rtc_tools/event_log_visualizer/plot_python.cc index 2efb1f1ea0..499fd43c2c 100644 --- a/rtc_tools/event_log_visualizer/plot_python.cc +++ b/rtc_tools/event_log_visualizer/plot_python.cc @@ -158,7 +158,8 @@ void PythonPlot::Draw() { } } -PythonPlotCollection::PythonPlotCollection() {} +PythonPlotCollection::PythonPlotCollection(bool shared_xaxis) + : shared_xaxis_(shared_xaxis) {} PythonPlotCollection::~PythonPlotCollection() {} @@ -170,11 +171,13 @@ void PythonPlotCollection::Draw() { printf("import colorsys\n"); for (size_t i = 0; i < plots_.size(); i++) { printf("plt.figure(%zu)\n", i); - // Link x-axes across all figures for synchronized zooming. - if (i == 0) { - printf("axis0 = plt.subplot(111)\n"); - } else { - printf("plt.subplot(111, sharex=axis0)\n"); + if (shared_xaxis_) { + // Link x-axes across all figures for synchronized zooming. + if (i == 0) { + printf("axis0 = plt.subplot(111)\n"); + } else { + printf("plt.subplot(111, sharex=axis0)\n"); + } } plots_[i]->Draw(); } diff --git a/rtc_tools/event_log_visualizer/plot_python.h b/rtc_tools/event_log_visualizer/plot_python.h index 61d17a0de3..23a0a92da5 100644 --- a/rtc_tools/event_log_visualizer/plot_python.h +++ b/rtc_tools/event_log_visualizer/plot_python.h @@ -23,10 +23,13 @@ class PythonPlot final : public Plot { class PythonPlotCollection final : public PlotCollection { public: - PythonPlotCollection(); + explicit PythonPlotCollection(bool shared_xaxis = false); ~PythonPlotCollection() override; void Draw() override; Plot* AppendNewPlot() override; + + private: + bool shared_xaxis_; }; } // namespace webrtc