Correct when the Design tab is created and why sketch_set_value exists

This commit is contained in:
SoftFever committed 2026-11-10 01:07:31 +08:00
1 parent 97999d5123
commit 5bfebec540
5 files changed
+28 -26

No files matched your search

+9 -9
View File
@@ -368,15 +368,15 @@ callers share, and the CAD tool calls that function with explicit arguments inst
widgets.
`call_cad_tool` needs the MCP server on (`--mcp`, or Preferences) and the CAD feature on
(Preferences > Features; the Design page is built only at startup, so turning it on takes a
restart); with the feature off it is refused, and the two inspect tools still answer, with a note
on how a person turns it on. A call is refused (`-32002`)
while the Design tab is busy: a `change` CAD tool does not run under an open feature card or sketch
session, nor a `change` or `sketch` one during a body Move, nor any while a rebuild owns the
document. Face and edge ids name faces and edges of the current model, and a rebuild renumbers
them while a stale id still names a real face or edge, so the replies carry the model's
`generation`: a call that passes ids with the `generation` they were read at is refused (`-32010`)
once the model has moved on, rather than acting on another face or edge.
(Preferences > Features; the main window creates the Design page only at startup, so turning it on
takes a restart); with the feature off it is refused, and the two inspect tools still answer, with a
note on how a person turns it on. A call is refused (`-32002`) while the Design tab is busy: a
`change` CAD tool does not run under an open feature card or sketch session, nor a `change` or
`sketch` one during a body Move, nor any while a rebuild owns the document. Face and edge ids name
faces and edges of the current model, and a rebuild renumbers them while a stale id still names a
real face or edge, so the replies carry the model's `generation`: a call that passes ids with the
`generation` they were read at is refused (`-32010`) once the model has moved on, rather than acting
on another face or edge.
The CAD tools add features through the kernel calls the cards use, named as the cards name them,
one checkpoint per call. A rebuild that fails is taken back with `CadDocument::rollback()`, which
+10 -9
View File
@@ -1071,15 +1071,16 @@ UI does not answer, the reply goes out without the note, which is only advice.
`run_cad_tool()` runs the CAD tool on the UI thread, inside `call_cad_tool`'s mutate guard, and
refuses a call by its cause, in this order. The MCP server is up before the main window, so first
come `ui_plater()`'s "shutting down" and "still starting" refusals, as for any tool. Then the G-code
viewer, which has no Design tab (`-32001`); the CAD feature off (Preferences > Features; the Design
page is built only at startup, so turning it on takes a restart); and a Design panel that cannot be
built (`-32001`: no page was made at startup, the page is mid-build, or its build failed), whose
message says to retry and then restart. The panel is otherwise built on the first call, since in a
headless session nobody clicks the tab; `get_app_state.design_tab` says whether this session built
it. Then come an unknown CAD tool (`-32601`, with the close names and a pointer to
`list_cad_tools`), a busy Design tab (`-32002`), and a `generation` that is not an unsigned integer
(`-32602`) or not the model's (`-32010`). Before the generation is read, the project's recipe is
loaded into an empty document (`DesignPanel::hydrate_from_model()`), as showing the tab would.
viewer, which has no Design tab (`-32001`); the CAD feature off (Preferences > Features; the main
window creates the Design page only at startup, so turning it on takes a restart); and a Design
panel that cannot be built (`-32001`: no page was made at startup, the page is mid-build, or its
build failed), whose message says to retry and then restart. The panel is otherwise built on the
first call, since in a headless session nobody clicks the tab; `get_app_state.design_tab` says
whether this session built it. Then come an unknown CAD tool (`-32601`, with the close names and a
pointer to `list_cad_tools`), a busy Design tab (`-32002`), and a `generation` that is not an
unsigned integer (`-32602`) or not the model's (`-32010`). Before the generation is read, the
project's recipe is loaded into an empty document (`DesignPanel::hydrate_from_model()`), as showing
the tab would.
Access decides what `DesignPanel::mcp_busy()` lets through. `read` CAD tools run under an open
feature card or sketch session, `sketch` CAD tools drive the live sketch session, and `change`
+6 -6
View File
@@ -157,7 +157,8 @@ const char* const kIdsNote =
const char* const kFailureNote = "A rejected rebuild is reported in the reply: ok is false or error is not empty.";
// cad_feature_note()'s text: run_cad_tool() refuses every CAD tool while the feature is off, and the
// Design page is built only at startup, so turning the feature on takes a restart.
// main window creates the Design page only at startup (its panel is built on first use), so turning
// the feature on takes a restart.
const char* const kCadOffNote = "The CAD feature is off: call_cad_tool is refused until a person enables it in "
"Preferences > Features and restarts OrcaSlicer.";
@@ -3167,11 +3168,10 @@ json action_sketch_heal(DesignPanel* panel, const json& params)
return out;
}
// Why sketch_set_value exists: committing a typed dimension could previously only be exercised
// by driving the in-canvas value field, and the rig's window manager never gives that frame
// keyboard focus, so the behaviour of apply_dimension on CONSTRAINED geometry was untestable.
// This calls the same function the widget calls, so the geometry can be asserted with no window
// manager involved. Note apply_dimension clears the selection.
// sketch_set_value commits a typed dimension by calling apply_dimension, the function the in-canvas
// value field calls, so what a typed value does to the geometry, constrained geometry included, can
// be asserted without a window manager giving that field keyboard focus. apply_dimension clears the
// selection.
json action_sketch_set_value(DesignPanel* panel, const json& params)
{
DesignSketchTool& t = mcp_sketch(panel);
+1 -1
View File
@@ -19,7 +19,7 @@ Python. It uses only the standard library. `docs/HLSD/mcp-server.md` covers the
an `OrcaSlicer.conf` that has a finished setup wizard and one printer and filament (Bambu Lab X1
Carbon 0.4 by default), with update checks and daily tips turned off. `--cad` turns the Design
(CAD) tab on, which `call_cad_tool` needs: it sets `enable_cad_feature` in a fresh datadir's
`OrcaSlicer.conf`, and in a reused one too, since the app reads that setting only at startup. The token comes from
`OrcaSlicer.conf`, and in a reused one too, since the app creates the Design tab only at startup, when that setting is on. The token comes from
`ORCA_MCP_TOKEN` or is generated, and it reaches the app through the environment, not the command
line. On Linux, `launch` also sets `SSL_CERT_FILE`, so a fresh datadir doesn't prompt for a CA
bundle. On Windows, it gives the instance its own WebView2 profile in the datadir, apart from the one
+2 -1
View File
@@ -248,7 +248,8 @@ def write_conf(conf, data):
def seed_datadir(datadir, printer, cad=False):
"""Seed a fresh datadir's OrcaSlicer.conf. A datadir that has one keeps it, except that cad turns
the Design tab on there too, since the app reads that setting only at startup."""
the Design tab on there too, since the app creates the Design tab only at startup, when that
setting is on."""
vendor, model, nozzle, filament = printer
os.makedirs(datadir, exist_ok=True)
conf = os.path.join(datadir, "OrcaSlicer.conf")