Use Craft CAD codecs for QCAD-compatible DXF and DWG exchange
This commit is contained in:
parent
f332150947
commit
66385e8bd7
|
|
@ -0,0 +1,2 @@
|
|||
# CAD text fixtures retain the format's CRLF line endings.
|
||||
*.dxf -text whitespace=cr-at-eol
|
||||
|
|
@ -18,6 +18,30 @@ version = "0.1.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
||||
|
||||
[[package]]
|
||||
name = "acadrust"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8923c99ea1f151cb7fc17ce2fc14f8b1e330fa22611e535602d985c0cc3c89a2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.13.2",
|
||||
"byteorder",
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
"foldhash 0.2.0",
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"memmap2",
|
||||
"nom",
|
||||
"oem_cp",
|
||||
"once_cell",
|
||||
"rayon",
|
||||
"ryu",
|
||||
"thiserror 2.0.21",
|
||||
"web-time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
|
|
@ -569,6 +593,12 @@ dependencies = [
|
|||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder-lite"
|
||||
version = "0.1.0"
|
||||
|
|
@ -887,6 +917,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core_detect"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
|
||||
|
||||
[[package]]
|
||||
name = "core_maths"
|
||||
version = "0.1.1"
|
||||
|
|
@ -905,6 +941,32 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-codepage"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=79e97b6febcb62de406e5bcf5a724bd3f7333065#79e97b6febcb62de406e5bcf5a724bd3f7333065"
|
||||
|
||||
[[package]]
|
||||
name = "craft-dwg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=79e97b6febcb62de406e5bcf5a724bd3f7333065#79e97b6febcb62de406e5bcf5a724bd3f7333065"
|
||||
dependencies = [
|
||||
"acadrust",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-dxf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=79e97b6febcb62de406e5bcf5a724bd3f7333065#79e97b6febcb62de406e5bcf5a724bd3f7333065"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"encoding_rs",
|
||||
"kurbo 0.13.1",
|
||||
"log",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.2"
|
||||
|
|
@ -1303,6 +1365,20 @@ version = "0.6.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core_detect",
|
||||
"multiversion_no_op",
|
||||
"rustversion",
|
||||
"scopeguard",
|
||||
"simdutf8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "endi"
|
||||
version = "1.1.1"
|
||||
|
|
@ -1554,6 +1630,12 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "font-types"
|
||||
version = "0.11.3"
|
||||
|
|
@ -1904,7 +1986,7 @@ version = "0.15.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
"foldhash 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2713,6 +2795,8 @@ name = "midra-layout"
|
|||
version = "0.6.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-dwg",
|
||||
"craft-dxf",
|
||||
"csv",
|
||||
"deckcraft-geom",
|
||||
"deckcraft-model",
|
||||
|
|
@ -2735,6 +2819,12 @@ dependencies = [
|
|||
"winresource",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
|
|
@ -2782,6 +2872,12 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "685a9ac4b61f4e728e1d2c6a7844609c16527aeb5e6c865915c08e619c16410f"
|
||||
|
||||
[[package]]
|
||||
name = "multiversion_no_op"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"
|
||||
|
||||
[[package]]
|
||||
name = "mutate_once"
|
||||
version = "0.1.2"
|
||||
|
|
@ -2855,6 +2951,16 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.8"
|
||||
|
|
@ -3207,6 +3313,15 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oem_cp"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c7959d3349f484aec36462f98226983578bf7d33f9b034c32967489c7000e1f"
|
||||
dependencies = [
|
||||
"phf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.4"
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ See [development setup](https://proxy.dandaedre.com/gitea/Beffroi/beffroi-tools/
|
|||
[Browse all starter files →](https://proxy.dandaedre.com/gitea/Beffroi/beffroi-tools/src/branch/main/docs/templates/midra-layout/README.md)
|
||||
|
||||
Matching Full HD and UHD 4K layouts are available in SVG, draw.io, geometry JSON,
|
||||
CSV, DXF, HTML, PPTX, Figma FIG and Illustrator AI. The catalog contains every
|
||||
CSV, DXF/DWG, HTML, PPTX, Figma FIG and Illustrator AI. The catalog contains every
|
||||
base file, import guidance and format dependencies.
|
||||
|
||||
## Explore further
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ description = "Midra layer positioning, geometry import and reviewed device cont
|
|||
|
||||
[features]
|
||||
default = ["vendor_formats"]
|
||||
vendor_formats = ["dep:deckcraft-pptx", "dep:deckcraft-model", "dep:deckcraft-geom", "dep:figcraft-format", "dep:figcraft-doc", "dep:figcraft-geom"]
|
||||
vendor_formats = ["dep:craft-dwg", "dep:deckcraft-pptx", "dep:deckcraft-model", "dep:deckcraft-geom", "dep:figcraft-format", "dep:figcraft-doc", "dep:figcraft-geom"]
|
||||
# Use with --no-default-features to exclude the optional codecs and their dependencies.
|
||||
no_proprietary = []
|
||||
|
||||
[dependencies]
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "79e97b6febcb62de406e5bcf5a724bd3f7333065" }
|
||||
craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "79e97b6febcb62de406e5bcf5a724bd3f7333065", optional = true }
|
||||
deckcraft-pptx = { version = "=0.6.1", optional = true }
|
||||
deckcraft-model = { version = "=0.6.1", optional = true }
|
||||
deckcraft-geom = { version = "=0.6.1", optional = true }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
use midra_layout::{
|
||||
Geometry, Layout,
|
||||
exchange::{self, Format, Options},
|
||||
import::parse_values,
|
||||
project::{Project, Resolution, write_file},
|
||||
};
|
||||
|
||||
|
|
@ -105,8 +104,12 @@ fn main() -> Result<(), String> {
|
|||
[command, paths @ ..] if command == "verify" && !paths.is_empty() => {
|
||||
let project = Project::from_layout(&Layout::default());
|
||||
for path in paths {
|
||||
let text = std::fs::read_to_string(path).map_err(|e| e.to_string())?;
|
||||
let imported = parse_values(&text)?;
|
||||
let bytes = std::fs::read(path).map_err(|e| e.to_string())?;
|
||||
let pages = midra_layout::interchange::import(&bytes, path)?;
|
||||
if pages.len() != 1 {
|
||||
return Err(format!("Expected one page: {path}"));
|
||||
}
|
||||
let imported = &pages[0].document;
|
||||
let shapes: Vec<_> = imported
|
||||
.shapes
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -255,65 +255,64 @@ fn export_html(canvas: [u32; 2], shapes: &[ExportShape]) -> String {
|
|||
output
|
||||
}
|
||||
|
||||
fn dxf_pair(output: &mut String, code: i32, value: impl std::fmt::Display) {
|
||||
output.push_str(&format!("{code}\r\n{value}\r\n"));
|
||||
}
|
||||
|
||||
fn export_dxf(canvas: [u32; 2], shapes: &[ExportShape]) -> String {
|
||||
let mut output = String::new();
|
||||
dxf_pair(&mut output, 999, "MIDRA_LAYOUT_GEOMETRY 1");
|
||||
dxf_pair(&mut output, 0, "SECTION");
|
||||
dxf_pair(&mut output, 2, "HEADER");
|
||||
dxf_pair(&mut output, 9, "$ACADVER");
|
||||
dxf_pair(&mut output, 1, "AC1021");
|
||||
dxf_pair(&mut output, 9, "$INSUNITS");
|
||||
dxf_pair(&mut output, 70, 0);
|
||||
dxf_pair(&mut output, 9, "$EXTMIN");
|
||||
dxf_pair(&mut output, 10, 0);
|
||||
dxf_pair(&mut output, 20, 0);
|
||||
dxf_pair(&mut output, 9, "$EXTMAX");
|
||||
dxf_pair(&mut output, 10, canvas[0]);
|
||||
dxf_pair(&mut output, 20, canvas[1]);
|
||||
dxf_pair(&mut output, 9, "$LIMMIN");
|
||||
dxf_pair(&mut output, 10, 0);
|
||||
dxf_pair(&mut output, 20, 0);
|
||||
dxf_pair(&mut output, 9, "$LIMMAX");
|
||||
dxf_pair(&mut output, 10, canvas[0]);
|
||||
dxf_pair(&mut output, 20, canvas[1]);
|
||||
dxf_pair(&mut output, 0, "ENDSEC");
|
||||
dxf_pair(&mut output, 0, "SECTION");
|
||||
dxf_pair(&mut output, 2, "TABLES");
|
||||
dxf_pair(&mut output, 0, "TABLE");
|
||||
dxf_pair(&mut output, 2, "LAYER");
|
||||
dxf_pair(&mut output, 70, shapes.len());
|
||||
use craft_dxf::model::{
|
||||
Color, Common, Entity, EntityKind, Layer, Lineweight, LwPolyline, LwVertex, Transparency,
|
||||
write::{Drawing, Format},
|
||||
};
|
||||
let bounds = [0.0, 0.0, f64::from(canvas[0]), f64::from(canvas[1])];
|
||||
let mut drawing = Drawing {
|
||||
format: Format::R2007,
|
||||
extents: bounds,
|
||||
limits: bounds,
|
||||
insunits: 0,
|
||||
..Default::default()
|
||||
};
|
||||
for (index, shape) in shapes.iter().enumerate() {
|
||||
dxf_pair(&mut output, 0, "LAYER");
|
||||
dxf_pair(&mut output, 2, &shape.id);
|
||||
dxf_pair(&mut output, 70, 0);
|
||||
dxf_pair(&mut output, 62, if index % 2 == 0 { 4 } else { 5 });
|
||||
dxf_pair(&mut output, 6, "CONTINUOUS");
|
||||
}
|
||||
dxf_pair(&mut output, 0, "ENDTAB");
|
||||
dxf_pair(&mut output, 0, "ENDSEC");
|
||||
dxf_pair(&mut output, 0, "SECTION");
|
||||
dxf_pair(&mut output, 2, "ENTITIES");
|
||||
for shape in shapes {
|
||||
let [x, y, width, height] = rounded(shape.geometry);
|
||||
let top = i64::from(canvas[1]) - y;
|
||||
drawing.layers.push(Layer {
|
||||
handle: None,
|
||||
name: shape.id.clone(),
|
||||
color: Color::Index(if index % 2 == 0 { 4 } else { 5 }),
|
||||
on: true,
|
||||
frozen: false,
|
||||
vp_freeze_new: false,
|
||||
locked: false,
|
||||
plot: true,
|
||||
linetype: "Continuous".into(),
|
||||
lineweight: Lineweight::Default,
|
||||
plot_style: None,
|
||||
transparency: Transparency::ByLayer,
|
||||
description: Some(shape.name.clone()),
|
||||
});
|
||||
let [x, y, width, height] = rounded(shape.geometry).map(|v| v as f64);
|
||||
let top = f64::from(canvas[1]) - y;
|
||||
let bottom = top - height;
|
||||
dxf_pair(&mut output, 999, format!("NAME {}", shape.name));
|
||||
dxf_pair(&mut output, 0, "LWPOLYLINE");
|
||||
dxf_pair(&mut output, 8, &shape.id);
|
||||
dxf_pair(&mut output, 90, 4);
|
||||
dxf_pair(&mut output, 70, 1);
|
||||
for [px, py] in [[x, top], [x + width, top], [x + width, bottom], [x, bottom]] {
|
||||
dxf_pair(&mut output, 10, px);
|
||||
dxf_pair(&mut output, 20, py);
|
||||
}
|
||||
let mut common = Common::read(&[]);
|
||||
common.layer = shape.id.clone();
|
||||
drawing.entities.push(Entity {
|
||||
common,
|
||||
kind: EntityKind::LwPolyline(LwPolyline {
|
||||
vertices: [[x, top], [x + width, top], [x + width, bottom], [x, bottom]]
|
||||
.into_iter()
|
||||
.map(|[x, y]| LwVertex {
|
||||
x,
|
||||
y,
|
||||
..Default::default()
|
||||
})
|
||||
.collect(),
|
||||
closed: true,
|
||||
plinegen: false,
|
||||
const_width: 0.0,
|
||||
elevation: 0.0,
|
||||
}),
|
||||
});
|
||||
}
|
||||
dxf_pair(&mut output, 0, "ENDSEC");
|
||||
dxf_pair(&mut output, 0, "EOF");
|
||||
output
|
||||
let (tags, _) = drawing.tags();
|
||||
// QCAD seeds stock objects at low handles before importing. Reserve that range
|
||||
// and remap definitions and references together with Craft's model helper.
|
||||
let mut tags = craft_dxf::model::write::remap_handles(&tags, |handle| Some(handle + 0x100));
|
||||
tags.insert(0, craft_dxf::Tag::s(999, "MIDRA_LAYOUT_GEOMETRY 1"));
|
||||
craft_dxf::write_ascii_as(&tags, true)
|
||||
}
|
||||
|
||||
pub(crate) fn parse_json(text: &str) -> Result<ImportDocument, String> {
|
||||
|
|
@ -421,26 +420,18 @@ pub(crate) fn parse_html(text: &str) -> Result<ImportDocument, String> {
|
|||
)
|
||||
}
|
||||
|
||||
fn dxf_pairs(text: &str) -> Result<Vec<(i32, &str)>, String> {
|
||||
let lines: Vec<_> = text.lines().collect();
|
||||
let (pairs, remainder) = lines.as_chunks::<2>();
|
||||
if !remainder.is_empty() {
|
||||
return Err("DXF must contain group-code/value line pairs.".into());
|
||||
}
|
||||
pairs
|
||||
.iter()
|
||||
.map(|pair| {
|
||||
pair[0]
|
||||
.trim()
|
||||
.parse::<i32>()
|
||||
.map(|code| (code, pair[1].trim()))
|
||||
.map_err(|_| "Invalid DXF group code.".into())
|
||||
})
|
||||
.collect()
|
||||
pub(crate) fn parse_dxf(text: &str) -> Result<ImportDocument, String> {
|
||||
parse_dxf_bytes(text.as_bytes())
|
||||
}
|
||||
|
||||
pub(crate) fn parse_dxf(text: &str) -> Result<ImportDocument, String> {
|
||||
let pairs = dxf_pairs(text)?;
|
||||
pub(crate) fn parse_dxf_bytes(bytes: &[u8]) -> Result<ImportDocument, String> {
|
||||
let tags = craft_dxf::parse_with_limit(bytes, MAX_EXCHANGE_BYTES / 4)
|
||||
.map_err(|e| format!("Invalid DXF: {e}"))?;
|
||||
let values: Vec<_> = tags.iter().map(|tag| (tag.code, tag.str())).collect();
|
||||
let pairs: Vec<_> = values
|
||||
.iter()
|
||||
.map(|(code, value)| (*code, value.trim()))
|
||||
.collect();
|
||||
if !pairs
|
||||
.iter()
|
||||
.any(|(code, value)| *code == 0 && *value == "LWPOLYLINE")
|
||||
|
|
|
|||
|
|
@ -713,7 +713,7 @@ impl Editor {
|
|||
.is_some_and(|extension| {
|
||||
let extension = extension.to_ascii_lowercase();
|
||||
midra_layout::interchange::extensions().contains(&extension.as_str())
|
||||
|| matches!(extension.as_str(), "pptx" | "fig" | "ai")
|
||||
|| matches!(extension.as_str(), "pptx" | "fig" | "ai" | "dwg")
|
||||
})
|
||||
}
|
||||
fn read_geometry_files(files: Vec<egui::DroppedFile>, p: &mut Paste) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ pub enum Codec {
|
|||
Json,
|
||||
Csv,
|
||||
Dxf,
|
||||
Dwg,
|
||||
Html,
|
||||
Pptx,
|
||||
Figma,
|
||||
|
|
@ -33,7 +34,7 @@ impl Codec {
|
|||
feature = "vendor_formats",
|
||||
not(feature = "no_proprietary")
|
||||
)) {
|
||||
formats.extend([Self::Pptx, Self::Figma, Self::Illustrator]);
|
||||
formats.extend([Self::Dwg, Self::Pptx, Self::Figma, Self::Illustrator]);
|
||||
}
|
||||
formats
|
||||
}
|
||||
|
|
@ -44,6 +45,7 @@ impl Codec {
|
|||
Self::Json => "Geometry JSON",
|
||||
Self::Csv => "Geometry CSV",
|
||||
Self::Dxf => "DXF · CAD",
|
||||
Self::Dwg => "DWG · CAD (Craft)",
|
||||
Self::Html => "HTML / CSS",
|
||||
Self::Pptx => "PowerPoint · PPTX",
|
||||
Self::Figma => "Figma · FIG",
|
||||
|
|
@ -57,6 +59,7 @@ impl Codec {
|
|||
Self::Json => "json",
|
||||
Self::Csv => "csv",
|
||||
Self::Dxf => "dxf",
|
||||
Self::Dwg => "dwg",
|
||||
Self::Html => "html",
|
||||
Self::Pptx => "pptx",
|
||||
Self::Figma => "fig",
|
||||
|
|
@ -64,10 +67,13 @@ impl Codec {
|
|||
}
|
||||
}
|
||||
pub fn artwork(self) -> bool {
|
||||
!matches!(self, Self::Csv | Self::Dxf)
|
||||
!matches!(self, Self::Csv | Self::Dxf | Self::Dwg)
|
||||
}
|
||||
pub fn help(self) -> &'static str {
|
||||
match self {
|
||||
Self::Dwg => {
|
||||
"Editable CAD rectangles via Craft. Unitless drawing: one unit equals one screen pixel; no pictures."
|
||||
}
|
||||
Self::Pptx => {
|
||||
"One editable slide. Coordinates use 96 pixels per inch. Import lets you choose a slide."
|
||||
}
|
||||
|
|
@ -150,9 +156,10 @@ pub fn import(bytes: &[u8], filename: &str) -> Result<Vec<Page>, String> {
|
|||
.and_then(|s| s.to_str())
|
||||
.unwrap_or("")
|
||||
.to_ascii_lowercase();
|
||||
let vendor = matches!(extension.as_str(), "pptx" | "fig" | "ai")
|
||||
let vendor = matches!(extension.as_str(), "pptx" | "fig" | "ai" | "dwg")
|
||||
|| bytes.starts_with(b"PK")
|
||||
|| bytes.starts_with(b"fig-");
|
||||
|| bytes.starts_with(b"fig-")
|
||||
|| bytes.starts_with(b"AC10");
|
||||
if vendor {
|
||||
if cfg!(feature = "no_proprietary") {
|
||||
return Err("Vendor format support is disabled in this no_proprietary build.".into());
|
||||
|
|
@ -166,6 +173,12 @@ pub fn import(bytes: &[u8], filename: &str) -> Result<Vec<Page>, String> {
|
|||
return Err("Vendor format support is not compiled in. Enable vendor_formats.".into());
|
||||
}
|
||||
}
|
||||
if extension == "dxf" || bytes.starts_with(b"AutoCAD Binary DXF") {
|
||||
return Ok(vec![Page {
|
||||
name: filename.into(),
|
||||
document: crate::geometry_formats::parse_dxf_bytes(bytes)?,
|
||||
}]);
|
||||
}
|
||||
let text = std::str::from_utf8(bytes).map_err(
|
||||
|_| "Unrecognized binary format. Choose PPTX, FIG, AI or a supported geometry file.",
|
||||
)?;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@ pub(crate) fn export(
|
|||
return Err("Rename the layer called ‘midra-background’ before native export; that name identifies the optional background.".into());
|
||||
}
|
||||
match codec {
|
||||
Codec::Dwg => {
|
||||
let dxf = exchange::encode_shapes(exchange::Format::Dxf, canvas, shapes)?;
|
||||
let (bytes, omitted) = craft_dwg::dxf_to_dwg_noted(dxf.as_bytes(), "AC1021")?;
|
||||
if !omitted.is_empty() {
|
||||
return Err(format!("DWG export omitted records: {omitted:?}"));
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
Codec::Pptx => export_pptx(canvas, shapes),
|
||||
Codec::Figma => export_fig(canvas, shapes),
|
||||
Codec::Illustrator => {
|
||||
|
|
@ -72,6 +80,21 @@ pub(crate) fn export(
|
|||
}
|
||||
}
|
||||
pub(crate) fn import(bytes: &[u8], extension: &str, filename: &str) -> Result<Vec<Page>, String> {
|
||||
if extension == "dwg" || craft_dwg::is_dwg(bytes) {
|
||||
let (dxf, notes) = craft_dwg::dwg_to_dxf_noted(
|
||||
bytes,
|
||||
craft_dwg::Limits {
|
||||
max_dwg_bytes: exchange::MAX_EXCHANGE_BYTES,
|
||||
max_dxf_bytes: exchange::MAX_EXCHANGE_BYTES,
|
||||
},
|
||||
)?;
|
||||
let mut document = crate::geometry_formats::parse_dxf_bytes(&dxf)?;
|
||||
document.note = format!("DWG via Craft. {} {}", document.note, notes.join("; "));
|
||||
return Ok(vec![Page {
|
||||
name: filename.into(),
|
||||
document,
|
||||
}]);
|
||||
}
|
||||
if extension == "ai" {
|
||||
return import_ai(bytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,101 @@
|
|||
use midra_layout::{
|
||||
Layout,
|
||||
exchange::Options,
|
||||
interchange::{self, Codec},
|
||||
project::Project,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn craft_dxf_has_owned_entities_and_roundtrips_binary_tags() {
|
||||
let project = Project::from_layout(&Layout::default());
|
||||
let ids: Vec<_> = project.layers.iter().map(|l| l.id).collect();
|
||||
let bytes = interchange::export(&project, &ids, Codec::Dxf, Options::default()).unwrap();
|
||||
let tags = craft_dxf::parse(&bytes).unwrap();
|
||||
let handles: Vec<_> = tags
|
||||
.iter()
|
||||
.filter(|t| t.code == 5 || t.code == 105)
|
||||
.map(|t| t.str())
|
||||
.collect();
|
||||
assert!(
|
||||
tags.iter()
|
||||
.any(|t| t.code == 100 && t.str() == "AcDbBlockTableRecord")
|
||||
);
|
||||
let mut entities = 0;
|
||||
for (index, tag) in tags.iter().enumerate() {
|
||||
if tag.code != 0 || tag.str() != "LWPOLYLINE" {
|
||||
continue;
|
||||
}
|
||||
entities += 1;
|
||||
let entity: Vec<_> = tags[index + 1..]
|
||||
.iter()
|
||||
.take_while(|t| t.code != 0)
|
||||
.collect();
|
||||
assert!(entity.iter().any(|t| t.code == 5));
|
||||
assert!(
|
||||
entity
|
||||
.iter()
|
||||
.any(|t| t.code == 330 && handles.contains(&t.str()))
|
||||
);
|
||||
for subclass in ["AcDbEntity", "AcDbPolyline"] {
|
||||
assert!(entity.iter().any(|t| t.code == 100 && t.str() == subclass));
|
||||
}
|
||||
}
|
||||
assert_eq!(entities, 2);
|
||||
let binary = craft_dxf::write_binary(&tags, true);
|
||||
let pages = interchange::import(&binary, "layout.DXF").unwrap();
|
||||
assert_eq!(
|
||||
pages[0]
|
||||
.document
|
||||
.shapes
|
||||
.iter()
|
||||
.map(|s| s.geometry)
|
||||
.collect::<Vec<_>>(),
|
||||
project.layers.iter().map(|l| l.bounds).collect::<Vec<_>>()
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))]
|
||||
#[test]
|
||||
fn craft_dwg_preserves_canvas_background_and_layer_boxes() {
|
||||
for resolution in [[1920, 1080], [3840, 2160]] {
|
||||
let mut project = Project::from_layout(&Layout::default());
|
||||
project.output_resolution = resolution.into();
|
||||
let ids: Vec<_> = project.layers.iter().map(|l| l.id).collect();
|
||||
for background in [false, true] {
|
||||
let bytes = interchange::export(
|
||||
&project,
|
||||
&ids,
|
||||
Codec::Dwg,
|
||||
Options {
|
||||
background,
|
||||
placeholders: false,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert!(craft_dwg::is_dwg(&bytes));
|
||||
let pages = interchange::import(&bytes, "layout.DWG").unwrap();
|
||||
let shapes = &pages[0].document.shapes;
|
||||
assert_eq!(shapes.len(), 2 + usize::from(background));
|
||||
let boxes: Vec<_> = shapes
|
||||
.iter()
|
||||
.filter(|s| !s.background_only)
|
||||
.map(|s| s.geometry)
|
||||
.collect();
|
||||
assert_eq!(
|
||||
boxes,
|
||||
project.layers.iter().map(|l| l.bounds).collect::<Vec<_>>()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(not(feature = "vendor_formats"), feature = "no_proprietary"))]
|
||||
#[test]
|
||||
fn licensing_build_rejects_dwg_explicitly() {
|
||||
assert!(!Codec::available().contains(&Codec::Dwg));
|
||||
assert!(
|
||||
interchange::import(b"AC1021invalid", "layout.dwg")
|
||||
.unwrap_err()
|
||||
.contains("support")
|
||||
);
|
||||
}
|
||||
|
|
@ -375,7 +375,18 @@ fn open_text_adapters_reject_wrong_versions_canvases_and_non_rectangles() {
|
|||
);
|
||||
|
||||
let dxf = exchange::export(&project, &ids, Format::Dxf, Options::default()).unwrap();
|
||||
assert!(parse_values(&dxf.replacen("70\r\n1\r\n", "70\r\n0\r\n", 1)).is_err());
|
||||
let mut tags = craft_dxf::parse(dxf.as_bytes()).unwrap();
|
||||
let start = tags
|
||||
.iter()
|
||||
.position(|t| t.code == 0 && t.str() == "LWPOLYLINE")
|
||||
.unwrap();
|
||||
let closed = tags[start + 1..]
|
||||
.iter_mut()
|
||||
.take_while(|t| t.code != 0)
|
||||
.find(|t| t.code == 70)
|
||||
.unwrap();
|
||||
*closed = craft_dxf::Tag::i(70, 0);
|
||||
assert!(parse_values(&craft_dxf::write_ascii_as(&tags, true)).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -488,7 +499,7 @@ fn check_native_templates(codecs: &[midra_layout::interchange::Codec]) {
|
|||
#[test]
|
||||
fn native_readme_templates_preserve_two_layer_geometry() {
|
||||
use midra_layout::interchange::Codec;
|
||||
check_native_templates(&[Codec::Pptx, Codec::Figma]);
|
||||
check_native_templates(&[Codec::Pptx, Codec::Figma, Codec::Dwg]);
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "vendor_formats", not(feature = "no_proprietary")))]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Midra Layout geometry exchange
|
||||
|
||||
The Export menu writes **SVG v2**, **draw.io v1**, **geometry JSON v1**,
|
||||
**geometry CSV v1**, **DXF**, **HTML/CSS v1**, **PPTX**, **Figma FIG** and
|
||||
**geometry CSV v1**, **DXF/DWG**, **HTML/CSS v1**, **PPTX**, **Figma FIG** and
|
||||
**Illustrator AI** (the latter via a local VectorCraft CLI). Project
|
||||
JSON is version 10 and is the full-fidelity save format. These exchanges
|
||||
preserve layer **visible-box geometry**, not sources, crop settings, zoom, pivots,
|
||||
|
|
@ -10,7 +10,7 @@ cropping; importing a picture does not reconstruct its crop or source settings.
|
|||
|
||||
The [starter-file catalog](../templates/midra-layout/README.md) centralizes ready-to-open
|
||||
two-layer templates under `docs/templates/midra-layout/` for Full HD (1920 × 1080) and UHD 4K
|
||||
(3840 × 2160), in all nine exchange formats (including PPTX, FIG and AI). The 4K geometry is an exact
|
||||
(3840 × 2160), in all ten exchange formats (including PPTX, FIG and AI). The 4K geometry is an exact
|
||||
2× scale of the Full HD layout. Regenerate them with:
|
||||
|
||||
```sh
|
||||
|
|
@ -110,7 +110,7 @@ optional executable rather than embedding that stack. Upstream licenses still
|
|||
apply to separately distributed tools; Midra does not bundle VectorCraft.
|
||||
|
||||
```sh
|
||||
# Normal build: native PPTX/FIG codecs and the optional AI converter interface.
|
||||
# Normal build: native PPTX/FIG/DWG codecs and the optional AI converter interface.
|
||||
cargo build --locked --release -p midra-layout
|
||||
# Excludes vendor codecs, their optional dependency trees and the AI interface.
|
||||
cargo build --locked --release -p midra-layout --no-default-features --features no_proprietary
|
||||
|
|
@ -260,18 +260,40 @@ meaning as JSON. Empty files, mismatched canvases, extra/missing fields and
|
|||
non-integer geometry are rejected. CSV carries background geometry but no image
|
||||
data or placeholder pictures.
|
||||
|
||||
## DXF profile
|
||||
## CAD: DXF and DWG profiles
|
||||
|
||||
UTF-8 ASCII DXF declares `AC1021` (AutoCAD 2007), unitless `$INSUNITS=0`, and
|
||||
whole-pixel `$LIMMIN`/`$LIMMAX` canvas bounds (with matching initial extents).
|
||||
Every stable ID has a layer-table entry and every shape is one closed,
|
||||
four-vertex `LWPOLYLINE`; its DXF layer name is the stable Midra layer ID.
|
||||
Because CAD Y increases upward, export writes `cad_y = canvas_height - screen_y`
|
||||
and import reverses that conversion. The `midra-background` entity is ignored as
|
||||
background. DXF cannot embed the supported self-contained placeholder artwork;
|
||||
human names are comments and may be discarded by CAD re-saving. Import requires
|
||||
explicit extents and axis-aligned closed rectangles rather than guessing scale,
|
||||
units or page origin.
|
||||
DXF uses the official shared `craft-dxf` document model and serializer, pinned to
|
||||
Craft libraries revision `79e97b6febcb62de406e5bcf5a724bd3f7333065` (MIT OR Apache-2.0).
|
||||
It writes UTF-8 ASCII DXF `AC1021` (AutoCAD 2007), with complete symbol tables,
|
||||
model/paper-space block records, dictionaries, layouts, unique handles, owner
|
||||
references and subclass markers. Handles reserve the low `0x100` range to avoid
|
||||
QCAD stock-object collisions; Craft remaps definitions and pointers together. This replaces the incomplete hand-written DXF
|
||||
skeleton rejected by QCAD. The rectangle/coordinate contract remains unchanged;
|
||||
older Midra DXF files are still readable.
|
||||
|
||||
Drawings are unitless (`$INSUNITS=0`): one CAD unit equals one screen pixel.
|
||||
Whole-pixel `$LIMMIN`/`$LIMMAX` describe the canvas, with matching initial extents.
|
||||
Every stable ID has a layer-table entry; every box is one closed four-vertex
|
||||
`LWPOLYLINE`. CAD Y increases upward, so `cad_y = canvas_height - screen_y`.
|
||||
Import reverses this conversion and requires explicit canvas limits (falling
|
||||
back to extents), rather than guessing scale or page origin. The special
|
||||
`midra-background` layer is excluded from destination mapping. Human names are
|
||||
layer descriptions; imported IDs remain CAD layer names. Pictures are omitted.
|
||||
DXF import uses Craft's bounded ASCII/binary tag reader and retains the existing
|
||||
axis-aligned rectangle restrictions.
|
||||
|
||||
DWG uses the optional `craft-dwg` byte bridge from the same pinned revision,
|
||||
backed by unmodified `acadrust` 0.6.6 (MPL-2.0). It converts the same DXF model to
|
||||
AutoCAD 2007 DWG and back; canvas limits, IDs, pixel rounding and background rules
|
||||
are identical. A writer report of omitted records rejects export. Reader notes
|
||||
appear in the import review. Both DWG input and expanded DXF are limited to
|
||||
16 MiB. DWG is available with `vendor_formats`, excluded by `no_proprietary`;
|
||||
DXF remains available in all builds. The bridge reports unsupported platforms
|
||||
explicitly (WebAssembly and FreeBSD ARM64 at this pin).
|
||||
|
||||
Geometry exchange is not a general CAD editor: arbitrary drawing entities,
|
||||
blocks and drafting annotations are not a supported round-trip profile. Keep
|
||||
original CAD drawings; import/export the rectangular layer layout separately.
|
||||
|
||||
## HTML/CSS v1
|
||||
|
||||
|
|
@ -325,7 +347,7 @@ the only positions present in that SVG. Include Midra Layout's background layer
|
|||
before exporting through draw.io when the full output-screen origin must survive
|
||||
the round trip.
|
||||
|
||||
Tests cover each format/artwork combination, the twelve text templates and four native PPTX/FIG templates (plus two AI templates in the opt-in CLI check),
|
||||
Tests cover each format/artwork combination, the twelve text templates and six native PPTX/FIG/DWG templates (plus two AI templates in the opt-in CLI check),
|
||||
full-screen layers vs backgrounds,
|
||||
negative/fractional coordinates, repeat round trips, compressed clipboard/files,
|
||||
embedded references, invalid IDs/versions and no-overwrite file handling.
|
||||
|
|
@ -356,3 +378,19 @@ Multiple references are flattened into the same single background image in
|
|||
artwork-capable exports; no format version changes. Reimport reconstructs that
|
||||
background as a geometry/artwork item, not the editable reference collection.
|
||||
Use project JSON v10 to preserve independent images and visibility.
|
||||
|
||||
### QCAD interoperability check
|
||||
|
||||
Validated with QCAD Professional 3.28.2: both 1080p and 4K DXF/DWG templates
|
||||
render two correctly placed rectangles without import/handle warnings. Saving
|
||||
both Full HD samples through QCAD as R21 (2007) and reimporting preserves both
|
||||
layer boxes. Example manual check (temporary output only):
|
||||
|
||||
```sh
|
||||
QT_QPA_PLATFORM=offscreen /path/to/qcad/dwg2dwg -r R21 -o /tmp/layout.dwg docs/templates/midra-layout/midra-layout-1080p-2-layers.dwg
|
||||
cargo run --locked -p midra-layout --example check_geometry_exchange -- verify /tmp/layout.dwg
|
||||
```
|
||||
|
||||
The verifier now uses the unified byte importer for text and binary formats.
|
||||
The `.ai` starter ZIP is only a download wrapper, not a new import format; its
|
||||
two entries must remain byte-identical to the `.ai` fixtures (Python regression).
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ See [formats and crop](guide/formats-and-crop.md) and
|
|||
that retains the full editor project.
|
||||
- **Work with another application:** drop a supported geometry file into the window,
|
||||
use **Import → Geometry file…**, or **Project → Export → Export layers…**. The [starter-file catalog](../templates/midra-layout/README.md)
|
||||
has matching Full HD and 4K files in SVG, draw.io, geometry JSON, CSV, DXF,
|
||||
has matching Full HD and 4K files in SVG, draw.io, geometry JSON, CSV, DXF/DWG,
|
||||
HTML, PPTX, Figma FIG and Illustrator AI. It also lists format dependencies.
|
||||
- **Use an Eikos 4K:** connect, review layer mappings, then explicitly load or
|
||||
send the chosen layers. Ordinary editing does not send commands to the device.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Replace the incomplete DXF skeleton with the official shared Craft DXF document writer/reader; add optional Craft DWG exchange with the same pixel geometry and canvas limits. Refresh CAD starter files and cover document structure, binary DXF and DWG round trips. Add a byte-preserving ZIP of the AI templates to bypass Gitea/browser PDF preview downloads.
|
||||
|
||||
- Place insufficient import-destination warnings directly below the destination scope selector instead of repeating them near the Import button.
|
||||
|
||||
- Simplify geometry/clipboard import into a shared review without repeated acquisition controls. Collapse clipboard and before/after details, emphasize destination mapping, and add independent All / Selected / Folder scopes plus per-item exclusion. Preserve compatible mappings and canvas selection; regression tests cover scope filtering, atomic import and review visibility.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ The title is clipped to the banner and appears only without an imported referenc
|
|||
image, at any output resolution. It is not exported to SVG or sent to Midra.
|
||||
|
||||
The initial backdrop is illustrative and adapts to every output resolution/aspect ratio; importing a reference picture replaces it.
|
||||
Project save/load, nine-format geometry exchange, arbitrary layer collections,
|
||||
Project save/load, ten-format geometry exchange, arbitrary layer collections,
|
||||
single-level folders and persistent Midra screen/layer links are implemented.
|
||||
File export offers current/specific/selected/all/visible scopes; device transfers
|
||||
use All/Selected/Folder. Organization never sends commands by itself.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
## Paste layer values and import geometry
|
||||
|
||||
Drop SVG, draw.io/XML, geometry JSON/CSV, DXF, HTML, PPTX, FIG or AI files into
|
||||
Drop SVG, draw.io/XML, geometry JSON/CSV, DXF/DWG, HTML, PPTX, FIG or AI files into
|
||||
the window to open the same geometry review as **Import → Geometry file…**.
|
||||
Native codecs still require their normal build options/dependencies. Filename
|
||||
extensions are case-insensitive; PNG/JPEG/BMP drops remain reference images.
|
||||
|
|
@ -120,11 +120,11 @@ viewport preferences, and all embedded reference images. Apply pending edits
|
|||
before saving. Opening asks before replacing current work and starts a fresh
|
||||
undo history. Existing files require confirmation before replacement.
|
||||
|
||||
The [starter-file catalog](../../templates/midra-layout/README.md) contains all nine
|
||||
The [starter-file catalog](../../templates/midra-layout/README.md) contains all ten
|
||||
exchange formats, with two layers for 1920 × 1080 and 3840 × 2160 canvases.
|
||||
|
||||
**Project → Export → Export layers…** opens one shared window. Choose SVG,
|
||||
draw.io, JSON, CSV, DXF, HTML, PPTX, Figma FIG or Illustrator AI, then
|
||||
draw.io, JSON, CSV, DXF/DWG, HTML, PPTX, Figma FIG or Illustrator AI, then
|
||||
**Current layer…**,
|
||||
**Selected layers…**, **Specific layer…**, **All layers…** and **Visible layers
|
||||
only…**. A current-layer export keeps its original screen position and full-screen
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ device readback and physical-screen acceptance.
|
|||
- [x] Clipboard/import mapping review with per-row target/ignore, independent
|
||||
size/position/available-zoom toggles, draw.io stroke handling and own-copy
|
||||
round trips. Real draw.io clipboard sample and draw.io-exported SVG supported.
|
||||
- [x] Nine-format file exchange: SVG, draw.io, geometry JSON, CSV, DXF, HTML,
|
||||
- [x] Ten-format file exchange: SVG, draw.io, geometry JSON, CSV, DXF/DWG, HTML,
|
||||
PPTX, FIG and AI through VectorCraft. Shared geometry, scope and review,
|
||||
optional artwork where supported, page/frame selection and licensing build flag.
|
||||
Two-layer Full HD and UHD templates exist for all nine formats.
|
||||
Two-layer Full HD and UHD templates exist for all ten formats.
|
||||
- [x] Project JSON v10, tested legacy/recovery migration, saved layer links,
|
||||
central application preferences, full Settings, themes and recent-theme list.
|
||||
- [x] Separate Midra connection and mapping/transfer controls, saved address,
|
||||
|
|
|
|||
|
|
@ -18,11 +18,25 @@ Review the detected rectangles and their destination layers before applying.
|
|||
| Geometry JSON | [Download .json](midra-layout-1080p-2-layers.json) | [Download .json](midra-layout-4k-2-layers.json) | Scripts and geometry exchange |
|
||||
| Geometry CSV | [Download .csv](midra-layout-1080p-2-layers.csv) | [Download .csv](midra-layout-4k-2-layers.csv) | Spreadsheets and data tools |
|
||||
| DXF | [Download .dxf](midra-layout-1080p-2-layers.dxf) | [Download .dxf](midra-layout-4k-2-layers.dxf) | CAD tools |
|
||||
| DWG | [Download .dwg](midra-layout-1080p-2-layers.dwg) | [Download .dwg](midra-layout-4k-2-layers.dwg) | CAD tools; Craft bridge |
|
||||
| HTML | [Download .html](midra-layout-1080p-2-layers.html) | [Download .html](midra-layout-4k-2-layers.html) | Browsers and web layouts |
|
||||
| PowerPoint | [Download .pptx](midra-layout-1080p-2-layers.pptx) | [Download .pptx](midra-layout-4k-2-layers.pptx) | PowerPoint, LibreOffice Impress or DeckCraft |
|
||||
| Figma FIG | [Download .fig](midra-layout-1080p-2-layers.fig) | [Download .fig](midra-layout-4k-2-layers.fig) | Figma or FigCraft |
|
||||
| Illustrator AI | [Download .ai](midra-layout-1080p-2-layers.ai) | [Download .ai](midra-layout-4k-2-layers.ai) | Illustrator or VectorCraft |
|
||||
|
||||
## Illustrator downloads in Gitea
|
||||
|
||||
[Download both Illustrator templates as ZIP](midra-layout-ai-templates.zip), then
|
||||
extract the `.ai` files. This avoids the browser's PDF viewer changing the download
|
||||
extension. These AI files contain PDF-compatible artwork: Gitea detects the `%PDF`
|
||||
header and serves them as `application/pdf` with an inline disposition. It does
|
||||
not convert them. If you already downloaded the original bytes under a `.pdf`
|
||||
name, rename the extension to `.ai`; do not print or re-export from the PDF viewer.
|
||||
|
||||
The ZIP contains exact copies of the two AI samples. After updating them, rebuild
|
||||
it with `python3 -m zipfile -c midra-layout-ai-templates.zip
|
||||
midra-layout-1080p-2-layers.ai midra-layout-4k-2-layers.ai` from this folder.
|
||||
|
||||
## Geometry files and saved projects
|
||||
|
||||
These files exchange visible layer boxes. They do not store the complete editor
|
||||
|
|
@ -41,6 +55,10 @@ CLI. See [dependencies and licensing builds](../../interfaces/midra-layout-excha
|
|||
Keep all formats here and link to this catalog instead of copying files or
|
||||
maintaining separate download lists. The [generation and verification commands](../../interfaces/midra-layout-exchange.md)
|
||||
rebuild both canvas sizes with the application exporter and verify their geometry.
|
||||
Text and native PPTX/FIG fixtures are covered by regression tests; the AI check
|
||||
Text and native PPTX/FIG/DWG fixtures are covered by regression tests; the AI check
|
||||
requires VectorCraft and is opt-in. The AI samples were checked with VectorCraft
|
||||
0.24.1, not Adobe Illustrator.
|
||||
|
||||
The DXF and DWG samples were opened and rendered with **QCAD Professional 3.28.2**.
|
||||
Both formats were also saved as R21 (2007) in QCAD and reimported with unchanged
|
||||
layer coordinates. DXF and DWG carry unitless pixel geometry and no pictures.
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
|
@ -17,7 +17,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
|||
CONFIG = ROOT / "docs/manuals"
|
||||
OUTPUT = ROOT / "build/manuals"
|
||||
REPOSITORY = "https://proxy.dandaedre.com/gitea/Beffroi/beffroi-tools/src/branch/main/"
|
||||
DOWNLOADS = {".png", ".jpg", ".jpeg", ".svg", ".gif", ".json", ".csv", ".dxf",
|
||||
DOWNLOADS = {".png", ".jpg", ".jpeg", ".svg", ".gif", ".json", ".csv", ".dxf", ".dwg", ".zip",
|
||||
".html", ".drawio", ".pptx", ".fig", ".ai", ".txt"}
|
||||
LINK = re.compile(r"(?P<start>\]\()(?P<url>[^\s)]+)(?P<end>\))"
|
||||
r"|(?P<attr>(?:href|src)=[\"'])(?P<html>[^\"']+)(?P<quote>[\"'])")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
"""Download wrappers must preserve the native starter files byte for byte."""
|
||||
import pathlib
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1] / "docs/templates/midra-layout"
|
||||
|
||||
|
||||
class MidraTemplateDownloads(unittest.TestCase):
|
||||
def test_ai_download_archive_preserves_names_and_original_bytes(self):
|
||||
names = {"midra-layout-1080p-2-layers.ai", "midra-layout-4k-2-layers.ai"}
|
||||
with zipfile.ZipFile(ROOT / "midra-layout-ai-templates.zip") as archive:
|
||||
self.assertEqual(set(archive.namelist()), names)
|
||||
for name in names:
|
||||
self.assertEqual(archive.read(name), (ROOT / name).read_bytes())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in New Issue