OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ | 10 #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
(...skipping 26 matching lines...) Expand all Loading... |
37 style = other.style; | 37 style = other.style; |
38 points = std::move(other.points); | 38 points = std::move(other.points); |
39 return *this; | 39 return *this; |
40 } | 40 } |
41 | 41 |
42 std::string label; | 42 std::string label; |
43 PlotStyle style; | 43 PlotStyle style; |
44 std::vector<TimeSeriesPoint> points; | 44 std::vector<TimeSeriesPoint> points; |
45 }; | 45 }; |
46 | 46 |
47 // This is basically a struct that represents of a general graph, with axes, | 47 // A container that represents a general graph, with axes, title and one or |
48 // title and one or more data series. We make it a class only to document that | 48 // more data series. A subclass should define the output format by overriding |
49 // it also specifies an interface for the draw()ing objects. | 49 // the Draw() method. |
50 class Plot { | 50 class Plot { |
51 public: | 51 public: |
52 virtual ~Plot() {} | 52 virtual ~Plot() {} |
53 virtual void draw() = 0; | |
54 | 53 |
55 float xaxis_min; | 54 // Overloaded to draw the plot. |
56 float xaxis_max; | 55 virtual void Draw() = 0; |
57 std::string xaxis_label; | 56 |
58 float yaxis_min; | 57 // Sets the lower x-axis limit to min_value (if left_margin == 0). |
59 float yaxis_max; | 58 // Sets the upper x-axis limit to max_value (if right_margin == 0). |
60 std::string yaxis_label; | 59 // The margins are measured as fractions of the interval |
61 std::vector<TimeSeries> series; | 60 // (max_value - min_value) and are added to either side of the plot. |
62 std::string title; | 61 void SetXAxis(float min_value, |
| 62 float max_value, |
| 63 std::string label, |
| 64 float left_margin = 0, |
| 65 float right_margin = 0); |
| 66 |
| 67 // Sets the lower and upper x-axis limits based on min_value and max_value, |
| 68 // but modified such that all points in the data series can be represented |
| 69 // on the x-axis. The margins are measured as fractions of the range of |
| 70 // x-values and are added to either side of the plot. |
| 71 void SetSuggestedXAxis(float min_value, |
| 72 float max_value, |
| 73 std::string label, |
| 74 float left_margin = 0, |
| 75 float right_margin = 0); |
| 76 |
| 77 // Sets the lower y-axis limit to min_value (if bottom_margin == 0). |
| 78 // Sets the upper y-axis limit to max_value (if top_margin == 0). |
| 79 // The margins are measured as fractions of the interval |
| 80 // (max_value - min_value) and are added to either side of the plot. |
| 81 void SetYAxis(float min_value, |
| 82 float max_value, |
| 83 std::string label, |
| 84 float bottom_margin = 0, |
| 85 float top_margin = 0); |
| 86 |
| 87 // Sets the lower and upper y-axis limits based on min_value and max_value, |
| 88 // but modified such that all points in the data series can be represented |
| 89 // on the y-axis. The margins are measured as fractions of the range of |
| 90 // y-values and are added to either side of the plot. |
| 91 void SetSuggestedYAxis(float min_value, |
| 92 float max_value, |
| 93 std::string label, |
| 94 float bottom_margin = 0, |
| 95 float top_margin = 0); |
| 96 |
| 97 // Sets the title of the plot. |
| 98 void SetTitle(std::string title); |
| 99 |
| 100 std::vector<TimeSeries> series_list_; |
| 101 |
| 102 protected: |
| 103 float xaxis_min_; |
| 104 float xaxis_max_; |
| 105 std::string xaxis_label_; |
| 106 float yaxis_min_; |
| 107 float yaxis_max_; |
| 108 std::string yaxis_label_; |
| 109 std::string title_; |
63 }; | 110 }; |
64 | 111 |
65 class PlotCollection { | 112 class PlotCollection { |
66 public: | 113 public: |
67 virtual ~PlotCollection() {} | 114 virtual ~PlotCollection() {} |
68 virtual void draw() = 0; | 115 virtual void Draw() = 0; |
69 virtual Plot* append_new_plot() = 0; | 116 virtual Plot* AppendNewPlot() = 0; |
70 | 117 |
71 protected: | 118 protected: |
72 std::vector<std::unique_ptr<Plot> > plots; | 119 std::vector<std::unique_ptr<Plot> > plots_; |
73 }; | 120 }; |
74 | 121 |
75 } // namespace plotting | 122 } // namespace plotting |
76 } // namespace webrtc | 123 } // namespace webrtc |
77 | 124 |
78 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ | 125 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
OLD | NEW |