mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-25 09:50:59 +00:00
Update translations. Code dedup and cleanup
This commit is contained in:
+112
-179
@@ -25,7 +25,7 @@
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
@@ -120,120 +120,43 @@ AppActionRunResult calib_command(CalibKind kind)
|
||||
return {AppActionRunResult::Level::Success};
|
||||
}
|
||||
|
||||
// Palette-only: developer mode overrides the saved mode (get_mode returns comDevelop), so choosing
|
||||
// Simple/Advanced/Expert must clear it first. Mirrors Preferences: persist the flag, then update.
|
||||
void select_mode(ConfigOptionMode mode)
|
||||
{
|
||||
GUI_App& app = wxGetApp();
|
||||
const bool was_developer = app.app_config->get_bool("developer_mode");
|
||||
if (was_developer)
|
||||
app.app_config->set_bool("developer_mode", false);
|
||||
app.save_mode(mode);
|
||||
if (was_developer)
|
||||
app.app_config->save();
|
||||
}
|
||||
constexpr const char* kCommandPrefix = "orca_command";
|
||||
|
||||
// Tile pictogram per command: the SVG base name of the icon the matching GUI control already uses
|
||||
// (menu/toolbar/sidebar). Absent key => blank tile. Keeping this as one table makes the curation
|
||||
// reviewable and lets a test check every value resolves to a real file.
|
||||
const std::map<std::string, std::string>& command_icons()
|
||||
// Thin AppAction wrapper for one catalog entry: identity and presentation come from the catalog,
|
||||
// run() routes back to it. The id is keyed by the stable catalog key (not the display title), so a
|
||||
// rename or a UI-language switch never re-keys the action.
|
||||
struct CommandAction : AppAction
|
||||
{
|
||||
static const std::map<std::string, std::string> icons = {
|
||||
// Slice & Export
|
||||
{"slice_and_preview", "media_play"},
|
||||
{"export_gcode", "menu_export_gcode"},
|
||||
{"export_stl", "menu_export_stl"},
|
||||
{"export_stl_multi", "menu_export_stl"},
|
||||
{"export_sliced_file", "menu_export_sliced_file"},
|
||||
{"export_all_sliced_file", "menu_export_sliced_file"},
|
||||
{"export_toolpaths_obj", "menu_export_toolpaths"},
|
||||
{"export_config", "menu_export_config"},
|
||||
{"export_3mf", "menu_save"},
|
||||
{"export_drc_single", "menu_export_stl"},
|
||||
{"export_drc_multi", "menu_export_stl"},
|
||||
// Commands
|
||||
{"load_project", "menu_open"},
|
||||
{"save_project", "menu_save"},
|
||||
{"save_project_as", "menu_save"},
|
||||
{"open_preferences", "cog"},
|
||||
{"go_to_layer", "height_range_layer"},
|
||||
// Mode: the sidebar mode toggle's own icon (ParamsPanel).
|
||||
{"mode_simple", "advanced"},
|
||||
{"mode_advanced", "advanced"},
|
||||
{"mode_expert", "advanced"},
|
||||
{"toggle_developer_mode", "advanced"},
|
||||
// Calibration
|
||||
{"calib_temperature", "calib_sf"},
|
||||
{"calib_max_volumetric", "calib_sf"},
|
||||
{"calib_pressure_advance", "calib_sf"},
|
||||
{"calib_flow_ratio", "calib_sf"},
|
||||
{"calib_retraction", "calib_sf"},
|
||||
{"calib_cornering", "calib_sf"},
|
||||
{"calib_input_shaping_freq", "calib_sf"},
|
||||
{"calib_input_shaping_damp", "calib_sf"},
|
||||
{"calib_vfa", "calib_sf"},
|
||||
// View
|
||||
{"reset_window_layout", "toolbar_reset"},
|
||||
// Object
|
||||
{"obj_delete", "menu_delete"},
|
||||
{"obj_delete_all", "menu_remove"},
|
||||
{"obj_mirror_x", "menu_mirror_x"},
|
||||
{"obj_mirror_y", "menu_mirror_y"},
|
||||
{"obj_mirror_z", "menu_mirror_z"},
|
||||
{"obj_split_objects", "menu_split_objects"},
|
||||
{"obj_split_parts", "menu_split_parts"},
|
||||
{"obj_drop", "toolbar_flatten"},
|
||||
{"obj_instances_up", "instance_add"},
|
||||
{"obj_instances_down", "instance_remove"},
|
||||
{"obj_arrange", "toolbar_arrange"},
|
||||
{"obj_orient", "toolbar_orient"},
|
||||
// Add Primitive
|
||||
{"add_primitive_cube", "menu_obj_cube"},
|
||||
{"add_primitive_cylinder", "menu_obj_cylinder"},
|
||||
{"add_primitive_sphere", "menu_obj_sphere"},
|
||||
{"add_primitive_cone", "menu_obj_cone"},
|
||||
{"add_primitive_disc", "menu_obj_disc"},
|
||||
{"add_primitive_torus", "menu_obj_torus"},
|
||||
{"add_primitive_text", "menu_obj_text"},
|
||||
{"add_primitive_svg", "menu_obj_svg"},
|
||||
// Plate
|
||||
{"plate_add", "toolbar_add_plate"},
|
||||
{"plate_duplicate", "menu_copy"},
|
||||
{"plate_delete", "menu_delete"},
|
||||
{"plate_rename", "plate_name_edit"},
|
||||
{"plate_toggle_lock", "lock_normal"},
|
||||
{"plate_goto", "go_next_plate"},
|
||||
// Printer / Presets
|
||||
{"sync_ams", "ams_fila_sync"},
|
||||
{"sync_presets", "printer_sync_ok"},
|
||||
{"preset_bundle", "menu_edit_preset"},
|
||||
// Import
|
||||
{"import_file", "menu_import"},
|
||||
{"import_zip_archive", "menu_import"},
|
||||
{"import_configs", "menu_import"},
|
||||
// Help
|
||||
{"help_open_config_folder", "folder-closed"},
|
||||
{"help_tip_of_the_day", "info"},
|
||||
{"help_check_updates", "ams_refresh_normal"},
|
||||
{"help_about", "OrcaSlicer_about"},
|
||||
{"open_wiki", "link_wiki_img"},
|
||||
};
|
||||
return icons;
|
||||
}
|
||||
std::string command_key;
|
||||
|
||||
AppActionRunResult run(const std::string& param) const override { return NativeCommands::run(command_key, param); }
|
||||
|
||||
explicit CommandAction(const NativeCommand& c)
|
||||
: AppAction(AppActionId{AppAction::compose_id(kCommandPrefix, c.key, kOrcaSourceKey)}, c.title, kOrcaSourceKey, kOrcaSourceName)
|
||||
, command_key(c.key)
|
||||
{
|
||||
this->kind = AppActionKind::Command;
|
||||
this->group = c.group;
|
||||
this->input = c.input;
|
||||
this->icon = c.icon;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<NativeCommand> build_command_catalog()
|
||||
{
|
||||
std::vector<NativeCommand> out;
|
||||
auto add = [&](std::string key, std::string title, std::string group, std::function<AppActionRunResult(const std::string&)> runner,
|
||||
std::string input = {}) {
|
||||
std::string icon;
|
||||
if (auto it = command_icons().find(key); it != command_icons().end())
|
||||
icon = it->second;
|
||||
std::string input = {}, std::string icon = {}) {
|
||||
out.push_back({std::move(key), std::move(title), std::move(group), std::move(input), std::move(icon), std::move(runner)});
|
||||
};
|
||||
// Presentation-first overload: keeps the tile icon next to the title/group it belongs to.
|
||||
auto add_with_icon = [&](std::string key, std::string title, std::string group, std::string icon,
|
||||
std::function<AppActionRunResult(const std::string&)> runner, std::string input = {}) {
|
||||
add(std::move(key), std::move(title), std::move(group), std::move(runner), std::move(input), std::move(icon));
|
||||
};
|
||||
|
||||
// ---- Slice & Export ----
|
||||
add("slice_and_preview", _u8L("Slice and Preview"), _u8L("Slice & Export"), [](const std::string&) {
|
||||
add_with_icon("slice_and_preview", _u8L("Slice and Preview"), _u8L("Slice & Export"), "media_play", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater) {
|
||||
plater->reslice();
|
||||
@@ -244,8 +167,8 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
|
||||
add(
|
||||
"go_to_layer", _u8L("Go to layer (percent)"), _u8L("Commands"),
|
||||
add_with_icon(
|
||||
"go_to_layer", _u8L("Go to layer (percent)"), _u8L("Commands"), "height_range_layer",
|
||||
[](const std::string& param) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater) {
|
||||
@@ -258,47 +181,52 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
},
|
||||
"percent");
|
||||
|
||||
// "go_to_tab" is two-phase: the palette collects the tab after activating it, so dispatch here
|
||||
// is a no-op (the jump goes through the go_to_tab web command).
|
||||
// "go_to_tab" is two-phase: the palette collects the tab after activating it, then hands the tab
|
||||
// id back as `param` (same contract as go_to_layer's percent).
|
||||
add(
|
||||
"go_to_tab", _u8L("Go to tab..."), _u8L("Commands"),
|
||||
[](const std::string&) { return AppActionRunResult{AppActionRunResult::Level::Success}; }, "tab");
|
||||
[](const std::string& param) {
|
||||
if (MainFrame* mf = wxGetApp().mainframe; mf && !param.empty())
|
||||
mf->select_tab(from_u8(param));
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
},
|
||||
"tab");
|
||||
|
||||
add("load_project", _u8L("Load Project"), _u8L("Commands"), [](const std::string&) {
|
||||
add_with_icon("load_project", _u8L("Load Project"), _u8L("Commands"), "menu_open", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->load_project();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("save_project", _u8L("Save Project"), _u8L("Commands"), [](const std::string&) {
|
||||
add_with_icon("save_project", _u8L("Save Project"), _u8L("Commands"), "menu_save", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->save_project(false);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("save_project_as", _u8L("Save Project As"), _u8L("Commands"), [](const std::string&) {
|
||||
add_with_icon("save_project_as", _u8L("Save Project As"), _u8L("Commands"), "menu_save", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->save_project(true);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("open_preferences", _u8L("Preferences"), _u8L("Commands"), [](const std::string&) {
|
||||
add_with_icon("open_preferences", _u8L("Preferences"), _u8L("Commands"), "cog", [](const std::string&) {
|
||||
wxGetApp().open_preferences();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
|
||||
// ---- Mode ----
|
||||
add("mode_simple", _u8L("Mode: Simple"), _u8L("Mode"), [](const std::string&) {
|
||||
select_mode(comSimple);
|
||||
add_with_icon("mode_simple", _u8L("Mode: Simple"), _u8L("Mode"), "advanced", [](const std::string&) {
|
||||
wxGetApp().set_mode(comSimple);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("mode_advanced", _u8L("Mode: Advanced"), _u8L("Mode"), [](const std::string&) {
|
||||
select_mode(comAdvanced);
|
||||
add_with_icon("mode_advanced", _u8L("Mode: Advanced"), _u8L("Mode"), "advanced", [](const std::string&) {
|
||||
wxGetApp().set_mode(comAdvanced);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("mode_expert", _u8L("Mode: Expert"), _u8L("Mode"), [](const std::string&) {
|
||||
select_mode(comExpert);
|
||||
add_with_icon("mode_expert", _u8L("Mode: Expert"), _u8L("Mode"), "advanced", [](const std::string&) {
|
||||
wxGetApp().set_mode(comExpert);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
// Mirrors Preferences > Developer > Developer mode: flip the flag, persist, refresh the UI.
|
||||
add("toggle_developer_mode", _u8L("Toggle Developer Mode"), _u8L("Mode"), [](const std::string&) {
|
||||
add_with_icon("toggle_developer_mode", _u8L("Toggle Developer Mode"), _u8L("Mode"), "advanced", [](const std::string&) {
|
||||
GUI_App& app = wxGetApp();
|
||||
const bool on = !app.app_config->get_bool("developer_mode");
|
||||
app.app_config->set_bool("developer_mode", on);
|
||||
@@ -308,50 +236,50 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
});
|
||||
|
||||
// ---- Export pipeline ----
|
||||
add("export_gcode", _u8L("Export G-code"), _u8L("Slice & Export"), [](const std::string&) {
|
||||
add_with_icon("export_gcode", _u8L("Export G-code"), _u8L("Slice & Export"), "menu_export_gcode", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_gcode(false);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_stl", _u8L("Export STL"), _u8L("Slice & Export"), [](const std::string&) {
|
||||
add_with_icon("export_stl", _u8L("Export STL"), _u8L("Slice & Export"), "menu_export_stl", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_stl();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_3mf", _u8L("Export 3MF"), _u8L("Slice & Export"), [](const std::string&) {
|
||||
add_with_icon("export_3mf", _u8L("Export 3MF"), _u8L("Slice & Export"), "menu_save", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_core_3mf();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_sliced_file", _u8L("Export Sliced File"), _u8L("Slice & Export"), [](const std::string&) {
|
||||
add_with_icon("export_sliced_file", _u8L("Export Sliced File"), _u8L("Slice & Export"), "menu_export_sliced_file", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_gcode_3mf(false);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_all_sliced_file", _u8L("Export All Sliced Files"), _u8L("Slice & Export"), [](const std::string&) {
|
||||
add_with_icon("export_all_sliced_file", _u8L("Export All Sliced Files"), _u8L("Slice & Export"), "menu_export_sliced_file", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_gcode_3mf(true);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
|
||||
// ---- Calibration ----
|
||||
add("calib_temperature", _u8L("Temperature Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_temperature", _u8L("Temperature Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::Temperature); });
|
||||
add("calib_max_volumetric", _u8L("Max Volumetric Speed Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_max_volumetric", _u8L("Max Volumetric Speed Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::MaxVolumetric); });
|
||||
add("calib_pressure_advance", _u8L("Pressure Advance Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_pressure_advance", _u8L("Pressure Advance Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::PressureAdvance); });
|
||||
add("calib_flow_ratio", _u8L("Flow Ratio Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_flow_ratio", _u8L("Flow Ratio Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::FlowRatio); });
|
||||
add("calib_retraction", _u8L("Retraction Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_retraction", _u8L("Retraction Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::Retraction); });
|
||||
add("calib_cornering", _u8L("Cornering Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_cornering", _u8L("Cornering Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::Cornering); });
|
||||
add("calib_input_shaping_freq", _u8L("Input Shaping Frequency Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_input_shaping_freq", _u8L("Input Shaping Frequency Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::InputShapingFreq); });
|
||||
add("calib_input_shaping_damp", _u8L("Input Shaping Damping Calibration"), _u8L("Calibration"),
|
||||
add_with_icon("calib_input_shaping_damp", _u8L("Input Shaping Damping Calibration"), _u8L("Calibration"), "calib_sf",
|
||||
[](const std::string&) { return calib_command(CalibKind::InputShapingDamp); });
|
||||
add("calib_vfa", _u8L("VFA Calibration"), _u8L("Calibration"), [](const std::string&) { return calib_command(CalibKind::VFA); });
|
||||
add_with_icon("calib_vfa", _u8L("VFA Calibration"), _u8L("Calibration"), "calib_sf", [](const std::string&) { return calib_command(CalibKind::VFA); });
|
||||
|
||||
// ---- View ----
|
||||
for (auto [key, dir, title] :
|
||||
@@ -386,39 +314,39 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
plater->get_camera().select_next_type();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("reset_window_layout", _u8L("Reset Window Layout"), _u8L("View"), [](const std::string&) {
|
||||
add_with_icon("reset_window_layout", _u8L("Reset Window Layout"), _u8L("View"), "toolbar_reset", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->reset_window_layout();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
|
||||
// ---- Object ----
|
||||
add("obj_delete", _u8L("Delete Selected"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_delete", _u8L("Delete Selected"), _u8L("Object"), "menu_delete", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return !p->is_selection_empty(); }, [](Plater* p) { p->remove_selected(); });
|
||||
});
|
||||
add("obj_delete_all", _u8L("Delete All Objects"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_delete_all", _u8L("Delete All Objects"), _u8L("Object"), "menu_remove", [](const std::string&) {
|
||||
return object_op(
|
||||
wxGetApp().plater(), [](Plater* p) { return p->can_delete_all(); }, [](Plater* p) { p->delete_all_objects_from_model(); });
|
||||
});
|
||||
add("obj_mirror_x", _u8L("Mirror X"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_mirror_x", _u8L("Mirror X"), _u8L("Object"), "menu_mirror_x", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_mirror(); }, [](Plater* p) { p->mirror(Axis::X); });
|
||||
});
|
||||
add("obj_mirror_y", _u8L("Mirror Y"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_mirror_y", _u8L("Mirror Y"), _u8L("Object"), "menu_mirror_y", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_mirror(); }, [](Plater* p) { p->mirror(Axis::Y); });
|
||||
});
|
||||
add("obj_mirror_z", _u8L("Mirror Z"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_mirror_z", _u8L("Mirror Z"), _u8L("Object"), "menu_mirror_z", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_mirror(); }, [](Plater* p) { p->mirror(Axis::Z); });
|
||||
});
|
||||
add("obj_split_objects", _u8L("Split to Objects"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_split_objects", _u8L("Split to Objects"), _u8L("Object"), "menu_split_objects", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_split_to_objects(); }, [](Plater* p) { p->split_object(true); });
|
||||
});
|
||||
add("obj_split_parts", _u8L("Split to Parts"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_split_parts", _u8L("Split to Parts"), _u8L("Object"), "menu_split_parts", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_split_to_volumes(); }, [](Plater* p) { p->split_volume(); });
|
||||
});
|
||||
add("obj_center", _u8L("Center Selected on Plate"), _u8L("Object"), [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return !p->is_selection_empty(); }, [](Plater* p) { p->center_selection(); });
|
||||
});
|
||||
add("obj_drop", _u8L("Drop to Bed"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_drop", _u8L("Drop to Bed"), _u8L("Object"), "toolbar_flatten", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return !p->is_selection_empty(); }, [](Plater* p) { p->drop_selection(); });
|
||||
});
|
||||
add("obj_fit_volume", _u8L("Scale to Fit Print Volume"), _u8L("Object"), [](const std::string&) {
|
||||
@@ -426,24 +354,24 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
wxGetApp().plater(), [](Plater* p) { return p->can_scale_to_print_volume(); },
|
||||
[](Plater* p) { p->scale_selection_to_fit_print_volume(); });
|
||||
});
|
||||
add("obj_instances_up", _u8L("Increase Instances"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_instances_up", _u8L("Increase Instances"), _u8L("Object"), "instance_add", [](const std::string&) {
|
||||
return object_op(
|
||||
wxGetApp().plater(), [](Plater* p) { return p->can_increase_instances(); }, [](Plater* p) { p->increase_instances(); });
|
||||
});
|
||||
add("obj_instances_down", _u8L("Decrease Instances"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_instances_down", _u8L("Decrease Instances"), _u8L("Object"), "instance_remove", [](const std::string&) {
|
||||
return object_op(
|
||||
wxGetApp().plater(), [](Plater* p) { return p->can_decrease_instances(); }, [](Plater* p) { p->decrease_instances(); });
|
||||
});
|
||||
add("obj_arrange", _u8L("Auto-Arrange"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_arrange", _u8L("Auto-Arrange"), _u8L("Object"), "toolbar_arrange", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_arrange(); }, [](Plater* p) { p->arrange(); });
|
||||
});
|
||||
add("obj_orient", _u8L("Auto-Orient"), _u8L("Object"), [](const std::string&) {
|
||||
add_with_icon("obj_orient", _u8L("Auto-Orient"), _u8L("Object"), "toolbar_orient", [](const std::string&) {
|
||||
return object_op(wxGetApp().plater(), [](Plater* p) { return p->can_arrange(); }, [](Plater* p) { p->orient(); });
|
||||
});
|
||||
|
||||
// ---- Add Primitive ---- (the Add > Add Primitive submenu; creates a new object)
|
||||
auto add_primitive = [&](std::string key, std::string title, const char* type_name) {
|
||||
add(std::move(key), std::move(title), _u8L("Add Primitive"), [type_name](const std::string&) {
|
||||
auto add_primitive = [&](std::string key, std::string title, std::string icon, const char* type_name) {
|
||||
add_with_icon(std::move(key), std::move(title), _u8L("Add Primitive"), std::move(icon), [type_name](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater) {
|
||||
ensure_3d_view(plater);
|
||||
@@ -453,13 +381,13 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
};
|
||||
add_primitive("add_primitive_cube", _u8L("Cube"), "Cube");
|
||||
add_primitive("add_primitive_cylinder", _u8L("Cylinder"), "Cylinder");
|
||||
add_primitive("add_primitive_sphere", _u8L("Sphere"), "Sphere");
|
||||
add_primitive("add_primitive_cone", _u8L("Cone"), "Cone");
|
||||
add_primitive("add_primitive_disc", _u8L("Disc"), "Disc");
|
||||
add_primitive("add_primitive_torus", _u8L("Torus"), "Torus");
|
||||
add("add_primitive_text", _u8L("Text"), _u8L("Add Primitive"), [](const std::string&) {
|
||||
add_primitive("add_primitive_cube", _u8L("Cube"), "menu_obj_cube", "Cube");
|
||||
add_primitive("add_primitive_cylinder", _u8L("Cylinder"), "menu_obj_cylinder", "Cylinder");
|
||||
add_primitive("add_primitive_sphere", _u8L("Sphere"), "menu_obj_sphere", "Sphere");
|
||||
add_primitive("add_primitive_cone", _u8L("Cone"), "menu_obj_cone", "Cone");
|
||||
add_primitive("add_primitive_disc", _u8L("Disc"), "menu_obj_disc", "Disc");
|
||||
add_primitive("add_primitive_torus", _u8L("Torus"), "menu_obj_torus", "Torus");
|
||||
add_with_icon("add_primitive_text", _u8L("Text"), _u8L("Add Primitive"), "menu_obj_text", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater) {
|
||||
ensure_3d_view(plater);
|
||||
@@ -469,7 +397,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
}
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("add_primitive_svg", _u8L("SVG"), _u8L("Add Primitive"), [](const std::string&) {
|
||||
add_with_icon("add_primitive_svg", _u8L("SVG"), _u8L("Add Primitive"), "menu_obj_svg", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (plater) {
|
||||
ensure_3d_view(plater);
|
||||
@@ -493,7 +421,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
}
|
||||
|
||||
// ---- Plate ----
|
||||
add("plate_add", _u8L("Add Plate"), _u8L("Plate"), [](const std::string&) {
|
||||
add_with_icon("plate_add", _u8L("Add Plate"), _u8L("Plate"), "toolbar_add_plate", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (!is_fff_plater(plater))
|
||||
return plate_unavailable();
|
||||
@@ -502,7 +430,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
plater->add_plate();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("plate_duplicate", _u8L("Duplicate Plate"), _u8L("Plate"), [](const std::string&) {
|
||||
add_with_icon("plate_duplicate", _u8L("Duplicate Plate"), _u8L("Plate"), "menu_copy", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (!is_fff_plater(plater))
|
||||
return plate_unavailable();
|
||||
@@ -511,7 +439,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
plater->duplicate_plate();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("plate_delete", _u8L("Delete Plate"), _u8L("Plate"), [](const std::string&) {
|
||||
add_with_icon("plate_delete", _u8L("Delete Plate"), _u8L("Plate"), "menu_delete", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (!is_fff_plater(plater))
|
||||
return plate_unavailable();
|
||||
@@ -520,7 +448,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
plater->delete_plate();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("plate_rename", _u8L("Rename Plate"), _u8L("Plate"), [](const std::string&) {
|
||||
add_with_icon("plate_rename", _u8L("Rename Plate"), _u8L("Plate"), "plate_name_edit", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (!is_fff_plater(plater))
|
||||
return plate_unavailable();
|
||||
@@ -531,7 +459,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
curr->set_plate_name(dlg.get_plate_name().ToUTF8().data());
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("plate_toggle_lock", _u8L("Toggle Plate Lock"), _u8L("Plate"), [](const std::string&) {
|
||||
add_with_icon("plate_toggle_lock", _u8L("Toggle Plate Lock"), _u8L("Plate"), "lock_normal", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (!is_fff_plater(plater))
|
||||
return plate_unavailable();
|
||||
@@ -541,7 +469,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
plates.lock_plate(index, !plates.is_locked(index));
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("plate_goto", _u8L("Go to Plate"), _u8L("Plate"), [](const std::string& param) {
|
||||
add_with_icon("plate_goto", _u8L("Go to Plate"), _u8L("Plate"), "go_next_plate", [](const std::string& param) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
if (!is_fff_plater(plater))
|
||||
return plate_unavailable();
|
||||
@@ -559,7 +487,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
});
|
||||
|
||||
// ---- Printer / device connection ----
|
||||
add("sync_ams", _u8L("Synchronize Filament List from AMS"), _u8L("Printer"), [](const std::string&) {
|
||||
add_with_icon("sync_ams", _u8L("Synchronize Filament List from AMS"), _u8L("Printer"), "ams_fila_sync", [](const std::string&) {
|
||||
Plater* plater = wxGetApp().plater();
|
||||
DeviceManager* dev = wxGetApp().getDeviceManager();
|
||||
if (dev && dev->get_selected_machine() && plater) {
|
||||
@@ -570,11 +498,11 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
});
|
||||
|
||||
// ---- Presets / cloud ----
|
||||
add("preset_bundle", _u8L("Open Preset Bundle"), _u8L("Presets"), [](const std::string&) {
|
||||
add_with_icon("preset_bundle", _u8L("Open Preset Bundle"), _u8L("Presets"), "menu_edit_preset", [](const std::string&) {
|
||||
wxGetApp().open_presetbundledialog();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("sync_presets", _u8L("Sync Presets"), _u8L("Presets"), [](const std::string&) {
|
||||
add_with_icon("sync_presets", _u8L("Sync Presets"), _u8L("Presets"), "printer_sync_ok", [](const std::string&) {
|
||||
if (!wxGetApp().is_user_login())
|
||||
return AppActionRunResult{AppActionRunResult::Level::Info, _L("Sign in to sync presets.")};
|
||||
wxGetApp().restart_sync_user_preset();
|
||||
@@ -582,7 +510,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
});
|
||||
|
||||
// ---- Import ----
|
||||
add("import_file", _u8L("Import 3MF/STL/STEP/SVG/OBJ/AMF"), _u8L("Import"), [](const std::string&) {
|
||||
add_with_icon("import_file", _u8L("Import 3MF/STL/STEP/SVG/OBJ/AMF"), _u8L("Import"), "menu_import", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater()) {
|
||||
#ifdef __APPLE__
|
||||
plater->add_model();
|
||||
@@ -592,39 +520,39 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
}
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("import_zip_archive", _u8L("Import ZIP Archive"), _u8L("Import"), [](const std::string&) {
|
||||
add_with_icon("import_zip_archive", _u8L("Import ZIP Archive"), _u8L("Import"), "menu_import", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->import_zip_archive();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("import_configs", _u8L("Import Configs"), _u8L("Import"), [](const std::string&) {
|
||||
add_with_icon("import_configs", _u8L("Import Configs"), _u8L("Import"), "menu_import", [](const std::string&) {
|
||||
if (MainFrame* mf = wxGetApp().mainframe)
|
||||
mf->load_config_file();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
|
||||
// ---- Export extras ----
|
||||
add("export_stl_multi", _u8L("Export All Objects as STLs"), _u8L("Export"), [](const std::string&) {
|
||||
add_with_icon("export_stl_multi", _u8L("Export All Objects as STLs"), _u8L("Export"), "menu_export_stl", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_stl(false, false, true);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_drc_single", _u8L("Export All Objects as DRC (one file)"), _u8L("Export"), [](const std::string&) {
|
||||
add_with_icon("export_drc_single", _u8L("Export All Objects as DRC (one file)"), _u8L("Export"), "menu_export_stl", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_stl(false, false, false, FT_DRC);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_drc_multi", _u8L("Export All Objects as DRCs"), _u8L("Export"), [](const std::string&) {
|
||||
add_with_icon("export_drc_multi", _u8L("Export All Objects as DRCs"), _u8L("Export"), "menu_export_stl", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_stl(false, false, true, FT_DRC);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_toolpaths_obj", _u8L("Export Toolpaths as OBJ"), _u8L("Export"), [](const std::string&) {
|
||||
add_with_icon("export_toolpaths_obj", _u8L("Export Toolpaths as OBJ"), _u8L("Export"), "menu_export_toolpaths", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater())
|
||||
plater->export_toolpaths_to_obj();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("export_config", _u8L("Export Preset Bundle"), _u8L("Export"), [](const std::string&) {
|
||||
add_with_icon("export_config", _u8L("Export Preset Bundle"), _u8L("Export"), "menu_export_config", [](const std::string&) {
|
||||
if (MainFrame* mf = wxGetApp().mainframe)
|
||||
mf->export_config();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
@@ -639,7 +567,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
wxGetApp().ShowUserGuide();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("help_open_config_folder", _u8L("Show Configuration Folder"), _u8L("Help"), [](const std::string&) {
|
||||
add_with_icon("help_open_config_folder", _u8L("Show Configuration Folder"), _u8L("Help"), "folder-closed", [](const std::string&) {
|
||||
Slic3r::GUI::desktop_open_datadir_folder();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
@@ -652,7 +580,7 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
dlg.ShowModal();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("help_tip_of_the_day", _u8L("Show Tip of the Day"), _u8L("Help"), [](const std::string&) {
|
||||
add_with_icon("help_tip_of_the_day", _u8L("Show Tip of the Day"), _u8L("Help"), "info", [](const std::string&) {
|
||||
if (Plater* plater = wxGetApp().plater()) {
|
||||
plater->get_dailytips()->open();
|
||||
if (GLCanvas3D* canvas = plater->get_current_canvas3D())
|
||||
@@ -660,15 +588,15 @@ std::vector<NativeCommand> build_command_catalog()
|
||||
}
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("help_check_updates", _u8L("Check for Updates"), _u8L("Help"), [](const std::string&) {
|
||||
add_with_icon("help_check_updates", _u8L("Check for Updates"), _u8L("Help"), "ams_refresh_normal", [](const std::string&) {
|
||||
wxGetApp().check_new_version_sf(true, 1);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("help_about", _u8L("About OrcaSlicer"), _u8L("Help"), [](const std::string&) {
|
||||
add_with_icon("help_about", _u8L("About OrcaSlicer"), _u8L("Help"), "OrcaSlicer_about", [](const std::string&) {
|
||||
Slic3r::GUI::about();
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
add("open_wiki", _u8L("Open Wiki"), _u8L("Help"), [](const std::string&) {
|
||||
add_with_icon("open_wiki", _u8L("Open Wiki"), _u8L("Help"), "link_wiki_img", [](const std::string&) {
|
||||
wxLaunchDefaultBrowser("https://www.orcaslicer.com/wiki/", wxBROWSER_NEW_WINDOW);
|
||||
return AppActionRunResult{AppActionRunResult::Level::Success};
|
||||
});
|
||||
@@ -706,6 +634,11 @@ const std::vector<NativeCommand>& NativeCommands::catalog()
|
||||
return commands;
|
||||
}
|
||||
|
||||
std::unique_ptr<AppAction> NativeCommands::make_action(const NativeCommand& command)
|
||||
{
|
||||
return std::make_unique<CommandAction>(command);
|
||||
}
|
||||
|
||||
AppActionRunResult NativeCommands::run(const std::string& key, const std::string& param)
|
||||
{
|
||||
GUI_App& app = wxGetApp();
|
||||
|
||||
Reference in New Issue
Block a user