OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
| 11 #define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
| 12 |
| 13 #include <memory> |
| 14 #include <string> |
| 15 #include <utility> |
| 16 #include <vector> |
| 17 |
| 18 namespace webrtc { |
| 19 namespace plotting { |
| 20 |
| 21 enum PlotStyle { LINE_GRAPH, BAR_GRAPH }; |
| 22 |
| 23 struct TimeSeriesPoint { |
| 24 TimeSeriesPoint(float x, float y) : x(x), y(y) {} |
| 25 TimeSeriesPoint(float x, float y, std::string message) |
| 26 : x(x), y(y), message(message) {} |
| 27 float x; |
| 28 float y; |
| 29 std::string message; |
| 30 }; |
| 31 |
| 32 struct TimeSeries { |
| 33 TimeSeries() = default; |
| 34 TimeSeries(TimeSeries&& other) |
| 35 : label(std::move(other.label)), |
| 36 style(other.style), |
| 37 points(std::move(other.points)) {} |
| 38 TimeSeries& operator=(TimeSeries&& other) { |
| 39 label = std::move(other.label); |
| 40 style = other.style; |
| 41 points = std::move(other.points); |
| 42 return *this; |
| 43 } |
| 44 |
| 45 std::string label; |
| 46 PlotStyle style; |
| 47 std::vector<TimeSeriesPoint> points; |
| 48 }; |
| 49 |
| 50 // This is basically a struct that represents of a general graph, with axes, |
| 51 // title and one or more data series. We make it a class only to document that |
| 52 // it also specifies an interface for the draw()ing objects. |
| 53 class Plot { |
| 54 public: |
| 55 virtual ~Plot() {} |
| 56 virtual void draw() = 0; |
| 57 |
| 58 float xaxis_min; |
| 59 float xaxis_max; |
| 60 std::string xaxis_label; |
| 61 float yaxis_min; |
| 62 float yaxis_max; |
| 63 std::string yaxis_label; |
| 64 std::vector<TimeSeries> series; |
| 65 std::string title; |
| 66 }; |
| 67 |
| 68 class PlotCollection { |
| 69 public: |
| 70 virtual ~PlotCollection() {} |
| 71 virtual void draw() = 0; |
| 72 virtual Plot* append_new_plot() = 0; |
| 73 |
| 74 protected: |
| 75 std::vector<std::unique_ptr<Plot> > plots; |
| 76 }; |
| 77 |
| 78 } // namespace plotting |
| 79 } // namespace webrtc |
| 80 |
| 81 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
OLD | NEW |