mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-04 02:38:05 -05:00
Regroup the slicer's MCP commands and let each run from its arguments
Outside the Design tab an agent had 175 commands, 50 of them in the tool list. There are now 118, named by what they act on (`object_`, `plate_`, `preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes its target and values in the call, acts on the selection when it names no target and says what it acted on; an old name is refused. Printers and system filaments install and uninstall, preferences read and write, plugins enable, reload, uninstall and refresh, and objects reorder, with no dialog to drive. The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the rows these commands share with the menus are fixed. For a person: an object row that cannot run says why instead of "Select an object first.", rows that failed no longer claim success, Duplicate Plate can be undone, and Refresh Plugins picked while a refresh runs now runs after it instead of beside it.
This commit is contained in:
1 parent
74c98e197c
commit
d64e10f4dd
287 files changed
+40484
-16770
No files matched your search
@@ -33,7 +33,7 @@ ENUM = {
|
||||
# a tool block's access -> CadAccess enumerator
|
||||
ACCESS = {"read": "Read", "change": "Change", "sketch": "Sketch", "ui": "Ui"}
|
||||
|
||||
# The headings of search_tools' index of the Design commands (Mcp::design_command_index()), in its order: every
|
||||
# The headings of tool_search's index of the Design commands (Mcp::design_command_index()), in its order: every
|
||||
# command's `section` is one of them. Menu rows holds the commands that take no arguments and only do what their row
|
||||
# does.
|
||||
SECTIONS = ("Document", "Sketch", "Solid", "Surface", "Construct", "Inspect", "Bodies", "History", "Menu rows")
|
||||
@@ -122,7 +122,7 @@ def faults(A):
|
||||
command's own row takes, which a call with none also gives. A command's rows are in one mode.
|
||||
|
||||
Every command, an entry with an action or a block that is no folded row, has a `section`, its heading in
|
||||
search_tools' index (SECTIONS); a folded or greyed row, which is no command, has none.
|
||||
tool_search's index (SECTIONS); a folded or greyed row, which is no command, has none.
|
||||
|
||||
`feature_row` marks a row whose action acts on the selected row of the Feature list, which a call of its
|
||||
command takes as its target when nothing is picked in the view (Mcp::open_refusal()): only a command with a row
|
||||
@@ -154,7 +154,7 @@ def faults(A):
|
||||
if not command and "section" in v:
|
||||
errs.append(f"{vid}: a folded or greyed row is no command and has no section")
|
||||
elif command and "section" not in v:
|
||||
errs.append(f"{vid}: a command needs a section, its heading in search_tools' index: one of {list(SECTIONS)}")
|
||||
errs.append(f"{vid}: a command needs a section, its heading in tool_search's index: one of {list(SECTIONS)}")
|
||||
elif command and v["section"] not in SECTIONS:
|
||||
errs.append(f'{vid}: section {v["section"]!r} is not one of {list(SECTIONS)}')
|
||||
if v.get("feature_row") and (not v.get("action") or "fold" in v):
|
||||
@@ -248,7 +248,7 @@ def main():
|
||||
"// not apply are shown disabled in place with their reason rather than removed. Row order was",
|
||||
"// ratified 2026-07-31; changing an index is a breaking change to every user's muscle memory.",
|
||||
"// An entry with an action or a tool block, and no fold_into, is a command of the catalog's group Design",
|
||||
"// (Mcp::register_cad_commands(), Mcp::is_design_command()), under its section in search_tools' index. A",
|
||||
"// (Mcp::register_cad_commands(), Mcp::is_design_command()), under its section in tool_search's index. A",
|
||||
"// call whose arguments are exactly those that choose one of its rows opens that row's tool for a person",
|
||||
"// (Mcp::opened_row()): none choose the entry's own row where it has an action, else the rows folded into it",
|
||||
"// with {}; a folded row's args, or the entry's own, choose that row. Any other call runs its tool block's",
|
||||
@@ -336,7 +336,7 @@ def main():
|
||||
" // The arguments that choose this row, as JSON text: a folded row's, or those that choose the own row of",
|
||||
" // an entry with an action and a tool block as a call with none does; nullptr for none.",
|
||||
" const char* args;",
|
||||
" // The heading its command is listed under in search_tools' index (kDesignSections,",
|
||||
" // The heading its command is listed under in tool_search's index (kDesignSections,",
|
||||
" // Mcp::design_command_index()); nullptr for an entry that is no command.",
|
||||
" const char* section;",
|
||||
" // Its action acts on the selected row of the Feature list, which a call of its command, not a person's",
|
||||
@@ -344,7 +344,7 @@ def main():
|
||||
" bool feature_row;",
|
||||
"};",
|
||||
"",
|
||||
"// The headings of search_tools' index of the Design commands, in its order. Menu rows holds the commands",
|
||||
"// The headings of tool_search's index of the Design commands, in its order. Menu rows holds the commands",
|
||||
"// that take no arguments and only do what their row does.",
|
||||
"static const char* const kDesignSections[] = {",
|
||||
]
|
||||
|
||||
@@ -4356,10 +4356,10 @@
|
||||
"access": "change",
|
||||
"ok_false": false,
|
||||
"summary": "Commit to Plate: send the visible bodies to Prepare at their Move-gizmo positions and show Prepare.",
|
||||
"details": "It is one Prepare undo step. A lone body is sent even when hidden. A body named in the Bodies list or with body_set names its object or part. Reply: objects (list_objects index after replace, name, parts: how many), bodies_sent, bodies_hidden, replaced.",
|
||||
"details": "It is one Prepare undo step. A lone body is sent even when hidden. A body named in the Bodies list or with body_set names its object or part. Reply: objects (object_list index after replace, name, parts: how many), bodies_sent, bodies_hidden, replaced.",
|
||||
"params": [
|
||||
{"name": "mode", "type": "string", "default": "", "enum": ["assembly", "bodies"], "description": "assembly: one object with a part per body; bodies: an object per body. Default: the Commit button's mode, which this leaves as it is."},
|
||||
{"name": "replace", "type": "array", "default": [], "description": "list_objects indices to delete in the same undo step, such as an earlier commit. Their settings, modifiers and paint go with them."}
|
||||
{"name": "replace", "type": "array", "default": [], "description": "object_list indices to delete in the same undo step, such as an earlier commit. Their settings, modifiers and paint go with them."}
|
||||
],
|
||||
"examples": [
|
||||
{
|
||||
|
||||
@@ -35,15 +35,19 @@ NOT_CALLERS = {"src/slic3r/GUI/Mcp/McpToolsCad.cpp"}
|
||||
# Owner methods an operation calls, by the operation that stands for them.
|
||||
BANNED = {
|
||||
"start_gcode_export": ["export_gcode_to"],
|
||||
"import_models": ["load_files"],
|
||||
"import_models": ["load_files", "import_zip_archive", "preview_zip_archive"],
|
||||
"open_project": ["load_project"],
|
||||
"new_project": ["new_project"],
|
||||
"save_project_as": ["save_project"],
|
||||
"export_sliced_3mf": ["export_gcode_3mf"],
|
||||
"export_model_3mf": ["export_core_3mf"],
|
||||
"export_stl": ["export_stl"],
|
||||
"export_toolpaths_obj": ["export_toolpaths_to_obj"],
|
||||
"select_plate": ["select_plate"],
|
||||
"set_plate_locked": ["lock_plate", "set_plate_locked"],
|
||||
"delete_plate": ["delete_plate"],
|
||||
"duplicate_plate": ["duplicate_plate"],
|
||||
"rename_plate": ["rename_plate"],
|
||||
"start_arrange": ["set_prepare_state", "arrange"],
|
||||
"start_slice": ["request_slice"],
|
||||
"show_layer_range": ["SetHigherValue", "SetLowerValue", "show_layer_range"],
|
||||
@@ -51,7 +55,44 @@ BANNED = {
|
||||
"assign_filament_preset": ["set_filament_preset", "select_filament_preset"],
|
||||
"import_presets": ["import_configs"],
|
||||
"set_instance_count": ["set_number_of_copies"],
|
||||
"delete_objects": ["delete_from_model_and_list", "delete_all_objects_from_model", "remove_selected"],
|
||||
"rename_object": ["rename_item"],
|
||||
"separate_instances": ["instances_to_separated_object", "instances_to_separated_objects", "split_instances"],
|
||||
# assemble_objects calls ObjectList::merge(), a name too common to ban (a bounding box's merge()).
|
||||
"split_object": ["split_object", "split_volume"],
|
||||
"change_part_type": ["set_volume_type"],
|
||||
"order_objects": ["order_objects"],
|
||||
"mirror_objects": ["mirror"],
|
||||
"center_objects": ["center_selection", "do_center_plate"],
|
||||
"scale_to_fit": ["scale_selection_to_fit_print_volume"],
|
||||
"drop_objects": ["drop_selection"],
|
||||
"orient_objects": ["orient"],
|
||||
"add_primitive": ["load_shape_object"],
|
||||
"set_objects_printable": ["toggle_printable_state", "update_printable_state", "set_printable"],
|
||||
"set_objects_auto_drop": ["set_auto_drop", "toggle_auto_drop"],
|
||||
"fix_objects": ["fix_through_cgal", "fix_all_through_cgal"],
|
||||
# clone_objects calls Selection::clone(), a name too common to ban (ConfigOption::clone()).
|
||||
"clone_objects": ["clone_selection"],
|
||||
"reload_parts": ["reload_parts_from_disk", "reload_from_disk", "reload_all_from_disk"],
|
||||
"replace_part": ["replace_part_with_file", "replace_with_stl"],
|
||||
"send_gcode_to_host": ["send_gcode_legacy"],
|
||||
"sync_presets": ["restart_sync_user_preset", "start_sync_user_preset"],
|
||||
"add_filament_slot": ["add_filament"],
|
||||
"delete_filament_slot": ["delete_filament", "change_filament"],
|
||||
"add_mixed_filament": ["ensure_mixed_filament", "add_mixed_filament"],
|
||||
# uninstall_printers, and the Printer Selection dialog's Confirm, apply the set through it too (apply_install_set).
|
||||
"install_printers": ["apply_vendor_config"],
|
||||
# uninstall_filaments writes the filaments section through it too.
|
||||
"install_filaments": ["set_section"],
|
||||
# The Preferences dialog's controls run these effects through apply_preference(), as set_preferences does.
|
||||
"set_preferences": ["set_visible_page_count", "set_max_recent_count", "update_filaments_area_height"],
|
||||
# The Plugins window's switches, Delete and Unsubscribe, and Reload and Reinstall run these through the operations.
|
||||
"set_plugin_enabled": ["load_plugin", "unload_plugin", "set_capability_enabled"],
|
||||
"uninstall_plugin": ["delete_plugin", "delete_and_unsubscribe_cloud_plugin"],
|
||||
"reload_plugin": ["download_and_install_cloud_plugin"],
|
||||
# The sync dialog's Synchronize now runs the sync through the operation, and a drop in the object list a drag.
|
||||
"sync_filaments_from_ams": ["sync_ams_list", "apply_ams_sync"],
|
||||
"reorder_objects": ["move_object"],
|
||||
"the undo snapshot of an operation": ["take_snapshot"],
|
||||
}
|
||||
|
||||
|
||||
@@ -6,49 +6,53 @@
|
||||
# Generate candidates with: python3 scripts/check_operation_calls.py --print
|
||||
|
||||
[src/slic3r/GUI/NativeCommands.cpp]
|
||||
# The asking path of a command: with no param, and for load_project with or without one, the command
|
||||
# calls the owner's method, which asks the person what an operation would be told.
|
||||
# The asking path of a command, its menu row's tile (Rows): the row's function calls the owner's method, which asks
|
||||
# the person what an operation would be told (project_open {}, project_save {save_as: true}, project_import {archive:
|
||||
# true}, project_export with a tile's arguments, filament_sync_ams {}).
|
||||
plater->load_project();
|
||||
plater->load_project(from_path(*path));
|
||||
return project_save_result(plater->save_project(true));
|
||||
return NativeCommands::project_save_result(plater->save_project(true));
|
||||
plater->import_zip_archive();
|
||||
plater->export_stl();
|
||||
plater->export_core_3mf();
|
||||
plater->export_gcode_3mf(all);
|
||||
plater->set_number_of_copies();
|
||||
# Another function that uses the same owner method: every object as its own STL, and the Draco exports.
|
||||
plater->export_gcode_3mf(all_plates);
|
||||
plater->export_toolpaths_to_obj();
|
||||
const std::optional<Ops::Refusal> refusal = plater->sidebar().sync_ams_list();
|
||||
# Another function that uses the same owner method: every object as its own STL, and the Draco exports, each asking
|
||||
# for its file or folder.
|
||||
plater->export_stl(false, false, true);
|
||||
plater->export_stl(false, false, true, FT_STL, from_path(*dir));
|
||||
plater->export_stl(false, false, false, FT_DRC);
|
||||
plater->export_stl(false, false, true, FT_DRC);
|
||||
# Another function that uses the same owner method: orient, which leaves a plate-only state behind as arrange does.
|
||||
plater->set_prepare_state(Job::PREPARE_STATE_DEFAULT);
|
||||
|
||||
[src/slic3r/GUI/Mcp/McpToolsConfig.cpp]
|
||||
# The undo step of a tool whose function has one automation entry point (set_settings' object, plate
|
||||
# and project scopes).
|
||||
# The undo step of a tool whose function has one automation entry point (settings_set's object and part
|
||||
# targets, plate_set_settings and project_set_settings).
|
||||
plater.take_snapshot("Move object");
|
||||
plater.take_snapshot("Plate Settings");
|
||||
plater.take_snapshot("Change object settings");
|
||||
# A tool selecting the plate it was given before its own work, as the plate's settings icon does.
|
||||
plater.select_plate(index);
|
||||
# Another function that uses the same owner method: set_settings makes the filament tab edit a slot's
|
||||
# preset, and delete_preset selects the preset, deletes it and selects back.
|
||||
# Another function that uses the same owner method: settings_set makes the filament tab edit a slot's
|
||||
# preset, and preset_delete selects the preset, deletes it and selects back.
|
||||
if (!tab->select_preset(name))
|
||||
if (!tab->select_preset(name))
|
||||
tab->select_preset(selected);
|
||||
|
||||
[src/slic3r/GUI/Mcp/McpToolsLayers.cpp]
|
||||
# The undo step of a tool whose function has one automation entry point (set_height_ranges).
|
||||
# The undo step of a tool whose function has one automation entry point (object_set_height_ranges).
|
||||
plater.take_snapshot("Edit height ranges");
|
||||
|
||||
[src/slic3r/GUI/Mcp/McpToolsProject.cpp]
|
||||
# The asking path of a command, its person's form: new_project and save_project called with no arguments
|
||||
# The asking path of a command, its person's form: project_new and project_save called with no arguments
|
||||
# call the owner's method, which asks the person what an operation would be told.
|
||||
plater->new_project();
|
||||
return NativeCommands::project_save_result(plater->save_project(false));
|
||||
|
||||
[src/slic3r/GUI/Mcp/McpToolsScene.cpp]
|
||||
# The undo step of a tool whose function has one automation entry point (transform).
|
||||
# The asking path of a command, its person's form: object_rename {} and object_set_instances {} call the owner's
|
||||
# method on the target they resolved from the selection, which asks the person what an operation would be told.
|
||||
list->rename_item();
|
||||
plater.set_number_of_copies();
|
||||
# The undo step of a tool whose function has one automation entry point (object_transform).
|
||||
plater.take_snapshot("Transform object");
|
||||
plater.take_snapshot("Transform part", UndoRedo::SnapshotType::GizmoAction);
|
||||
|
||||
|
||||
Reference in new issue
Block a user