Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-08-01 12:01:26 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-08-01 12:01:26 +0300
commit5f89414501f84fc7075173bb8b9c9e514ec30607 (patch)
tree7cc27baa1497a8afd2d96e6f4b47a1dd5b849b31
parent299739eeda87841d2c1779e9edfc6dcb09118b7a (diff)
parent1ca8ff1285a10d723469d6723708f32078e0693b (diff)
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer
-rw-r--r--src/slic3r/GUI/GUI_ObjectManipulation.cpp46
-rw-r--r--src/slic3r/GUI/GUI_ObjectManipulation.hpp10
2 files changed, 30 insertions, 26 deletions
diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp
index a4aa3c6d8..7dd73ece9 100644
--- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp
+++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp
@@ -286,9 +286,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn, wxBU_EXACTFIT);
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
- change_scale_value(0, 100.);
- change_scale_value(1, 100.);
- change_scale_value(2, 100.);
+ wxGetApp().plater()->take_snapshot(_(L("Reset scale")));
+ // the empty strings prevent taking another three snapshots
+ change_scale_value(0, 100., std::string());
+ change_scale_value(1, 100., std::string());
+ change_scale_value(2, 100., std::string());
});
return sizer;
};
@@ -323,7 +325,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
selection.synchronize_unselected_instances(Selection::SYNC_ROTATION_GENERAL);
selection.synchronize_unselected_volumes();
// Copy rotation values from GLVolumes into Model (ModelInstance / ModelVolume), trigger background processing.
- canvas->do_rotate(L("Set Rotation"));
+ canvas->do_rotate(L("Reset Rotation"));
UpdateAndShow(true);
});
@@ -350,9 +352,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
const Geometry::Transformation& instance_trafo = volume->get_instance_transformation();
Vec3d diff = m_cache.position - instance_trafo.get_matrix(true).inverse() * Vec3d(0., 0., get_volume_min_z(volume));
- change_position_value(0, diff.x());
- change_position_value(1, diff.y());
- change_position_value(2, diff.z());
+ // Take an undo/redo snapshot and prevent change_position_value from doing it three times.
+ wxGetApp().plater()->take_snapshot(_(L("Drop to bed")));
+ change_position_value(0, diff.x(), std::string());
+ change_position_value(1, diff.y(), std::string());
+ change_position_value(2, diff.z(), std::string());
}
});
return sizer;
@@ -697,7 +701,7 @@ void ObjectManipulation::reset_settings_value()
// m_dirty = true;
}
-void ObjectManipulation::change_position_value(int axis, double value)
+void ObjectManipulation::change_position_value(int axis, double value, const std::string& snapshot_name)
{
if (std::abs(m_cache.position_rounded(axis) - value) < EPSILON)
return;
@@ -709,14 +713,14 @@ void ObjectManipulation::change_position_value(int axis, double value)
Selection& selection = canvas->get_selection();
selection.start_dragging();
selection.translate(position - m_cache.position, selection.requires_local_axes());
- canvas->do_move(L("Set Position"));
+ canvas->do_move(snapshot_name);
m_cache.position = position;
m_cache.position_rounded(axis) = DBL_MAX;
this->UpdateAndShow(true);
}
-void ObjectManipulation::change_rotation_value(int axis, double value)
+void ObjectManipulation::change_rotation_value(int axis, double value, const std::string& snapshot_name)
{
if (std::abs(m_cache.rotation_rounded(axis) - value) < EPSILON)
return;
@@ -740,14 +744,14 @@ void ObjectManipulation::change_rotation_value(int axis, double value)
selection.rotate(
(M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation),
transformation_type);
- canvas->do_rotate(L("Set Orientation"));
+ canvas->do_rotate(snapshot_name);
m_cache.rotation = rotation;
m_cache.rotation_rounded(axis) = DBL_MAX;
this->UpdateAndShow(true);
}
-void ObjectManipulation::change_scale_value(int axis, double value)
+void ObjectManipulation::change_scale_value(int axis, double value, const std::string& snapshot_name)
{
if (std::abs(m_cache.scale_rounded(axis) - value) < EPSILON)
return;
@@ -755,7 +759,7 @@ void ObjectManipulation::change_scale_value(int axis, double value)
Vec3d scale = m_cache.scale;
scale(axis) = value;
- this->do_scale(axis, scale);
+ this->do_scale(axis, scale, snapshot_name);
m_cache.scale = scale;
m_cache.scale_rounded(axis) = DBL_MAX;
@@ -763,7 +767,7 @@ void ObjectManipulation::change_scale_value(int axis, double value)
}
-void ObjectManipulation::change_size_value(int axis, double value)
+void ObjectManipulation::change_size_value(int axis, double value, const std::string& snapshot_name)
{
if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
return;
@@ -781,14 +785,14 @@ void ObjectManipulation::change_size_value(int axis, double value)
selection.get_unscaled_instance_bounding_box().size() :
wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size();
- this->do_scale(axis, 100. * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)));
+ this->do_scale(axis, 100. * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)), snapshot_name);
m_cache.size = size;
m_cache.size_rounded(axis) = DBL_MAX;
this->UpdateAndShow(true);
}
-void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
+void ObjectManipulation::do_scale(int axis, const Vec3d &scale, const std::string& snapshot_name) const
{
Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
Vec3d scaling_factor = scale;
@@ -805,7 +809,7 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
selection.start_dragging();
selection.scale(scaling_factor * 0.01, transformation_type);
- wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale"));
+ wxGetApp().plater()->canvas3D()->do_scale(snapshot_name);
}
void ObjectManipulation::on_change(t_config_option_key opt_key, const boost::any& value)
@@ -833,13 +837,13 @@ void ObjectManipulation::on_change(t_config_option_key opt_key, const boost::any
double new_value = boost::any_cast<double>(m_og->get_value(opt_key));
if (boost::starts_with(opt_key, "position_"))
- change_position_value(axis, new_value);
+ change_position_value(axis, new_value, L("Set Position"));
else if (boost::starts_with(opt_key, "rotation_"))
- change_rotation_value(axis, new_value);
+ change_rotation_value(axis, new_value, L("Set Orientation"));
else if (boost::starts_with(opt_key, "scale_"))
- change_scale_value(axis, new_value);
+ change_scale_value(axis, new_value, L("Set Scale"));
else if (boost::starts_with(opt_key, "size_"))
- change_size_value(axis, new_value);
+ change_size_value(axis, new_value, L("Set Scale"));
}
void ObjectManipulation::on_fill_empty_value(const std::string& opt_key)
diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.hpp b/src/slic3r/GUI/GUI_ObjectManipulation.hpp
index e4e190b5b..bda7aa55f 100644
--- a/src/slic3r/GUI/GUI_ObjectManipulation.hpp
+++ b/src/slic3r/GUI/GUI_ObjectManipulation.hpp
@@ -135,11 +135,11 @@ private:
void update_mirror_buttons_visibility();
// change values
- void change_position_value(int axis, double value);
- void change_rotation_value(int axis, double value);
- void change_scale_value(int axis, double value);
- void change_size_value(int axis, double value);
- void do_scale(int axis, const Vec3d &scale) const;
+ void change_position_value(int axis, double value, const std::string& snapshot_name);
+ void change_rotation_value(int axis, double value, const std::string& snapshot_name);
+ void change_scale_value(int axis, double value, const std::string& snapshot_name);
+ void change_size_value(int axis, double value, const std::string& snapshot_name);
+ void do_scale(int axis, const Vec3d &scale, const std::string& snapshot_name) const;
void on_change(t_config_option_key opt_key, const boost::any& value);
void on_fill_empty_value(const std::string& opt_key);