Design tab: show/hide the printer bed; give Placement its own toolbar slot

Port of snaporca ca25352d74. Hand-applied rather than cherry-picked: unlike the
Phase B commits, which only touched DesignPanel.{cpp,hpp} and transfer verbatim,
this one reaches into GLCanvas3D and DesignCanvas, where the forks genuinely
differ — mainline passes m_show_world_axes to _render_bed where Snapmaker passes
a local show_axes, and the surrounding code sits ~90 lines further down. git am
refused, correctly; the six edits were applied against mainline's own context and
the DesignPanel half came across as a patch.

Bed toggle: a "Bed" checkbox in the document/view row, on by default, in that row
rather than in a card because a view option must stay reachable with no tool open.
It drives GLCanvas3D::m_show_bed (default true, so Prepare and Preview are
untouched) and gates _render_platelist as well as _render_bed — hiding the bed
while leaving its grid and outline floating would read as a rendering fault.

Bound to wxEVT_TOGGLEBUTTON, not wxEVT_CHECKBOX: Orca's CheckBox derives from
wxBitmapToggleButton, so a wxEVT_CHECKBOX handler never fires.

Also gives the Placement drawer its own "placement" toolbar slot. put("place")
already holds the Place-on-Face button, and put() formats slot item 0 as the
control and later items as its chevron, so sharing the slot bottom-aligned the
drawer's button like a chevron.

