diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
index 88f8ab6c81..64dc7cd1cb 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp
@@ -397,12 +397,6 @@ ModelVolumePtrs prepare_volumes_to_slice(const ModelVolume &mv)
}
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)
@@ -429,7 +423,7 @@ bool GLGizmoEmboss::do_mirror(size_t axis)
Selection &selection = m_parent.get_selection();
selection.setup_cache();
- auto selection_mirror_fnc = [&selection, &axis]() { selection.mirror((Axis) axis, get_transformation_type(selection)); };
+ auto selection_mirror_fnc = [&selection, &axis]() { selection.mirror((Axis) axis, get_drag_transformation_type(selection)); };
selection_transform(selection, selection_mirror_fnc, m_volume);
m_parent.do_mirror(L("Set Mirror"));
@@ -518,7 +512,7 @@ bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
// temporary rotation
Selection& selection = m_parent.get_selection();
- selection.rotate(Vec3d(0., 0., angle), get_transformation_type(selection));
+ selection.rotate(Vec3d(0., 0., angle), get_drag_transformation_type(selection));
angle += *m_rotate_start_angle;
// move to range <-M_PI, M_PI>
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp
index d85b0b909f..2064567ade 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp
@@ -232,16 +232,6 @@ bool GLGizmoSVG::is_svg_object(const ModelVolume &volume) {
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_Independent :
- TransformationType::Instance_Relative_Independent; // object
-}
-} // namespace
-
bool GLGizmoSVG::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
{
if (mouse_event.Moving()) return false;
@@ -265,7 +255,7 @@ bool GLGizmoSVG::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
Selection &selection = m_parent.get_selection();
auto selection_rotate_fnc = [z_rotation, &selection]() {
- selection.rotate(Vec3d(0., 0., z_rotation), get_transformation_type(selection));
+ selection.rotate(Vec3d(0., 0., z_rotation), get_drag_transformation_type(selection));
};
selection_transform(selection, selection_rotate_fnc, m_volume);
@@ -1808,7 +1798,7 @@ void GLGizmoSVG::draw_size()
selection.setup_cache();
auto selection_scale_fnc = [&selection, rel_scale = *new_relative_scale]() {
- selection.scale(rel_scale, get_transformation_type(selection));
+ selection.scale(rel_scale, get_drag_transformation_type(selection));
};
selection_transform(selection, selection_scale_fnc, m_volume);
@@ -1969,7 +1959,7 @@ void GLGizmoSVG::draw_mirroring()
selection.setup_cache();
auto selection_mirror_fnc = [&selection, &axis](){
- selection.mirror(axis, get_transformation_type(selection));
+ selection.mirror(axis, get_drag_transformation_type(selection));
};
selection_transform(selection, selection_mirror_fnc, m_volume);
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp
index 428705ff88..a83a6456b6 100644
--- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp
+++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp
@@ -175,7 +175,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
if (act_volume_ids.empty()) {
stop_worker_thread_request();
close();
- if (! m_parent.get_selection().is_single_volume()) {
+ if (m_parent.get_selection().volumes_count() != 1) {
MessageDialog msg((wxWindow*)wxGetApp().mainframe,
_L("Simplification is currently only allowed when a single part is selected"),
_L("Error"));
diff --git a/src/slic3r/GUI/SurfaceDrag.cpp b/src/slic3r/GUI/SurfaceDrag.cpp
index 251dee46cf..7f29414790 100644
--- a/src/slic3r/GUI/SurfaceDrag.cpp
+++ b/src/slic3r/GUI/SurfaceDrag.cpp
@@ -379,8 +379,9 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
assert(!selection.is_empty());
if(selection.is_empty()) return;
- assert(selection.is_single_full_object() || selection.is_single_volume());
- if (!selection.is_single_full_object() && !selection.is_single_volume()) return;
+ bool is_single_volume = selection.volumes_count() == 1;
+ assert(is_single_volume);
+ if (!is_single_volume) return;
// Fix angle for mirrored volume
bool is_mirrored = false;
@@ -391,7 +392,6 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
if (instance != nullptr)
is_mirrored = has_reflection(instance->get_matrix());
} else {
- // selection.is_single_volume()
const ModelVolume *volume = get_model_volume(*gl_volume, selection.get_model()->objects);
if (volume != nullptr)
is_mirrored = has_reflection(volume->get_matrix());
@@ -404,9 +404,9 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
selection.setup_cache();
auto selection_rotate_fnc = [&selection, &relative_angle](){
- TransformationType transformation_type = selection.is_single_volume() ?
- TransformationType::Local_Relative_Independent :
- TransformationType::Instance_Relative_Independent;
+ TransformationType transformation_type = selection.is_single_full_object() ?
+ TransformationType::Instance_Relative_Independent:
+ TransformationType::Local_Relative_Independent;
selection.rotate(Vec3d(0., 0., relative_angle), transformation_type);
};
selection_transform(selection, selection_rotate_fnc);
@@ -438,6 +438,13 @@ void do_local_z_move(GLCanvas3D &canvas, double relative_move) {
canvas.do_move(snapshot_name);
}
+TransformationType get_drag_transformation_type(const Selection &selection)
+{
+ assert(selection.volumes_count() == 1);
+ return selection.is_single_full_object() ?
+ TransformationType::Instance_Relative_Joint :
+ TransformationType::Local_Relative_Joint;
+}
} // namespace Slic3r::GUI
// private implementation
diff --git a/src/slic3r/GUI/SurfaceDrag.hpp b/src/slic3r/GUI/SurfaceDrag.hpp
index 6bc3c523ed..aaf506582d 100644
--- a/src/slic3r/GUI/SurfaceDrag.hpp
+++ b/src/slic3r/GUI/SurfaceDrag.hpp
@@ -15,6 +15,7 @@ class ModelVolume;
namespace Slic3r::GUI {
class GLCanvas3D;
class Selection;
+class TransformationType;
struct Camera;
// Data for drag&drop over surface with mouse
@@ -148,5 +149,12 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle);
/// Relative move along emboss direction
void do_local_z_move(GLCanvas3D &canvas, double relative_move);
+///
+///
+///
+///
+///
+TransformationType get_drag_transformation_type(const Selection &selection);
+
} // namespace Slic3r::GUI
#endif // slic3r_SurfaceDrag_hpp_
\ No newline at end of file