Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions i18n/en.msg
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,9 @@ gpui.c.kicad.exit.full.screen = Exit full screen
gpui.c.kicad.the.editor.takes.the.whole = The editor takes the whole window; only this row stays
gpui.c.kicad.closing = KiCad is closing. The editor opens again once it has closed.
gpui.c.kicad.closing.ask = KiCad is waiting for an answer before it closes: "{title}". Its window may be behind another one.
gpui.c.solid.load.big = Load it anyway
gpui.c.solid.loading.big = Loading it anyway…
gpui.c.solid.big.next = Loading it may take a while and a lot of memory.

# ---- gpui-d: setup, pairing, hubs, palette, picker, projects, composer, menus ----
gpui.assets.missing = Assets missing in {dir}: {files}
Expand Down
3 changes: 3 additions & 0 deletions i18n/es.msg
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,9 @@ gpui.c.kicad.exit.full.screen = Salir de pantalla completa
gpui.c.kicad.the.editor.takes.the.whole = El editor ocupa toda la ventana; solo queda esta fila
gpui.c.kicad.closing = KiCad se está cerrando. El editor vuelve a abrirse cuando termine de cerrarse.
gpui.c.kicad.closing.ask = KiCad espera una respuesta antes de cerrarse: «{title}». Su ventana puede estar detrás de otra.
gpui.c.solid.load.big = Cargarlo de todos modos
gpui.c.solid.loading.big = Cargándolo de todos modos…
gpui.c.solid.big.next = Cargarlo puede tardar y usar mucha memoria.

# ---- gpui-d: setup, pairing, hubs, palette, picker, projects, composer, menus ----
gpui.assets.missing = Faltan recursos en {dir}: {files}
Expand Down
3 changes: 3 additions & 0 deletions i18n/ja.msg
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,9 @@ gpui.c.kicad.exit.full.screen = 全画面を終了
gpui.c.kicad.the.editor.takes.the.whole = エディタがウィンドウ全体を使います。この行だけが残ります
gpui.c.kicad.closing = KiCad を閉じています。閉じ終わるとエディタがもう一度開きます。
gpui.c.kicad.closing.ask = KiCad は閉じる前に応答を待っています:「{title}」。そのウィンドウが別のウィンドウの後ろにあるかもしれません。
gpui.c.solid.load.big = それでも読み込む
gpui.c.solid.loading.big = それでも読み込み中…
gpui.c.solid.big.next = 読み込みには時間と多くのメモリがかかることがあります。

