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
243 changes: 237 additions & 6 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ debug = 0
krilla = { version = "=0.8.2", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }

# Keep the complete egui family and native event bridge on reviewed fork commits.
ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
Expand Down
5 changes: 5 additions & 0 deletions apps/draftcraft-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ fn install_io() {
plot: Some(|d, space, opts| draftcraft_io::plotter::plot(d, space, opts).map_err(|e| e.to_string())),
});
draftcraft_engine::cmd::file::set_image_decoder(|b| draftcraft_io::raster::decode(b).map_err(|e| e.to_string()));
draftcraft_engine::cmd::file::set_pdf_hooks(draftcraft_engine::cmd::file::PdfHooks {
pages: |b| draftcraft_io::pdf_read::pages(b).map_err(|e| e.to_string()),
rasterize: |b, page, dpi| draftcraft_io::pdf_read::rasterize(b, page, dpi).map_err(|e| e.to_string()),
import: draftcraft_io::pdf_read::import_flat,
});
draftcraft_engine::cmd::file::set_write_as(|d, name, o| {
draftcraft_io::write_with(d, name, &draftcraft_io::SaveOptions { version: o.version, binary: o.binary }).map_err(|e| e.to_string())
});
Expand Down
7 changes: 4 additions & 3 deletions apps/draftcraft-cli/tests/it/undrawn_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ fn cli(args: &[&str]) -> Output {
Command::new(env!("CARGO_BIN_EXE_draftcraft-cli")).args(args).output().unwrap()
}

/// A line, two foreign REGIONs and a PDF underlay: the last three are kept as unknown entities.
/// A line, two foreign REGIONs and a DWF underlay: the last three are kept as unknown entities
/// (PDF underlays are drawn; DWF ones are not available yet).
const PROXIES: &str = "0\nSECTION\n2\nENTITIES\n\
0\nLINE\n8\n0\n10\n0\n20\n0\n11\n5\n21\n5\n\
0\nREGION\n8\n0\n70\n1\n1\nabc\n\
0\nREGION\n8\n0\n70\n1\n1\ndef\n\
0\nPDFUNDERLAY\n8\n0\n10\n0\n20\n0\n41\n1\n42\n1\n43\n1\n\
0\nDWFUNDERLAY\n8\n0\n10\n0\n20\n0\n41\n1\n42\n1\n43\n1\n\
0\nENDSEC\n0\nEOF\n";

#[test]
Expand All @@ -34,7 +35,7 @@ fn convert_to_an_image_warns_about_entities_it_cannot_draw() {
let err = String::from_utf8_lossy(&out.stderr);
let warnings: Vec<&str> = err.lines().filter(|l| l.contains("not drawn")).collect();
assert_eq!(warnings.len(), 1, "{ext}: {err}");
assert_eq!(warnings[0], format!("{input}: 3 entities not drawn (PDFUNDERLAY: 1, REGION: 2)"), "{ext}");
assert_eq!(warnings[0], format!("{input}: 3 entities not drawn (DWFUNDERLAY: 1, REGION: 2)"), "{ext}");
}

