File formats: a DWG placed while converted keeps Place's context, and the conversion can be canceled

- A DWG placed while it is converted goes on the layer that was current
  when Place started and, with `replace`, in place of the object selected
  then, selected again unless it changed meanwhile. A layer the user made
  current since stays current, as for other files read for Place.
- Place's checks run before the conversion starts, so a bad param or a
  selection Replace can't swap (several objects, part of a symbol
  instance) is reported at once and nothing is converted.
- The open progress window shows a DWG drawing being converted.
  `file.cancelOpen` drops the conversion, so its dialog never opens, and
  `file.openInBackground` closes the window while it goes on in the
  status bar. Both commands' help text and `docs/mcp.md` say so.
This commit is contained in:
dotCooCoo
2026-12-04 03:50:30 -08:00
parent 21408d593d
commit 5436a18547
7 changed files with 215 additions and 54 deletions
+2 -2
View File
@@ -1732,13 +1732,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"file.cancelOpen",
"Cancel Opening",
"",
"{} stop opening every file being read in the background (its progress window's Cancel): the files don't open → {cancelled: n}",
"{} stop opening every file being read in the background and every DWG drawing being converted (its progress window's Cancel): the files don't open and the drawings don't open or place → {cancelled: n}",
),
(
"file.openInBackground",
"Continue in Background",
"",
"{} close the progress window of the files being opened; they go on being read, shown in the status bar → {hidden: n}",
"{} close the progress window of the files being opened and the DWG drawings being converted; they go on, shown in the status bar → {hidden: n}",
),
(
"file.cancelPlace",
+131 -15
View File
@@ -77,9 +77,17 @@ struct Source {
name: String,
path: Option<String>,
file: Arc<DialogFile>,
/// A DWG drawing's conversion, kept while the dialog is open so that its previews and its OK
/// read the drawing without converting it again.
_held: Option<vectorcraft_cad::dwg::Held>,
/// What a DWG drawing converted off the UI thread brings.
converted: Option<Converted>,
}
/// A DWG drawing converted off the UI thread ([`converted`]).
pub(crate) struct Converted {
/// Its conversion, kept while the dialog is open so that its previews and its OK read the
/// drawing without converting it again.
_held: vectorcraft_cad::dwg::Held,
/// Where it is placed, taken when Place started; `None` when it opens.
placement: Option<crate::opening::Placement>,
}
/// The DXF Import Options dialog: the layout preview and what the drawing declares on the left, the
@@ -351,25 +359,47 @@ pub fn convert_in_background(app: &mut VectorcraftApp, name: &str, bytes: &[u8],
/// [`offer_place`] for a file the user places where files are read off the UI thread: a DWG
/// drawing is converted first ([`convert_in_background`]) → true; false when `p` names no DWG
/// drawing.
/// drawing. Place's checks run first, as for other files read for Place: a bad param, or a
/// selection that `replace` can't swap, is reported in the status bar at once and nothing is
/// converted (true).
pub fn convert_place_in_background(app: &mut VectorcraftApp, p: &Value) -> bool {
let named = p.get("path").or_else(|| p.get("name")).and_then(Value::as_str).map(fileio::extension);
if p.get("dxf").is_some() || named.as_deref() != Some("dwg") {
return false;
}
let Some((name, bytes, path)) = place_source(app, p, |ext| ext == "dwg") else { return false };
if !vectorcraft_cad::is_dwg(&bytes) {
return false;
}
if p.get("replace").and_then(Value::as_bool) == Some(true) {
// The edit the tool computes on another thread comes first: the object Replace swaps is the
// one selected after it.
let r = app.session.finish_tool_edit();
crate::canvas::apply_requests(app, r);
}
if let Err(e) = app.session.prepare_place(p) {
app.status(e.to_string());
return true;
}
convert_in_background(app, &name, &bytes, path, Some(p))
}
/// A DWG drawing converted off the UI thread ([`convert_in_background`]): its dialog opens, to
/// place it with the `file.place` params `place`, or else to open it (it then goes on the recent
/// files); a drawing that can't be read is reported.
pub(crate) fn converted(app: &mut VectorcraftApp, name: &str, conversion: crate::opening::Conversion, path: Option<String>, place: Option<&Value>) {
/// place it with the `file.place` params `place` where `placement` says, or else to open it (it
/// then goes on the recent files); a drawing that can't be read is reported.
pub(crate) fn converted(
app: &mut VectorcraftApp,
name: &str,
conversion: crate::opening::Conversion,
path: Option<String>,
place: Option<&Value>,
placement: Option<crate::opening::Placement>,
) {
let (bytes, info) = conversion;
match info {
Ok((info, held)) => {
let opens = place.is_none();
if show(app, name, &bytes, path.clone(), place, &info, Some(held))
if show(app, name, &bytes, path.clone(), place, &info, Some(Converted { _held: held, placement }))
&& opens
&& let Some(path) = &path
{
@@ -381,8 +411,8 @@ pub(crate) fn converted(app: &mut VectorcraftApp, name: &str, conversion: crate:
}
}
/// Open the dialog for `bytes`, the drawing `info` describes (see [`offer`]), keeping `held`, its
/// DWG conversion, while it is open.
/// Open the dialog for `bytes`, the drawing `info` describes (see [`offer`]), with what its
/// conversion off the UI thread brings, if it was converted there.
fn show(
app: &mut VectorcraftApp,
name: &str,
@@ -390,7 +420,7 @@ fn show(
path: Option<String>,
place: Option<&Value>,
info: &vectorcraft_cad::DxfInfo,
held: Option<vectorcraft_cad::dwg::Held>,
converted: Option<Converted>,
) -> bool {
let mut choices = DxfChoices {
layout: info.layouts.first().cloned().unwrap_or_else(|| "Model".into()),
@@ -407,7 +437,7 @@ fn show(
}
}
let file = DialogFile::new(bytes.to_vec());
let source = Source { place: place.map(|p| other_place_params(p, &["dxf"])), name: name.to_string(), path, file: file.clone(), _held: held };
let source = Source { place: place.map(|p| other_place_params(p, &["dxf"])), name: name.to_string(), path, file: file.clone(), converted };
let dialog = DxfImportDialog::new(place.is_some(), file, info, choices);
open_held(app, dialog, move |app, choices| confirm(app, &source, choices)).is_some()
}
@@ -465,7 +495,32 @@ fn confirm(app: &mut VectorcraftApp, source: &Source, choices: &DxfChoices) -> R
Some(place) => {
let mut p = with_file(place, source.path.as_deref(), &source.name, &source.file);
p["dxf"] = dxf;
crate::place::run_for_user(app, &p).map(|_| ())
let placement = source.converted.as_ref().and_then(|c| c.placement.as_ref());
// Where new art goes now is taken before Replace selects the object it swaps again.
let current = placement.and_then(|_| crate::placing::Insertion::of(app));
// A drawing converted off the UI thread replaces the object selected when Place
// started, selected again, unless it changed meanwhile.
if let Some((old, node)) = placement.and_then(|pl| pl.replaced.as_ref()) {
let st = app.session.doc().map_err(|e| e.to_string())?;
if st.doc.node(*old) != Some(node) {
return Err("replace: the object to replace was changed or deleted".into());
}
if st.selection.objects != [*old] || st.selection.symbol_part.is_some() {
app.session.execute("select.set", &json!({ "ids": [old.0] })).map_err(|e| e.to_string())?;
}
}
// It goes where new art went when Place started, and what the user changed since is
// kept, as for other files read for Place.
let restore = placement.and_then(|pl| pl.insertion.clone()).map(|insertion| {
let insertion = insertion.or_now(current.as_ref(), app, false);
insertion.clone().set(app);
insertion
});
let r = crate::place::run_for_user(app, &p).map(|_| ());
if let (Some(current), Some(insertion)) = (current, restore) {
current.restore_changed(&insertion, app);
}
r
}
None => io::open_document(app, &source.name, &source.file.bytes, source.path.clone(), &json!({ "dxf": dxf })).map(|_| ()),
}
@@ -801,9 +856,42 @@ mod tests {
});
}
/// The progress window shows a DWG drawing being converted: Cancel drops it, so its dialog
/// never opens, and Continue in Background leaves it converting in the status bar only.
#[cfg(not(any(target_arch = "wasm32", all(target_os = "freebsd", target_arch = "aarch64"))))]
#[test]
fn a_dwg_conversion_can_be_cancelled_or_continued_in_the_background() {
vectorcraft_engine::dwg::allow_in_process();
let (_dir, plan) = dwg_file("dxf-import-dwg-cancel");
crate::opening::tests::with_threads(|| {
let mut app = host::app();
app.services.read = Some(Box::new(|p: &str| std::fs::read(p).map_err(|e| e.to_string())));
assert!(!crate::menus::enabled(&app, "file.cancelOpen"));
crate::io::open_file(&mut app, &plan, true).unwrap();
let (tx, done) = std::sync::mpsc::channel();
let result = std::mem::replace(&mut app.opening.converting[0].done, done).recv().unwrap();
assert!(crate::menus::enabled(&app, "file.cancelOpen") && crate::menus::enabled(&app, "file.openInBackground"));
assert!(crate::opening::shown(&app).is_some_and(|s| s.title.contains("plan.dwg")));
assert_eq!(app.run("file.cancelOpen", json!({})).unwrap()["cancelled"], 1);
assert!(app.opening.converting.is_empty() && app.ui.status.is_empty(), "{}", app.ui.status);
assert!(!crate::menus::enabled(&app, "file.cancelOpen"));
assert!(tx.send(result).is_err(), "nothing waits for the result");
crate::opening::poll(&mut app);
assert!(!host::is_open(&app, KIND));
// Continue in Background.
crate::io::open_file(&mut app, &plan, true).unwrap();
assert_eq!(app.run("file.openInBackground", json!({})).unwrap()["hidden"], 1);
assert!(crate::opening::shown(&app).is_none() && !crate::menus::enabled(&app, "file.openInBackground"));
assert_eq!(app.ui.status, "Converting plan.dwg…");
finish_conversions(&mut app);
assert!(host::is_open(&app, KIND));
});
}
/// A DWG drawing placed while it is converted goes in the document it was placed in, which
/// becomes the active one again; it is not placed when that document was closed or reverted
/// meanwhile, and the status bar says why.
/// becomes the active one again, on the layer that was current when Place started and, with
/// `replace`, in place of the object selected then; it is not placed when that document was
/// closed or reverted meanwhile, and the status bar says why.
#[cfg(not(any(target_arch = "wasm32", all(target_os = "freebsd", target_arch = "aarch64"))))]
#[test]
fn a_dwg_drawing_placed_while_converted_goes_in_its_own_document() {
@@ -825,7 +913,11 @@ mod tests {
app.services.write = Some(Box::new(|p: &str, b: &[u8]| std::fs::write(p, b).map_err(|e| e.to_string())));
app.run("file.new", json!({"width": 600, "height": 400})).unwrap();
let first = app.session.doc().unwrap().uid;
let bottom = app.session.doc().unwrap().active_layer;
let ink = vectorcraft_doc::NodeId(app.run("layer.new", json!({})).unwrap()["id"].as_u64().unwrap());
crate::place::run_for_user(&mut app, &json!({ "path": plan })).unwrap();
// The user makes another layer current, then another document.
app.session.doc_mut().unwrap().active_layer = bottom;
app.run("file.new", json!({"width": 600, "height": 400})).unwrap();
let other = app.session.doc().unwrap().uid;
let (before, other_before) = (undo_steps(&app, first), undo_steps(&app, other));
@@ -835,6 +927,30 @@ mod tests {
host::confirm(&mut app, KIND).unwrap();
placed(&mut app);
assert_eq!((undo_steps(&app, first), undo_steps(&app, other)), (before + 1, other_before));
let st = app.session.doc().unwrap();
assert_eq!(st.doc.parent_of(st.selection.objects[0]), Some(ink), "on the layer current when Place started");
assert_eq!(st.active_layer, bottom, "the layer the user made current stays current");
// Replace: the object selected when Place started is replaced, not the one selected since.
let rect = |app: &mut VectorcraftApp, x: f64| {
app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap();
app.session.doc().unwrap().selection.objects[0]
};
let replaced = rect(&mut app, 10.0);
crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap();
// Meanwhile the user draws on another layer, which stays current.
app.session.doc_mut().unwrap().active_layer = Some(ink);
let selected_since = rect(&mut app, 50.0);
finish_conversions(&mut app);
host::confirm(&mut app, KIND).unwrap();
placed(&mut app);
let st = app.session.doc().unwrap();
assert!(st.doc.node(replaced).is_none() && st.doc.node(selected_since).is_some(), "{}", app.ui.status);
assert_eq!(st.active_layer, Some(ink), "the layer the user made current stays current");
// A selection Replace can't swap is refused at once, and nothing is converted.
app.run("select.all", json!({})).unwrap();
crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap();
assert!(app.opening.converting.is_empty());
assert!(app.ui.status.contains("select the one object to replace"), "{}", app.ui.status);
// Closed meanwhile.
crate::place::run_for_user(&mut app, &json!({ "path": plan })).unwrap();
app.session.execute("file.close", &json!({})).unwrap();
+1 -1
View File
@@ -346,7 +346,7 @@ fn ui_enabled(app: &VectorcraftApp, id: &str) -> bool {
"file.reveal" => app.services.reveal.is_some() && app.session.active().is_some_and(|d| d.path.is_some()),
"file.cancelExport" | "file.exportInBackground" => app.background.running(crate::background::Kind::Export),
"file.cancelSave" | "file.saveInBackground" => app.background.running(crate::background::Kind::Save),
"file.cancelOpen" => !app.opening.pending.is_empty(),
"file.cancelOpen" => crate::opening::can_cancel(app),
"file.openInBackground" => crate::opening::any_shown(app),
"file.cancelPlace" => crate::placing::can_cancel(app),
crate::dialogs::failed_plugins::COMMAND => vectorcraft_engine::cmd::plugin::failed_load_count(&app.session) > 0,
+2 -2
View File
@@ -1733,13 +1733,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"file.cancelOpen",
"Cancel Opening",
"",
"{} stop opening every file being read in the background (its progress window's Cancel): the files don't open → {cancelled: n}",
"{} stop opening every file being read in the background and every DWG drawing being converted (its progress window's Cancel): the files don't open and the drawings don't open or place → {cancelled: n}",
),
(
"file.openInBackground",
"Continue in Background",
"",
"{} close the progress window of the files being opened; they go on being read, shown in the status bar → {hidden: n}",
"{} close the progress window of the files being opened and the DWG drawings being converted; they go on, shown in the status bar → {hidden: n}",
),
(
"file.cancelPlace",
+67 -28
View File
@@ -50,12 +50,27 @@ pub struct Converting {
name: String,
/// The `file.place` params when it is being placed, else `None` (it opens).
place: Option<Value>,
/// The document it is placed in ([`vectorcraft_engine::DocState::uid`]) and that document's
/// [`vectorcraft_engine::DocState::reverts`] when the conversion started, when it is placed.
placed_in: Option<(u64, u64)>,
/// Where it is placed, when it is placed.
placed_in: Option<Placement>,
pub(crate) done: Receiver<Conversion>,
/// The automation roots in force where the open or place started.
scope: ScopeHandle,
/// Continue in Background: the progress window no longer shows it.
hidden: bool,
/// [`crate::export_progress::now`] when the conversion started.
started: f64,
}
/// Where a DWG drawing placed while it is converted goes, taken when Place started.
pub(crate) struct Placement {
/// The document ([`vectorcraft_engine::DocState::uid`]) and its
/// [`vectorcraft_engine::DocState::reverts`].
doc: u64,
reverts: u64,
/// Where new art went in it.
pub(crate) insertion: Option<crate::placing::Insertion>,
/// With `replace`, the object selected to be replaced, as it was.
pub(crate) replaced: Option<(vectorcraft_doc::NodeId, vectorcraft_doc::Node)>,
}
/// The files being read.
@@ -165,10 +180,20 @@ pub(crate) fn finish_answered(app: &mut VectorcraftApp, path: &str, file: ReadFi
/// Convert `bytes`, the DWG drawing `name` (at `path`, if read from a file), to DXF and read its
/// layouts and units on a job of its own. Its DXF Import Options open once that is done
/// ([`poll`], [`crate::dialogs::dxf_import::converted`]), to place it with the `file.place` params
/// `place` in the document active now, or else to open it.
/// `place` in the document active now, where new art goes now and, with `replace`, in place of the
/// object selected now, or else to open it.
pub(crate) fn convert_drawing(app: &mut VectorcraftApp, name: &str, bytes: Vec<u8>, path: Option<String>, place: Option<Value>) {
let replace = place.as_ref().is_some_and(|p| p.get("replace").and_then(Value::as_bool) == Some(true));
let placed_in = match place {
Some(_) => app.session.doc().ok().map(|st| (st.uid, st.reverts)),
Some(_) => app.session.doc().ok().map(|st| Placement {
doc: st.uid,
reverts: st.reverts,
insertion: crate::placing::Insertion::of(app),
replaced: match &st.selection.objects[..] {
[id] if replace => st.doc.node(*id).map(|n| (*id, n.clone())),
_ => None,
},
}),
None => None,
};
let (tx, done) = channel();
@@ -193,7 +218,8 @@ pub(crate) fn convert_drawing(app: &mut VectorcraftApp, name: &str, bytes: Vec<u
);
let label = format!("Converting {}", fileio::file_name(name));
app.status(format!("{label}…"));
app.opening.converting.push(Converting { label, path, name: name.to_string(), place, placed_in, done, scope });
let started = crate::export_progress::now(app);
app.opening.converting.push(Converting { label, path, name: name.to_string(), place, placed_in, done, scope, hidden: false, started });
}
/// Lists the file being read for `path` and tells the status bar → `{background: true, status}`.
@@ -257,14 +283,14 @@ pub fn poll(app: &mut VectorcraftApp) {
// A drawing being placed is placed in the document it was placed in, which becomes the
// active one again, as [`crate::placing`] places files read off the UI thread; it is not
// placed when that document was closed or reverted meanwhile.
if let Some((doc, reverts)) = c.placed_in {
if let Some(placement) = &c.placed_in {
let name = fileio::file_name(&c.name);
match app.session.documents().iter().position(|st| st.uid == doc) {
match app.session.documents().iter().position(|st| st.uid == placement.doc) {
None => {
app.status(format!("Couldn't place {name}: the document it was placed in was closed"));
continue;
}
Some(d) if app.session.documents()[d].reverts != reverts => {
Some(d) if app.session.documents()[d].reverts != placement.reverts => {
app.status(format!("Couldn't place {name}: the document it was placed in was reverted"));
continue;
}
@@ -273,7 +299,7 @@ pub fn poll(app: &mut VectorcraftApp) {
}
}
}
c.scope.run(|| crate::dialogs::dxf_import::converted(app, &c.name, r, c.path, c.place.as_ref()));
c.scope.run(|| crate::dialogs::dxf_import::converted(app, &c.name, r, c.path, c.place.as_ref(), c.placed_in));
if !may_switch(app) {
return;
}
@@ -301,49 +327,62 @@ pub fn poll(app: &mut VectorcraftApp) {
}
}
/// The progress window's Cancel: the files being read don't open. An importer plug-in stops
/// between two slices of its budget; a built-in reader finishes reading and the result is dropped
/// → `{cancelled: n}`.
/// The progress window's Cancel: the files being read don't open, and the DWG drawings being
/// converted don't open or place. An importer plug-in stops between two slices of its budget; a
/// built-in reader or a conversion finishes and the result is dropped → `{cancelled: n}`.
pub fn cancel_all(app: &mut VectorcraftApp) -> Value {
let cancelled = std::mem::take(&mut app.opening.pending);
let converting = std::mem::take(&mut app.opening.converting);
for p in &cancelled {
p.token.cancel();
// The status bar no longer says it is opening.
if app.ui.status == format!("{}…", p.label) {
}
// The status bar no longer says it is opening or converting.
for label in cancelled.iter().map(|p| &p.label).chain(converting.iter().map(|c| &c.label)) {
if app.ui.status == format!("{label}…") {
app.ui.status.clear();
}
}
json!({ "cancelled": cancelled.len() })
json!({ "cancelled": cancelled.len() + converting.len() })
}
/// The progress window's Continue in Background: the files go on being read, shown in the status
/// bar only → `{hidden: n}`.
/// Can a file being read, or a DWG drawing being converted, be cancelled?
pub fn can_cancel(app: &VectorcraftApp) -> bool {
!app.opening.pending.is_empty() || !app.opening.converting.is_empty()
}
/// The progress window's Continue in Background: the files go on being read, and the drawings
/// converted, shown in the status bar only → `{hidden: n}`.
pub fn hide_all(app: &mut VectorcraftApp) -> Value {
let mut n = 0;
for p in app.opening.pending.iter_mut().filter(|p| !p.hidden) {
p.hidden = true;
n += 1;
for hidden in app.opening.pending.iter_mut().map(|p| &mut p.hidden).chain(app.opening.converting.iter_mut().map(|c| &mut c.hidden)) {
if !*hidden {
*hidden = true;
n += 1;
}
}
json!({ "hidden": n })
}
/// Is a file being read that the progress window shows?
/// Is a file being read, or a DWG drawing being converted, that the progress window shows?
pub fn any_shown(app: &VectorcraftApp) -> bool {
app.opening.pending.iter().any(|p| !p.hidden)
app.opening.pending.iter().any(|p| !p.hidden) || app.opening.converting.iter().any(|c| !c.hidden)
}
/// The progress window's entry for the first file being read it shows.
/// The progress window's entry for the first file being read, or drawing being converted, it
/// shows.
pub(crate) fn shown(app: &VectorcraftApp) -> Option<Shown> {
let waiting: Vec<&Pending> = app.opening.pending.iter().filter(|p| !p.hidden).collect();
let first = *waiting.first()?;
let pending = app.opening.pending.iter().filter(|p| !p.hidden).map(|p| (&p.label, p.started));
let converting = app.opening.converting.iter().filter(|c| !c.hidden).map(|c| (&c.label, c.started));
let waiting: Vec<(&String, f64)> = pending.chain(converting).collect();
let &(label, started) = waiting.first()?;
let more = waiting.len() - 1;
Some(Shown {
title: format!("{}…", crate::i18n::msg(&first.label)),
title: format!("{}…", crate::i18n::msg(label)),
step: tl!("Reading the file…").to_string(),
fraction: None,
counts: None,
queued: (more > 0).then(|| crate::i18n::tn(more as u64, "{n} more file waiting", "{n} more files waiting").to_string()),
started: first.started,
started,
cancel: "file.cancelOpen",
hide: Some("file.openInBackground"),
})
+7 -6
View File
@@ -61,9 +61,10 @@ struct Paste {
/// Where new art goes in the active document: the current layer, the isolated group or object, and
/// the drawing mode with the object Draw Inside draws into. A paste and a placed file read off the
/// UI thread keep the one from when they were given.
/// UI thread keep the one from when they were given, and so does a DWG drawing placed while it is
/// converted ([`crate::opening::convert_drawing`]).
#[derive(Clone, PartialEq)]
struct Insertion {
pub(crate) struct Insertion {
layer: Option<vectorcraft_doc::NodeId>,
isolation: Option<vectorcraft_doc::NodeId>,
draw_mode: vectorcraft_engine::DrawMode,
@@ -72,13 +73,13 @@ struct Insertion {
impl Insertion {
/// Where new art goes in `app`'s active document now.
fn of(app: &VectorcraftApp) -> Option<Self> {
pub(crate) fn of(app: &VectorcraftApp) -> Option<Self> {
let st = app.session.doc().ok()?;
Some(Self { layer: st.active_layer, isolation: st.isolation, draw_mode: app.session.draw_mode, draw_inside: app.session.draw_inside })
}
/// Make it where new art goes in `app`'s active document → where new art went before.
fn set(self, app: &mut VectorcraftApp) -> Option<Self> {
pub(crate) fn set(self, app: &mut VectorcraftApp) -> Option<Self> {
let st = app.session.doc_mut().ok()?;
let (layer, isolation) = (std::mem::replace(&mut st.active_layer, self.layer), std::mem::replace(&mut st.isolation, self.isolation));
let draw_mode = std::mem::replace(&mut app.session.draw_mode, self.draw_mode);
@@ -104,7 +105,7 @@ impl Insertion {
/// `self` when new art can still go there ([`Self::usable`]), else `now`: where new art went
/// before the paste or the place selected anything again.
fn or_now(self, now: Option<&Self>, app: &VectorcraftApp, draws_inside: bool) -> Self {
pub(crate) fn or_now(self, now: Option<&Self>, app: &VectorcraftApp, draws_inside: bool) -> Self {
match now {
Some(now) if !self.usable(app, draws_inside) => now.clone(),
_ => self,
@@ -114,7 +115,7 @@ impl Insertion {
/// Put back each part of `self` (where new art went before [`Self::set`] set `started`) that
/// differs from `started`, what the user changed meanwhile; a part the paste or the place
/// itself changed stays as it left it.
fn restore_changed(self, started: &Self, app: &mut VectorcraftApp) {
pub(crate) fn restore_changed(self, started: &Self, app: &mut VectorcraftApp) {
if let Ok(st) = app.session.doc_mut() {
if self.layer != started.layer {
st.active_layer = self.layer;
+5
View File
@@ -12590,6 +12590,11 @@ In the desktop app and `vectorcraft-cli` the conversion runs in a copy of the pr
a damaged file stops that copy, not the app; it gives up after 30 minutes. Files over 512 MiB, or whose DXF would
pass 1 GiB, are refused. What the conversion skips (objects of types it can't read) is listed in `warnings`. R1.x and
R2.x drawings (`MC0.`, `AC1.` and `AC2.` headers) and the web build answer an error saying to save the drawing as DXF.
When the user opens or places a DWG drawing in the desktop app, it is converted off the UI thread: the status bar and,
after 0.4 s, the open progress window show it (`file.cancelOpen` drops it, `file.openInBackground` closes the window),
and its DXF Import Options open once it is converted. A drawing being placed goes in the document, on the layer and
(with `replace`) in place of the object that were current when Place started; it is not placed when that document
was closed or reverted meanwhile, or when the object to replace was changed or deleted.
```json
{"name":"run_command","arguments":{"command":"document.dxfInfo","params":{"path":"/tmp/plan.dxf"}}}