From 1b934518b3a7d22ed7d751aee5a03e731c0fc1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Tue, 2 Aug 2022 13:20:54 +0200 Subject: [PATCH] Modified text drawing methods in debugging visualization (SVG) to support changing font size. --- src/libslic3r/SVG.cpp | 24 +++++++++++++----------- src/libslic3r/SVG.hpp | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/libslic3r/SVG.cpp b/src/libslic3r/SVG.cpp index 6a743b1eb..4928d5433 100644 --- a/src/libslic3r/SVG.cpp +++ b/src/libslic3r/SVG.cpp @@ -274,26 +274,28 @@ std::string SVG::get_path_d(const ClipperLib::Path &path, double scale, bool clo return d.str(); } -void SVG::draw_text(const Point &pt, const char *text, const char *color) +void SVG::draw_text(const Point &pt, const char *text, const char *color, const coordf_t font_size) { fprintf(this->f, - "%s", - to_svg_x(pt(0)-origin(0)), - to_svg_y(pt(1)-origin(1)), + R"(%s)", + to_svg_x(float(pt.x() - origin.x())), + to_svg_y(float(pt.y() - origin.y())), + font_size, color, text); } -void SVG::draw_legend(const Point &pt, const char *text, const char *color) +void SVG::draw_legend(const Point &pt, const char *text, const char *color, const coordf_t font_size) { fprintf(this->f, - "", - to_svg_x(pt(0)-origin(0)), - to_svg_y(pt(1)-origin(1)), + R"()", + to_svg_x(float(pt.x() - origin.x())), + to_svg_y(float(pt.y() - origin.y())), color); fprintf(this->f, - "%s", - to_svg_x(pt(0)-origin(0)) + 20.f, - to_svg_y(pt(1)-origin(1)), + R"(%s)", + to_svg_x(float(pt.x() - origin.x())) + 20.f, + to_svg_y(float(pt.y() - origin.y())), + font_size, "black", text); } diff --git a/src/libslic3r/SVG.hpp b/src/libslic3r/SVG.hpp index 314fae9b9..3ff2213d8 100644 --- a/src/libslic3r/SVG.hpp +++ b/src/libslic3r/SVG.hpp @@ -72,8 +72,8 @@ public: void draw(const ClipperLib::Path &polygon, double scale, std::string fill = "grey", coordf_t stroke_width = 0); void draw(const ClipperLib::Paths &polygons, double scale, std::string fill = "grey", coordf_t stroke_width = 0); - void draw_text(const Point &pt, const char *text, const char *color); - void draw_legend(const Point &pt, const char *text, const char *color); + void draw_text(const Point &pt, const char *text, const char *color, coordf_t font_size = 20.f); + void draw_legend(const Point &pt, const char *text, const char *color, coordf_t font_size = 10.f); void Close();