mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 11:45:55 +08:00
Unify place of transformation
This commit is contained in:
parent
7f73a0e73d
commit
5ffa19b529
@ -639,6 +639,19 @@ ExPolygons Emboss::text2shapes(FontFile & font,
|
|||||||
return Private::dilate_to_unique_points(result);
|
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) {
|
bool Emboss::is_italic(FontFile &font) {
|
||||||
std::optional<stbtt_fontinfo> font_info_opt =
|
std::optional<stbtt_fontinfo> font_info_opt =
|
||||||
Private::load_font_info(font);
|
Private::load_font_info(font);
|
||||||
|
@ -134,6 +134,15 @@ public:
|
|||||||
const char * text,
|
const char * text,
|
||||||
const FontProp &font_prop);
|
const FontProp &font_prop);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use data from font property to modify transformation
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="font_prop">Z-move as surface distance(FontProp::distance)
|
||||||
|
/// Z-rotation as angle to Y axis(FontProp::angle)</param>
|
||||||
|
/// <param name="transformation"></param>
|
||||||
|
static void apply_transformation(const FontProp &font_prop,
|
||||||
|
Transform3d &transformation);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read information from naming table of font file
|
/// Read information from naming table of font file
|
||||||
/// search for italic (or oblique), bold italic (or bold oblique)
|
/// search for italic (or oblique), bold italic (or bold oblique)
|
||||||
|
@ -274,21 +274,11 @@ bool GLGizmoEmboss::on_mouse_for_translate(const wxMouseEvent &mouse_event)
|
|||||||
// hide common dragging of object
|
// hide common dragging of object
|
||||||
m_parent.toggle_model_objects_visibility(false, m_volume->get_object(), gl_volume->instance_idx(), m_volume);
|
m_parent.toggle_model_objects_visibility(false, m_volume->get_object(), gl_volume->instance_idx(), m_volume);
|
||||||
|
|
||||||
// Show temporary position
|
// Calculate temporary position
|
||||||
// TODO: store z-rotation and aply after transformation matrix
|
|
||||||
Transform3d object_trmat = m_raycast_manager.get_transformation(hit->tr_key);
|
Transform3d object_trmat = m_raycast_manager.get_transformation(hit->tr_key);
|
||||||
Transform3d trmat = Emboss::create_transformation_onto_surface(hit->position, hit->normal);
|
Transform3d trmat = Emboss::create_transformation_onto_surface(hit->position, hit->normal);
|
||||||
|
|
||||||
const FontProp& font_prop = m_volume->text_configuration->font_item.prop;
|
const FontProp& font_prop = m_volume->text_configuration->font_item.prop;
|
||||||
if (font_prop.angle.has_value()) {
|
Emboss::apply_transformation(font_prop, trmat);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_temp_transformation = object_trmat * trmat;
|
m_temp_transformation = object_trmat * trmat;
|
||||||
} else if (mouse_event.LeftUp()) {
|
} else if (mouse_event.LeftUp()) {
|
||||||
// TODO: Disable apply common transformation after draggig
|
// TODO: Disable apply common transformation after draggig
|
||||||
|
@ -140,24 +140,13 @@ void EmbossCreateJob::process(Ctl &ctl) {
|
|||||||
} else {
|
} else {
|
||||||
//m_transformation = Emboss::create_transformation_onto_surface(hit->position, hit->normal);
|
//m_transformation = Emboss::create_transformation_onto_surface(hit->position, hit->normal);
|
||||||
assert(m_input->hit_vol_tr.has_value());
|
assert(m_input->hit_vol_tr.has_value());
|
||||||
|
|
||||||
if (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);
|
Transform3d object_trmat = m_input->raycast_manager->get_transformation(hit->tr_key);
|
||||||
|
|
||||||
const FontProp &font_prop = m_input->text_configuration.font_item.prop;
|
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);
|
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;
|
m_transformation = m_input->hit_vol_tr->inverse() * object_trmat * surface_trmat;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user