// A DXF copy keeps them, so there is nothing to warn about.
Expand Down
5 changes: 5 additions & 0 deletions apps/draftcraft-web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ mod web {
plot: Some(|d, space, opts| draftcraft_io::plotter::plot(d, space, opts).map_err(|e| e.to_string())),
});
draftcraft_engine::cmd::file::set_image_decoder(|b| draftcraft_io::raster::decode(b).map_err(|e| e.to_string()));
draftcraft_engine::cmd::file::set_pdf_hooks(draftcraft_engine::cmd::file::PdfHooks {
pages: |b| draftcraft_io::pdf_read::pages(b).map_err(|e| e.to_string()),
rasterize: |b, page, dpi| draftcraft_io::pdf_read::rasterize(b, page, dpi).map_err(|e| e.to_string()),
import: draftcraft_io::pdf_read::import_flat,
});
draftcraft_engine::cmd::file::set_write_as(|d, name, o| {
draftcraft_io::write_with(d, name, &draftcraft_io::SaveOptions { version: o.version, binary: o.binary }).map_err(|e| e.to_string())
});
Expand Down
27 changes: 24 additions & 3 deletions apps/draftcraft/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ pub fn install_io() {
plot: Some(|d, space, opts| draftcraft_io::plotter::plot(d, space, opts).map_err(|e| e.to_string())),
});
draftcraft_engine::cmd::file::set_image_decoder(|b| draftcraft_io::raster::decode(b).map_err(|e| e.to_string()));
draftcraft_engine::cmd::file::set_pdf_hooks(draftcraft_engine::cmd::file::PdfHooks {
pages: |b| draftcraft_io::pdf_read::pages(b).map_err(|e| e.to_string()),
rasterize: |b, page, dpi| draftcraft_io::pdf_read::rasterize(b, page, dpi).map_err(|e| e.to_string()),
import: draftcraft_io::pdf_read::import_flat,
});
draftcraft_engine::cmd::file::set_write_as(|d, name, o| {
draftcraft_io::write_with(d, name, &draftcraft_io::SaveOptions { version: o.version, binary: o.binary }).map_err(|e| e.to_string())
});
Expand Down Expand Up @@ -180,6 +185,13 @@ fn services() -> Services {
let dialog = if dir.is_empty() { dialog } else { dialog.set_directory(dir) };
dialog.pick_file().map(|p| p.to_string_lossy().to_string())
})),
pick_file: Some(Box::new(|label: &str, exts: &[&str]| {
rfd::FileDialog::new()
.add_filter(i18n::t(label), exts)
.add_filter(i18n::t("All files"), &["*"])
.pick_file()
.map(|p| p.to_string_lossy().to_string())
})),
no_file_system: false,
}
}
Expand All @@ -188,9 +200,17 @@ fn services() -> Services {
/// filter's extension, and macOS accepts only listed extensions, replacing any other with the
/// first one. DWG must be listed for a `.dwg` name to survive, and a drawing opened from DWG
/// then defaults to DWG; other names keep DXF first.
fn filters_for_save(name: &str) -> [(&'static str, &'static str); 6] {
let mut filters =
[("Drawing (DXF)", "dxf"), ("Drawing (DWG)", "dwg"), ("Drawing Template (DWT)", "dwt"), ("SVG", "svg"), ("PNG", "png"), ("PDF", "pdf")];
fn filters_for_save(name: &str) -> [(&'static str, &'static str); 8] {
let mut filters = [
("Drawing (DXF)", "dxf"),
("Drawing (DWG)", "dwg"),
("Drawing Template (DWT)", "dwt"),
("SVG", "svg"),
("PNG", "png"),
("PDF", "pdf"),
("Sheet Set (DCSS)", "dcss"),
("ZIP archive", "zip"),
];
let lower = name.to_ascii_lowercase();
filters.sort_by_key(|(_, ext)| !lower.ends_with(&format!(".{ext}")));
filters
Expand Down Expand Up @@ -503,6 +523,7 @@ mod tests {
assert_eq!(first("Drawing1"), "dxf");
assert_eq!(first("plan.pdf"), "pdf");
assert_eq!(first("office.dwt"), "dwt");
assert_eq!(first("Project.dcss"), "dcss");
for name in ["a.dwg", "b.dxf", "c"] {
let exts: Vec<_> = filters_for_save(name).iter().map(|(_, e)| *e).collect();
assert!(exts.contains(&"dwg") && exts.contains(&"dxf"), "{name}");
Expand Down
1 change: 1 addition & 0 deletions crates/doc/src/dynblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::foreign::ForeignObject;
use crate::{Drawing, Handle, RawTag};

mod apply;
pub mod author;
mod grips;
mod reference;
pub use apply::{drag_grip, set_property};
Expand Down
Loading