196/196 targets, 0 compile errors, orca-slicer links (165 MB). The build script
still exits non-zero at the AppImage bundling step on libpython3.12.so.1.0 —
that is snaporca-96t, packaging only, and does not affect the binary.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tommaso Bianchi
2026-07-25 18:33:33 +02:00
co-authored by Claude Opus 5
parent d4904b8e2e
commit 8621f1168e
6 changed files with 42 additions and 5 deletions
+8
View File
@@ -414,6 +414,14 @@ void DesignCanvas::refresh_bed()
m_bed.set_shape(bed_shape_opt->values, printable_height, {}, {}, "", false); // mainline added extruder_areas/heights params
}
void DesignCanvas::set_show_bed(bool b)
{
if (!m_canvas) return;
if (m_canvas->get_show_bed() == b) return; // no repaint for a no-op toggle
m_canvas->set_show_bed(b);
request_repaint();
}
bool DesignCanvas::is_sketching() const { return m_sketch_tool.is_active(); }
void DesignCanvas::cancel_sketch()
+1
View File
@@ -58,6 +58,7 @@ public:
void finish_sketch();
bool is_sketching() const;
void refresh_bed(); // re-sync the bed to the current printer (call on tab activation)
void set_show_bed(bool b); // view option: draw the printer bed + plate grid, or not
void cancel_sketch();
void set_on_sketch_commit(std::function<void(const SketchProfile&, const SketchPlane&)> cb);
void set_on_sketch_entities_commit(
+23 -3
View File
@@ -752,8 +752,11 @@ DesignPanel::DesignPanel(wxWindow* parent)
// Placement — operations that MOVE a body without changing its shape. Transform and
// Mirror place one body directly; a Mate places one body relative to another. They were
// in Dress-up (fillet/draft/shell) and Datum, which mixed shape-finishing and reference
// geometry with rigid-body placement. "place" was already an empty slot in the bar order.
feat_dropdown("place", "design_move", _L("Placement (transform / mirror / mate)"), {
// geometry with rigid-body placement.
// Own slot id: "place" is taken by the Place-on-Face button, and put() formats slot
// item 0 as the control and every later item as its chevron, so sharing a slot would
// bottom-align this drawer's button like a chevron.
feat_dropdown("placement", "design_move", _L("Placement (transform / mirror / mate)"), {
{"design_move", _L("Transform"), _L("Move and/or rotate an existing body"),
[this] {
if (m_doc.bodies.empty()) {
@@ -1248,6 +1251,23 @@ DesignPanel::DesignPanel(wxWindow* parent)
b_export->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { on_export_step(); });
add_doc(b_export);
// View option, not a document action: hide the printer bed to model without it. Lives in
// this row because it must stay reachable with no tool open — a card would come and go.
m_show_bed = new CheckBox(m_toolbar);
m_show_bed->SetValue(true); // bed visible by default, as the tab opens today
m_show_bed->SetToolTip(_L("Show the printer bed and its plate grid"));
// wxEVT_TOGGLEBUTTON, NOT wxEVT_CHECKBOX: Orca's CheckBox derives from
// wxBitmapToggleButton (Widgets/CheckBox.hpp), so a wxEVT_CHECKBOX handler never fires.
// Read the control rather than the event so the state cannot disagree with the glyph.
m_show_bed->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& e) {
if (m_viewport) m_viewport->set_show_bed(m_show_bed->GetValue());
e.Skip();
});
auto* bed_lbl = new wxStaticText(m_toolbar, wxID_ANY, _L("Bed"));
bed_lbl->SetForegroundColour(dp_sec_text());
m_tb_doc->Add(m_show_bed, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);
m_tb_doc->Add(bed_lbl, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 4);
// These act on bodies / the view, so they ride in the feature group, in the slots
// the user assigned them (9, 11bis, 16).
auto* b_place = doc_btn("toolbar_flatten", _L("Place on Face (F) — lay the picked face on the bed"),
@@ -1286,7 +1306,7 @@ DesignPanel::DesignPanel(wxWindow* parent)
};
put("sketch"); put("constrain"); // 7, 7bis
add_sep(m_tb_feature);
put("material"); put("place"); put("plane"); // 8, 9, 10
put("material"); put("place"); put("placement"); put("plane"); // 8, 9, 9bis, 10
put("dressup"); put("section"); // 11, 11bis
put("hole"); put("boolean"); put("cut"); // 12, 13, 14
put("surface"); put("color"); put("flip"); // 14bis, 15, 16
+1
View File
@@ -255,6 +255,7 @@ private:
void push_polygon_params();
wxSizer* m_tb_commit{nullptr}; // far-right Commit to Plate, beside Confirm/Cancel
wxSizer* m_tb_doc{nullptr}; // toolbar document/view actions (new, commit, export, section, place)
CheckBox* m_show_bed{nullptr}; // view option: draw the printer bed + plate grid, or not
wxSizer* m_box_move{nullptr}; // Move/Rotate numeric options (distance, axis, angle)
wxSizer* m_box_polygon{nullptr}; // Polygon tool options (sides / circumscribed)
wxSizer* m_box_sketch{nullptr};
+4 -2
View File
@@ -2076,9 +2076,11 @@ void GLCanvas3D::render(bool only_init)
/* view3D render*/
int hover_id = (m_hover_plate_idxs.size() > 0)?m_hover_plate_idxs.front():-1;
if (m_canvas_type == ECanvasType::CanvasView3D) {
if (!no_partplate)
// m_show_bed gates the plate list too: hiding the bed but leaving its grid and outline
// floating would read as a rendering fault rather than a deliberate view option.
if (!no_partplate && m_show_bed)
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward(), m_show_world_axes);
if (!no_partplate) //BBS: add outline logic
if (!no_partplate && m_show_bed) //BBS: add outline logic
_render_platelist(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward(), only_current, only_body, hover_id, true, show_grid);
//BBS: add outline logic
+5
View File
@@ -551,6 +551,9 @@ private:
// SnapOrca Design: render the world-axis triad at the bed centre (= modeling origin) instead of
// the bed corner. Default false preserves the main editor's corner triad.
bool m_axes_at_bed_center{false};
// SnapOrca Design: draw the printer bed and its plate grid at all. Default true, so the
// main editor is untouched; the Design tab lets the user hide it to model without a bed.
bool m_show_bed{true};
#ifdef SLIC3R_CAD
DesignSketchTool* m_design_sketch_tool{nullptr};
#endif
@@ -900,6 +903,8 @@ public:
void enable_collapse_toolbar(bool enable);
void enable_plate_chrome(bool enable);
void set_axes_at_bed_center(bool b) { m_axes_at_bed_center = b; }
void set_show_bed(bool b) { m_show_bed = b; }
bool get_show_bed() const { return m_show_bed; }
#ifdef SLIC3R_CAD
void set_design_sketch_tool(DesignSketchTool* tool) { m_design_sketch_tool = tool; }
DesignSketchTool* get_design_sketch_tool() const { return m_design_sketch_tool; }