# ---- gpui-d: setup, pairing, hubs, palette, picker, projects, composer, menus ----
gpui.assets.missing = {dir} にアセットがありません: {files}
Expand Down
2 changes: 2 additions & 0 deletions native/gpui/src/screens/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ impl Backplane {
}
}
// zoomed in on a STEP: its solids there meshed finer by the hub, the model replaced when they are
// "Load it anyway": a model the hub refused for its size, read past the limit
crate::viewers::solid::SolidEvent::LoadBig(key) => { let _ = this.tx.try_send(Command::Rpc("kicad.big".into(), super::settings::Secret(serde_json::json!({"key": key})), "big")); }
crate::viewers::solid::SolidEvent::Refine(key, at, r) => { let _ = this.tx.try_send(Command::Rpc("kicad.refine".into(), super::settings::Secret(serde_json::json!({"key": key, "at": at, "r": r})), "refine")); }
// a part clicked on the board's model: the board's probe, lit on the schematic and the board as a tap there is
crate::viewers::solid::SolidEvent::Pick(r) => super::plotview::probe_part(this, r),
Expand Down
58 changes: 42 additions & 16 deletions native/gpui/src/viewers/solid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ pub fn read_frame(b: &[u8]) -> Option<Vec<(String, Item)>> {
Some(out)
}
#[derive(Debug, PartialEq)]
pub enum SolidFrame { Model(String, Mesh), /// why there is no model (the hub's `none`) and its `retryable` flag, the previous model stays
Note(String, String, Option<bool>), Bad(String),
pub enum SolidFrame { Model(String, Mesh), /// why there is no model (the hub's `none`), its `retryable` flag and its `big` one (refused for its
/// size, so the page offers "Load it anyway"); the previous model stays
Note(String, String, Option<bool>, bool), Bad(String),
/// the parts of the model start again: `of` instances will come
Parts(String, u32),
/// one part model at its instances (placed), and how many instances have now come
Expand Down Expand Up @@ -284,7 +285,7 @@ pub fn parse_frame(b: &[u8]) -> Option<SolidFrame> {
if !is_solid_key(&key) { return None }
if let Some(Item::Text(why)) = get("none") {
let retryable = match get("retryable") { Some(Item::Bool(b)) => Some(*b), _ => None };
return Some(SolidFrame::Note(key, why.clone(), retryable))
return Some(SolidFrame::Note(key, why.clone(), retryable, matches!(get("big"), Some(Item::Bool(true)))))
}
if let Some(Item::Text(text)) = get("stage") {
let ms = |k: &str| match get(k) { Some(Item::Int(v)) if *v > 0 => *v as u64, _ => 0 };
Expand Down Expand Up @@ -486,7 +487,7 @@ impl Scene {
self.key = key; self.parts.clear(); self.done = 0; self.of = of; *reset = true; Ok(true)
}
SolidFrame::Part(key, m, done) => { if key != self.key { return Ok(false) } self.parts.push(Arc::new(m)); self.done = done.min(self.of.max(done)); Ok(true) }
SolidFrame::Note(key, why, retryable) => { if key != self.key { *self = Scene { key: key.clone(), ..Default::default() } } Err(SolidFrame::Note(key, why, retryable)) }
SolidFrame::Note(key, why, retryable, big) => { if key != self.key { *self = Scene { key: key.clone(), ..Default::default() } } Err(SolidFrame::Note(key, why, retryable, big)) }
other => Err(other),
}
}
Expand Down Expand Up @@ -603,7 +604,8 @@ pub fn stage_line(text: &str, secs: u64, about_ms: u64) -> String {
}
/// What the page asks of the window: the model of this source made again (its Retry, after the hub could not make it).
/// `Refine`: the person zoomed in on a STEP: its solids near `at` (the model's millimetres) within `r`, meshed finer (kicad.refine).
pub enum SolidEvent { Retry(String), Refine(String, [f32; 3], f32), /** a click on a board's model: the reference of the part under it, "" the board or nothing */ Pick(String) }
/// `LoadBig`: the person asked for a model the hub refused for its size, read past the limit (kicad.big).
pub enum SolidEvent { Retry(String), Refine(String, [f32; 3], f32), LoadBig(String), /** a click on a board's model: the reference of the part under it, "" the board or nothing */ Pick(String) }
impl EventEmitter<SolidEvent> for SolidPage {}
/// Whether a source's model can be refined: a STEP's (the Mech tab's parts; a board's model is made at its finest already).
pub fn refinable(key: &str) -> bool {
Expand Down Expand Up @@ -871,7 +873,7 @@ pub struct SolidPage {
/** the page's keys (0.14's: f/Home fit, 0-6 views, arrows turn, shift+arrows move, +/- zoom), taken when the model is pressed; the wheel's burst, to settle after it */ focus: FocusHandle, wheel: u64,
/** what the hub said it is doing for a model (Stage), shown with its time running; whether a second's tick is running for it */ stage: Option<Stage>, ticking: bool,
/** the share of DRAFT_PIXELS a picture in motion gets, from how long the last ones took (draft_scale) */ draft_scale: f32,
/** the hub could not make this source's model (its Note): the page offers Retry when retryable */ failed: bool, retryable: Option<bool>, /** last Retry press time (1 s client cooldown) */ last_retry: Option<std::time::Instant>,
/** the hub could not make this source's model (its Note): the page offers Retry when retryable */ failed: bool, retryable: Option<bool>, /** refused for its size: the page offers "Load it anyway" */ big: bool, /** last Retry press time (1 s client cooldown) */ last_retry: Option<std::time::Instant>,
pub note: String, /** the canvas supplies its own controls in Split */ pub inline_controls: bool, worker: Worker, size: Arc<Mutex<[f32; 5]>> /* panel width, height, scale factor, origin x, y (logical px) */,
/** runs in normal clients too (one relaxed atomic per qualifying paint); measures the GPUI paint callback with non-zero bounds, not GPU presentation */
painted: Arc<AtomicU64>, painted_gen: Arc<AtomicU64>, pub stats: Stats,
Expand All @@ -884,7 +886,7 @@ impl SolidPage {
if weak.update(cx, |this, cx| this.apply(msg, cx)).is_err() { break }
}
}).detach();
SolidPage { source_rev: 0, seen_source: None, source_subscription: None, press_btn: None, press: None, names_probe: true, core: SolidCore::new(), drag: None, fading: false, focus: cx.focus_handle(), wheel: 0, stage: None, ticking: false, draft_scale: 1.0, failed: false, retryable: None, last_retry: None, note: "No 3D model yet".into(), /* i18n-ok: the note is drawn through note_words */ inline_controls: true, worker: Worker::spawn(tx),
SolidPage { source_rev: 0, seen_source: None, source_subscription: None, press_btn: None, press: None, names_probe: true, core: SolidCore::new(), drag: None, fading: false, focus: cx.focus_handle(), wheel: 0, stage: None, ticking: false, draft_scale: 1.0, failed: false, retryable: None, big: false, last_retry: None, note: "No 3D model yet".into(), /* i18n-ok: the note is drawn through note_words */ inline_controls: true, worker: Worker::spawn(tx),
size: Arc::new(Mutex::new([0.0, 0.0, 1.0, 0.0, 0.0])), painted: Arc::new(AtomicU64::new(0)), painted_gen: Arc::new(AtomicU64::new(0)), stats: Stats::default() }
}
/// The background to draw on (the setting resolved by the window): a change draws the picture again at once, the camera untouched.
Expand All @@ -904,6 +906,7 @@ impl SolidPage {
let changed = self.core.mirror_layers(&src.core, (w, h));
self.failed = src.failed;
self.retryable = src.retryable;
self.big = src.big;
self.note.clone_from(&src.note);
let stage = src.stage.clone();
if self.stage != stage { self.set_stage(stage, cx); }
Expand Down Expand Up @@ -995,20 +998,21 @@ impl SolidPage {
self.stage = None;
stage_cleared = true;
}
if res.clear_failed { self.failed = false; self.retryable = None; }
if res.clear_failed { self.failed = false; self.retryable = None; self.big = false; }
if res.clear_note { self.note.clear(); }
if res.should_render { self.ask_render(self.drag.is_some()); }
if res.notify || stage_cleared { cx.notify(); }
}
Msg::Mesh(SolidFrame::Model(..) | SolidFrame::Parts(..) | SolidFrame::Part(..)) => {} // the worker makes these a Scene
Msg::Mesh(SolidFrame::Note(key, why, retryable)) => { // why there is no model; the same source's previous model stays shown
Msg::Mesh(SolidFrame::Note(key, why, retryable, big)) => { // why there is no model; the same source's previous model stays shown
self.core.apply_note(key);
self.stage = None;
self.failed = !why.is_empty() && !crate::screens::panestate::is_empty_none(&why);
self.retryable = retryable;
self.big = self.failed && big;
self.note = if self.core.mesh.is_some() { format!("{why}{PREVIOUS_SHOWN}") } else { why }; cx.notify();
}
Msg::Mesh(SolidFrame::Bad(e)) => { self.failed = true; self.retryable = Some(true); self.note = e; self.set_stage(None, cx); }
Msg::Mesh(SolidFrame::Bad(e)) => { self.failed = true; self.retryable = Some(true); self.big = false; self.note = e; self.set_stage(None, cx); }
Msg::Mesh(SolidFrame::Stage(key, text, ms, about)) => {
if key == self.core.key && !text.is_empty() { self.failed = false; }
if text.is_empty() && self.stage.as_ref().is_some_and(|s| s.key != key) { return } // another source's end: not this one's stage
Expand Down Expand Up @@ -1116,6 +1120,25 @@ impl SolidPage {
let k = this.core.key.clone(); cx.emit(SolidEvent::Retry(k));
}))
}
/// "Load it anyway", for a model the hub refused for its size: it is read past the limit (kicad.big); the page says so until the hub's
/// own stage comes (bounded at 15 s, as a Retry).
fn load_big_button(&self, cx: &mut Context<Self>) -> impl IntoElement {
div().id("solid-load-big").px_2().py_1().text_size(crate::scale::tpx(12.)).border_1().border_color(rgb(0x3a4456)).child(trs("Load it anyway"))
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
.text_color(rgb(0xc8ced9)).bg(rgba(0x1d2430dd)).cursor_pointer().hover(|d| d.bg(rgba(0x2a3548ee)))
.on_click(cx.listener(|this, _, _, cx| {
if this.core.key.is_empty() { return }
let k = this.core.key.clone(); this.big = false;
/* i18n-ok: stage_line draws through trs */ this.set_stage(Some(Stage { key: k.clone(), text: "Loading it anyway…".into(), since: std::time::Instant::now(), about: 0, retrying: true }), cx);
cx.emit(SolidEvent::LoadBig(k)); cx.notify();
}))
}
/// What the page offers under a failed model's note: "Load it anyway" for one refused for its size, else Retry when retryable.
fn failed_action(&self, st_retry: bool, cx: &mut Context<Self>) -> Option<AnyElement> {
if self.core.key.is_empty() || !self.failed { return None }
if self.big { return Some(self.load_big_button(cx).into_any_element()) }
st_retry.then(|| self.retry_button(cx).into_any_element())
}
/// Snap view: the picture on screen as a PNG in `dir` (never over a file); the path, or why not.
pub fn snap(&mut self, dir: &std::path::Path) -> Result<std::path::PathBuf, String> {
/* i18n-ok: a reason inside the translated "Snap view failed" */ let img = self.core.image.clone().ok_or("no picture yet")?;
Expand Down Expand Up @@ -1236,9 +1259,10 @@ impl Render for SolidPage {
_ if making_other || (self.core.image.is_none() && !stage.is_empty()) => div().id("solid-stage").size_full().child(crate::screens::panestate::view_on_backdrop(self.core.back, &crate::screens::panestate::PaneState::loading(stage.clone()), None)).into_any_element(),
Some(i) => img(i.clone()).size_full().object_fit(ObjectFit::Fill).into_any_element(),
None => {
let st = crate::screens::panestate::classify_solid_note(&self.note, self.failed && !self.core.key.is_empty(), self.retryable);
let retry = st.retry.then(|| self.retry_button(cx).into_any_element());
crate::screens::panestate::view_on_backdrop(self.core.back, &st, retry)
let mut st = crate::screens::panestate::classify_solid_note(&self.note, self.failed && !self.core.key.is_empty(), self.retryable);
let action = self.failed_action(st.retry, cx);
if self.big && action.is_some() { st.retry = true; st.next = trs("Loading it may take a while and a lot of memory."); }
crate::screens::panestate::view_on_backdrop(self.core.back, &st, action)
}
};
let tools = (self.inline_controls && self.core.mesh.is_some() && !making_other).then(|| {
Expand All @@ -1247,7 +1271,7 @@ impl Render for SolidPage {
div().id("solid-page").size_full().overflow_hidden().relative().track_focus(&self.focus).key_context("Viewer").child(body).child(probe).children(tools)
.on_key_down(cx.listener(|this, e: &KeyDownEvent, _, cx| if this.on_key(e, cx) { cx.stop_propagation() }))
.when(self.core.image.is_some() && !making_other && !self.note.is_empty(), |d| d.child(div().absolute().bottom_2().left_2().px_2().flex().items_center().gap_2().text_size(crate::scale::tpx(12.)).text_color(rgb(0x8a93a3)).child(note_words(&self.note))
.when(self.failed && self.retryable.unwrap_or_else(|| crate::screens::panestate::is_retryable_none(&self.note)) && !self.core.key.is_empty(), |d| d.child(self.retry_button(cx)))))
.children(self.failed_action(self.retryable.unwrap_or_else(|| crate::screens::panestate::is_retryable_none(&self.note)), cx))))
.when(self.core.image.is_some() && !making_other && (!stage.is_empty() || !self.parts_progress().is_empty()), |d| d.child(div().id("solid-parts").absolute().bottom_2().right_2().px_2().text_size(crate::scale::tpx(12.)).text_color(rgb(0x8a93a3)).child(if stage.is_empty() { trs(&self.parts_progress()) } else { stage.clone() })))
.on_mouse_down(MouseButton::Left, cx.listener(|this, e: &MouseDownEvent, window, cx| this.mouse_down(e, window, cx)))
.on_mouse_down(crate::mousecfg::BUTTONS[1], cx.listener(|this, e: &MouseDownEvent, window, cx| this.mouse_down(e, window, cx)))
Expand Down Expand Up @@ -1503,9 +1527,11 @@ mod tests {
let mut f = vec![0xa3]; text(&mut f, "key"); text(&mut f, "2|board"); text(&mut f, "n"); f.push(12); text(&mut f, "mesh"); f.push(0x59); f.extend((bytes.len() as u16).to_be_bytes()); f.extend(&bytes);
match parse_frame(&f) { Some(SolidFrame::Model(k, m)) => { assert_eq!(k, "2|board"); assert_eq!(m.tris.len(), 12) } other => panic!("{other:?}") }
let mut n = vec![0xa2]; text(&mut n, "key"); text(&mut n, "3|board"); text(&mut n, "none"); text(&mut n, "no model for this board");
assert_eq!(parse_frame(&n), Some(SolidFrame::Note("3|board".into(), "no model for this board".into(), None)));
assert_eq!(parse_frame(&n), Some(SolidFrame::Note("3|board".into(), "no model for this board".into(), None, false)));
let mut nr = vec![0xa3]; text(&mut nr, "key"); text(&mut nr, "3|board"); text(&mut nr, "none"); text(&mut nr, "boom"); text(&mut nr, "retryable"); nr.push(0xf5);
assert_eq!(parse_frame(&nr), Some(SolidFrame::Note("3|board".into(), "boom".into(), Some(true))));
assert_eq!(parse_frame(&nr), Some(SolidFrame::Note("3|board".into(), "boom".into(), Some(true), false)));
let mut nb = vec![0xa4]; text(&mut nb, "key"); text(&mut nb, "2|board"); text(&mut nb, "none"); text(&mut nb, "too big"); text(&mut nb, "retryable"); nb.push(0xf4); text(&mut nb, "big"); nb.push(0xf5);
assert_eq!(parse_frame(&nb), Some(SolidFrame::Note("2|board".into(), "too big".into(), Some(false), true)), "a model refused for its size offers Load it anyway");
let mut other = f.clone(); other[6] = b'1'; assert!(parse_frame(&other).is_none());
assert!(parse_frame(&[0xff, 0x00]).is_none());
// a tag wraps ONE value: tag 6 over the map's text key must not eat the next item
Expand Down
4 changes: 3 additions & 1 deletion native/host/src/bin/bp-plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ fn main() {
}
let kind: u32 = k.parse().unwrap_or(0);
if kind >= 2 {
let g = solidread::read(kind, file, &std::env::var("BACKPLANE_KICAD_CLI").unwrap_or_default(), &tools(), a.get(2).map_or("", String::as_str));
// BACKPLANE_PLOT_ASKED: the person asked for this model past the size limit (the hub's kicad.big)
let asked = std::env::var("BACKPLANE_PLOT_ASKED").map_or(false, |v| v == "1");
let g = solidread::read_streaming(kind, file, &std::env::var("BACKPLANE_KICAD_CLI").unwrap_or_default(), &tools(), a.get(2).map_or("", String::as_str), None, asked, None);
let Some(p) = g.plot else { eprintln!("{}", g.text); std::process::exit(g.code) };
std::io::stdout().write_all(&plotgen::lines(&p)).unwrap();
println!();
Expand Down
Loading
Loading