From 6bcc576b5fbcc869f2db39af32f276366d71a0b4 Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Wed, 21 Jul 2021 08:34:43 +0200 Subject: [PATCH] truncate model name --- src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 7 ++++++- tests/libslic3r/test_indexed_triangle_set.cpp | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index 07a08de9c..fc53490d7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -46,11 +46,13 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi { const int min_triangle_count = 4; // tetrahedron // GUI size constants + // TODO: calculate from translation text sizes const int top_left_width = 100; const int bottom_left_width = 100; const int input_width = 100; const int input_small_width = 80; const int window_offset = 100; + const int max_char_in_name = 25; int flag = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse; @@ -85,7 +87,10 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Mesh name") + ":"); ImGui::SameLine(top_left_width); - m_imgui->text(volume->name); + std::string name = volume->name; + if (name.length() > max_char_in_name) + name = name.substr(0, max_char_in_name-3) + "..."; + m_imgui->text(name); m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Triangles") + ":"); ImGui::SameLine(top_left_width); m_imgui->text(std::to_string(triangle_count)); diff --git a/tests/libslic3r/test_indexed_triangle_set.cpp b/tests/libslic3r/test_indexed_triangle_set.cpp index 195c32003..b640d8410 100644 --- a/tests/libslic3r/test_indexed_triangle_set.cpp +++ b/tests/libslic3r/test_indexed_triangle_set.cpp @@ -233,8 +233,7 @@ TEST_CASE("Reduce one edge by Quadric Edge Collapse", "[its]") #include "test_utils.hpp" TEST_CASE("Simplify mesh by Quadric edge collapse to 5%", "[its]") { - TriangleMesh mesh = load_model("frog_legs.obj"); - //TriangleMesh mesh; load_obj("C:/Users/filip/Documents/models/scarecrow_torso.obj", &mesh); + TriangleMesh mesh = load_model("frog_legs.obj"); double original_volume = its_volume(mesh.its); uint32_t wanted_count = mesh.its.indices.size() * 0.05; REQUIRE_FALSE(mesh.empty());