diff --git a/src/libslic3r/Emboss.cpp b/src/libslic3r/Emboss.cpp index 5358b9c127..827499eb93 100644 --- a/src/libslic3r/Emboss.cpp +++ b/src/libslic3r/Emboss.cpp @@ -639,6 +639,19 @@ ExPolygons Emboss::text2shapes(FontFile & font, return Private::dilate_to_unique_points(result); } +void Emboss::apply_transformation(const FontProp &font_prop, + Transform3d &transformation) +{ + if (font_prop.angle.has_value()) { + double angle_z = *font_prop.angle; + transformation *= Eigen::AngleAxisd(angle_z, Vec3d::UnitZ()); + } + if (font_prop.distance.has_value()) { + Vec3d translate = Vec3d::UnitZ() * (*font_prop.distance); + transformation.translate(translate); + } +} + bool Emboss::is_italic(FontFile &font) { std::optional font_info_opt = Private::load_font_info(font); diff --git a/src/libslic3r/Emboss.hpp b/src/libslic3r/Emboss.hpp index 6b7473fb7d..69c2893a6a 100644 --- a/src/libslic3r/Emboss.hpp +++ b/src/libslic3r/Emboss.hpp @@ -134,6 +134,15 @@ public: const char * text, const FontProp &font_prop); + /// + /// Use data from font property to modify transformation + /// + /// Z-move as surface distance(FontProp::distance) + /// Z-rotation as angle to Y axis(FontProp::angle) + /// + static void apply_transformation(const FontProp &font_prop, + Transform3d &transformation); + /// /// Read information from naming table of font file /// search for italic (or oblique), bold italic (or bold oblique) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 09f3438586..0ae36bc7b6 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -274,21 +274,11 @@ bool GLGizmoEmboss::on_mouse_for_translate(const wxMouseEvent &mouse_event) // hide common dragging of object m_parent.toggle_model_objects_visibility(false, m_volume->get_object(), gl_volume->instance_idx(), m_volume); - // Show temporary position - // TODO: store z-rotation and aply after transformation matrix + // Calculate temporary position Transform3d object_trmat = m_raycast_manager.get_transformation(hit->tr_key); Transform3d trmat = Emboss::create_transformation_onto_surface(hit->position, hit->normal); - const FontProp& font_prop = m_volume->text_configuration->font_item.prop; - if (font_prop.angle.has_value()) { - double angle_z = *font_prop.angle; - trmat *= Eigen::AngleAxisd(angle_z, Vec3d::UnitZ()); - } - if (font_prop.distance.has_value()) { - Vec3d translate = Vec3d::UnitZ() * (*font_prop.distance); - trmat.translate(translate); - } - + Emboss::apply_transformation(font_prop, trmat); m_temp_transformation = object_trmat * trmat; } else if (mouse_event.LeftUp()) { // TODO: Disable apply common transformation after draggig diff --git a/src/slic3r/GUI/Jobs/EmbossJob.cpp b/src/slic3r/GUI/Jobs/EmbossJob.cpp index 10de894858..26b3c2bf63 100644 --- a/src/slic3r/GUI/Jobs/EmbossJob.cpp +++ b/src/slic3r/GUI/Jobs/EmbossJob.cpp @@ -140,24 +140,13 @@ void EmbossCreateJob::process(Ctl &ctl) { } else { //m_transformation = Emboss::create_transformation_onto_surface(hit->position, hit->normal); assert(m_input->hit_vol_tr.has_value()); - if (m_input->hit_vol_tr.has_value()) { Transform3d object_trmat = m_input->raycast_manager->get_transformation(hit->tr_key); - const FontProp &font_prop = m_input->text_configuration.font_item.prop; - if (font_prop.angle.has_value()) { - double angle_z = *font_prop.angle; - object_trmat *= Eigen::AngleAxisd(angle_z, Vec3d::UnitZ()); - } - if (font_prop.distance.has_value()) { - Vec3d translate = Vec3d::UnitZ() * (*font_prop.distance); - object_trmat.translate(translate); - } - Transform3d surface_trmat = Emboss::create_transformation_onto_surface(hit->position, hit->normal); + Emboss::apply_transformation(font_prop, surface_trmat); m_transformation = m_input->hit_vol_tr->inverse() * object_trmat * surface_trmat; - } - + } } }