@@ -503,6 +503,20 @@ void Line::_draw(const Color &col, float size) const
col.color_c_ptr(), size);
}
+/**
+ * @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).
*
@@ -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:
This is a simple plotting class that represents a poly-line. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/KsPlotTools.cpp | 14 ++++++++++++++ src/KsPlotTools.hpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+)