From e8a499df7bc87bd91e82df5e5f358b99cc614567 Mon Sep 17 00:00:00 2001 From: harrierpigeon Date: Sun, 4 Oct 2026 19:21:22 -0500 Subject: [PATCH] Belt: register the raw G-code toggle as a Preview shortcut Main's assignable shortcuts replaced the canvas key switch that carried the belt "show designed / show raw G-code" toggle on B. Register it as ToggleBeltRawGcode, bound to B in the Preview (B is only taken on the Plater, by the mesh boolean gizmo), so it can be rebound and is listed in the shortcuts dialog. The legend checkbox shows whatever key is bound. --- src/slic3r/GUI/GCodeViewer.cpp | 7 +++++-- src/slic3r/GUI/GLCanvas3D.cpp | 12 +++++++++++- src/slic3r/GUI/Shortcuts.cpp | 1 + src/slic3r/GUI/Shortcuts.hpp | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 5e21b6c617..26c3e2e111 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -13,6 +13,7 @@ #include "libslic3r/Geometry/ConvexHull.hpp" #include "GUI_App.hpp" +#include "Shortcuts.hpp" #include "MainFrame.hpp" #include "Plater.hpp" #include "Camera.hpp" @@ -5148,8 +5149,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv // Checked = show the raw machine-frame G-code (designed/upright view off). Worded to // match the canvas-toolbar menu item "Show raw G-code (belt only)". m_belt_show_designed // is the inverse of this checkbox, so bind a temporary and flip it on change. - bool show_raw = !m_belt_show_designed; - if (ImGui::Checkbox(_u8L("Show raw G-code (belt only) [B]").c_str(), &show_raw)) { + bool show_raw = !m_belt_show_designed; + const std::string key = wxGetApp().shortcuts().display(Shortcut::ToggleBeltRawGcode); + const std::string label = _u8L("Show raw G-code (belt only)") + (key.empty() ? std::string() : " [" + key + "]"); + if (ImGui::Checkbox(label.c_str(), &show_raw)) { m_belt_show_designed = !show_raw; // The designed-view back-transform is baked into the toolpath geometry at load // time, so the toggle only takes effect once the preview is re-converted. Defer diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 55a3728c2e..4ec3982e52 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3804,6 +3804,16 @@ bool GLCanvas3D::handle_shortcut(const KeyChord& chord) m_dirty = true; request_extra_frame(); break; + case Shortcut::ToggleBeltRawGcode: + // Same state as the legend checkbox and the canvas-toolbar menu item. The designed-view + // back-transform is baked into the toolpaths at load time, so the preview is re-converted. + if (m_gcode_viewer.is_belt_view()) { + m_gcode_viewer.toggle_belt_show_designed(); + if (Plater* plater = wxGetApp().plater()) + plater->refresh_belt_view(); + m_dirty = true; + } + break; case Shortcut::ToggleOneLayerMode: get_gcode_viewer().get_layers_slider()->switch_one_layer_mode(); m_dirty = true; @@ -10196,7 +10206,7 @@ void GLCanvas3D::_render_canvas_toolbar() }; // Belt printers, G-code preview only: toggle the designed (upright) view vs the raw - // machine-frame G-code. Same state as hotkey B and the legend checkbox; the reload is + // machine-frame G-code. Same state as the shortcut and the legend checkbox; the reload is // deferred (CallAfter) so the preview is not rebuilt mid-render. if (m_canvas_type == ECanvasType::CanvasPreview && m_gcode_viewer.is_belt_view()) { create_menu_item( _utf8(L("Show raw G-code (belt only)")), diff --git a/src/slic3r/GUI/Shortcuts.cpp b/src/slic3r/GUI/Shortcuts.cpp index 8773c6f364..2395d31778 100644 --- a/src/slic3r/GUI/Shortcuts.cpp +++ b/src/slic3r/GUI/Shortcuts.cpp @@ -149,6 +149,7 @@ constexpr std::array shortcut_table = {{ SHORTCUT(ShowWireframe, "show_wireframe", L("Show/Hide wireframe"), CANVAS, { WXK_RETURN, CTRL_SHIFT }), SHORTCUT(ToggleGcodeWindow, "toggle_gcode_window", L("On/Off G-code window"), PREVIEW, { 'C' }), SHORTCUT(ToggleOneLayerMode, "toggle_one_layer_mode", L("On/Off one layer mode of the vertical slider"), PREVIEW, { 'L' }), + SHORTCUT(ToggleBeltRawGcode, "toggle_belt_raw_gcode", L("Show raw G-code (belt only)"), PREVIEW, { 'B' }), // Application SHORTCUT(Preferences, "preferences", L("Preferences"), GLOBAL, PREFERENCES_CHORD), diff --git a/src/slic3r/GUI/Shortcuts.hpp b/src/slic3r/GUI/Shortcuts.hpp index 0e61554e2f..6a58d64971 100644 --- a/src/slic3r/GUI/Shortcuts.hpp +++ b/src/slic3r/GUI/Shortcuts.hpp @@ -46,7 +46,7 @@ enum class Shortcut : uint8_t { // Camera ViewDefault, ViewTop, ViewBottom, ViewFront, ViewRear, ViewLeft, ViewRight, ViewPlate, ZoomIn, ZoomOut, Mouse3DSettings, // Display - ShowLabels, ShowWireframe, ToggleGcodeWindow, ToggleOneLayerMode, + ShowLabels, ShowWireframe, ToggleGcodeWindow, ToggleOneLayerMode, ToggleBeltRawGcode, // Application Preferences, Search, SwitchView, CollapseSidebar, ReloadDevicePage, KeyboardShortcuts, // Speed Dial