mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-18 22:42:37 +00:00
Port the MCP verb surface: run_verb / list_verbs / sketch_set_value
Carries snaporca 39fac9b725. Parity re-verified: 17 files identical, 8 diverging by their expected counts, DesignPanel.cpp still at 32 — the mirrored files were copied and the two divergent ones patched hunk by hunk, so the counts returning to their expected values is the proof each landed on the right side. All 90 offer verbs are now firable by name over the socket, which matters because a deck key can only send a keystroke and 49 of them have no shortcut at all. sketch_set_value calls the same apply_dimension the in-canvas value field calls, so a typed dimension can be asserted with no window manager in the way. Three guards came with it, each confirmed against the source: on_mass_properties bounds-checks m_sel_solid_body (it defaults to -1, and run_verb bypasses the menu grey-out that used to hide that); sketch_set_value validates its value at the boundary because apply_dimension records a driving constraint even for values it refused to apply; and run_verb refuses btn:/fly: verbs that do not apply to the selection while leaving key: verbs alone, so the socket offers exactly what the GUI offers. Dispatch is deferred through CallAfter so no modal verb can wedge the socket thread. GUI target builds and links against the rebuilt deps image. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
5d7fc8c545
commit
fbf858ba47
@@ -5433,6 +5433,16 @@ void DesignPanel::on_check_interference()
|
||||
// than in the on_add_* family. The caller only reaches us with m_sel_solid_body in range.
|
||||
void DesignPanel::on_mass_properties()
|
||||
{
|
||||
// This bounds check is not defensive padding — it is what makes the verb safe to fire from
|
||||
// the socket, which has no offer menu to grey the row out. The menu-only route never reached
|
||||
// here with nothing selected; run_verb does. Nothing selected is not an error, hence the
|
||||
// neutral colour, not the error red.
|
||||
if (m_sel_solid_body < 0 || m_sel_solid_body >= int(m_doc.bodies.size())) {
|
||||
m_status->SetForegroundColour(wxNullColour);
|
||||
set_status(_L("Select a solid body first — its mass properties are what is reported"));
|
||||
m_status->Refresh();
|
||||
return;
|
||||
}
|
||||
const auto mp = GeometryEngine::mass_properties(m_doc.bodies[m_sel_solid_body].shape);
|
||||
if (!mp.valid) {
|
||||
m_status->SetForegroundColour(wxColour(235, 110, 110));
|
||||
@@ -5801,6 +5811,23 @@ void DesignPanel::run_offer_action(const char* action)
|
||||
it->second();
|
||||
}
|
||||
|
||||
// Look a verb up by its offer id and dispatch it — the "run_verb" half of the MCP offer surface.
|
||||
// Unknown ids and rows whose action string is null (kernel support, no GUI route yet) return
|
||||
// false without touching anything, so the caller can tell "no such verb" from "not wired yet".
|
||||
bool DesignPanel::mcp_run_verb(const char* verb_id)
|
||||
{
|
||||
if (!verb_id) return false;
|
||||
for (int i = 0; i < kOfferVerbCount; ++i) {
|
||||
const OfferVerb& v = kOfferVerbs[i];
|
||||
if (std::string(v.id) == verb_id) {
|
||||
if (v.action == nullptr) return false;
|
||||
run_offer_action(v.action);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
wxPoint DesignPanel::offer_anchor() const
|
||||
{
|
||||
const wxPoint mouse = wxGetMousePosition();
|
||||
|
||||
Reference in New Issue
Block a user