Add emboss text test

(created mainly to profile conversion)
This commit is contained in:
Filip Sykala 2022-03-25 11:06:58 +01:00
parent 1633f2c796
commit 08c6e4faec
2 changed files with 32 additions and 5 deletions

View File

@ -73,11 +73,10 @@ void EmbossUpdateJob::finalize(bool canceled, std::exception_ptr &)
GUI_App & app = wxGetApp(); // may be move to input
Plater * plater = app.plater();
ObjectList * obj_list = app.obj_list();
GLCanvas3D * canvas = plater->canvas3D();
GLGizmosManager &manager = canvas->get_gizmos_manager();
// Check emboss gizmo is still open
GLGizmosManager &manager = canvas->get_gizmos_manager();
if (manager.get_current_type() != GLGizmosManager::Emboss) return;
std::string snap_name = GUI::format(_L("Text: %1%"), m_input.text_configuration.text);
@ -110,15 +109,16 @@ void EmbossUpdateJob::finalize(bool canceled, std::exception_ptr &)
*selection.get_volume_idxs().begin());
int object_idx = gl_volume->object_idx();
int volume_idx = gl_volume->volume_idx();
ObjectList *obj_list = app.obj_list();
obj_list->update_name_in_list(object_idx, volume_idx);
// update printable state on canvas
if (volume->type() == ModelVolumeType::MODEL_PART)
canvas->update_instance_printable_state_for_object(
(size_t) object_idx);
canvas->update_instance_printable_state_for_object((size_t) object_idx);
// redraw scene
canvas->reload_scene(true);
bool refresh_immediately = false;
canvas->reload_scene(refresh_immediately);
}

View File

@ -154,6 +154,33 @@ TEST_CASE("Convert glyph % to model", "[Emboss]")
CHECK(!its.indices.empty());
}
TEST_CASE("Convert text with glyph cache to model", "[Emboss]")
{
std::string font_path = get_font_filepath();
std::string text =
"Because Ford never learned to say his original name, \n\
his father eventually died of shame, which is still \r\n\
a terminal disease in some parts of the Galaxy.\n\r\
The other kids at school nicknamed him Ix,\n\
which in the language of Betelgeuse Five translates as\t\n\
\"boy who is not able satisfactorily to explain what a Hrung is,\n\
nor why it should choose to collapse on Betelgeuse Seven\".";
float line_height = 10.f, depth = 2.f;
auto font = Emboss::create_font_file(font_path.c_str());
REQUIRE(font != nullptr);
Emboss::FontFileWithCache ffwc(std::move(font));
FontProp fp{line_height, depth};
ExPolygons shapes = Emboss::text2shapes(ffwc, text.c_str(), fp);
REQUIRE(!shapes.empty());
Emboss::ProjectZ projection(depth);
indexed_triangle_set its = Emboss::polygons2model(shapes, projection);
CHECK(!its.indices.empty());
//its_write_obj(its, "C:/data/temp/text.obj");
}
TEST_CASE("Test hit point", "[AABBTreeIndirect]")
{
indexed_triangle_set its;