Object's properties updated while manipulating gizmos

This commit is contained in:
Enrico Turri 2018-09-05 16:22:48 +02:00
parent 42567e3af2
commit 677dad0669
5 changed files with 55 additions and 32 deletions

View File

@ -1182,10 +1182,6 @@ sub rotate {
# $self->reset_thumbnail($obj_idx);
}
if (defined $axis) {
Slic3r::GUI::update_rotation_value(deg2rad($angle), $axis == X ? "x" : ($axis == Y ? "y" : "z"));
}
# update print and start background processing
$self->{print}->add_model_object($model_object, $obj_idx);

View File

@ -3130,6 +3130,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
v->set_offset(v->get_offset() + Vec3d(vector(0), vector(1), 0.0));
}
update_position_values(volume->get_offset());
m_mouse.drag.start_position_3D = cur_pos;
m_gizmos.refresh();
@ -3169,6 +3170,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
for (GLVolume* v : volumes)
{
v->set_scaling_factor((double)scale_factor);
update_scale_values((double)scale_factor);
}
break;
}
@ -3179,6 +3181,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
for (GLVolume* v : volumes)
{
v->set_rotation((double)angle_z);
update_rotation_value((double)angle_z, Z);
}
break;
}
@ -3195,8 +3198,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
const Vec3d& size = bb.size();
m_on_update_geometry_info_callback.call(size(0), size(1), size(2), m_gizmos.get_scale());
update_scale_values(size, m_gizmos.get_scale());
update_rotation_value(volumes[0]->get_rotation(), "z");
}
if ((m_gizmos.get_current_type() != Gizmos::Rotate) && (volumes.size() > 1))
@ -3297,7 +3298,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
case Gizmos::Scale:
{
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
Slic3r::GUI::update_settings_value();
break;
}
case Gizmos::Rotate:
@ -3309,6 +3309,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
break;
}
m_gizmos.stop_dragging();
Slic3r::GUI::update_settings_value();
}
m_mouse.drag.move_volume_idx = -1;

View File

@ -1547,7 +1547,7 @@ void update_scale_values()
auto size = (*m_objects)[m_selected_object_id]->instance_bounding_box(0).size();
if (g_is_percent_scale) {
auto scale = instance->scaling_factor * 100;
auto scale = instance->scaling_factor * 100.0;
og->set_value("scale_x", int(scale));
og->set_value("scale_y", int(scale));
og->set_value("scale_z", int(scale));
@ -1569,21 +1569,31 @@ void update_position_values()
og->set_value("position_z", 0);
}
void update_scale_values(const Vec3d& size, float scaling_factor)
void update_position_values(const Vec3d& position)
{
auto og = get_optgroup(ogFrequentlyObjectSettings);
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
og->set_value("position_x", int(position(0)));
og->set_value("position_y", int(position(1)));
og->set_value("position_z", int(position(2)));
}
void update_scale_values(double scaling_factor)
{
auto og = get_optgroup(ogFrequentlyObjectSettings);
if (g_is_percent_scale) {
auto scale = scaling_factor * 100;
// this is temporary
// to be able to update the values as size
// we need to store somewhere the original size
// or have it passed as parameter
if (!g_is_percent_scale)
og->set_value("scale_unit", _("%"));
auto scale = scaling_factor * 100.0;
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(size(0) + 0.5));
og->set_value("scale_y", int(size(1) + 0.5));
og->set_value("scale_z", int(size(2) + 0.5));
}
}
void update_rotation_values()
@ -1595,14 +1605,31 @@ void update_rotation_values()
og->set_value("rotation_z", int(Geometry::rad2deg(instance->rotation)));
}
void update_rotation_value(const double angle, const std::string& axis)
void update_rotation_value(double angle, Axis axis)
{
auto og = get_optgroup(ogFrequentlyObjectSettings);
int deg = int(Geometry::rad2deg(angle));
// if (deg>180) deg -= 360;
std::string axis_str;
switch (axis)
{
case X:
{
axis_str = "rotation_x";
break;
}
case Y:
{
axis_str = "rotation_y";
break;
}
case Z:
{
axis_str = "rotation_z";
break;
}
}
og->set_value("rotation_"+axis, deg);
og->set_value(axis_str, int(Geometry::rad2deg(angle)));
}
void set_uniform_scaling(const bool uniform_scale)

View File

@ -107,14 +107,16 @@ void update_settings_value();
void set_extruder_column_hidden(bool hide);
// update extruder in current config
void update_extruder_in_config(const wxString& selection);
// update position values displacements or "gizmos"
void update_position_values();
void update_position_values(const Vec3d& position);
// update scale values after scale unit changing or "gizmos"
void update_scale_values();
void update_scale_values(const Vec3d& size, float scale);
void update_scale_values(double scaling_factor);
// update rotation values object selection changing
void update_rotation_values();
// update rotation value after "gizmos"
void update_rotation_value(const double angle, const std::string& axis);
void update_rotation_value(double angle, Axis axis);
void set_uniform_scaling(const bool uniform_scale);
void on_begin_drag(wxDataViewEvent &event);

View File

@ -155,9 +155,6 @@ void select_current_object(int idx)
void remove_obj()
%code%{ Slic3r::GUI::remove(); %};
void update_rotation_value(double angle, const char *axis)
%code%{ Slic3r::GUI::update_rotation_value(angle, axis); %};
std::string fold_utf8_to_ascii(const char *src)
%code%{ RETVAL = Slic3r::fold_utf8_to_ascii(src); %};