diff options
author | Yordan Karadzhov (VMware) <y.karadz@gmail.com> | 2020-12-09 15:45:28 +0200 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2020-12-22 10:53:53 -0500 |
commit | 737c50f0b4d9764a3e6a246b33b5dc40700f35a7 (patch) | |
tree | 8dc9c696ffb960bdd83987df97eddf7fdb82d244 | |
parent | f994d53c7cbfd26bfa7007dd426caf702ffff814 (diff) | |
download | kernel-shark-737c50f0b4d9764a3e6a246b33b5dc40700f35a7.tar.gz |
kernel-shark: Add class Polyline to KsPlot namespace
This is a simple plotting class that represents a poly-line.
Link: https://lore.kernel.org/linux-trace-devel/20201209134530.428368-9-y.karadz@gmail.com
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | src/KsPlotTools.cpp | 14 | ||||
-rw-r--r-- | src/KsPlotTools.hpp | 16 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/KsPlotTools.cpp b/src/KsPlotTools.cpp index 529f737d..9f983864 100644 --- a/src/KsPlotTools.cpp +++ b/src/KsPlotTools.cpp @@ -504,6 +504,20 @@ void Line::_draw(const Color &col, float size) const } /** + * @brief Create a default polyline. All points are initialized at (0, 0). + * + * @param n: The number of points connected by the polyline. + */ +Polyline::Polyline(size_t n) +: Shape(n) +{} + +void Polyline::_draw(const Color &col, float size) const +{ + ksplot_draw_polyline(_points, _nPoints, col.color_c_ptr(), size); +} + +/** * @brief Create a default polygon. All points are initialized at (0, 0). * * @param n: The number of edges of the polygon. diff --git a/src/KsPlotTools.hpp b/src/KsPlotTools.hpp index 5ce8f6fc..4a7ca0a6 100644 --- a/src/KsPlotTools.hpp +++ b/src/KsPlotTools.hpp @@ -253,6 +253,22 @@ private: void _draw(const Color &col, float size = 1.) const override; }; +/** This class represents a polyline. */ +class Polyline : public Shape { +public: + Polyline(size_t n); + + /** + * @brief Destroy the polyline object. Keep this destructor virtual. + */ + virtual ~Polyline() {} + +private: + Polyline() = delete; + + void _draw(const Color &, float size = 1.) const override; +}; + /** This class represents a polygon. */ class Polygon : public Shape { public: |