use crate::{GuideModel, GuideStepData, MainWindow};
use slint::{ComponentHandle as _, ModelRc, SharedString, VecModel};
const STEPS: &[(&str, &str, &str)] = &[
(
"Start a new design",
"Open the New Design dialog (the empty state's \"New from Template\" card, \
or File > New Design...). For this walkthrough: Preform Shape Cylinder, \
Half-Width 1.50, Length/Width 1.00, Depth 1.50, Index Gear 96, Symmetry \
Order 8, Mirror on, Starting Material (none). Click Create.",
"new_design_dialog",
),
(
"Add the girdle first",
"The girdle needs to exist before the crown and pavilion, since it gives \
both blocks something to meet, and it needs its own anchor. On the Tier \
tab: Angle 90.0 (exactly -- 0.0 would classify as a second table, not a \
girdle), Meets: Exact scale value 1.0, Name G1, Indices \
0,12,24,36,48,60,72,84. Click Add Tier, then check the tier table's own \
C/P/G column reads G for this row.",
"tier_table",
),
(
"Add the pavilion main facets",
"Eight facets, angled steeply below the girdle: Angle -40.0 (a typical \
starting point -- refine later with Solve and Optimize), Meets: Named \
facet(s) G1, Name P1, the same eight indices as the girdle. Click Add \
Tier, then check the MARGIN column reads comfortably Safe.",
"tier_table",
),
(
"Add the crown main facets",
"Eight facets, angled above the girdle: Angle 34.5, Meets: Named facet(s) \
G1, Name C1, the same eight indices again. Click Add Tier.",
"tier_table",
),
(
"Add the table",
"One flat facet at the top, not indexed around the gear: Angle 0.0, \
Meets: Unspecified vertex (or Exact scale value, if you want to state the \
table size directly), Name T, Indices blank. Click Add Tier.",
"tier_table",
),
(
"Pick a real material",
"In the Design Settings panel, set Material to Diamond and click Apply \
Material. Watch the Effective RI / Critical Angle readouts update, and \
re-check the pavilion tier's MARGIN column at the new, smaller critical \
angle.",
"design_settings",
),
(
"Solve and check",
"Click Solve on the command bar (in the Inspector's own command bar row, \
above the tier table). \"Closed solid -- volume ...\" means you have a \
valid stone; a \"no anchor\" or \"Degenerate\"/\"Unbounded\" message names \
the tier most likely responsible -- check its angle and constraint.",
"",
),
(
"Check the orbits",
"For each multi-index tier (girdle, pavilion mains, crown mains), check \
the ORBIT column reads \"orbit x8\". An amber \"6/8 orbit\" means an index \
position is missing or inconsistent -- compare the tier's Indices field \
against the intended list.",
"tier_table",
),
(
"Yield and rendering (optional)",
"On the Preform tab's Yield section (in the Inspector), set Girdle \
Diameter (mm) to a real size and pick a Yield Material, then Solve again \
to see Volumetric Yield and Est. Carat Weight. Switch to the Live Render \
tab to see the stone rendered in the material you picked.",
"",
),
(
"You have a working design",
"That is the full worked example -- a girdle, pavilion, crown and table \
that solves and closes. From here: Chapter 8 covers Deep Solve, Optimize, \
Adopt and Apply for verifying and improving it further.",
"",
),
];
pub(in crate::gui::editor) fn setup_guide(ui: &MainWindow) {
let steps: Vec<GuideStepData> = STEPS
.iter()
.map(|(title, body, highlight_target)| GuideStepData {
title: SharedString::from(*title),
body: SharedString::from(*body),
highlight_target: SharedString::from(*highlight_target),
})
.collect();
ui.global::<GuideModel>()
.set_steps(ModelRc::new(VecModel::from(steps)));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn steps_are_non_empty_and_use_recognized_highlight_targets() {
const RECOGNIZED: &[&str] = &["", "tier_table", "design_settings", "new_design_dialog"];
for (title, body, highlight_target) in STEPS {
assert_ne!(*title, "");
assert_ne!(*body, "");
assert!(
RECOGNIZED.contains(highlight_target),
"step {title:?} has an unrecognized highlight_target {highlight_target:?}"
);
}
}
#[test]
fn step_titles_are_unique() {
for (i, (title, ..)) in STEPS.iter().enumerate() {
for (other, ..) in &STEPS[i + 1..] {
assert_ne!(title, other, "duplicate guide step title {title:?}");
}
}
}
}