feat(save): warn before dropping AEC/Civil objects or overwriting on Save-As
Two in-canvas confirmations on the Save-As path: - AEC/Civil drop warning: when the drawing carries unsupported AEC/Civil (application) objects that survive only as verbatim source-version bytes, saving to a different version or to DXF would silently drop them. The dialog reports the count and offers "Save in source version" (keep) vs "Save anyway" (drop). Same-version DWG saves are lossless and skip it. - Overwrite confirmation: when the chosen filename already exists in the target folder, "Replace" / "Cancel" before clobbering it. The two chain (AEC first, then overwrite) via per-flow acknowledgement flags reset whenever the Save dialog opens or closes. Detection is a new io::dropped_on_save_count over the document's Unknown (raw-passthrough) objects/entities. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ab9285f114
commit
b77187e672
7 changed files with 267 additions and 1 deletions
|
|
@ -442,6 +442,37 @@ pub fn format_for_version(version: acadrust::DxfVersion, is_dxf: bool) -> String
|
|||
format!("{} {}", if is_dxf { "DXF" } else { "DWG" }, year)
|
||||
}
|
||||
|
||||
/// Count of unsupported "raw passthrough" objects/entities — AEC / application
|
||||
/// objects with no native representation, kept only as verbatim source-version
|
||||
/// bytes — that would be DROPPED when saving `doc` to `target_version` (or to
|
||||
/// DXF). Returns 0 for a same-version DWG save, where they round-trip verbatim.
|
||||
/// Used to warn the user before a lossy Save-As.
|
||||
pub fn dropped_on_save_count(
|
||||
doc: &acadrust::CadDocument,
|
||||
target_version: acadrust::DxfVersion,
|
||||
is_dxf: bool,
|
||||
) -> usize {
|
||||
if !is_dxf && target_version == doc.version {
|
||||
return 0;
|
||||
}
|
||||
let mut n = doc
|
||||
.objects
|
||||
.values()
|
||||
.filter(|o| {
|
||||
matches!(
|
||||
o,
|
||||
acadrust::objects::ObjectType::Unknown { raw_dwg_data: Some(_), .. }
|
||||
)
|
||||
})
|
||||
.count();
|
||||
for e in doc.entities() {
|
||||
if matches!(e, acadrust::EntityType::Unknown(_)) {
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
// ── Plot Style Table ──────────────────────────────────────────────────────
|
||||
|
||||
/// Show a file-open dialog and load the selected CTB or STB file.
|
||||
|
|
|
|||
Loading…
Reference in a new issue