Fix: missunderstanding function is_single_volume()

This commit is contained in:
Filip Sykala - NTB T15p 2023-10-25 17:14:38 +02:00
parent 10d578b6a7
commit 9c054b05c1
5 changed files with 27 additions and 28 deletions

View File

@ -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>

View File

@ -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);

View File

@ -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"));

View File

@ -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

View File

@ -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);
/// <param name="relative_move">Relative move along emboss direction</param>
void do_local_z_move(GLCanvas3D &canvas, double relative_move);
/// <summary>
///
/// </summary>
/// <param name="selection"></param>
/// <returns></returns>
TransformationType get_drag_transformation_type(const Selection &selection);
} // namespace Slic3r::GUI
#endif // slic3r_SurfaceDrag_hpp_