indicatrix-cut 0.7.2

Desktop faceting-design editor: library browsing, spectral 3D rendering, material retargeting, and a solid inspection view.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
//! The command table: every action the palette can run.
//!
//! **Adding a command is one entry in [`COMMANDS`].** Give it a unique `id`, the name users
//! already know from the menu or button, a few search keywords, its key combination if it
//! has one (it must also be a row of `gui::editor::shortcuts::SHORTCUTS`), the checks that
//! decide when it is available, and what it runs. The palette, its search, its disabled
//! reasons and the guide locks all come from the entry; nothing else needs touching.
//!
//! A command runs the same Slint callback or property its menu item or button uses. Put the
//! guide's lock first in `requires`, so a locked command always says "Locked by the guide".

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 _;

/// A run action that invokes one callback of a global: `call!(EditorModel.invoke_undo)`.
macro_rules! call {
    ($model:ident . $method:ident) => {
        |ui: &MainWindow| {
            ui.global::<crate::$model>().$method();
        }
    };
}

/// A run action that sets one property of a global: `set!(ShortcutsModel.set_open(true))`.
macro_rules! set {
    ($model:ident . $method:ident ( $value:expr )) => {
        |ui: &MainWindow| {
            ui.global::<crate::$model>().$method($value);
        }
    };
}

/// Every palette command, in the order equal search scores keep.
pub static COMMANDS: &[Command] = &[
    // --- File -------------------------------------------------------------------------
    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),
    ),
    // --- Edit -------------------------------------------------------------------------
    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),
    ),
    // --- View -------------------------------------------------------------------------
    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,
    ),
    // --- Tiers ------------------------------------------------------------------------
    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,
    ),
    // --- Solve ------------------------------------------------------------------------
    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)),
    ),
    // --- Tools ------------------------------------------------------------------------
    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,
    ),
    // --- Help -------------------------------------------------------------------------
    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;