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.
This commit is contained in:
harrierpigeon
2026-10-04 19:21:22 -05:00
parent bbb94724ba
commit e8a499df7b
4 changed files with 18 additions and 4 deletions
+5 -2
View File
@@ -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
+11 -1
View File
@@ -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)")),
+1
View File
@@ -149,6 +149,7 @@ constexpr std::array<ShortcutInfo, size_t(Shortcut::Count)> 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),
+1 -1
View File
@@ -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