mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 04:50:37 +08:00
Fix mirroring for embossed text
This commit is contained in:
parent
95178a2ba3
commit
0e41e2aaca
@ -397,7 +397,13 @@ ModelVolumePtrs prepare_volumes_to_slice(const ModelVolume &mv)
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TransformationType get_transformation_type(const Selection &selection)
|
||||||
|
{
|
||||||
|
assert(selection.is_single_full_object() || selection.is_single_volume());
|
||||||
|
return selection.is_single_volume() ? TransformationType::Local_Relative_Joint : TransformationType::Instance_Relative_Joint; // object
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool GLGizmoEmboss::do_mirror(size_t axis)
|
bool GLGizmoEmboss::do_mirror(size_t axis)
|
||||||
{
|
{
|
||||||
@ -411,32 +417,47 @@ bool GLGizmoEmboss::do_mirror(size_t axis)
|
|||||||
if (m_parent.get_gizmos_manager().get_current_type() != GLGizmosManager::Emboss)
|
if (m_parent.get_gizmos_manager().get_current_type() != GLGizmosManager::Emboss)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const TextConfiguration &tc= *m_volume->text_configuration;
|
const std::optional<TextConfiguration> &tc = m_volume->text_configuration;
|
||||||
if(tc.style.prop.per_glyph){
|
assert(tc.has_value());
|
||||||
// init textlines before mirroring on mirrored text volume transformation
|
bool is_per_glyph = tc.has_value()? tc->style.prop.per_glyph : false;
|
||||||
|
|
||||||
|
const std::optional<EmbossShape> &es = m_volume->emboss_shape;
|
||||||
|
assert(es.has_value());
|
||||||
|
bool use_surface = es.has_value()? es->projection.use_surface : false;
|
||||||
|
if (!use_surface && !is_per_glyph) {
|
||||||
|
// do normal mirror with fix matrix
|
||||||
|
Selection &selection = m_parent.get_selection();
|
||||||
|
selection.setup_cache();
|
||||||
|
|
||||||
|
auto selection_mirror_fnc = [&selection, &axis]() { selection.mirror((Axis) axis, get_transformation_type(selection)); };
|
||||||
|
selection_transform(selection, selection_mirror_fnc, m_volume);
|
||||||
|
|
||||||
|
m_parent.do_mirror(L("Set Mirror"));
|
||||||
|
wxGetApp().obj_manipul()->UpdateAndShow(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3d scale = Vec3d::Ones();
|
||||||
|
scale[axis] = -1.;
|
||||||
|
|
||||||
Transform3d tr = m_volume->get_matrix();
|
Transform3d tr = m_volume->get_matrix();
|
||||||
if (m_volume->emboss_shape.has_value()) {
|
if (es.has_value()) {
|
||||||
const std::optional<Transform3d> &fix_tr = m_volume->emboss_shape->fix_3mf_tr;
|
const std::optional<Transform3d> &fix_tr = es->fix_3mf_tr;
|
||||||
if (fix_tr.has_value())
|
if (fix_tr.has_value())
|
||||||
tr = tr * (fix_tr->inverse());
|
tr = tr * (fix_tr->inverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
// mirror
|
// mirror
|
||||||
Vec3d scale = Vec3d::Ones();
|
|
||||||
scale[axis] = -1.;
|
|
||||||
tr = tr * Eigen::Scaling(scale);
|
tr = tr * Eigen::Scaling(scale);
|
||||||
|
|
||||||
// collect volumes in object
|
if (is_per_glyph) {
|
||||||
|
// init textlines before mirroring on mirrored text volume transformation
|
||||||
ModelVolumePtrs volumes = prepare_volumes_to_slice(*m_volume);
|
ModelVolumePtrs volumes = prepare_volumes_to_slice(*m_volume);
|
||||||
m_text_lines.init(tr, volumes, m_style_manager, m_text_lines.get_lines().size());
|
m_text_lines.init(tr, volumes, m_style_manager, m_text_lines.get_lines().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// mirror
|
|
||||||
Transform3d tr = m_volume->get_matrix();
|
|
||||||
Vec3d scale = Vec3d::Ones();
|
|
||||||
scale[axis] = -1.;
|
|
||||||
tr = tr * Eigen::Scaling(scale);
|
|
||||||
m_volume->set_transformation(tr);
|
m_volume->set_transformation(tr);
|
||||||
|
// setting to volume is not visible for user(not GLVolume)
|
||||||
// NOTE: Staff around volume transformation change is done in job finish
|
// NOTE: Staff around volume transformation change is done in job finish
|
||||||
return process();
|
return process();
|
||||||
}
|
}
|
||||||
@ -477,16 +498,6 @@ bool GLGizmoEmboss::init_create(ModelVolumeType volume_type)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
TransformationType get_transformation_type(const Selection &selection)
|
|
||||||
{
|
|
||||||
assert(selection.is_single_full_object() || selection.is_single_volume());
|
|
||||||
return selection.is_single_volume() ?
|
|
||||||
TransformationType::Local_Relative_Joint :
|
|
||||||
TransformationType::Instance_Relative_Joint; // object
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
|
bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
|
||||||
{
|
{
|
||||||
if (mouse_event.Moving()) return false;
|
if (mouse_event.Moving()) return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user