From fe39af7d7b9c51294b73d04b883e64b8823e54a7 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 26 Jan 2023 23:24:54 +0100 Subject: [PATCH] Fixed cut gizmo and SLA shift --- src/libslic3r/GCode/WipeTower.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 7 +++++++ src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 10 +++++++++- src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp | 4 +++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 639739967..237ec3604 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -932,7 +932,7 @@ void WipeTower::toolchange_Unload( // this is to align ramming and future wiping extrusions, so the future y-steps can be uniform from the start: // the perimeter_width will later be subtracted, it is there to not load while moving over just extruded material Vec2f pos = Vec2f(end_of_ramming.x(), end_of_ramming.y() + (y_step/m_extra_spacing-m_perimeter_width) / 2.f + m_perimeter_width); - if (m_semm) + if (m_semm) writer.travel(pos, 2400.f); else writer.set_position(pos); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index fc54622e8..2b73c0e62 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -85,6 +85,12 @@ void GLGizmoHollow::on_render() return; } + if (m_state == On) { + // This gizmo is showing the object elevated. Tell the common + // SelectionInfo object to lie about the actual shift. + m_c->selection_info()->set_use_shift(true); + } + glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_DEPTH_TEST)); @@ -828,6 +834,7 @@ void GLGizmoHollow::on_set_state() // the gizmo was just turned Off m_parent.post_event(SimpleEvent(EVT_GLCANVAS_FORCE_UPDATE)); m_c->instances_hider()->set_hide_full_scene(false); + m_c->selection_info()->set_use_shift(false); // see top of on_render for details } m_old_state = m_state; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index e7ea945e3..4b449b3cc 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -87,6 +87,12 @@ void GLGizmoSlaSupports::data_changed() void GLGizmoSlaSupports::on_render() { + if (m_state == On) { + // This gizmo is showing the object elevated. Tell the common + // SelectionInfo object to lie about the actual shift. + m_c->selection_info()->set_use_shift(true); + } + if (!m_sphere.model.is_initialized()) { indexed_triangle_set its = its_make_sphere(1.0, double(PI) / 12.0); m_sphere.model.init_from(its); @@ -836,8 +842,10 @@ void GLGizmoSlaSupports::on_set_state() m_old_mo_id = -1; } - if (m_state == Off) + if (m_state == Off) { m_c->instances_hider()->set_hide_full_scene(false); + m_c->selection_info()->set_use_shift(true); // see top of on_render for details + } } m_old_state = m_state; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp b/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp index 21e1bb73c..01b888be0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp @@ -163,7 +163,8 @@ public: ModelVolume* model_volume() const { return m_model_volume; } ModelInstance *model_instance() const; int get_active_instance() const; - float get_sla_shift() const { return m_z_shift; } + float get_sla_shift() const { return m_use_shift ? m_z_shift : 0.f; } + void set_use_shift(bool use) { m_use_shift = use; } protected: void on_update() override; @@ -175,6 +176,7 @@ private: ModelVolume* m_model_volume = nullptr; // int m_active_inst = -1; float m_z_shift = 0.f; + bool m_use_shift = false; };