diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 94555f50e..0c45b70ac 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -1368,13 +1368,20 @@ void update_settings_value() { auto og = get_optgroup(ogFrequentlyObjectSettings); if (m_selected_object_id < 0 || m_objects->size() <= m_selected_object_id) { - og->set_value("scale_x", 0); + og->set_value("position_x", 0); + og->set_value("position_y", 0); + og->set_value("position_z", 0); + og->set_value("scale_x", 0); og->set_value("scale_y", 0); og->set_value("scale_z", 0); + og->set_value("rotation_x", 0); + og->set_value("rotation_y", 0); + og->set_value("rotation_z", 0); og->disable(); return; } g_is_percent_scale = boost::any_cast(og->get_value("scale_unit")) == _("%"); + update_position_values(); update_scale_values(); update_rotation_values(); og->enable(); @@ -1535,8 +1542,31 @@ void update_extruder_in_config(const wxString& selection) void update_scale_values() { - update_scale_values((*m_objects)[m_selected_object_id]->instance_bounding_box(0).size(), - (*m_objects)[m_selected_object_id]->instances[0]->scaling_factor); + auto og = get_optgroup(ogFrequentlyObjectSettings); + auto instance = (*m_objects)[m_selected_object_id]->instances.front(); + auto size = (*m_objects)[m_selected_object_id]->instance_bounding_box(0).size(); + + if (g_is_percent_scale) { + auto scale = instance->scaling_factor * 100; + og->set_value("scale_x", int(scale)); + og->set_value("scale_y", int(scale)); + og->set_value("scale_z", int(scale)); + } + else { + og->set_value("scale_x", int(instance->scaling_factor * size(0) + 0.5)); + og->set_value("scale_y", int(instance->scaling_factor * size(1) + 0.5)); + og->set_value("scale_z", int(instance->scaling_factor * size(2) + 0.5)); + } +} + +void update_position_values() +{ + auto og = get_optgroup(ogFrequentlyObjectSettings); + auto instance = (*m_objects)[m_selected_object_id]->instances.front(); + + og->set_value("position_x", int(instance->offset(0))); + og->set_value("position_y", int(instance->offset(1))); + og->set_value("position_z", 0); } void update_scale_values(const Vec3d& size, float scaling_factor) @@ -1559,15 +1589,10 @@ void update_scale_values(const Vec3d& size, float scaling_factor) void update_rotation_values() { auto og = get_optgroup(ogFrequentlyObjectSettings); - + auto instance = (*m_objects)[m_selected_object_id]->instances.front(); og->set_value("rotation_x", 0); og->set_value("rotation_y", 0); - - auto rotation_z = (*m_objects)[m_selected_object_id]->instances[0]->rotation; - auto deg = int(Geometry::rad2deg(rotation_z)); -// if (deg > 180) deg -= 360; - - og->set_value("rotation_z", deg); + og->set_value("rotation_z", int(Geometry::rad2deg(instance->rotation))); } void update_rotation_value(const double angle, const std::string& axis) diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp index 82bfe4a6c..c64dd8f22 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp @@ -107,6 +107,7 @@ void update_settings_value(); void set_extruder_column_hidden(bool hide); // update extruder in current config void update_extruder_in_config(const wxString& selection); +void update_position_values(); // update scale values after scale unit changing or "gizmos" void update_scale_values(); void update_scale_values(const Vec3d& size, float scale);