Index: webrtc/tools/event_log_visualizer/plot_base.h |
diff --git a/webrtc/tools/event_log_visualizer/plot_base.h b/webrtc/tools/event_log_visualizer/plot_base.h |
index 925dcecf3db1546cc684ff5d5b0500f101670713..2d948fcb70d87cd8870696d8e50c7c43ea5e02c8 100644 |
--- a/webrtc/tools/event_log_visualizer/plot_base.h |
+++ b/webrtc/tools/event_log_visualizer/plot_base.h |
@@ -10,11 +10,14 @@ |
#ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
#define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
+#include <algorithm> |
danilchap
2016/07/27 08:39:07
with implementation moved to .cc this include can
terelius
2016/07/28 15:23:04
Done.
|
#include <memory> |
#include <string> |
#include <utility> |
#include <vector> |
+#include "webrtc/base/checks.h" |
danilchap
2016/07/27 08:39:07
and this one too
terelius
2016/07/28 15:23:04
Done.
|
+ |
namespace webrtc { |
namespace plotting { |
@@ -44,32 +47,79 @@ struct TimeSeries { |
std::vector<TimeSeriesPoint> points; |
}; |
-// This is basically a struct that represents of a general graph, with axes, |
-// title and one or more data series. We make it a class only to document that |
-// it also specifies an interface for the draw()ing objects. |
+// A container that represents a general graph, with axes, title and one or |
+// more data series. A subclass should define the output format by overriding |
+// the Draw() method. |
class Plot { |
public: |
virtual ~Plot() {} |
- virtual void draw() = 0; |
- |
- float xaxis_min; |
- float xaxis_max; |
- std::string xaxis_label; |
- float yaxis_min; |
- float yaxis_max; |
- std::string yaxis_label; |
- std::vector<TimeSeries> series; |
- std::string title; |
+ |
+ // Overloaded to draw the plot. |
+ virtual void Draw() = 0; |
+ |
+ // Sets the lower x-axis limit to min_value (if left_margin == 0). |
+ // Sets the upper x-axis limit to max_value (if right_margin == 0). |
+ // The margins are measured as fractions of the interval |
+ // (max_value - min_value) and are added to either side of the plot. |
+ void SetXAxis(float min_value, |
+ float max_value, |
+ std::string label, |
+ float left_margin = 0, |
+ float right_margin = 0); |
+ |
+ // Sets the lower and upper x-axis limits based on min_value and max_value, |
+ // but modified such that all points in the data series can be represented |
+ // on the x-axis. The margins are measured as fractions of the range of |
+ // x-values and are added to either side of the plot. |
+ void SetSuggestedXAxis(float min_value, |
+ float max_value, |
+ std::string label, |
+ float left_margin = 0, |
+ float right_margin = 0); |
+ |
+ // Sets the lower y-axis limit to min_value (if bottom_margin == 0). |
+ // Sets the upper y-axis limit to max_value (if top_margin == 0). |
+ // The margins are measured as fractions of the interval |
+ // (max_value - min_value) and are added to either side of the plot. |
+ void SetYAxis(float min_value, |
+ float max_value, |
+ std::string label, |
+ float bottom_margin = 0, |
+ float top_margin = 0); |
+ |
+ // Sets the lower and upper y-axis limits based on min_value and max_value, |
+ // but modified such that all points in the data series can be represented |
+ // on the y-axis. The margins are measured as fractions of the range of |
+ // y-values and are added to either side of the plot. |
+ void SetSuggestedYAxis(float min_value, |
+ float max_value, |
+ std::string label, |
+ float bottom_margin = 0, |
+ float top_margin = 0); |
+ |
+ // Sets the title of the plot. |
+ void SetTitle(std::string title); |
+ |
+ std::vector<TimeSeries> series_list_; |
+ |
+ protected: |
+ float xaxis_min_; |
+ float xaxis_max_; |
+ std::string xaxis_label_; |
+ float yaxis_min_; |
+ float yaxis_max_; |
+ std::string yaxis_label_; |
+ std::string title_; |
}; |
class PlotCollection { |
public: |
virtual ~PlotCollection() {} |
- virtual void draw() = 0; |
- virtual Plot* append_new_plot() = 0; |
+ virtual void Draw() = 0; |
+ virtual Plot* AppendNewPlot() = 0; |
protected: |
- std::vector<std::unique_ptr<Plot> > plots; |
+ std::vector<std::unique_ptr<Plot> > plots_; |
}; |
} // namespace plotting |