mod requires;
use super::{
registry::{Category, Command, command},
rules::Check,
run,
state::GuideGroup,
};
use crate::MainWindow;
use requires::{
ADVANCED, ADVANCED_DESIGN, CONCAVE_TIER, DEEP_SOLVE, EDITOR, FILE_OPS, FILE_OPS_DESIGN,
FILE_OPS_LIBRARY, HISTORY_DESIGN, HISTORY_EDITOR, INSPECTOR_OPTIMIZE, INSPECTOR_PREFORM,
INSPECTOR_SCHEDULE, INSPECTOR_TIER, LIBRARY_SELECTED, MATERIAL_EDITOR, NEW_DESIGN, NONE,
OPTIMIZE, REDO, SLICE, SOLVE, SOLVE_SETTING, TIER_ACTION, TIER_FORM, TIER_TABLE, TO_ADVANCED,
TO_SIMPLE, UNDO, VIEW_TABS,
};
use slint::ComponentHandle as _;
macro_rules! call {
($model:ident . $method:ident) => {
|ui: &MainWindow| {
ui.global::<crate::$model>().$method();
}
};
}
macro_rules! set {
($model:ident . $method:ident ( $value:expr )) => {
|ui: &MainWindow| {
ui.global::<crate::$model>().$method($value);
}
};
}
pub static COMMANDS: &[Command] = &[
command(
"file.new",
"New Design...",
Category::File,
"create start blank empty template",
Some("Ctrl+N"),
NEW_DESIGN,
set!(EditorModel.set_new_dialog_open(true)),
),
command(
"file.open",
"Open...",
Category::File,
"load design file open",
Some("Ctrl+O"),
FILE_OPS,
call!(EditorModel.invoke_open_native),
),
command(
"file.save",
"Save",
Category::File,
"write store keep",
Some("Ctrl+S"),
FILE_OPS_DESIGN,
call!(EditorModel.invoke_save_native),
),
command(
"file.save_as",
"Save As...",
Category::File,
"write copy rename new file",
Some("Ctrl+Shift+S"),
FILE_OPS_DESIGN,
call!(EditorModel.invoke_save_native_as),
),
command(
"file.save_variant",
"Save as Variant...",
Category::File,
"named copy branch version alternative keep try library",
None,
HISTORY_DESIGN,
run::save_variant,
),
command(
"file.load_selected",
"Load Selected Library Design",
Category::File,
"library catalogue edit open into editor",
None,
FILE_OPS_LIBRARY,
call!(EditorModel.invoke_load_selected),
),
command(
"file.export_asc",
"Export Edited .asc",
Category::File,
"gemcad text export save",
None,
FILE_OPS_DESIGN,
call!(EditorModel.invoke_export_asc),
),
command(
"file.export_gcs",
"Export as Gem Cut Studio (.gcs)...",
Category::File,
"experimental export gcs save",
None,
FILE_OPS_DESIGN,
call!(EditorModel.invoke_export_gcs),
),
command(
"file.export_cutting_sheet",
"Export Cutting Sheet (HTML)...",
Category::File,
"print instructions html export save",
None,
FILE_OPS_DESIGN,
call!(EditorModel.invoke_export_cutting_sheet),
),
command(
"file.export_diagram",
"Export Diagram (PNG)...",
Category::File,
"picture image png export save",
None,
FILE_OPS_DESIGN,
call!(EditorModel.invoke_export_diagram),
),
command(
"file.reveal_last_saved",
"Show Last Saved File in Folder",
Category::File,
"reveal explorer location open folder",
None,
&[Check::HasLastSaved],
call!(EditorModel.invoke_reveal_last_saved_path),
),
command(
"edit.undo",
"Undo",
Category::Edit,
"revert back history",
Some("Ctrl+Z"),
UNDO,
call!(EditorModel.invoke_undo),
),
command(
"edit.redo",
"Redo",
Category::Edit,
"again forward history",
Some("Ctrl+Y"),
REDO,
call!(EditorModel.invoke_redo),
),
command(
"edit.edit_as_text",
"Edit Instructions as Text...",
Category::Edit,
"raw asc text cutting instructions lines type write compare",
None,
ADVANCED_DESIGN,
call!(RawTextModel.invoke_open),
),
command(
"edit.preferences",
"Preferences...",
Category::Edit,
"settings options scale contrast handles tutorials",
Some("Ctrl+,"),
ADVANCED,
set!(PreferencesModel.set_dialog_open(true)),
),
command(
"edit.simple_interface",
"Use the Simple Interface",
Category::Edit,
"simple basic fewer controls mode",
None,
TO_SIMPLE,
|ui: &MainWindow| run::set_simple_interface(ui, true),
),
command(
"edit.advanced_interface",
"Use the Advanced Interface",
Category::Edit,
"advanced all controls mode",
None,
TO_ADVANCED,
|ui: &MainWindow| run::set_simple_interface(ui, false),
),
command(
"view.tab_3d",
"Go to 3D Spectral Preview",
Category::View,
"gem viewer first tab",
Some("Ctrl+1"),
NONE,
|ui: &MainWindow| run::show_tab(ui, run::TAB_3D),
),
command(
"view.tab_cutting",
"Go to Cutting Instructions",
Category::View,
"cutting table angles tab",
Some("Ctrl+2"),
VIEW_TABS,
|ui: &MainWindow| run::show_tab(ui, run::TAB_CUTTING),
),
command(
"view.tab_files",
"Go to Files & Downloads",
Category::View,
"attachments files tab",
Some("Ctrl+3"),
VIEW_TABS,
|ui: &MainWindow| run::show_tab(ui, run::TAB_FILES),
),
command(
"view.live_render",
"Show Live Render",
Category::View,
"render ray trace view tab",
Some("Ctrl+E"),
VIEW_TABS,
run::show_live_render_view,
),
command(
"view.edit",
"Show Edit Tab",
Category::View,
"editor designer tier table view tab",
Some("Ctrl+E"),
EDITOR,
run::show_edit_view,
),
command(
"view.solid",
"Solid View",
Category::View,
"edit viewport mode shaded",
Some("1"),
EDITOR,
|ui: &MainWindow| run::set_solid_view_mode(ui, 0),
),
command(
"view.path_traced",
"Path-Traced View",
Category::View,
"edit viewport mode render ray",
Some("2"),
EDITOR,
|ui: &MainWindow| run::set_solid_view_mode(ui, 1),
),
command(
"view.both",
"Solid and Path-Traced View",
Category::View,
"edit viewport mode both overlay",
Some("3"),
EDITOR,
|ui: &MainWindow| run::set_solid_view_mode(ui, 2),
),
command(
"view.diagram",
"Diagram View",
Category::View,
"edit viewport mode gemcad 2d plan",
Some("4"),
EDITOR,
|ui: &MainWindow| run::set_solid_view_mode(ui, 3),
),
command(
"view.live_solid",
"Live Render: Solid Mode",
Category::View,
"fast raster shaded",
None,
VIEW_TABS,
|ui: &MainWindow| run::set_live_view_mode(ui, 0),
),
command(
"view.live_traced",
"Live Render: Path-Traced Mode",
Category::View,
"ray traced accurate",
None,
VIEW_TABS,
|ui: &MainWindow| run::set_live_view_mode(ui, 1),
),
command(
"view.inspector_tier",
"Inspector: Tier Tab",
Category::View,
"facet form angle indices",
None,
INSPECTOR_TIER,
|ui: &MainWindow| run::show_inspector_tab(ui, 0),
),
command(
"view.inspector_preform",
"Inspector: Preform Tab",
Category::View,
"rough shape yield girdle",
None,
INSPECTOR_PREFORM,
|ui: &MainWindow| run::show_inspector_tab(ui, 1),
),
command(
"view.inspector_optimize",
"Inspector: Optimize Tab",
Category::View,
"weights budget search",
None,
INSPECTOR_OPTIMIZE,
|ui: &MainWindow| run::show_inspector_tab(ui, 2),
),
command(
"view.inspector_schedule",
"Inspector: Schedule Tab",
Category::View,
"cutting instructions table",
None,
INSPECTOR_SCHEDULE,
|ui: &MainWindow| run::show_inspector_tab(ui, 3),
),
command(
"view.inspector_history",
"Inspector: History Tab",
Category::View,
"undo steps jump back pictures earlier",
None,
EDITOR,
|ui: &MainWindow| run::show_inspector_tab(ui, 4),
),
command(
"view.inspector_variants",
"Inspector: Variants",
Category::View,
"saved copies branches versions compare open earlier alternatives",
None,
HISTORY_EDITOR,
run::show_variants,
),
command(
"view.library_panel",
"Show or Hide the Library Panel",
Category::View,
"catalogue list sidebar collapse expand",
None,
NONE,
run::toggle_library_panel,
),
command(
"view.slice",
"Toggle Slice Mode",
Category::View,
"cut facet mouse line drag",
Some("S"),
SLICE,
run::toggle_slice_mode,
),
command(
"view.snap",
"Toggle Snap to Gear Steps",
Category::View,
"snapping handles angle depth",
None,
NONE,
run::toggle_snap,
),
command(
"tiers.add",
"Add Tier",
Category::Tiers,
"new facet tier form",
None,
TIER_FORM,
run::add_tier,
),
command(
"tiers.add_concave",
"Add Concave Tier",
Category::Tiers,
"tool cut cylinder cone sphere",
None,
CONCAVE_TIER,
call!(EditorModel.invoke_add_concave_tier),
),
command(
"tiers.duplicate",
"Duplicate Selected Tier",
Category::Tiers,
"copy clone",
Some("Ctrl+D"),
TIER_ACTION,
run::duplicate_selected_tier,
),
command(
"tiers.delete",
"Delete Selected Tier",
Category::Tiers,
"remove",
Some("Delete"),
TIER_ACTION,
run::delete_selected_tier,
),
command(
"tiers.move_up",
"Move Selected Tier Earlier",
Category::Tiers,
"reorder up cutting order",
Some("Alt+Up"),
TIER_ACTION,
|ui: &MainWindow| run::move_selected_tier(ui, -1),
),
command(
"tiers.move_down",
"Move Selected Tier Later",
Category::Tiers,
"reorder down cutting order",
Some("Alt+Down"),
TIER_ACTION,
|ui: &MainWindow| run::move_selected_tier(ui, 1),
),
command(
"tiers.adopt_all",
"Adopt All Imported Meets",
Category::Tiers,
"adopt convert meet imported",
None,
TIER_TABLE,
call!(EditorModel.invoke_adopt_all),
),
command(
"tiers.adopt_selected",
"Adopt Imported Meets of Selected Tiers",
Category::Tiers,
"adopt convert meet imported",
None,
TIER_TABLE,
call!(EditorModel.invoke_adopt_selected),
),
command(
"tiers.filter",
"Filter Tiers",
Category::Tiers,
"search find tier table",
Some("Ctrl+F"),
&[Check::EditView],
run::focus_tier_filter,
),
command(
"tiers.clear_selection",
"Clear Tier Selection",
Category::Tiers,
"deselect none",
Some("Esc"),
&[Check::TierSelected],
run::clear_tier_selection,
),
command(
"solve.run",
"Solve",
Category::Solve,
"calculate depths validate check",
Some("F5"),
SOLVE,
call!(EditorModel.invoke_solve),
),
command(
"solve.abandon",
"Abandon Solve",
Category::Solve,
"cancel stop",
None,
&[Check::SolveRunning],
call!(EditorModel.invoke_solve_cancel),
),
command(
"solve.deep",
"Deep Solve",
Category::Solve,
"verify printed proportions repair slow",
None,
DEEP_SOLVE,
call!(EditorModel.invoke_deep_solve),
),
command(
"solve.deep_cancel",
"Cancel Deep Solve",
Category::Solve,
"stop abandon",
None,
&[Check::DeepSolveRunning],
call!(EditorModel.invoke_deep_solve_cancel),
),
command(
"solve.optimize",
"Optimize",
Category::Solve,
"improve optics search free tiers",
None,
OPTIMIZE,
run::optimize,
),
command(
"solve.optimize_cancel",
"Cancel Optimize",
Category::Solve,
"stop abandon",
None,
&[Check::OptimizeRunning],
call!(EditorModel.invoke_optimize_cancel),
),
command(
"solve.retarget",
"Retarget...",
Category::Solve,
"material angles refractive index change",
None,
ADVANCED_DESIGN,
call!(RetargetModel.invoke_open),
),
command(
"solve.snapshot",
"Snapshot Design",
Category::Solve,
"capture remember state compare later",
None,
ADVANCED_DESIGN,
call!(EditorModel.invoke_snapshot_design),
),
command(
"solve.compare",
"Compare to Snapshot",
Category::Solve,
"diff differences changes",
None,
&[
Check::Guide(GuideGroup::Advanced),
Check::Design,
Check::HasSnapshot,
],
call!(EditorModel.invoke_compare_to_snapshot),
),
command(
"solve.tilt_curves",
"Compute Tilt Curves",
Category::Solve,
"brilliance windowing extinction performance",
None,
ADVANCED_DESIGN,
call!(EditorModel.invoke_compute_tilt_curves_for_open_design),
),
command(
"solve.auto_off",
"Auto-solve: Off",
Category::Solve,
"automatic re-solve budget manual",
None,
SOLVE_SETTING,
set!(EditorModel.set_auto_solve_budget_ms(0)),
),
command(
"solve.auto_150ms",
"Auto-solve: 150 ms",
Category::Solve,
"automatic re-solve budget",
None,
SOLVE_SETTING,
set!(EditorModel.set_auto_solve_budget_ms(150)),
),
command(
"solve.auto_300ms",
"Auto-solve: 300 ms",
Category::Solve,
"automatic re-solve budget",
None,
SOLVE_SETTING,
set!(EditorModel.set_auto_solve_budget_ms(300)),
),
command(
"solve.auto_1s",
"Auto-solve: 1 s",
Category::Solve,
"automatic re-solve budget second",
None,
SOLVE_SETTING,
set!(EditorModel.set_auto_solve_budget_ms(1000)),
),
command(
"solve.auto_3s",
"Auto-solve: 3 s",
Category::Solve,
"automatic re-solve budget seconds",
None,
SOLVE_SETTING,
set!(EditorModel.set_auto_solve_budget_ms(3000)),
),
command(
"tools.plan_rough",
"Plan Rough...",
Category::Tools,
"rough planner block yield library stones",
None,
NONE,
call!(RoughPlanModel.invoke_open),
),
command(
"tools.angle_sweep",
"Angle Sweep...",
Category::Tools,
"vary angle range step table chart csv metrics compare try tier",
None,
ADVANCED_DESIGN,
call!(SweepModel.invoke_open_dialog),
),
command(
"tools.cutting_mode",
"Cutting Mode...",
Category::Tools,
"cut cutting steps step by step walk through done progress mark bench tick indices",
None,
ADVANCED_DESIGN,
call!(CuttingModeModel.invoke_open_cutting_mode),
),
command(
"tools.regenerate_previews",
"Regenerate Preview Images...",
Category::Tools,
"library thumbnails batch pictures",
None,
&[Check::PreviewBatchIdle],
call!(LibraryModel.invoke_regenerate_all_previews),
),
command(
"tools.regenerate_tilt",
"Regenerate Tilt Curves...",
Category::Tools,
"library batch performance",
None,
&[Check::TiltBatchIdle],
call!(LibraryModel.invoke_regenerate_all_tilt_curves),
),
command(
"tools.regenerate_both",
"Regenerate Both Previews and Tilt Curves...",
Category::Tools,
"library batch pictures performance",
None,
&[Check::PreviewBatchIdle, Check::TiltBatchIdle],
call!(LibraryModel.invoke_regenerate_all_previews_and_tilt_curves),
),
command(
"tools.tilt_chart",
"Show Tilt Performance Chart",
Category::Tools,
"tilt curve graph brilliance windowing extinction",
None,
NONE,
call!(TiltModel.invoke_toggle_dialog),
),
command(
"tools.material_editor",
"New or Edit Gem Material...",
Category::Tools,
"custom material refractive index color",
None,
MATERIAL_EDITOR,
set!(ViewportModel.set_material_editor_open(true)),
),
command(
"tools.render_settings",
"Render Settings...",
Category::Tools,
"quality samples bounces live render",
None,
VIEW_TABS,
run::open_render_settings,
),
command(
"tools.export_render",
"Export Render Image...",
Category::Tools,
"high resolution picture save render",
None,
VIEW_TABS,
run::open_render_export,
),
command(
"help.manual",
"User Manual",
Category::Help,
"documentation help read",
None,
NONE,
|ui: &MainWindow| ui.invoke_open_user_manual(),
),
command(
"help.context",
"Help for This Screen",
Category::Help,
"manual page this panel context f1 what is this",
Some("F1"),
NONE,
|ui: &MainWindow| crate::gui::help::context::open_context_help(ui),
),
command(
"help.shortcuts",
"Keyboard Shortcuts",
Category::Help,
"keys keybindings hotkeys",
Some("?"),
NONE,
set!(ShortcutsModel.set_open(true)),
),
command(
"help.guide",
"Guide: New Design Walkthrough",
Category::Help,
"tutorial worked example learn",
None,
EDITOR,
call!(GuideModel.invoke_start),
),
command(
"help.tutorials",
"Tutorials...",
Category::Help,
"tutorial guide lesson learn how to browse",
None,
NONE,
call!(TutorialsModel.invoke_open_browser),
),
command(
"help.build_library_design",
"Build the Selected Library Design",
Category::Help,
"tutorial lesson rebuild library design step by step learn recreate guide",
None,
LIBRARY_SELECTED,
call!(BuildDesignModel.invoke_start_selected),
),
command(
"help.welcome_tour",
"Welcome Tour",
Category::Help,
"tour introduction welcome first start learn",
None,
NONE,
set!(PreferencesModel.set_first_run_tour_pending(true)),
),
];
#[cfg(test)]
mod tests;