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_RTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ | 10 #ifndef WEBRTC_RTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 style = other.style; | 46 style = other.style; |
47 points = std::move(other.points); | 47 points = std::move(other.points); |
48 return *this; | 48 return *this; |
49 } | 49 } |
50 | 50 |
51 std::string label; | 51 std::string label; |
52 PlotStyle style; | 52 PlotStyle style; |
53 std::vector<TimeSeriesPoint> points; | 53 std::vector<TimeSeriesPoint> points; |
54 }; | 54 }; |
55 | 55 |
| 56 struct Interval { |
| 57 Interval() = default; |
| 58 Interval(double begin, double end) : begin(begin), end(end) {} |
| 59 |
| 60 double begin; |
| 61 double end; |
| 62 }; |
| 63 |
| 64 struct IntervalSeries { |
| 65 enum Orientation { kHorizontal, kVertical }; |
| 66 |
| 67 IntervalSeries() = default; |
| 68 IntervalSeries(const std::string& label, |
| 69 const std::string& color, |
| 70 IntervalSeries::Orientation orientation) |
| 71 : label(label), color(color), orientation(orientation) {} |
| 72 |
| 73 std::string label; |
| 74 std::string color; |
| 75 Orientation orientation; |
| 76 std::vector<Interval> intervals; |
| 77 }; |
| 78 |
56 // A container that represents a general graph, with axes, title and one or | 79 // A container that represents a general graph, with axes, title and one or |
57 // more data series. A subclass should define the output format by overriding | 80 // more data series. A subclass should define the output format by overriding |
58 // the Draw() method. | 81 // the Draw() method. |
59 class Plot { | 82 class Plot { |
60 public: | 83 public: |
61 virtual ~Plot() {} | 84 virtual ~Plot() {} |
62 | 85 |
63 // Overloaded to draw the plot. | 86 // Overloaded to draw the plot. |
64 virtual void Draw() = 0; | 87 virtual void Draw() = 0; |
65 | 88 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 std::string label, | 125 std::string label, |
103 float bottom_margin = 0, | 126 float bottom_margin = 0, |
104 float top_margin = 0); | 127 float top_margin = 0); |
105 | 128 |
106 // Sets the title of the plot. | 129 // Sets the title of the plot. |
107 void SetTitle(std::string title); | 130 void SetTitle(std::string title); |
108 | 131 |
109 // Add a new TimeSeries to the plot. | 132 // Add a new TimeSeries to the plot. |
110 void AppendTimeSeries(TimeSeries&& time_series); | 133 void AppendTimeSeries(TimeSeries&& time_series); |
111 | 134 |
| 135 // Add a new IntervalSeries to the plot. |
| 136 void AppendIntervalSeries(IntervalSeries&& interval_series); |
| 137 |
112 // Add a new TimeSeries to the plot if the series contains contains data. | 138 // Add a new TimeSeries to the plot if the series contains contains data. |
113 // Otherwise, the call has no effect and the timeseries is destroyed. | 139 // Otherwise, the call has no effect and the timeseries is destroyed. |
114 void AppendTimeSeriesIfNotEmpty(TimeSeries&& time_series); | 140 void AppendTimeSeriesIfNotEmpty(TimeSeries&& time_series); |
115 | 141 |
116 protected: | 142 protected: |
117 float xaxis_min_; | 143 float xaxis_min_; |
118 float xaxis_max_; | 144 float xaxis_max_; |
119 std::string xaxis_label_; | 145 std::string xaxis_label_; |
120 float yaxis_min_; | 146 float yaxis_min_; |
121 float yaxis_max_; | 147 float yaxis_max_; |
122 std::string yaxis_label_; | 148 std::string yaxis_label_; |
123 std::string title_; | 149 std::string title_; |
124 std::vector<TimeSeries> series_list_; | 150 std::vector<TimeSeries> series_list_; |
| 151 std::vector<IntervalSeries> interval_list_; |
125 }; | 152 }; |
126 | 153 |
127 class PlotCollection { | 154 class PlotCollection { |
128 public: | 155 public: |
129 virtual ~PlotCollection() {} | 156 virtual ~PlotCollection() {} |
130 virtual void Draw() = 0; | 157 virtual void Draw() = 0; |
131 virtual Plot* AppendNewPlot() = 0; | 158 virtual Plot* AppendNewPlot() = 0; |
132 | 159 |
133 protected: | 160 protected: |
134 std::vector<std::unique_ptr<Plot> > plots_; | 161 std::vector<std::unique_ptr<Plot> > plots_; |
135 }; | 162 }; |
136 | 163 |
137 } // namespace plotting | 164 } // namespace plotting |
138 } // namespace webrtc | 165 } // namespace webrtc |
139 | 166 |
140 #endif // WEBRTC_RTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ | 167 #endif // WEBRTC_RTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
OLD | NEW |