forked from 1b-agent/opencadstudio-upstream
web: enable STL/STEP export and OBJ import, drag-and-drop open
STLOUT/STEPOUT wrote via std::fs and IMPORTOBJ read via std::fs, all of which fail on wasm32. The export pickers now mirror the PDF path (pick_*_owned returns a name-only PathBuf; the browser download names the file) and the write tail swaps fs::write for sys::download_bytes. OBJ import reads the picked file's bytes directly, like the web open picker. Opening by drag-and-drop was dead on the web build: winit never emits FileDropped there. A wasm-gated io::web_drop module installs DOM dragover/drop listeners, filters .dwg/.dxf, reads the File bytes async, and queues them; the existing 50 ms PollWebControl tick drains the queue into the same open path the picker uses (progress overlay, recovery, OPFS recent cache). Also floors the model-space plot sheet: extents smaller than 10 mm (or the 0x0 paper a fresh unsaved drawing carries) now fall back to the standard sheet instead of producing a ~3 pt page.
This commit is contained in:
1 parent
2a05479d69
commit
ad60be11ed
8 files changed
+362
-38
No files matched your search
@@ -1930,6 +1930,10 @@ pub enum Message {
|
||||
OpenPathPicked(Option<(PathBuf, u64)>),
|
||||
/// A file was dragged from the desktop and dropped on the window (#344).
|
||||
FileDropped(PathBuf),
|
||||
/// Web only: a drawing dragged onto the page — the DOM drop listener has
|
||||
/// already read the bytes; this opens through the web-picker flow (#344).
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
WebFileDropped(String, Vec<u8>),
|
||||
/// Web only: Ctrl+V captured by a focused text field, whose iced-internal
|
||||
/// paste is inert there — read the async clipboard instead (#346).
|
||||
WebFieldPaste,
|
||||
@@ -3519,6 +3523,8 @@ pub enum Message {
|
||||
/// Trigger OBJ import: show open-file dialog.
|
||||
ObjImport,
|
||||
/// Callback after the user picks (or cancels) the OBJ file path.
|
||||
/// Web never constructs it — the browser handle's bytes are read directly.
|
||||
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
|
||||
ObjImportPath(Option<std::path::PathBuf>),
|
||||
ObjImportFinished(
|
||||
u64,
|
||||
@@ -4311,6 +4317,9 @@ impl Drop for OpenCADStudio {
|
||||
/// unavailable for now (see issue #45). Native keeps the multi-window `run`.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn run_web() -> iced::Result {
|
||||
// winit never emits DroppedFile on the web, so the document drag & drop
|
||||
// listeners are installed here and feed the control poll (#344).
|
||||
crate::io::web_drop::install();
|
||||
iced::application(
|
||||
OpenCADStudio::boot_web,
|
||||
OpenCADStudio::update,
|
||||
|
||||
Reference in new issue
Block a user