forked from 1b-agent/opencadstudio-upstream
Cargo: codec e023bc3 (acadrust sync), kernel abca4e8, graph c63556f
The codec now holds wide EntityType variants boxed (MText, Helix, Dimension, Hatch, Viewport, MultiLeader, Surface, Table, Ole2Frame, Light, Extended). Constructors box their entity; nested patterns reach a dimension through entities::dimension::as_dimension(_mut). Also follows BlockAction::action_ids, LineTypeComplexData::source_flags and the decimal tab stop with an explicit character. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
218150c76a
commit
e4d04ef132
87 files changed
+380
-269
No files matched your search
Generated
+36
-8
@@ -2397,7 +2397,7 @@ dependencies = [
|
|||||||
"hayro-syntax",
|
"hayro-syntax",
|
||||||
"kurbo 0.13.1",
|
"kurbo 0.13.1",
|
||||||
"moxcms",
|
"moxcms",
|
||||||
"phf",
|
"phf 0.13.1",
|
||||||
"rustc-hash 2.1.3",
|
"rustc-hash 2.1.3",
|
||||||
"siphasher",
|
"siphasher",
|
||||||
"skrifa 0.42.1",
|
"skrifa 0.42.1",
|
||||||
@@ -4348,6 +4348,15 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oem_cp"
|
||||||
|
version = "2.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8c7959d3349f484aec36462f98226983578bf7d33f9b034c32967489c7000e1f"
|
||||||
|
dependencies = [
|
||||||
|
"phf 0.11.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.4"
|
version = "1.21.4"
|
||||||
@@ -4373,7 +4382,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opencadcodec"
|
name = "opencadcodec"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=102f04c#102f04c8ecda1cd409f7ecc4b6eab2dc895c9095"
|
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=e023bc3#e023bc37235dddecf9b3e79c522d8936d15e21e6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bitflags 2.13.1",
|
"bitflags 2.13.1",
|
||||||
@@ -4385,6 +4394,7 @@ dependencies = [
|
|||||||
"itoa",
|
"itoa",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"nom 7.1.3",
|
"nom 7.1.3",
|
||||||
|
"oem_cp",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rayon",
|
"rayon",
|
||||||
"ryu",
|
"ryu",
|
||||||
@@ -4396,7 +4406,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opencadgraph"
|
name = "opencadgraph"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=88cdae0#88cdae06858f6811f5058a5686bc1edb5ff39910"
|
source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=c63556f#c63556f9f7a3cf658fd003a2e47fe67283b6afa7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"opencadkernel",
|
"opencadkernel",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -4405,7 +4415,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opencadkernel"
|
name = "opencadkernel"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=5811296#5811296a6c98ea9b12defa977f08d74cfc739014"
|
source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=abca4e8#abca4e81b089114a776ad6fe72a40c51a35646cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cavalier_contours",
|
"cavalier_contours",
|
||||||
"opencadcodec",
|
"opencadcodec",
|
||||||
@@ -4416,7 +4426,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opencadkernel-constraints"
|
name = "opencadkernel-constraints"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=5811296#5811296a6c98ea9b12defa977f08d74cfc739014"
|
source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=abca4e8#abca4e81b089114a776ad6fe72a40c51a35646cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nalgebra",
|
"nalgebra",
|
||||||
]
|
]
|
||||||
@@ -4595,6 +4605,15 @@ dependencies = [
|
|||||||
"indexmap",
|
"indexmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf"
|
||||||
|
version = "0.11.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
||||||
|
dependencies = [
|
||||||
|
"phf_shared 0.11.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
@@ -4602,7 +4621,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
|
checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"phf_macros",
|
"phf_macros",
|
||||||
"phf_shared",
|
"phf_shared 0.13.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4612,7 +4631,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
|
checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"phf_shared",
|
"phf_shared 0.13.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4622,12 +4641,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
|
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"phf_generator",
|
"phf_generator",
|
||||||
"phf_shared",
|
"phf_shared 0.13.1",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.119",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_shared"
|
||||||
|
version = "0.11.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
||||||
|
dependencies = [
|
||||||
|
"siphasher",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf_shared"
|
name = "phf_shared"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
|
|||||||
+4
-4
@@ -37,10 +37,10 @@ rfd = "0.17"
|
|||||||
clap = { version = "4", features = ["derive", "string"] }
|
clap = { version = "4", features = ["derive", "string"] }
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "102f04c", features = ["serde"] }
|
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "e023bc3", features = ["serde"] }
|
||||||
kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "5811296", features = ["acis", "offset"] }
|
kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "abca4e8", features = ["acis", "offset"] }
|
||||||
kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "5811296" }
|
kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "abca4e8" }
|
||||||
graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "88cdae0" }
|
graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "c63556f" }
|
||||||
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
||||||
# Shared SAVE serialization dispatch + web-worker wire format: one
|
# Shared SAVE serialization dispatch + web-worker wire format: one
|
||||||
# implementation for the inline (fallback/native) path and the worker path.
|
# implementation for the inline (fallback/native) path and the worker path.
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ fn push_fixture_entities(doc: &mut CadDocument, quick: bool) -> Vec<Handle> {
|
|||||||
d.definition_point = Vector3::new(x + 5.0, y + 3.0, 0.0);
|
d.definition_point = Vector3::new(x + 5.0, y + 3.0, 0.0);
|
||||||
d.base.text_middle_point = Vector3::new(x + 5.0, y + 4.0, 0.0);
|
d.base.text_middle_point = Vector3::new(x + 5.0, y + 4.0, 0.0);
|
||||||
handles.push(
|
handles.push(
|
||||||
doc.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
doc.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ serde_json = { version = "1", optional = true }
|
|||||||
# Pulled in only by the `host` feature, which adds the `opencadcodec`-typed
|
# Pulled in only by the `host` feature, which adds the `opencadcodec`-typed
|
||||||
# `HostApi` runtime surface. The default crate stays dependency-free so engine
|
# `HostApi` runtime surface. The default crate stays dependency-free so engine
|
||||||
# crates and external tooling can depend on the manifest/ribbon contract cheaply.
|
# crates and external tooling can depend on the manifest/ribbon contract cheaply.
|
||||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "102f04c", optional = true, features = ["serde"] }
|
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "e023bc3", optional = true, features = ["serde"] }
|
||||||
|
|
||||||
# Runtime IPC and serialization (host feature only).
|
# Runtime IPC and serialization (host feature only).
|
||||||
interprocess = { version = "2", optional = true }
|
interprocess = { version = "2", optional = true }
|
||||||
@@ -39,7 +39,7 @@ serde_json = "1"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
cargo-lock = "11"
|
cargo-lock = "11"
|
||||||
# opencadcodec is scanned at build time to generate the embedded type registry.
|
# opencadcodec is scanned at build time to generate the embedded type registry.
|
||||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "102f04c", features = ["serde"] }
|
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "e023bc3", features = ["serde"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
@@ -3583,7 +3583,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn unsupported_canvas_kind_has_typed_snapshot_fields() {
|
fn unsupported_canvas_kind_has_typed_snapshot_fields() {
|
||||||
use crate::host::codec;
|
use crate::host::codec;
|
||||||
let hatch = codec::EntityType::Hatch(codec::entities::Hatch::default());
|
let hatch = codec::EntityType::Hatch(Box::new(codec::entities::Hatch::default()));
|
||||||
let snapshot = entity_snapshot(&hatch).unwrap();
|
let snapshot = entity_snapshot(&hatch).unwrap();
|
||||||
let fields = snapshot
|
let fields = snapshot
|
||||||
.get("Hatch")
|
.get("Hatch")
|
||||||
@@ -3713,7 +3713,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn canvas_layer_patch_preserves_unmapped_hatch_fields() {
|
fn canvas_layer_patch_preserves_unmapped_hatch_fields() {
|
||||||
use crate::host::codec;
|
use crate::host::codec;
|
||||||
let hatch = codec::EntityType::Hatch(codec::entities::Hatch::default());
|
let hatch = codec::EntityType::Hatch(Box::new(codec::entities::Hatch::default()));
|
||||||
let patched = patch_canvas_layer(&hatch, "HATCHES").unwrap();
|
let patched = patch_canvas_layer(&hatch, "HATCHES").unwrap();
|
||||||
assert_eq!(patched.common().layer, "HATCHES");
|
assert_eq!(patched.common().layer, "HATCHES");
|
||||||
assert_eq!(hatch.common().layer, "0");
|
assert_eq!(hatch.common().layer, "0");
|
||||||
@@ -3809,13 +3809,13 @@ mod tests {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
hatch.paths.push(path);
|
hatch.paths.push(path);
|
||||||
let entity = codec::EntityType::Hatch(hatch.clone());
|
let entity = codec::EntityType::Hatch(Box::new(hatch.clone()));
|
||||||
validate_new_canvas_entity(&entity).unwrap();
|
validate_new_canvas_entity(&entity).unwrap();
|
||||||
|
|
||||||
let mut invalid = hatch.clone();
|
let mut invalid = hatch.clone();
|
||||||
invalid.paths.clear();
|
invalid.paths.clear();
|
||||||
assert!(
|
assert!(
|
||||||
validate_new_canvas_entity(&codec::EntityType::Hatch(invalid))
|
validate_new_canvas_entity(&codec::EntityType::Hatch(Box::new(invalid)))
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
.contains("at least one boundary path")
|
.contains("at least one boundary path")
|
||||||
);
|
);
|
||||||
@@ -3824,7 +3824,7 @@ mod tests {
|
|||||||
invalid.is_solid = false;
|
invalid.is_solid = false;
|
||||||
invalid.pattern_scale = 0.0;
|
invalid.pattern_scale = 0.0;
|
||||||
assert!(
|
assert!(
|
||||||
validate_new_canvas_entity(&codec::EntityType::Hatch(invalid))
|
validate_new_canvas_entity(&codec::EntityType::Hatch(Box::new(invalid)))
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
.contains("greater than zero")
|
.contains("greater than zero")
|
||||||
);
|
);
|
||||||
@@ -3841,13 +3841,13 @@ mod tests {
|
|||||||
associative.paths[0].boundary_handles.push(boundary);
|
associative.paths[0].boundary_handles.push(boundary);
|
||||||
validate_canvas_entity_references(
|
validate_canvas_entity_references(
|
||||||
&document,
|
&document,
|
||||||
&codec::EntityType::Hatch(associative.clone()),
|
&codec::EntityType::Hatch(Box::new(associative.clone())),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
associative.paths[0].boundary_handles[0] = codec::Handle::new(u64::MAX);
|
associative.paths[0].boundary_handles[0] = codec::Handle::new(u64::MAX);
|
||||||
assert!(validate_canvas_entity_references(
|
assert!(validate_canvas_entity_references(
|
||||||
&document,
|
&document,
|
||||||
&codec::EntityType::Hatch(associative),
|
&codec::EntityType::Hatch(Box::new(associative)),
|
||||||
)
|
)
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
.contains("does not exist"));
|
.contains("does not exist"));
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ publish = false
|
|||||||
# exactly one implementation. No UI/app dependencies — only the codec + serde.
|
# exactly one implementation. No UI/app dependencies — only the codec + serde.
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "102f04c", features = ["serde"] }
|
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "e023bc3", features = ["serde"] }
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
@@ -8,7 +8,7 @@ publish = false
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "102f04c", features = ["serde"] }
|
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "e023bc3", features = ["serde"] }
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ ocs_plugin_api = { path = "../../crates/ocs_plugin_api", features = ["host"] }
|
|||||||
# entry): the plugin's entities and the host's re-exports are the same types
|
# entry): the plugin's entities and the host's re-exports are the same types
|
||||||
# only when both resolve the same revision. The registration `rustc` /
|
# only when both resolve the same revision. The registration `rustc` /
|
||||||
# `acadrust_source` gates enforce this at load time too.
|
# `acadrust_source` gates enforce this at load time too.
|
||||||
acadrust = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "102f04c" }
|
acadrust = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "e023bc3" }
|
||||||
Generated
+11
-1
@@ -1245,6 +1245,15 @@ dependencies = [
|
|||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oem_cp"
|
||||||
|
version = "2.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8c7959d3349f484aec36462f98226983578bf7d33f9b034c32967489c7000e1f"
|
||||||
|
dependencies = [
|
||||||
|
"phf 0.11.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.4"
|
version = "1.21.4"
|
||||||
@@ -1264,7 +1273,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opencadcodec"
|
name = "opencadcodec"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=102f04c#102f04c8ecda1cd409f7ecc4b6eab2dc895c9095"
|
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=e023bc3#e023bc37235dddecf9b3e79c522d8936d15e21e6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
@@ -1276,6 +1285,7 @@ dependencies = [
|
|||||||
"itoa",
|
"itoa",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"nom",
|
"nom",
|
||||||
|
"oem_cp",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rayon",
|
"rayon",
|
||||||
"ryu",
|
"ryu",
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
viewport.twist_angle = std::f64::consts::FRAC_PI_2;
|
viewport.twist_angle = std::f64::consts::FRAC_PI_2;
|
||||||
viewport.view_target = Vector3::new(5.0, 10.0, 0.0);
|
viewport.view_target = Vector3::new(5.0, 10.0, 0.0);
|
||||||
}
|
}
|
||||||
document.add_entity_to_layout(EntityType::Viewport(viewport), "Sheet")?;
|
document.add_entity_to_layout(EntityType::Viewport(Box::new(viewport)), "Sheet")?;
|
||||||
|
|
||||||
let mut file = std::fs::OpenOptions::new()
|
let mut file = std::fs::OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ mod ocs {
|
|||||||
text.rotation = rotation;
|
text.rotation = rotation;
|
||||||
host_ctx::with_host(|host| {
|
host_ctx::with_host(|host| {
|
||||||
host_ctx::ensure_undo_started(host);
|
host_ctx::ensure_undo_started(host);
|
||||||
host.add_entity(EntityType::MText(text)).value()
|
host.add_entity(EntityType::MText(Box::new(text))).value()
|
||||||
})
|
})
|
||||||
.ok_or_else(|| vm.new_runtime_error("ocs: not running inside a PY_ command".to_owned()))
|
.ok_or_else(|| vm.new_runtime_error("ocs: not running inside a PY_ command".to_owned()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2129,7 +2129,7 @@ mod tests {
|
|||||||
dimension.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
dimension.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
||||||
dimension.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
dimension.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
document
|
document
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(dimension)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
crate::modules::draw::modify::explode::bake_dimension_blocks(&mut document);
|
crate::modules::draw::modify::explode::bake_dimension_blocks(&mut document);
|
||||||
|
|
||||||
@@ -2152,7 +2152,7 @@ mod tests {
|
|||||||
dimension.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
dimension.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
app.tabs[app.active_tab]
|
app.tabs[app.active_tab]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(dimension)));
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))));
|
||||||
let path = std::env::temp_dir().join(format!(
|
let path = std::env::temp_dir().join(format!(
|
||||||
"ocs_verified_dimension_{}_{}.dwg",
|
"ocs_verified_dimension_{}_{}.dwg",
|
||||||
std::process::id(),
|
std::process::id(),
|
||||||
@@ -2190,7 +2190,7 @@ mod tests {
|
|||||||
let i = app.active_tab;
|
let i = app.active_tab;
|
||||||
app.tabs[i]
|
app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(dimension)));
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))));
|
||||||
let path = std::env::temp_dir().join(format!(
|
let path = std::env::temp_dir().join(format!(
|
||||||
"ocs_verified_dimension_follow_up_{}_{}.dwg",
|
"ocs_verified_dimension_follow_up_{}_{}.dwg",
|
||||||
std::process::id(),
|
std::process::id(),
|
||||||
@@ -2240,7 +2240,7 @@ mod tests {
|
|||||||
app.tabs[i]
|
app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.document
|
.document
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let path = std::env::temp_dir().join(format!(
|
let path = std::env::temp_dir().join(format!(
|
||||||
"ocs_verified_dim_{}_{}.dwg",
|
"ocs_verified_dim_{}_{}.dwg",
|
||||||
@@ -2330,7 +2330,7 @@ mod tests {
|
|||||||
viewport.width = 100.0;
|
viewport.width = 100.0;
|
||||||
viewport.height = 50.0;
|
viewport.height = 50.0;
|
||||||
viewport.turn_on();
|
viewport.turn_on();
|
||||||
scene.add_entity(codec::EntityType::Viewport(viewport));
|
scene.add_entity(codec::EntityType::Viewport(Box::new(viewport)));
|
||||||
for entity in scene.document.entities_mut() {
|
for entity in scene.document.entities_mut() {
|
||||||
if let codec::EntityType::Viewport(viewport) = entity {
|
if let codec::EntityType::Viewport(viewport) = entity {
|
||||||
viewport.status.grid_on = true;
|
viewport.status.grid_on = true;
|
||||||
@@ -2774,7 +2774,7 @@ mod tests {
|
|||||||
codec::MText::with_value("\\A1;10.5000", codec::types::Vector3::new(10.0, 20.0, 0.0));
|
codec::MText::with_value("\\A1;10.5000", codec::types::Vector3::new(10.0, 20.0, 0.0));
|
||||||
app.tabs[i]
|
app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(codec::EntityType::MText(mtext));
|
.add_entity(codec::EntityType::MText(Box::new(mtext)));
|
||||||
|
|
||||||
let q = app.automation_op(
|
let q = app.automation_op(
|
||||||
r#"{"op":"query","type":"MTEXT","detail":"full","fields":["value","text","height","bounds"]}"#,
|
r#"{"op":"query","type":"MTEXT","detail":"full","fields":["value","text","height","bounds"]}"#,
|
||||||
@@ -3642,7 +3642,7 @@ mod tests {
|
|||||||
let mut dst_mtext = MText::new();
|
let mut dst_mtext = MText::new();
|
||||||
dst_mtext.value = "DSTM".into();
|
dst_mtext.value = "DSTM".into();
|
||||||
dst_mtext.height = 2.0;
|
dst_mtext.height = 2.0;
|
||||||
let dst_mtext_h = app.tabs[i].scene.add_entity(EntityType::MText(dst_mtext));
|
let dst_mtext_h = app.tabs[i].scene.add_entity(EntityType::MText(Box::new(dst_mtext)));
|
||||||
|
|
||||||
// Drive the interactive command exactly as the viewport does:
|
// Drive the interactive command exactly as the viewport does:
|
||||||
// phase 1 source pick, phase 2 destination selection.
|
// phase 1 source pick, phase 2 destination selection.
|
||||||
|
|||||||
@@ -1405,7 +1405,7 @@ mod paste_entities_kernel_tests {
|
|||||||
fn remaps_leader_annotation_link_to_pasted_handles() {
|
fn remaps_leader_annotation_link_to_pasted_handles() {
|
||||||
let mut seed = codec::CadDocument::new();
|
let mut seed = codec::CadDocument::new();
|
||||||
let note = seed
|
let note = seed
|
||||||
.add_entity(codec::EntityType::MText(codec::entities::MText::new()))
|
.add_entity(codec::EntityType::MText(Box::new(codec::entities::MText::new())))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut leader = codec::entities::Leader::default();
|
let mut leader = codec::entities::Leader::default();
|
||||||
leader.annotation_handle = note;
|
leader.annotation_handle = note;
|
||||||
|
|||||||
@@ -36,10 +36,12 @@ impl OpenCADStudio {
|
|||||||
) {
|
) {
|
||||||
let i = self.active_tab;
|
let i = self.active_tab;
|
||||||
let valid = matches!(
|
let valid = matches!(
|
||||||
self.tabs[i].scene.document.get_entity(dimension),
|
self.tabs[i]
|
||||||
Some(codec::EntityType::Dimension(
|
.scene
|
||||||
codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_)
|
.document
|
||||||
))
|
.get_entity(dimension)
|
||||||
|
.and_then(crate::entities::dimension::as_dimension),
|
||||||
|
Some(codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_))
|
||||||
);
|
);
|
||||||
if !valid {
|
if !valid {
|
||||||
self.command_line.push_error(
|
self.command_line.push_error(
|
||||||
@@ -415,8 +417,12 @@ fn apply_dimspace(
|
|||||||
requested_spacing: Option<f64>,
|
requested_spacing: Option<f64>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
use codec::entities::Dimension;
|
use codec::entities::Dimension;
|
||||||
let (axis, normal, definition, auto_spacing) = match scene.document.get_entity(base_h) {
|
let base = scene
|
||||||
Some(codec::EntityType::Dimension(dimension @ Dimension::Linear(d))) => {
|
.document
|
||||||
|
.get_entity(base_h)
|
||||||
|
.and_then(crate::entities::dimension::as_dimension);
|
||||||
|
let (axis, normal, definition, auto_spacing) = match base {
|
||||||
|
Some(dimension @ Dimension::Linear(d)) => {
|
||||||
let spacing = dimension_auto_spacing(
|
let spacing = dimension_auto_spacing(
|
||||||
&scene.document,
|
&scene.document,
|
||||||
dimension,
|
dimension,
|
||||||
@@ -433,7 +439,7 @@ fn apply_dimspace(
|
|||||||
spacing,
|
spacing,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Some(codec::EntityType::Dimension(dimension @ Dimension::Aligned(d))) => {
|
Some(dimension @ Dimension::Aligned(d)) => {
|
||||||
let spacing = dimension_auto_spacing(
|
let spacing = dimension_auto_spacing(
|
||||||
&scene.document,
|
&scene.document,
|
||||||
dimension,
|
dimension,
|
||||||
@@ -471,7 +477,7 @@ fn apply_dimspace(
|
|||||||
kernel::space::move_to_dimension_spacing([p.x, p.y, p.z], frame, target);
|
kernel::space::move_to_dimension_spacing([p.x, p.y, p.z], frame, target);
|
||||||
*p = codec::types::Vector3::new(point[0], point[1], point[2]);
|
*p = codec::types::Vector3::new(point[0], point[1], point[2]);
|
||||||
};
|
};
|
||||||
match dim {
|
match &mut **dim {
|
||||||
Dimension::Linear(d) => {
|
Dimension::Linear(d) => {
|
||||||
slide(&mut d.definition_point);
|
slide(&mut d.definition_point);
|
||||||
d.base.definition_point = d.definition_point;
|
d.base.definition_point = d.definition_point;
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ impl OpenCADStudio {
|
|||||||
let delta_safe = self.delta_add_safe(i, &entity);
|
let delta_safe = self.delta_add_safe(i, &entity);
|
||||||
let pending = self.begin_undo(i, label, 1, delta_safe);
|
let pending = self.begin_undo(i, label, 1, delta_safe);
|
||||||
let is_associative_dimension = matches!(
|
let is_associative_dimension = matches!(
|
||||||
entity,
|
crate::entities::dimension::as_dimension(&entity),
|
||||||
codec::EntityType::Dimension(
|
Some(codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_))
|
||||||
codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
let association_enabled = self.tabs[i].scene.document.header.dimension_associativity == 2;
|
let association_enabled = self.tabs[i].scene.document.header.dimension_associativity == 2;
|
||||||
let committed = if preserve_commit_layer {
|
let committed = if preserve_commit_layer {
|
||||||
@@ -257,10 +255,8 @@ impl OpenCADStudio {
|
|||||||
};
|
};
|
||||||
let pending = self.begin_undo(i, label, 1, delta_safe);
|
let pending = self.begin_undo(i, label, 1, delta_safe);
|
||||||
let is_associative_dimension = matches!(
|
let is_associative_dimension = matches!(
|
||||||
entity,
|
crate::entities::dimension::as_dimension(&entity),
|
||||||
codec::EntityType::Dimension(
|
Some(codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_))
|
||||||
codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
let association_enabled = self.tabs[i].scene.document.header.dimension_associativity == 2;
|
let association_enabled = self.tabs[i].scene.document.header.dimension_associativity == 2;
|
||||||
let committed = if preserve_commit_layer {
|
let committed = if preserve_commit_layer {
|
||||||
@@ -324,8 +320,8 @@ impl OpenCADStudio {
|
|||||||
let label = self.history_label_from_active_cmd(i, "DIMENSION");
|
let label = self.history_label_from_active_cmd(i, "DIMENSION");
|
||||||
let association_mode = self.tabs[i].scene.document.header.dimension_associativity;
|
let association_mode = self.tabs[i].scene.document.header.dimension_associativity;
|
||||||
let single_source_dimension = matches!(
|
let single_source_dimension = matches!(
|
||||||
&entity,
|
crate::entities::dimension::as_dimension(&entity),
|
||||||
codec::EntityType::Dimension(codec::entities::Dimension::Ordinate(_))
|
Some(codec::entities::Dimension::Ordinate(_))
|
||||||
);
|
);
|
||||||
// A dimension placed on the sheet but measuring model geometry
|
// A dimension placed on the sheet but measuring model geometry
|
||||||
// through a viewport carries the compensation as a negative
|
// through a viewport carries the compensation as a negative
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ impl OpenCADStudio {
|
|||||||
Operation::Rotate(degrees) => {
|
Operation::Rotate(degrees) => {
|
||||||
dimension.base_mut().text_rotation = degrees.to_radians();
|
dimension.base_mut().text_rotation = degrees.to_radians();
|
||||||
}
|
}
|
||||||
Operation::Oblique(degrees) => match dimension {
|
Operation::Oblique(degrees) => match &mut **dimension {
|
||||||
codec::entities::Dimension::Linear(value) => {
|
codec::entities::Dimension::Linear(value) => {
|
||||||
value.ext_line_rotation = degrees.to_radians();
|
value.ext_line_rotation = degrees.to_radians();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ impl OpenCADStudio {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match dim {
|
match &mut **dim {
|
||||||
Dimension::Linear(d) => {
|
Dimension::Linear(d) => {
|
||||||
stretched |= mv(&mut d.first_point);
|
stretched |= mv(&mut d.first_point);
|
||||||
stretched |= mv(&mut d.second_point);
|
stretched |= mv(&mut d.second_point);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ impl OpenCADStudio {
|
|||||||
});
|
});
|
||||||
let label = self.history_label_from_active_cmd(i, "MVIEW");
|
let label = self.history_label_from_active_cmd(i, "MVIEW");
|
||||||
let pending = self.begin_undo(i, label, 1, true);
|
let pending = self.begin_undo(i, label, 1, true);
|
||||||
let handle = self.commit_entity_handle(codec::EntityType::Viewport(viewport));
|
let handle = self.commit_entity_handle(codec::EntityType::Viewport(Box::new(viewport)));
|
||||||
if let (Some(handle), Some(saved)) = (handle, saved_view) {
|
if let (Some(handle), Some(saved)) = (handle, saved_view) {
|
||||||
if let Some(codec::EntityType::Viewport(viewport)) =
|
if let Some(codec::EntityType::Viewport(viewport)) =
|
||||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||||
@@ -244,7 +244,8 @@ impl OpenCADStudio {
|
|||||||
viewport.id = 2;
|
viewport.id = 2;
|
||||||
viewport.clip_boundary_handle = clip_handle;
|
viewport.clip_boundary_handle = clip_handle;
|
||||||
viewport.status.non_rectangular_clipping = !clip_handle.is_null();
|
viewport.status.non_rectangular_clipping = !clip_handle.is_null();
|
||||||
let viewport_handle = self.commit_entity_handle(codec::EntityType::Viewport(viewport));
|
let viewport_handle =
|
||||||
|
self.commit_entity_handle(codec::EntityType::Viewport(Box::new(viewport)));
|
||||||
if let Some(viewport_handle) = viewport_handle {
|
if let Some(viewport_handle) = viewport_handle {
|
||||||
if !created_boundary {
|
if !created_boundary {
|
||||||
let before = self.tabs[i]
|
let before = self.tabs[i]
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ impl OpenCADStudio {
|
|||||||
} else {
|
} else {
|
||||||
line.layer
|
line.layer
|
||||||
};
|
};
|
||||||
scene.add_entity(codec::EntityType::MText(mtext));
|
scene.add_entity(codec::EntityType::MText(Box::new(mtext)));
|
||||||
erase.extend(line.handles);
|
erase.extend(line.handles);
|
||||||
}
|
}
|
||||||
erase.sort();
|
erase.sort();
|
||||||
|
|||||||
@@ -2389,7 +2389,7 @@ impl OpenCADStudio {
|
|||||||
Vector3::new(mv.center.x - mv.target.x, mv.center.y - mv.target.y, 0.0);
|
Vector3::new(mv.center.x - mv.target.x, mv.center.y - mv.target.y, 0.0);
|
||||||
vp.view_height = mv.height;
|
vp.view_height = mv.height;
|
||||||
vp.custom_scale = scale;
|
vp.custom_scale = scale;
|
||||||
scene.add_entity(codec::EntityType::Viewport(vp));
|
scene.add_entity(codec::EntityType::Viewport(Box::new(vp)));
|
||||||
// A paper-space named view of the same name frames it.
|
// A paper-space named view of the same name frames it.
|
||||||
let mut named = codec::tables::View::new(title.as_str());
|
let mut named = codec::tables::View::new(title.as_str());
|
||||||
named.handle = scene.document.allocate_handle();
|
named.handle = scene.document.allocate_handle();
|
||||||
|
|||||||
@@ -126,10 +126,10 @@ mod tests {
|
|||||||
let i = app.active_tab;
|
let i = app.active_tab;
|
||||||
let first = app.tabs[i]
|
let first = app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(codec::EntityType::Viewport(codec::entities::Viewport::new()));
|
.add_entity(codec::EntityType::Viewport(Box::new(codec::entities::Viewport::new())));
|
||||||
let second = app.tabs[i]
|
let second = app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(codec::EntityType::Viewport(codec::entities::Viewport::new()));
|
.add_entity(codec::EntityType::Viewport(Box::new(codec::entities::Viewport::new())));
|
||||||
app.tabs[i].scene.active_viewport = Some(first);
|
app.tabs[i].scene.active_viewport = Some(first);
|
||||||
let _ = app.run_command_line("UCSFOLLOW 1");
|
let _ = app.run_command_line("UCSFOLLOW 1");
|
||||||
assert!(app.tabs[i].scene.ucs_follow());
|
assert!(app.tabs[i].scene.ucs_follow());
|
||||||
|
|||||||
@@ -1000,7 +1000,10 @@ impl OpenCADStudio {
|
|||||||
match self.tabs[i]
|
match self.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.document
|
.document
|
||||||
.add_entity_to_layout(codec::EntityType::Viewport(vp), &layout_name)
|
.add_entity_to_layout(
|
||||||
|
codec::EntityType::Viewport(Box::new(vp)),
|
||||||
|
&layout_name,
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Ok(handle) => {
|
Ok(handle) => {
|
||||||
self.tabs[i].scene.auto_fit_viewport(handle);
|
self.tabs[i].scene.auto_fit_viewport(handle);
|
||||||
@@ -2207,7 +2210,7 @@ mod tests {
|
|||||||
locked_hatch.common.layer = "LOCKED_LAYER".into();
|
locked_hatch.common.layer = "LOCKED_LAYER".into();
|
||||||
let h_locked_hatch = app.tabs[i]
|
let h_locked_hatch = app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity_clone(EntityType::Hatch(locked_hatch));
|
.add_entity_clone(EntityType::Hatch(Box::new(locked_hatch)));
|
||||||
|
|
||||||
let h_line = app.tabs[i]
|
let h_line = app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ impl OpenCADStudio {
|
|||||||
|
|
||||||
fn is_angular_dimension(entity: &EntityType) -> bool {
|
fn is_angular_dimension(entity: &EntityType) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
entity,
|
crate::entities::dimension::as_dimension(entity),
|
||||||
EntityType::Dimension(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
Some(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -841,7 +841,7 @@ impl super::OpenCADStudio {
|
|||||||
// catastrophic cancellation. Insertion is a pure translation, so zeroing
|
// catastrophic cancellation. Insertion is a pure translation, so zeroing
|
||||||
// it keeps the layout's shape, wrapping and alignment identical.
|
// it keeps the layout's shape, wrapping and alignment identical.
|
||||||
mt.insertion_point = Vector3::new(0.0, 0.0, 0.0);
|
mt.insertion_point = Vector3::new(0.0, 0.0, 0.0);
|
||||||
let entity = EntityType::MText(mt.clone());
|
let entity = EntityType::MText(Box::new(mt.clone()));
|
||||||
let anno = 1.0;
|
let anno = 1.0;
|
||||||
let bg = self.tabs[i].scene.bg_color;
|
let bg = self.tabs[i].scene.bg_color;
|
||||||
let wires: Vec<WireModel> = tessellate::tessellate(
|
let wires: Vec<WireModel> = tessellate::tessellate(
|
||||||
@@ -1753,7 +1753,8 @@ impl super::OpenCADStudio {
|
|||||||
));
|
));
|
||||||
mt.insertion_point = codec::types::Vector3::new(position.x, position.y, position.z);
|
mt.insertion_point = codec::types::Vector3::new(position.x, position.y, position.z);
|
||||||
self.push_undo_snapshot(i, "MTEXT");
|
self.push_undo_snapshot(i, "MTEXT");
|
||||||
let handle = self.commit_entity_handle(plane.place_entity(EntityType::MText(mt)));
|
let handle =
|
||||||
|
self.commit_entity_handle(plane.place_entity(EntityType::MText(Box::new(mt))));
|
||||||
if annotative {
|
if annotative {
|
||||||
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
||||||
if let (Some(handle), Some(scale)) = (handle, scale) {
|
if let (Some(handle), Some(scale)) = (handle, scale) {
|
||||||
@@ -1869,7 +1870,8 @@ impl super::OpenCADStudio {
|
|||||||
));
|
));
|
||||||
mt.insertion_point = codec::types::Vector3::new(position.x, position.y, position.z);
|
mt.insertion_point = codec::types::Vector3::new(position.x, position.y, position.z);
|
||||||
self.push_undo_snapshot(i, "MTEXT");
|
self.push_undo_snapshot(i, "MTEXT");
|
||||||
let handle = self.commit_entity_handle(plane.place_entity(EntityType::MText(mt)));
|
let handle =
|
||||||
|
self.commit_entity_handle(plane.place_entity(EntityType::MText(Box::new(mt))));
|
||||||
self.tabs[i].dirty = true;
|
self.tabs[i].dirty = true;
|
||||||
if annotative {
|
if annotative {
|
||||||
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
||||||
@@ -1885,7 +1887,7 @@ impl super::OpenCADStudio {
|
|||||||
if let (Some(h), Some(ed)) = (handle, self.mtext_editor.as_mut()) {
|
if let (Some(h), Some(ed)) = (handle, self.mtext_editor.as_mut()) {
|
||||||
ed.editing = Some(h);
|
ed.editing = Some(h);
|
||||||
if let Some(EntityType::MText(mtext)) = self.tabs[i].scene.document.get_entity(h) {
|
if let Some(EntityType::MText(mtext)) = self.tabs[i].scene.document.get_entity(h) {
|
||||||
ed.original = Some(mtext.clone());
|
ed.original = Some((**mtext).clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ mod tests {
|
|||||||
vp.width = 200.;
|
vp.width = 200.;
|
||||||
vp.height = 100.;
|
vp.height = 100.;
|
||||||
vp.view_height = 50.;
|
vp.view_height = 50.;
|
||||||
let handle = scene.add_entity(codec::EntityType::Viewport(vp));
|
let handle = scene.add_entity(codec::EntityType::Viewport(Box::new(vp)));
|
||||||
scene.active_viewport = Some(handle);
|
scene.active_viewport = Some(handle);
|
||||||
let mut camera = scene.navigation_camera();
|
let mut camera = scene.navigation_camera();
|
||||||
camera.target = DVec3::new(120., 30., 8.);
|
camera.target = DVec3::new(120., 30., 8.);
|
||||||
|
|||||||
@@ -943,7 +943,7 @@ impl<'a> HostSession<'a> {
|
|||||||
frame.common.layer = layer;
|
frame.common.layer = layer;
|
||||||
}
|
}
|
||||||
self.push_undo("Embed picture");
|
self.push_undo("Embed picture");
|
||||||
let handle = self.add_entity(EntityType::Ole2Frame(frame));
|
let handle = self.add_entity(EntityType::Ole2Frame(Box::new(frame)));
|
||||||
if handle.is_null() {
|
if handle.is_null() {
|
||||||
return Err("the picture frame could not be added".into());
|
return Err("the picture frame could not be added".into());
|
||||||
}
|
}
|
||||||
@@ -6708,7 +6708,7 @@ mod tests {
|
|||||||
let EntityType::Dimension(dimension) = &mut after else {
|
let EntityType::Dimension(dimension) = &mut after else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
};
|
};
|
||||||
if let codec::entities::Dimension::Linear(value) = dimension {
|
if let codec::entities::Dimension::Linear(value) = &mut **dimension {
|
||||||
value.second_point.x = 30.0;
|
value.second_point.x = 30.0;
|
||||||
}
|
}
|
||||||
ocs_plugin_api::entity_coverage::validate_entity_mutation(&before, &after).unwrap();
|
ocs_plugin_api::entity_coverage::validate_entity_mutation(&before, &after).unwrap();
|
||||||
@@ -7414,7 +7414,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let mut viewport = codec::entities::Viewport::new();
|
let mut viewport = codec::entities::Viewport::new();
|
||||||
viewport.common.owner_handle = owner;
|
viewport.common.owner_handle = owner;
|
||||||
let viewport_handle = host.add_entity(EntityType::Viewport(viewport));
|
let viewport_handle = host.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||||
let scale_handle = host.document_mut().allocate_handle();
|
let scale_handle = host.document_mut().allocate_handle();
|
||||||
let mut scale = codec::objects::Scale::new("1:1", 1.0, 1.0);
|
let mut scale = codec::objects::Scale::new("1:1", 1.0, 1.0);
|
||||||
scale.handle = scale_handle;
|
scale.handle = scale_handle;
|
||||||
@@ -10861,7 +10861,7 @@ mod tests {
|
|||||||
bare.height = 30.0;
|
bare.height = 30.0;
|
||||||
let bare = host
|
let bare = host
|
||||||
.document_mut()
|
.document_mut()
|
||||||
.add_entity(EntityType::Viewport(bare))
|
.add_entity(EntityType::Viewport(Box::new(bare)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
host.document().get_entity(bare).map(|e| match e {
|
host.document().get_entity(bare).map(|e| match e {
|
||||||
|
|||||||
+37
-33
@@ -1489,12 +1489,14 @@ impl OpenCADStudio {
|
|||||||
if let Some((anno_field, insert_after)) = anno {
|
if let Some((anno_field, insert_after)) = anno {
|
||||||
let is_anno = crate::scene::annotative::is_annotative(doc, entity)
|
let is_anno = crate::scene::annotative::is_annotative(doc, entity)
|
||||||
|| match entity {
|
|| match entity {
|
||||||
codec::EntityType::Dimension(codec::entities::Dimension::Arc(
|
codec::EntityType::Dimension(dimension)
|
||||||
dimension,
|
if matches!(**dimension, codec::entities::Dimension::Arc(_)) =>
|
||||||
)) => crate::scene::annotative::dim_style_is_annotative(
|
{
|
||||||
doc,
|
crate::scene::annotative::dim_style_is_annotative(
|
||||||
&dimension.base.style_name,
|
doc,
|
||||||
),
|
&dimension.base().style_name,
|
||||||
|
)
|
||||||
|
}
|
||||||
codec::EntityType::Tolerance(_) => {
|
codec::EntityType::Tolerance(_) => {
|
||||||
crate::scene::annotative::annotation_style_is_annotative(doc, entity)
|
crate::scene::annotative::annotation_style_is_annotative(doc, entity)
|
||||||
}
|
}
|
||||||
@@ -1530,7 +1532,9 @@ impl OpenCADStudio {
|
|||||||
"annotative",
|
"annotative",
|
||||||
yes_no_choice(t.is_annotative || is_anno),
|
yes_no_choice(t.is_annotative || is_anno),
|
||||||
),
|
),
|
||||||
codec::EntityType::Dimension(codec::entities::Dimension::Arc(_)) => {
|
codec::EntityType::Dimension(dimension)
|
||||||
|
if matches!(**dimension, codec::entities::Dimension::Arc(_)) =>
|
||||||
|
{
|
||||||
set_row(
|
set_row(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
"annotative",
|
"annotative",
|
||||||
@@ -1683,10 +1687,14 @@ impl OpenCADStudio {
|
|||||||
format!("{} ({})", t!("Surface"), t!("Extrusion"))
|
format!("{} ({})", t!("Surface"), t!("Extrusion"))
|
||||||
}
|
}
|
||||||
// The reference names an angular dimension by its kind.
|
// The reference names an angular dimension by its kind.
|
||||||
codec::EntityType::Dimension(codec::entities::Dimension::Angular2Ln(_)) => {
|
codec::EntityType::Dimension(dimension)
|
||||||
|
if matches!(**dimension, codec::entities::Dimension::Angular2Ln(_)) =>
|
||||||
|
{
|
||||||
t!("Angular Dimension").into_owned()
|
t!("Angular Dimension").into_owned()
|
||||||
}
|
}
|
||||||
codec::EntityType::Dimension(codec::entities::Dimension::Angular3Pt(_)) => {
|
codec::EntityType::Dimension(dimension)
|
||||||
|
if matches!(**dimension, codec::entities::Dimension::Angular3Pt(_)) =>
|
||||||
|
{
|
||||||
t!("3 Point Angular Dimension").into_owned()
|
t!("3 Point Angular Dimension").into_owned()
|
||||||
}
|
}
|
||||||
codec::EntityType::Underlay(underlay) => match underlay.underlay_type {
|
codec::EntityType::Underlay(underlay) => match underlay.underlay_type {
|
||||||
@@ -1719,22 +1727,14 @@ impl OpenCADStudio {
|
|||||||
title
|
title
|
||||||
} else {
|
} else {
|
||||||
use codec::entities::Dimension;
|
use codec::entities::Dimension;
|
||||||
match entity {
|
match crate::entities::dimension::as_dimension(entity) {
|
||||||
codec::EntityType::Dimension(Dimension::Aligned(_)) => {
|
Some(Dimension::Aligned(_)) => t!("Aligned Dimensional Constraint"),
|
||||||
t!("Aligned Dimensional Constraint")
|
Some(Dimension::Angular2Ln(_)) => t!("Angular Dimension (Dynamic)"),
|
||||||
}
|
Some(Dimension::Angular3Pt(_)) => {
|
||||||
codec::EntityType::Dimension(Dimension::Angular2Ln(_)) => {
|
|
||||||
t!("Angular Dimension (Dynamic)")
|
|
||||||
}
|
|
||||||
codec::EntityType::Dimension(Dimension::Angular3Pt(_)) => {
|
|
||||||
t!("3 Point Angular Dimension (Dynamic)")
|
t!("3 Point Angular Dimension (Dynamic)")
|
||||||
}
|
}
|
||||||
codec::EntityType::Dimension(Dimension::Radius(_)) => {
|
Some(Dimension::Radius(_)) => t!("Radius Dimensional Constraint"),
|
||||||
t!("Radius Dimensional Constraint")
|
Some(Dimension::Diameter(_)) => t!("Diameter Dimensional Constraint"),
|
||||||
}
|
|
||||||
codec::EntityType::Dimension(Dimension::Diameter(_)) => {
|
|
||||||
t!("Diameter Dimensional Constraint")
|
|
||||||
}
|
|
||||||
_ => t!("Linear Dimensional Constraint"),
|
_ => t!("Linear Dimensional Constraint"),
|
||||||
}
|
}
|
||||||
.into_owned()
|
.into_owned()
|
||||||
@@ -2743,7 +2743,7 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
|||||||
// scale are available.
|
// scale are available.
|
||||||
if let codec::EntityType::Dimension(dim) = contextual.as_ref() {
|
if let codec::EntityType::Dimension(dim) = contextual.as_ref() {
|
||||||
if matches!(
|
if matches!(
|
||||||
dim,
|
&**dim,
|
||||||
codec::entities::Dimension::Linear(_)
|
codec::entities::Dimension::Linear(_)
|
||||||
| codec::entities::Dimension::Aligned(_)
|
| codec::entities::Dimension::Aligned(_)
|
||||||
) && !dim.base().text_user_positioned
|
) && !dim.base().text_user_positioned
|
||||||
@@ -2780,13 +2780,17 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let dynamic_angle = match contextual.as_ref() {
|
let contextual_dimension =
|
||||||
codec::EntityType::Dimension(
|
crate::entities::dimension::as_dimension(contextual.as_ref());
|
||||||
dim @ (codec::entities::Dimension::Angular2Ln(_)
|
let dynamic_angle = contextual_dimension
|
||||||
| codec::entities::Dimension::Angular3Pt(_)),
|
.filter(|dim| {
|
||||||
) if self.tabs[i].scene.is_dynamic_dimension(handle) => Some(dim),
|
matches!(
|
||||||
_ => None,
|
dim,
|
||||||
};
|
codec::entities::Dimension::Angular2Ln(_)
|
||||||
|
| codec::entities::Dimension::Angular3Pt(_)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.filter(|_| self.tabs[i].scene.is_dynamic_dimension(handle));
|
||||||
if let Some(dim) = dynamic_angle {
|
if let Some(dim) = dynamic_angle {
|
||||||
// A dynamic angle shows a triangle at each end of its arc
|
// A dynamic angle shows a triangle at each end of its arc
|
||||||
// pointing away from it, and squares at the arc point and
|
// pointing away from it, and squares at the arc point and
|
||||||
@@ -3060,8 +3064,8 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
|||||||
) -> Option<Handle> {
|
) -> Option<Handle> {
|
||||||
let i = self.active_tab;
|
let i = self.active_tab;
|
||||||
let tracks_dimension_chain = matches!(
|
let tracks_dimension_chain = matches!(
|
||||||
&entity,
|
crate::entities::dimension::as_dimension(&entity),
|
||||||
codec::EntityType::Dimension(
|
Some(
|
||||||
codec::entities::Dimension::Linear(_)
|
codec::entities::Dimension::Linear(_)
|
||||||
| codec::entities::Dimension::Aligned(_)
|
| codec::entities::Dimension::Aligned(_)
|
||||||
| codec::entities::Dimension::Angular2Ln(_)
|
| codec::entities::Dimension::Angular2Ln(_)
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ fn fixture_dimension_reference(app: &mut OpenCADStudio) -> String {
|
|||||||
dimension.base.style_name = "BO_ARROWSTYLE".to_string();
|
dimension.base.style_name = "BO_ARROWSTYLE".to_string();
|
||||||
app.tabs[i]
|
app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)));
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))));
|
||||||
name.to_string()
|
name.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ fn fixture_dimension_name_reference(app: &mut OpenCADStudio) -> String {
|
|||||||
dimension.base.style_name = "BO_ARROWNAMESTYLE".to_string();
|
dimension.base.style_name = "BO_ARROWNAMESTYLE".to_string();
|
||||||
app.tabs[i]
|
app.tabs[i]
|
||||||
.scene
|
.scene
|
||||||
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)));
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))));
|
||||||
name.to_string()
|
name.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2913,9 +2913,12 @@ impl OpenCADStudio {
|
|||||||
&value,
|
&value,
|
||||||
);
|
);
|
||||||
if applied && field == "dim_text_inside" {
|
if applied && field == "dim_text_inside" {
|
||||||
if let Some(codec::EntityType::Dimension(
|
let radial = app.tabs[i]
|
||||||
codec::entities::Dimension::LargeRadial(dimension),
|
.scene
|
||||||
)) = app.tabs[i].scene.document.get_entity_mut(handle)
|
.document
|
||||||
|
.get_entity_mut(handle)
|
||||||
|
.and_then(crate::entities::dimension::as_dimension_mut);
|
||||||
|
if let Some(codec::entities::Dimension::LargeRadial(dimension)) = radial
|
||||||
{
|
{
|
||||||
dimension.base.text_user_positioned = false;
|
dimension.base.text_user_positioned = false;
|
||||||
}
|
}
|
||||||
@@ -4182,9 +4185,13 @@ impl OpenCADStudio {
|
|||||||
&val,
|
&val,
|
||||||
);
|
);
|
||||||
if applied && field == "dim_text_inside" {
|
if applied && field == "dim_text_inside" {
|
||||||
if let Some(codec::EntityType::Dimension(
|
if let Some(codec::entities::Dimension::LargeRadial(
|
||||||
codec::entities::Dimension::LargeRadial(dimension),
|
dimension,
|
||||||
)) = self.tabs[i].scene.document.get_entity_mut(handle)
|
)) = self.tabs[i]
|
||||||
|
.scene
|
||||||
|
.document
|
||||||
|
.get_entity_mut(handle)
|
||||||
|
.and_then(crate::entities::dimension::as_dimension_mut)
|
||||||
{
|
{
|
||||||
dimension.base.text_user_positioned = false;
|
dimension.base.text_user_positioned = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1084,7 +1084,7 @@ mod tests {
|
|||||||
.document
|
.document
|
||||||
.entities()
|
.entities()
|
||||||
.filter_map(|entity| match entity {
|
.filter_map(|entity| match entity {
|
||||||
EntityType::Hatch(hatch) => Some(hatch),
|
EntityType::Hatch(hatch) => Some(&**hatch),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fn fixture() -> (OpenCADStudio, Handle, ViewportFrame) {
|
|||||||
viewport.custom_scale = 0.1;
|
viewport.custom_scale = 0.1;
|
||||||
viewport.view_direction = Vector3::UNIT_Z;
|
viewport.view_direction = Vector3::UNIT_Z;
|
||||||
viewport.turn_on();
|
viewport.turn_on();
|
||||||
let viewport = scene.add_entity(EntityType::Viewport(viewport));
|
let viewport = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||||
let frame = scene.viewport_frame(viewport).unwrap();
|
let frame = scene.viewport_frame(viewport).unwrap();
|
||||||
scene.document.header.dimension_associativity = 2;
|
scene.document.header.dimension_associativity = 2;
|
||||||
let i = app.active_tab;
|
let i = app.active_tab;
|
||||||
@@ -323,7 +323,7 @@ fn viewport_dimension_linear_aligned_and_radial_object_picks() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
preview_text(
|
preview_text(
|
||||||
&app,
|
&app,
|
||||||
&EntityType::Dimension(dimension(&app.tabs[i].scene.document).clone())
|
&EntityType::Dimension(Box::new(dimension(&app.tabs[i].scene.document).clone()))
|
||||||
),
|
),
|
||||||
value,
|
value,
|
||||||
"{name}"
|
"{name}"
|
||||||
@@ -361,7 +361,7 @@ fn viewport_dimension_angular_preserves_angle_without_length_factor() {
|
|||||||
let _ = app.feed_command(StepInput::Point(place));
|
let _ = app.feed_command(StepInput::Point(place));
|
||||||
let doc = &app.tabs[app.active_tab].scene.document;
|
let doc = &app.tabs[app.active_tab].scene.document;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
preview_text(&app, &EntityType::Dimension(dimension(doc).clone())),
|
preview_text(&app, &EntityType::Dimension(Box::new(dimension(doc).clone()))),
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
assert!((dimension(doc).measurement() - 90.0).abs() < 1e-5);
|
assert!((dimension(doc).measurement() - 90.0).abs() < 1e-5);
|
||||||
@@ -1461,9 +1461,9 @@ fn viewport_dimension_invalid_paths_leave_no_partial_association() {
|
|||||||
Vector3::new(55.0, 60.0, 0.0),
|
Vector3::new(55.0, 60.0, 0.0),
|
||||||
)));
|
)));
|
||||||
for (source, path) in [(model, vec![Handle::new(u64::MAX)]), (leaf, vec![root])] {
|
for (source, path) in [(model, vec![Handle::new(u64::MAX)]), (leaf, vec![root])] {
|
||||||
let dim = scene.add_entity(EntityType::Dimension(Dimension::Aligned(
|
let dim = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(
|
||||||
DimensionAligned::new(Vector3::new(50.0, 50.0, 0.0), Vector3::new(55.0, 50.0, 0.0)),
|
DimensionAligned::new(Vector3::new(50.0, 50.0, 0.0), Vector3::new(55.0, 50.0, 0.0)),
|
||||||
)));
|
))));
|
||||||
let invalid = AcceptedSnap {
|
let invalid = AcceptedSnap {
|
||||||
paper_point: DVec3::new(50.0, 50.0, 0.0),
|
paper_point: DVec3::new(50.0, 50.0, 0.0),
|
||||||
model_point: DVec3::ZERO,
|
model_point: DVec3::ZERO,
|
||||||
|
|||||||
@@ -3248,7 +3248,7 @@ pub(crate) fn materialize_large_radial_text_position(
|
|||||||
let Some(EntityType::Dimension(dimension)) = document.get_entity(handle) else {
|
let Some(EntityType::Dimension(dimension)) = document.get_entity(handle) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if !matches!(dimension, Dimension::LargeRadial(_)) || dimension.base().text_user_positioned {
|
if !matches!(&**dimension, Dimension::LargeRadial(_)) || dimension.base().text_user_positioned {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let source = document.dim_styles.iter().find(|style| {
|
let source = document.dim_styles.iter().find(|style| {
|
||||||
@@ -3262,8 +3262,8 @@ pub(crate) fn materialize_large_radial_text_position(
|
|||||||
.map(|style| resolved_dimension_style(style, dimension, document))
|
.map(|style| resolved_dimension_style(style, dimension, document))
|
||||||
.map(|style| styled_dimension_text_position(dimension, &style, 1.0))
|
.map(|style| styled_dimension_text_position(dimension, &style, 1.0))
|
||||||
.unwrap_or_else(|| dimension_text_pos_f64(dimension, None, 2.5, 1.0));
|
.unwrap_or_else(|| dimension_text_pos_f64(dimension, None, 2.5, 1.0));
|
||||||
if let Some(EntityType::Dimension(Dimension::LargeRadial(radial))) =
|
if let Some(Dimension::LargeRadial(radial)) =
|
||||||
document.get_entity_mut(handle)
|
document.get_entity_mut(handle).and_then(as_dimension_mut)
|
||||||
{
|
{
|
||||||
radial.base.text_middle_point = position;
|
radial.base.text_middle_point = position;
|
||||||
}
|
}
|
||||||
@@ -6491,7 +6491,7 @@ fn dimension_text_entity(
|
|||||||
}
|
}
|
||||||
mtext.normal = base.normal;
|
mtext.normal = base.normal;
|
||||||
mtext.common = base.common.clone();
|
mtext.common = base.common.clone();
|
||||||
return Some(EntityType::MText(mtext));
|
return Some(EntityType::MText(Box::new(mtext)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = if style.is_some_and(|style| style.dimtxtdirection) {
|
let value = if style.is_some_and(|style| style.dimtxtdirection) {
|
||||||
@@ -7150,7 +7150,7 @@ fn dimension_tolerance_entity(
|
|||||||
mtext.style = primary_style;
|
mtext.style = primary_style;
|
||||||
mtext.attachment_point = codec::entities::AttachmentPoint::MiddleCenter;
|
mtext.attachment_point = codec::entities::AttachmentPoint::MiddleCenter;
|
||||||
mtext.common = primary_common;
|
mtext.common = primary_common;
|
||||||
return Some(EntityType::MText(mtext));
|
return Some(EntityType::MText(Box::new(mtext)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut t = Text::with_value(tol, pos)
|
let mut t = Text::with_value(tol, pos)
|
||||||
@@ -9559,3 +9559,22 @@ mod layout_parity_tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The dimension an entity is, if it is one. The variant holds it boxed, so
|
||||||
|
/// a pattern cannot reach into it; match on this instead.
|
||||||
|
pub(crate) fn as_dimension(entity: &codec::EntityType) -> Option<&codec::entities::Dimension> {
|
||||||
|
match entity {
|
||||||
|
codec::EntityType::Dimension(dimension) => Some(dimension),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [`as_dimension`], mutably.
|
||||||
|
pub(crate) fn as_dimension_mut(
|
||||||
|
entity: &mut codec::EntityType,
|
||||||
|
) -> Option<&mut codec::entities::Dimension> {
|
||||||
|
match entity {
|
||||||
|
codec::EntityType::Dimension(dimension) => Some(dimension),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -620,7 +620,7 @@ fn dynamic_data_text(data: &DynamicBlockData) -> String {
|
|||||||
"{}; dependencies {}; parameters {}; distance multiplier {:.6}; angle {:.6}",
|
"{}; dependencies {}; parameters {}; distance multiplier {:.6}; angle {:.6}",
|
||||||
value.action.element.name,
|
value.action.element.name,
|
||||||
value.action.dependencies.len(),
|
value.action.dependencies.len(),
|
||||||
value.action.parameter_ids.len(),
|
value.action.action_ids.len(),
|
||||||
value.offsets.distance_multiplier,
|
value.offsets.distance_multiplier,
|
||||||
value.offsets.angle_offset
|
value.offsets.angle_offset
|
||||||
),
|
),
|
||||||
@@ -628,14 +628,14 @@ fn dynamic_data_text(data: &DynamicBlockData) -> String {
|
|||||||
"{}; dependencies {}; parameters {}; connections {}",
|
"{}; dependencies {}; parameters {}; connections {}",
|
||||||
value.action.element.name,
|
value.action.element.name,
|
||||||
value.action.dependencies.len(),
|
value.action.dependencies.len(),
|
||||||
value.action.parameter_ids.len(),
|
value.action.action_ids.len(),
|
||||||
value.connections.len()
|
value.connections.len()
|
||||||
),
|
),
|
||||||
DynamicBlockData::RotateAction(value) | DynamicBlockData::ScaleAction(value) => format!(
|
DynamicBlockData::RotateAction(value) | DynamicBlockData::ScaleAction(value) => format!(
|
||||||
"{}; dependencies {}; parameters {}; base {:.6},{:.6},{:.6}; dependent {}",
|
"{}; dependencies {}; parameters {}; base {:.6},{:.6},{:.6}; dependent {}",
|
||||||
value.action.action.element.name,
|
value.action.action.element.name,
|
||||||
value.action.action.dependencies.len(),
|
value.action.action.dependencies.len(),
|
||||||
value.action.action.parameter_ids.len(),
|
value.action.action.action_ids.len(),
|
||||||
value.action.base_point.x,
|
value.action.base_point.x,
|
||||||
value.action.base_point.y,
|
value.action.base_point.y,
|
||||||
value.action.base_point.z,
|
value.action.base_point.z,
|
||||||
|
|||||||
@@ -676,7 +676,9 @@ pub fn adapt_mtext_paragraphs(
|
|||||||
ATab::Left(_) => TabKind::Left,
|
ATab::Left(_) => TabKind::Left,
|
||||||
ATab::Center(_) => TabKind::Center,
|
ATab::Center(_) => TabKind::Center,
|
||||||
ATab::Right(_) => TabKind::Right,
|
ATab::Right(_) => TabKind::Right,
|
||||||
ATab::Decimal(..) => TabKind::Decimal,
|
ATab::Decimal(..) | ATab::DecimalWithCharacter { .. } => {
|
||||||
|
TabKind::Decimal
|
||||||
|
}
|
||||||
};
|
};
|
||||||
TabStop {
|
TabStop {
|
||||||
position: ts.position() as f32 * entity_height,
|
position: ts.position() as f32 * entity_height,
|
||||||
|
|||||||
@@ -158,6 +158,16 @@ pub trait TextContent {
|
|||||||
fn replace_text(&mut self, search: &str, rep: &str);
|
fn replace_text(&mut self, search: &str, rep: &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Entity variants holding their entity boxed (MTEXT) dispatch through here.
|
||||||
|
impl<T: TextContent + ?Sized> TextContent for Box<T> {
|
||||||
|
fn text_content(&self) -> Option<String> {
|
||||||
|
(**self).text_content()
|
||||||
|
}
|
||||||
|
fn replace_text(&mut self, search: &str, rep: &str) {
|
||||||
|
(**self).replace_text(search, rep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Human-readable variant name used by Quick Select / Select Similar
|
/// Human-readable variant name used by Quick Select / Select Similar
|
||||||
/// filtering. Stable across releases — the strings here are the canonical
|
/// filtering. Stable across releases — the strings here are the canonical
|
||||||
/// type identifiers throughout the UI.
|
/// type identifiers throughout the UI.
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ pub(crate) fn build_entity(
|
|||||||
if let Some(style) = text_style_field(spec, document)? {
|
if let Some(style) = text_style_field(spec, document)? {
|
||||||
mtext.style = style;
|
mtext.style = style;
|
||||||
}
|
}
|
||||||
EntityType::MText(mtext)
|
EntityType::MText(Box::new(mtext))
|
||||||
}
|
}
|
||||||
"INSERT" => {
|
"INSERT" => {
|
||||||
let block = spec["block"].as_str().unwrap_or("");
|
let block = spec["block"].as_str().unwrap_or("");
|
||||||
@@ -724,7 +724,7 @@ pub(crate) fn build_entity(
|
|||||||
let mut path = BoundaryPath::external();
|
let mut path = BoundaryPath::external();
|
||||||
path.add_edge(BoundaryEdge::Polyline(PolylineEdge::new(vertices, true)));
|
path.add_edge(BoundaryEdge::Polyline(PolylineEdge::new(vertices, true)));
|
||||||
hatch.paths.push(path);
|
hatch.paths.push(path);
|
||||||
EntityType::Hatch(hatch)
|
EntityType::Hatch(Box::new(hatch))
|
||||||
}
|
}
|
||||||
other => {
|
other => {
|
||||||
return Err(failure(
|
return Err(failure(
|
||||||
|
|||||||
@@ -472,6 +472,7 @@ fn complex_elements(
|
|||||||
scale: decimal(*scale),
|
scale: decimal(*scale),
|
||||||
rotation: decimal(*rot_deg).to_radians(),
|
rotation: decimal(*rot_deg).to_radians(),
|
||||||
absolute_rotation: false,
|
absolute_rotation: false,
|
||||||
|
source_flags: 0,
|
||||||
offset: [decimal(*x), decimal(*y)],
|
offset: [decimal(*x), decimal(*y)],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,6 +493,7 @@ fn complex_elements(
|
|||||||
scale: decimal(*scale),
|
scale: decimal(*scale),
|
||||||
rotation: decimal(*rot_deg).to_radians(),
|
rotation: decimal(*rot_deg).to_radians(),
|
||||||
absolute_rotation: false,
|
absolute_rotation: false,
|
||||||
|
source_flags: 0,
|
||||||
offset: [decimal(*x), decimal(*y)],
|
offset: [decimal(*x), decimal(*y)],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+8
-5
@@ -2969,7 +2969,7 @@ mod dimension_arrow_save_tests {
|
|||||||
dimension.definition_point = Vector3::new(0.0, 20.0, 0.0);
|
dimension.definition_point = Vector3::new(0.0, 20.0, 0.0);
|
||||||
dimension.base.definition_point = dimension.definition_point;
|
dimension.base.definition_point = dimension.definition_point;
|
||||||
dimension.base.text_middle_point = Vector3::new(50.0, 20.0, 0.0);
|
dimension.base.text_middle_point = Vector3::new(50.0, 20.0, 0.0);
|
||||||
doc.add_entity(EntityType::Dimension(Dimension::Linear(dimension)))
|
doc.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
doc
|
doc
|
||||||
}
|
}
|
||||||
@@ -3545,11 +3545,12 @@ mod prepare_save_tests {
|
|||||||
dim.base.definition_point = Vector3::ZERO;
|
dim.base.definition_point = Vector3::ZERO;
|
||||||
dim.base.common.handle = doc.allocate_handle();
|
dim.base.common.handle = doc.allocate_handle();
|
||||||
let handle = dim.base.common.handle;
|
let handle = dim.base.common.handle;
|
||||||
doc.add_entity(EntityType::Dimension(Dimension::Linear(dim)))
|
doc.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let prepared = prepare_document_for_save(doc.clone(), doc.version);
|
let prepared = prepare_document_for_save(doc.clone(), doc.version);
|
||||||
let EntityType::Dimension(Dimension::Linear(linear)) = prepared.get_entity(handle).unwrap()
|
let Some(Dimension::Linear(linear)) =
|
||||||
|
crate::entities::dimension::as_dimension(prepared.get_entity(handle).unwrap())
|
||||||
else {
|
else {
|
||||||
panic!("dimension missing from prepared clone");
|
panic!("dimension missing from prepared clone");
|
||||||
};
|
};
|
||||||
@@ -3565,7 +3566,9 @@ mod prepare_save_tests {
|
|||||||
assert_eq!(linear.base.definition_point, linear.definition_point);
|
assert_eq!(linear.base.definition_point, linear.definition_point);
|
||||||
|
|
||||||
// The live document is untouched: no block name, stale group-10.
|
// The live document is untouched: no block name, stale group-10.
|
||||||
let EntityType::Dimension(Dimension::Linear(live)) = doc.get_entity(handle).unwrap() else {
|
let Some(Dimension::Linear(live)) =
|
||||||
|
crate::entities::dimension::as_dimension(doc.get_entity(handle).unwrap())
|
||||||
|
else {
|
||||||
panic!("dimension missing from live document");
|
panic!("dimension missing from live document");
|
||||||
};
|
};
|
||||||
assert!(live.base.block_name.is_empty());
|
assert!(live.base.block_name.is_empty());
|
||||||
@@ -3582,7 +3585,7 @@ mod prepare_save_tests {
|
|||||||
let mut dim =
|
let mut dim =
|
||||||
DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||||
dim.base.common.handle = doc.allocate_handle();
|
dim.base.common.handle = doc.allocate_handle();
|
||||||
doc.add_entity(EntityType::Dimension(Dimension::Linear(dim)))
|
doc.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
for ext in ["dwg", "dxf"] {
|
for ext in ["dwg", "dxf"] {
|
||||||
let inline = save_to_bytes(&doc, ext, codec::DxfVersion::AC1032).expect("inline");
|
let inline = save_to_bytes(&doc, ext, codec::DxfVersion::AC1032).expect("inline");
|
||||||
|
|||||||
+1
-1
@@ -168,7 +168,7 @@ pub fn add_embedded_image(
|
|||||||
) -> Result<codec::Handle, String> {
|
) -> Result<codec::Handle, String> {
|
||||||
let (upper_left, lower_right) = corners_from_placement(origin, width, image.aspect());
|
let (upper_left, lower_right) = corners_from_placement(origin, width, image.aspect());
|
||||||
let ole = build_embedded_ole(image, upper_left, lower_right);
|
let ole = build_embedded_ole(image, upper_left, lower_right);
|
||||||
doc.add_entity(codec::EntityType::Ole2Frame(ole))
|
doc.add_entity(codec::EntityType::Ole2Frame(Box::new(ole)))
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3336,7 +3336,7 @@ mod tests {
|
|||||||
// Hatch (pattern names have no table — preserved verbatim).
|
// Hatch (pattern names have no table — preserved verbatim).
|
||||||
let mut hatch = codec::entities::Hatch::new();
|
let mut hatch = codec::entities::Hatch::new();
|
||||||
hatch.pattern.name = "ANSI31".to_string();
|
hatch.pattern.name = "ANSI31".to_string();
|
||||||
doc.add_entity(codec::EntityType::Hatch(hatch)).unwrap();
|
doc.add_entity(codec::EntityType::Hatch(Box::new(hatch))).unwrap();
|
||||||
// Dim-style reference via a tolerance entity.
|
// Dim-style reference via a tolerance entity.
|
||||||
doc.dim_styles
|
doc.dim_styles
|
||||||
.add(codec::tables::DimStyle::new("ARCH"))
|
.add(codec::tables::DimStyle::new("ARCH"))
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ pub(crate) fn aligned_dimension_entity(
|
|||||||
crate::entities::dimension::reset_automatic_text_position(&mut dim.base);
|
crate::entities::dimension::reset_automatic_text_position(&mut dim.base);
|
||||||
dim.base.actual_measurement = dim.measurement();
|
dim.base.actual_measurement = dim.measurement();
|
||||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text_override);
|
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text_override);
|
||||||
EntityType::Dimension(Dimension::Aligned(dim))
|
EntityType::Dimension(Box::new(Dimension::Aligned(dim)))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CadCommand for AlignedDimensionCommand {
|
impl CadCommand for AlignedDimensionCommand {
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ impl AngularDimensionCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn commit(&self, dimension: Dimension) -> CmdResult {
|
fn commit(&self, dimension: Dimension) -> CmdResult {
|
||||||
let entity = self.plane.place_entity(EntityType::Dimension(dimension));
|
let entity = self.plane.place_entity(EntityType::Dimension(Box::new(dimension)));
|
||||||
CmdResult::CommitDimension {
|
CmdResult::CommitDimension {
|
||||||
entity,
|
entity,
|
||||||
association: DimensionAssociationInput::Explicit(self.source_refs.clone()),
|
association: DimensionAssociationInput::Explicit(self.source_refs.clone()),
|
||||||
@@ -1242,7 +1242,7 @@ pub(crate) fn angular_two_line_entity(
|
|||||||
dim.base.insertion_point = dim.dimension_arc;
|
dim.base.insertion_point = dim.dimension_arc;
|
||||||
dim.base.actual_measurement = dim.measurement_degrees();
|
dim.base.actual_measurement = dim.measurement_degrees();
|
||||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
||||||
Some(EntityType::Dimension(Dimension::Angular2Ln(dim)))
|
Some(EntityType::Dimension(Box::new(Dimension::Angular2Ln(dim))))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A three-point angular dimension (vertex, two points, arc point), for a
|
/// A three-point angular dimension (vertex, two points, arc point), for a
|
||||||
@@ -1261,7 +1261,7 @@ pub(crate) fn angular_three_point_entity(
|
|||||||
dim.base.insertion_point = dim.definition_point;
|
dim.base.insertion_point = dim.definition_point;
|
||||||
dim.base.actual_measurement = dim.measurement_degrees();
|
dim.base.actual_measurement = dim.measurement_degrees();
|
||||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
||||||
Some(EntityType::Dimension(Dimension::Angular3Pt(dim)))
|
Some(EntityType::Dimension(Box::new(Dimension::Angular3Pt(dim))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn v3(point: DVec3) -> Vector3 {
|
fn v3(point: DVec3) -> Vector3 {
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ impl ArcLengthDimensionCommand {
|
|||||||
|handle| DimensionAssociationInput::Explicit(selection.association_sources(handle)),
|
|handle| DimensionAssociationInput::Explicit(selection.association_sources(handle)),
|
||||||
);
|
);
|
||||||
CmdResult::CommitDimension {
|
CmdResult::CommitDimension {
|
||||||
entity: plane.place_entity(EntityType::Dimension(Dimension::Arc(dimension))),
|
entity: plane.place_entity(EntityType::Dimension(Box::new(Dimension::Arc(dimension)))),
|
||||||
association,
|
association,
|
||||||
preserve_base_style: false,
|
preserve_base_style: false,
|
||||||
continue_command: false,
|
continue_command: false,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ impl DiameterDimensionCommand {
|
|||||||
if let Some(angle) = self.text_angle {
|
if let Some(angle) = self.text_angle {
|
||||||
dim.base.text_rotation = angle;
|
dim.base.text_rotation = angle;
|
||||||
}
|
}
|
||||||
plane.place_entity(EntityType::Dimension(Dimension::Diameter(dim)))
|
plane.place_entity(EntityType::Dimension(Box::new(Dimension::Diameter(dim))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ pub(crate) fn diameter_constraint_entity(
|
|||||||
dim.leader_length = chord.distance(location).max(radius * 0.5);
|
dim.leader_length = chord.distance(location).max(radius * 0.5);
|
||||||
dim.base.actual_measurement = dim.measurement();
|
dim.base.actual_measurement = dim.measurement();
|
||||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
||||||
Some(EntityType::Dimension(Dimension::Diameter(dim)))
|
Some(EntityType::Dimension(Box::new(Dimension::Diameter(dim))))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CadCommand for DiameterDimensionCommand {
|
impl CadCommand for DiameterDimensionCommand {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ impl DimBaselineCommand {
|
|||||||
let increment = self.effective_increment(&style.style_name);
|
let increment = self.effective_increment(&style.style_name);
|
||||||
let plane = plane_from_normal(dimension.base().definition_point, style.normal);
|
let plane = plane_from_normal(dimension.base().definition_point, style.normal);
|
||||||
let pick = pick.and_then(|point| plane.project(point.to_array()).map(Vec2::from));
|
let pick = pick.and_then(|point| plane.project(point.to_array()).map(Vec2::from));
|
||||||
let kind = match dimension {
|
let kind = match &**dimension {
|
||||||
Dimension::Linear(source) => {
|
Dimension::Linear(source) => {
|
||||||
let first = project(&plane, source.first_point);
|
let first = project(&plane, source.first_point);
|
||||||
let second = project(&plane, source.second_point);
|
let second = project(&plane, source.second_point);
|
||||||
@@ -441,7 +441,7 @@ impl CadCommand for DimBaselineCommand {
|
|||||||
self.committed += 1;
|
self.committed += 1;
|
||||||
self.advance(1.0);
|
self.advance(1.0);
|
||||||
CmdResult::CommitDimension {
|
CmdResult::CommitDimension {
|
||||||
entity: EntityType::Dimension(dimension),
|
entity: EntityType::Dimension(Box::new(dimension)),
|
||||||
association: DimensionAssociationInput::Infer(None),
|
association: DimensionAssociationInput::Infer(None),
|
||||||
preserve_base_style: self.preserve_base_style,
|
preserve_base_style: self.preserve_base_style,
|
||||||
continue_command: true,
|
continue_command: true,
|
||||||
@@ -489,7 +489,7 @@ impl CadCommand for DimBaselineCommand {
|
|||||||
fn dimension_preview(&self, cursor: DVec3) -> Option<Vec<DimensionPreview>> {
|
fn dimension_preview(&self, cursor: DVec3) -> Option<Vec<DimensionPreview>> {
|
||||||
self.build_dimension(cursor).map(|dimension| {
|
self.build_dimension(cursor).map(|dimension| {
|
||||||
vec![DimensionPreview {
|
vec![DimensionPreview {
|
||||||
entity: EntityType::Dimension(dimension),
|
entity: EntityType::Dimension(Box::new(dimension)),
|
||||||
preserve_base_style: self.preserve_base_style,
|
preserve_base_style: self.preserve_base_style,
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ impl DimContinueCommand {
|
|||||||
let style = SourceStyle::from_base(dimension.base());
|
let style = SourceStyle::from_base(dimension.base());
|
||||||
let plane = plane_from_normal(dimension.base().definition_point, style.normal);
|
let plane = plane_from_normal(dimension.base().definition_point, style.normal);
|
||||||
let pick = pick_world.and_then(|point| plane.project(point.to_array()).map(Vec2::from));
|
let pick = pick_world.and_then(|point| plane.project(point.to_array()).map(Vec2::from));
|
||||||
let kind = match dimension {
|
let kind = match &**dimension {
|
||||||
Dimension::Linear(source) => {
|
Dimension::Linear(source) => {
|
||||||
let rotation = source.rotation;
|
let rotation = source.rotation;
|
||||||
let perpendicular = Vec2::new(-rotation.sin(), rotation.cos());
|
let perpendicular = Vec2::new(-rotation.sin(), rotation.cos());
|
||||||
@@ -383,7 +383,7 @@ impl CadCommand for DimContinueCommand {
|
|||||||
}
|
}
|
||||||
self.advance(point);
|
self.advance(point);
|
||||||
CmdResult::CommitDimension {
|
CmdResult::CommitDimension {
|
||||||
entity: EntityType::Dimension(dimension),
|
entity: EntityType::Dimension(Box::new(dimension)),
|
||||||
association: DimensionAssociationInput::Infer(None),
|
association: DimensionAssociationInput::Infer(None),
|
||||||
preserve_base_style: self.preserve_base_style,
|
preserve_base_style: self.preserve_base_style,
|
||||||
continue_command: true,
|
continue_command: true,
|
||||||
@@ -433,7 +433,7 @@ impl CadCommand for DimContinueCommand {
|
|||||||
fn dimension_preview(&self, cursor: DVec3) -> Option<Vec<DimensionPreview>> {
|
fn dimension_preview(&self, cursor: DVec3) -> Option<Vec<DimensionPreview>> {
|
||||||
self.build_dimension(cursor).map(|dimension| {
|
self.build_dimension(cursor).map(|dimension| {
|
||||||
vec![DimensionPreview {
|
vec![DimensionPreview {
|
||||||
entity: EntityType::Dimension(dimension),
|
entity: EntityType::Dimension(Box::new(dimension)),
|
||||||
preserve_base_style: self.preserve_base_style,
|
preserve_base_style: self.preserve_base_style,
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -145,13 +145,17 @@ impl CadCommand for DimJogLineCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn on_entity_pick(&mut self, handle: Handle, _point: DVec3) -> CmdResult {
|
fn on_entity_pick(&mut self, handle: Handle, _point: DVec3) -> CmdResult {
|
||||||
let Some(EntityType::Dimension(dimension @ (Dimension::Linear(_) | Dimension::Aligned(_)))) =
|
let Some(EntityType::Dimension(dimension)) = self.picked_entity.take() else {
|
||||||
self.picked_entity.take()
|
|
||||||
else {
|
|
||||||
return CmdResult::ReportError(
|
return CmdResult::ReportError(
|
||||||
t!("DIMJOGLINE: select a linear or aligned dimension.").into_owned(),
|
t!("DIMJOGLINE: select a linear or aligned dimension.").into_owned(),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
let dimension = *dimension;
|
||||||
|
if !matches!(dimension, Dimension::Linear(_) | Dimension::Aligned(_)) {
|
||||||
|
return CmdResult::ReportError(
|
||||||
|
t!("DIMJOGLINE: select a linear or aligned dimension.").into_owned(),
|
||||||
|
);
|
||||||
|
}
|
||||||
if handle.is_null() {
|
if handle.is_null() {
|
||||||
return CmdResult::NeedPoint;
|
return CmdResult::NeedPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ impl CadCommand for DimSpaceCommand {
|
|||||||
for selected in entities {
|
for selected in entities {
|
||||||
if selected.handle != *base
|
if selected.handle != *base
|
||||||
&& matches!(
|
&& matches!(
|
||||||
selected.entity,
|
crate::entities::dimension::as_dimension(&selected.entity),
|
||||||
EntityType::Dimension(
|
Some(
|
||||||
codec::entities::Dimension::Linear(_)
|
codec::entities::Dimension::Linear(_)
|
||||||
| codec::entities::Dimension::Aligned(_)
|
| codec::entities::Dimension::Aligned(_)
|
||||||
)
|
)
|
||||||
@@ -124,11 +124,14 @@ impl CadCommand for DimSpaceCommand {
|
|||||||
match &mut self.step {
|
match &mut self.step {
|
||||||
Step::PickBase => {
|
Step::PickBase => {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
self.picked_entity.take(),
|
self.picked_entity
|
||||||
Some(EntityType::Dimension(
|
.take()
|
||||||
|
.as_ref()
|
||||||
|
.and_then(crate::entities::dimension::as_dimension),
|
||||||
|
Some(
|
||||||
codec::entities::Dimension::Linear(_)
|
codec::entities::Dimension::Linear(_)
|
||||||
| codec::entities::Dimension::Aligned(_)
|
| codec::entities::Dimension::Aligned(_)
|
||||||
))
|
)
|
||||||
) {
|
) {
|
||||||
return CmdResult::ReportError(
|
return CmdResult::ReportError(
|
||||||
t!("DIMSPACE: select a linear or aligned dimension.").into_owned(),
|
t!("DIMSPACE: select a linear or aligned dimension.").into_owned(),
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ impl CadCommand for FieldPlaceCommand {
|
|||||||
mtext.attachment_point = self.attachment;
|
mtext.attachment_point = self.attachment;
|
||||||
// No defined width: the field text never wraps.
|
// No defined width: the field text never wraps.
|
||||||
mtext.rectangle_width = 0.0;
|
mtext.rectangle_width = 0.0;
|
||||||
CmdResult::CommitAndExit(self.plane.place_entity(EntityType::MText(mtext)))
|
CmdResult::CommitAndExit(self.plane.place_entity(EntityType::MText(Box::new(mtext))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_enter(&mut self) -> CmdResult {
|
fn on_enter(&mut self) -> CmdResult {
|
||||||
|
|||||||
@@ -138,7 +138,9 @@ impl JoggedRadiusDimensionCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
CmdResult::CommitDimension {
|
CmdResult::CommitDimension {
|
||||||
entity: plane.place_entity(EntityType::Dimension(Dimension::LargeRadial(dimension))),
|
entity: plane.place_entity(EntityType::Dimension(Box::new(Dimension::LargeRadial(
|
||||||
|
dimension,
|
||||||
|
)))),
|
||||||
association,
|
association,
|
||||||
preserve_base_style: false,
|
preserve_base_style: false,
|
||||||
continue_command: false,
|
continue_command: false,
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ impl LeaderCommand {
|
|||||||
CmdResult::CommitManyAndEditText {
|
CmdResult::CommitManyAndEditText {
|
||||||
entities: vec![
|
entities: vec![
|
||||||
self.plane.place_entity(EntityType::Leader(leader)),
|
self.plane.place_entity(EntityType::Leader(leader)),
|
||||||
self.plane.place_entity(EntityType::MText(mtext)),
|
self.plane.place_entity(EntityType::MText(Box::new(mtext))),
|
||||||
],
|
],
|
||||||
edit_index: 1,
|
edit_index: 1,
|
||||||
open_editor,
|
open_editor,
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ pub(crate) fn linear_dimension_entity(
|
|||||||
crate::entities::dimension::reset_automatic_text_position(&mut dim.base);
|
crate::entities::dimension::reset_automatic_text_position(&mut dim.base);
|
||||||
dim.base.actual_measurement = dim.measurement();
|
dim.base.actual_measurement = dim.measurement();
|
||||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text_override);
|
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text_override);
|
||||||
EntityType::Dimension(Dimension::Linear(dim))
|
EntityType::Dimension(Box::new(Dimension::Linear(dim)))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CadCommand for LinearDimensionCommand {
|
impl CadCommand for LinearDimensionCommand {
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ impl CadCommand for MLeaderCommand {
|
|||||||
text.insertion_point.z,
|
text.insertion_point.z,
|
||||||
));
|
));
|
||||||
self.text = text.value.clone();
|
self.text = text.value.clone();
|
||||||
self.selected_mtext = Some(text);
|
self.selected_mtext = Some(*text);
|
||||||
self.content_type = LeaderContentType::MText;
|
self.content_type = LeaderContentType::MText;
|
||||||
self.order = CreationOrder::ContentFirst;
|
self.order = CreationOrder::ContentFirst;
|
||||||
self.step = Step::PickPoints;
|
self.step = Step::PickPoints;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ impl OrdinateDimCommand {
|
|||||||
}
|
}
|
||||||
dim.refresh_measurement();
|
dim.refresh_measurement();
|
||||||
self.plane
|
self.plane
|
||||||
.place_entity(EntityType::Dimension(Dimension::Ordinate(dim)))
|
.place_entity(EntityType::Dimension(Box::new(Dimension::Ordinate(dim))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ impl QdimCommand {
|
|||||||
]);
|
]);
|
||||||
(
|
(
|
||||||
self.plane
|
self.plane
|
||||||
.place_entity(EntityType::Dimension(Dimension::Linear(dimension))),
|
.place_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension)))),
|
||||||
association,
|
association,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,7 @@ impl QdimCommand {
|
|||||||
dimension.refresh_measurement();
|
dimension.refresh_measurement();
|
||||||
(
|
(
|
||||||
self.plane
|
self.plane
|
||||||
.place_entity(EntityType::Dimension(Dimension::Ordinate(dimension))),
|
.place_entity(EntityType::Dimension(Box::new(Dimension::Ordinate(dimension)))),
|
||||||
DimensionAssociationInput::Explicit(vec![point.sources.first().copied()]),
|
DimensionAssociationInput::Explicit(vec![point.sources.first().copied()]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ impl QdimCommand {
|
|||||||
dimension.base.text_user_positioned = true;
|
dimension.base.text_user_positioned = true;
|
||||||
dimension.leader_length = chord.distance(text);
|
dimension.leader_length = chord.distance(text);
|
||||||
dimension.base.actual_measurement = dimension.measurement();
|
dimension.base.actual_measurement = dimension.measurement();
|
||||||
EntityType::Dimension(Dimension::Radius(dimension))
|
EntityType::Dimension(Box::new(Dimension::Radius(dimension)))
|
||||||
} else {
|
} else {
|
||||||
let opposite = center - direction * radius;
|
let opposite = center - direction * radius;
|
||||||
let mut dimension = DimensionDiameter::new(v3(chord), v3(opposite));
|
let mut dimension = DimensionDiameter::new(v3(chord), v3(opposite));
|
||||||
@@ -415,7 +415,7 @@ impl QdimCommand {
|
|||||||
dimension.base.text_user_positioned = true;
|
dimension.base.text_user_positioned = true;
|
||||||
dimension.leader_length = chord.distance(text);
|
dimension.leader_length = chord.distance(text);
|
||||||
dimension.base.actual_measurement = dimension.measurement();
|
dimension.base.actual_measurement = dimension.measurement();
|
||||||
EntityType::Dimension(Dimension::Diameter(dimension))
|
EntityType::Dimension(Box::new(Dimension::Diameter(dimension)))
|
||||||
};
|
};
|
||||||
(self.plane.place_entity(entity), association)
|
(self.plane.place_entity(entity), association)
|
||||||
})
|
})
|
||||||
@@ -680,7 +680,7 @@ fn preview_entity(index: usize, entity: &EntityType) -> Vec<WireModel> {
|
|||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
let mut lines: Vec<Vec<[f64; 3]>> = Vec::new();
|
let mut lines: Vec<Vec<[f64; 3]>> = Vec::new();
|
||||||
match dimension {
|
match &**dimension {
|
||||||
Dimension::Linear(value) => {
|
Dimension::Linear(value) => {
|
||||||
let first = d3(value.first_point);
|
let first = d3(value.first_point);
|
||||||
let second = d3(value.second_point);
|
let second = d3(value.second_point);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ pub(crate) fn radial_dimension_entity(
|
|||||||
if let Some(angle) = text_angle {
|
if let Some(angle) = text_angle {
|
||||||
dim.base.text_rotation = angle;
|
dim.base.text_rotation = angle;
|
||||||
}
|
}
|
||||||
plane.place_entity(EntityType::Dimension(Dimension::Radius(dim)))
|
plane.place_entity(EntityType::Dimension(Box::new(Dimension::Radius(dim))))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A radius dimension for a dimensional constraint: the leader leaves the
|
/// A radius dimension for a dimensional constraint: the leader leaves the
|
||||||
@@ -111,7 +111,7 @@ pub(crate) fn radius_constraint_entity(
|
|||||||
dim.leader_length = chord.distance(location).max(radius * 0.5);
|
dim.leader_length = chord.distance(location).max(radius * 0.5);
|
||||||
dim.base.actual_measurement = dim.measurement();
|
dim.base.actual_measurement = dim.measurement();
|
||||||
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
|
||||||
Some(EntityType::Dimension(Dimension::Radius(dim)))
|
Some(EntityType::Dimension(Box::new(Dimension::Radius(dim))))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The unit direction a radial constraint's dimension points in, from the
|
/// The unit direction a radial constraint's dimension points in, from the
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ fn separate(p: &Piece, doc: &CadDocument) -> Vec<EntityType> {
|
|||||||
let at = p.point(p.rect[0] + x * (p.rect[1] - p.rect[0]), p.rect[3]);
|
let at = p.point(p.rect[0] + x * (p.rect[1] - p.rect[0]), p.rect[3]);
|
||||||
let mut m = mtext_from(p.entity, p.content.clone(), at, p.height, p.rotation);
|
let mut m = mtext_from(p.entity, p.content.clone(), at, p.height, p.rotation);
|
||||||
m.attachment_point = attachment;
|
m.attachment_point = attachment;
|
||||||
vec![EntityType::MText(m)]
|
vec![EntityType::MText(Box::new(m))]
|
||||||
}
|
}
|
||||||
EntityType::MText(m) => {
|
EntityType::MText(m) => {
|
||||||
// The drawn words, grouped into lines by their baseline.
|
// The drawn words, grouped into lines by their baseline.
|
||||||
@@ -261,7 +261,8 @@ fn separate(p: &Piece, doc: &CadDocument) -> Vec<EntityType> {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" ");
|
.join(" ");
|
||||||
let at = p.point(line[0].0 - origin_along, p.rect[3] - k as f64 * step);
|
let at = p.point(line[0].0 - origin_along, p.rect[3] - k as f64 * step);
|
||||||
EntityType::MText(mtext_from(p.entity, value, at, line[0].1.height, m.rotation))
|
let height = line[0].1.height;
|
||||||
|
EntityType::MText(Box::new(mtext_from(p.entity, value, at, height, m.rotation)))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@@ -352,7 +353,7 @@ pub fn plan(
|
|||||||
}
|
}
|
||||||
Some(Txt2MtxtPlan {
|
Some(Txt2MtxtPlan {
|
||||||
erase: pieces.iter().map(|p| p.handle).collect(),
|
erase: pieces.iter().map(|p| p.handle).collect(),
|
||||||
add: vec![EntityType::MText(m)],
|
add: vec![EntityType::MText(Box::new(m))],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ impl CadCommand for PasteSpecCommand {
|
|||||||
mtext.style = self.style.clone();
|
mtext.style = self.style.clone();
|
||||||
mtext.attachment_point = AttachmentPoint::TopLeft;
|
mtext.attachment_point = AttachmentPoint::TopLeft;
|
||||||
mtext.rectangle_width = 0.0;
|
mtext.rectangle_width = 0.0;
|
||||||
CmdResult::CommitAndExit(self.plane.place_entity(EntityType::MText(mtext)))
|
CmdResult::CommitAndExit(self.plane.place_entity(EntityType::MText(Box::new(mtext))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_enter(&mut self) -> CmdResult {
|
fn on_enter(&mut self) -> CmdResult {
|
||||||
|
|||||||
@@ -925,7 +925,7 @@ mod tests {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
hatch.paths.push(path);
|
hatch.paths.push(path);
|
||||||
let entity = EntityType::Hatch(hatch);
|
let entity = EntityType::Hatch(Box::new(hatch));
|
||||||
HatcheditCommand::with_handle(Handle::new(7), "ANSI31".into(), 1.0, 0.0, false)
|
HatcheditCommand::with_handle(Handle::new(7), "ANSI31".into(), 1.0, 0.0, false)
|
||||||
.with_appearance(Some(&entity), Color::Index(6), Transparency::T_40)
|
.with_appearance(Some(&entity), Color::Index(6), Transparency::T_40)
|
||||||
.with_origin([9.0, 8.0])
|
.with_origin([9.0, 8.0])
|
||||||
@@ -1096,7 +1096,7 @@ mod tests {
|
|||||||
counter_clockwise: true,
|
counter_clockwise: true,
|
||||||
}));
|
}));
|
||||||
hatch.paths.push(path);
|
hatch.paths.push(path);
|
||||||
let entity = EntityType::Hatch(hatch);
|
let entity = EntityType::Hatch(Box::new(hatch));
|
||||||
let mut command =
|
let mut command =
|
||||||
HatcheditCommand::with_handle(Handle::new(7), "ANSI31".into(), 1.0, 0.0, false)
|
HatcheditCommand::with_handle(Handle::new(7), "ANSI31".into(), 1.0, 0.0, false)
|
||||||
.with_appearance(Some(&entity), Color::ByLayer, Transparency::ByLayer);
|
.with_appearance(Some(&entity), Color::ByLayer, Transparency::ByLayer);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ impl ImageCommand {
|
|||||||
let (upper_left, lower_right) =
|
let (upper_left, lower_right) =
|
||||||
corners_from_placement(ins, world_width, self.aspect());
|
corners_from_placement(ins, world_width, self.aspect());
|
||||||
let ole = build_embedded_ole(image, upper_left, lower_right);
|
let ole = build_embedded_ole(image, upper_left, lower_right);
|
||||||
self.plane.place_entity(EntityType::Ole2Frame(ole))
|
self.plane.place_entity(EntityType::Ole2Frame(Box::new(ole)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1439,7 +1439,7 @@ fn sync_dimension_base_points_and_collect_pending(doc: &mut CadDocument) -> Vec<
|
|||||||
let EntityType::Dimension(dimension) = entity else {
|
let EntityType::Dimension(dimension) = entity else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let definition_point = match dimension {
|
let definition_point = match &**dimension {
|
||||||
Dimension::Linear(value) => Some(value.definition_point),
|
Dimension::Linear(value) => Some(value.definition_point),
|
||||||
Dimension::Aligned(value) => Some(value.definition_point),
|
Dimension::Aligned(value) => Some(value.definition_point),
|
||||||
Dimension::Radius(value) => Some(value.definition_point),
|
Dimension::Radius(value) => Some(value.definition_point),
|
||||||
@@ -1493,7 +1493,7 @@ pub fn bake_dimension_blocks(doc: &mut CadDocument) {
|
|||||||
let dimensions: Vec<(Handle, Dimension)> = pending
|
let dimensions: Vec<(Handle, Dimension)> = pending
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|handle| match doc.get_entity(handle) {
|
.filter_map(|handle| match doc.get_entity(handle) {
|
||||||
Some(EntityType::Dimension(d)) => Some((handle, d.clone())),
|
Some(EntityType::Dimension(d)) => Some((handle, (**d).clone())),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
@@ -1654,7 +1654,7 @@ mod tests {
|
|||||||
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
// block_name is left empty — exactly what OCS-created dimensions carry.
|
// block_name is left empty — exactly what OCS-created dimensions carry.
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
@@ -1693,7 +1693,7 @@ mod tests {
|
|||||||
// Exactly what OCS-created dimensions carry: insertion == text anchor.
|
// Exactly what OCS-created dimensions carry: insertion == text anchor.
|
||||||
d.base.insertion_point = d.base.text_middle_point;
|
d.base.insertion_point = d.base.text_middle_point;
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
@@ -1720,7 +1720,7 @@ mod tests {
|
|||||||
d.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
d.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
||||||
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
@@ -1798,7 +1798,7 @@ mod tests {
|
|||||||
d.rotation = 0.0;
|
d.rotation = 0.0;
|
||||||
d.definition_point = Vector3::new(0.0, 8.0, 0.0);
|
d.definition_point = Vector3::new(0.0, 8.0, 0.0);
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
let name = match doc.get_entity(handle) {
|
let name = match doc.get_entity(handle) {
|
||||||
@@ -1827,7 +1827,7 @@ mod tests {
|
|||||||
let mut d = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
let mut d = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||||
d.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
d.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
let name = match doc.get_entity(handle) {
|
let name = match doc.get_entity(handle) {
|
||||||
@@ -1875,7 +1875,7 @@ mod tests {
|
|||||||
.collect();
|
.collect();
|
||||||
assert!(!expected.is_empty(), "the dimension explodes into no lines");
|
assert!(!expected.is_empty(), "the dimension explodes into no lines");
|
||||||
|
|
||||||
let mut turned = EntityType::Dimension(flat);
|
let mut turned = EntityType::Dimension(Box::new(flat));
|
||||||
crate::scene::view::dispatch::apply_transform(
|
crate::scene::view::dispatch::apply_transform(
|
||||||
&mut turned,
|
&mut turned,
|
||||||
&EntityTransform::Rotate {
|
&EntityTransform::Rotate {
|
||||||
@@ -1911,7 +1911,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
d.definition_point = Vector3::new(5.0, 5.0, 0.0); // arc location
|
d.definition_point = Vector3::new(5.0, 5.0, 0.0); // arc location
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Angular3Pt(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Angular3Pt(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
let name = match doc.get_entity(handle) {
|
let name = match doc.get_entity(handle) {
|
||||||
@@ -1940,7 +1940,7 @@ mod tests {
|
|||||||
let mut d = DimensionDiameter::new(edge, far);
|
let mut d = DimensionDiameter::new(edge, far);
|
||||||
d.base.text_middle_point = Vector3::new(3.0, 9.0, 0.0);
|
d.base.text_middle_point = Vector3::new(3.0, 9.0, 0.0);
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Diameter(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Diameter(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
let name = match doc.get_entity(handle) {
|
let name = match doc.get_entity(handle) {
|
||||||
@@ -1971,7 +1971,7 @@ mod tests {
|
|||||||
d.rotation = std::f64::consts::FRAC_PI_2; // 90°, vertical dimension line
|
d.rotation = std::f64::consts::FRAC_PI_2; // 90°, vertical dimension line
|
||||||
d.definition_point = Vector3::new(8.0, 0.0, 0.0);
|
d.definition_point = Vector3::new(8.0, 0.0, 0.0);
|
||||||
let handle = doc
|
let handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
let name = match doc.get_entity(handle) {
|
let name = match doc.get_entity(handle) {
|
||||||
@@ -2064,7 +2064,7 @@ mod tests {
|
|||||||
DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||||
d.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
d.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
||||||
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
doc.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
doc.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let path =
|
let path =
|
||||||
@@ -2171,7 +2171,7 @@ mod tests {
|
|||||||
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
d.base.common.xdictionary_handle = Some(dict_handle);
|
d.base.common.xdictionary_handle = Some(dict_handle);
|
||||||
let dim_handle = doc
|
let dim_handle = doc
|
||||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
bake_dimension_blocks(&mut doc);
|
bake_dimension_blocks(&mut doc);
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ fn mtext(lines: &[DgnGeom], style: String, node: bool) -> Option<EntityType> {
|
|||||||
m.rotation = *rotation;
|
m.rotation = *rotation;
|
||||||
m.rectangle_width = 0.0;
|
m.rectangle_width = 0.0;
|
||||||
m.style = style;
|
m.style = style;
|
||||||
Some(EntityType::MText(m))
|
Some(EntityType::MText(Box::new(m)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The object(s) one element converts to.
|
/// The object(s) one element converts to.
|
||||||
|
|||||||
@@ -1482,7 +1482,7 @@ pub fn convert(
|
|||||||
let layer = naming.layer(pdf_layer, Kind::Text);
|
let layer = naming.layer(pdf_layer, Kind::Text);
|
||||||
mtext.common.color = color_on(&layer, color_of(text.color));
|
mtext.common.color = color_on(&layer, color_of(text.color));
|
||||||
mtext.common.layer = layer;
|
mtext.common.layer = layer;
|
||||||
result.entities.push(EntityType::MText(mtext));
|
result.entities.push(EntityType::MText(Box::new(mtext)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1712,7 +1712,7 @@ fn fill_entities(
|
|||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
hatch.elevation = z;
|
hatch.elevation = z;
|
||||||
vec![EntityType::Hatch(hatch)]
|
vec![EntityType::Hatch(Box::new(hatch))]
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory::submit!(crate::command::CommandRegistration {
|
inventory::submit!(crate::command::CommandRegistration {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ impl MvsetupCommand {
|
|||||||
if self.arrangement == Arrangement::Engineering {
|
if self.arrangement == Arrangement::Engineering {
|
||||||
viewport.view_direction = directions[(row * 2 + column) as usize].clone();
|
viewport.view_direction = directions[(row * 2 + column) as usize].clone();
|
||||||
}
|
}
|
||||||
viewports.push(EntityType::Viewport(viewport));
|
viewports.push(EntityType::Viewport(Box::new(viewport)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CmdResult::CommitEntitiesAndExit(viewports)
|
CmdResult::CommitEntitiesAndExit(viewports)
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ pub fn supports_annotation_context(entity: &EntityType) -> bool {
|
|||||||
| EntityType::Tolerance(_)
|
| EntityType::Tolerance(_)
|
||||||
| EntityType::Hatch(_) => true,
|
| EntityType::Hatch(_) => true,
|
||||||
EntityType::Dimension(dimension) => {
|
EntityType::Dimension(dimension) => {
|
||||||
!matches!(dimension, codec::entities::Dimension::Arc(_))
|
!matches!(&**dimension, codec::entities::Dimension::Arc(_))
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ mod tests {
|
|||||||
dimension.base.block_name = "SVC_TARGET".to_string();
|
dimension.base.block_name = "SVC_TARGET".to_string();
|
||||||
scene
|
scene
|
||||||
.document
|
.document
|
||||||
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// A table's picture block and a block-valued cell, by handle.
|
// A table's picture block and a block-valued cell, by handle.
|
||||||
@@ -894,7 +894,7 @@ mod tests {
|
|||||||
dimension.base.block_name = "SVC_RENAMED".to_string();
|
dimension.base.block_name = "SVC_RENAMED".to_string();
|
||||||
scene
|
scene
|
||||||
.document
|
.document
|
||||||
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)))
|
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut style = DimStyle::new("SVC_STYLE");
|
let mut style = DimStyle::new("SVC_STYLE");
|
||||||
style.dimblk = target;
|
style.dimblk = target;
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ impl Scene {
|
|||||||
self.previous_view = Some(ViewSnapshot::Floating {
|
self.previous_view = Some(ViewSnapshot::Floating {
|
||||||
layout,
|
layout,
|
||||||
handle,
|
handle,
|
||||||
viewport: Box::new(viewport.clone()),
|
viewport: viewport.clone(),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -538,7 +538,7 @@ impl Scene {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let current = Box::new(current.clone());
|
let current = current.clone();
|
||||||
if let Some(EntityType::Viewport(destination)) =
|
if let Some(EntityType::Viewport(destination)) =
|
||||||
self.document.get_entity_mut(handle)
|
self.document.get_entity_mut(handle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -869,7 +869,7 @@ pub(crate) fn constraint_from_associative_dimension(
|
|||||||
Some(ParametricRef::whole(*reference.xrefs.first()?))
|
Some(ParametricRef::whole(*reference.xrefs.first()?))
|
||||||
};
|
};
|
||||||
let measurement = DrivingValue::Literal(dimension.measurement());
|
let measurement = DrivingValue::Literal(dimension.measurement());
|
||||||
match dimension {
|
match &**dimension {
|
||||||
Dimension::Aligned(_) => Some((
|
Dimension::Aligned(_) => Some((
|
||||||
ConstraintKind::Distance,
|
ConstraintKind::Distance,
|
||||||
vec![point(0)?, point(1)?],
|
vec![point(0)?, point(1)?],
|
||||||
@@ -921,7 +921,7 @@ pub(crate) fn radial_extension_points(
|
|||||||
let EntityType::Dimension(dimension_entity) = document.get_entity(dimension)? else {
|
let EntityType::Dimension(dimension_entity) = document.get_entity(dimension)? else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let target_point = match dimension_entity {
|
let target_point = match &**dimension_entity {
|
||||||
Dimension::Radius(radius) => radius.definition_point,
|
Dimension::Radius(radius) => radius.definition_point,
|
||||||
Dimension::Diameter(diameter) => diameter.angle_vertex,
|
Dimension::Diameter(diameter) => diameter.angle_vertex,
|
||||||
Dimension::LargeRadial(radial) => radial.chord_point,
|
Dimension::LargeRadial(radial) => radial.chord_point,
|
||||||
@@ -1009,7 +1009,7 @@ impl Scene {
|
|||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let radial_data = match dimension_entity {
|
let radial_data = match &**dimension_entity {
|
||||||
Dimension::Radius(radius) => Some((
|
Dimension::Radius(radius) => Some((
|
||||||
radius.angle_vertex,
|
radius.angle_vertex,
|
||||||
radius.measurement(),
|
radius.measurement(),
|
||||||
@@ -1223,7 +1223,7 @@ impl Scene {
|
|||||||
};
|
};
|
||||||
// Radial references identify a circle/arc and angle, rather than a vertex.
|
// Radial references identify a circle/arc and angle, rather than a vertex.
|
||||||
let radial_dimension = matches!(
|
let radial_dimension = matches!(
|
||||||
dimension_entity,
|
&**dimension_entity,
|
||||||
Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_)
|
Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_)
|
||||||
);
|
);
|
||||||
if radial_dimension {
|
if radial_dimension {
|
||||||
@@ -1383,7 +1383,7 @@ impl Scene {
|
|||||||
let Some(EntityType::Dimension(entity)) = self.document.get_entity(dimension) else {
|
let Some(EntityType::Dimension(entity)) = self.document.get_entity(dimension) else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
match entity {
|
match &**entity {
|
||||||
// A radial dimension's single reference describes the point where
|
// A radial dimension's single reference describes the point where
|
||||||
// the leader meets the circle.
|
// the leader meets the circle.
|
||||||
Dimension::Radius(radius) => vec![radius.definition_point],
|
Dimension::Radius(radius) => vec![radius.definition_point],
|
||||||
@@ -1458,17 +1458,15 @@ impl Scene {
|
|||||||
let measurement_supported = !association.trans_space
|
let measurement_supported = !association.trans_space
|
||||||
|| self.document.get_entity(dimension).is_some_and(|entity| {
|
|| self.document.get_entity(dimension).is_some_and(|entity| {
|
||||||
matches!(
|
matches!(
|
||||||
entity,
|
crate::entities::dimension::as_dimension(entity),
|
||||||
EntityType::Dimension(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
Some(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
||||||
) || persisted_measurement_scale(&self.document, entity).is_some()
|
) || persisted_measurement_scale(&self.document, entity).is_some()
|
||||||
});
|
});
|
||||||
let measurement_supported = measurement_supported
|
let measurement_supported = measurement_supported
|
||||||
&& self.document.get_entity(dimension).is_some_and(|entity| {
|
&& self.document.get_entity(dimension).is_some_and(|entity| {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
entity,
|
crate::entities::dimension::as_dimension(entity),
|
||||||
EntityType::Dimension(
|
Some(Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_))
|
||||||
Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1652,7 +1650,7 @@ impl Scene {
|
|||||||
let Some(EntityType::Dimension(entity)) = self.document.get_entity(dimension) else {
|
let Some(EntityType::Dimension(entity)) = self.document.get_entity(dimension) else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
let radial_data = match entity {
|
let radial_data = match &**entity {
|
||||||
Dimension::Radius(radius) => Some((
|
Dimension::Radius(radius) => Some((
|
||||||
radius.angle_vertex,
|
radius.angle_vertex,
|
||||||
radius.measurement(),
|
radius.measurement(),
|
||||||
@@ -1850,8 +1848,8 @@ impl Scene {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let angular = matches!(
|
let angular = matches!(
|
||||||
&before,
|
crate::entities::dimension::as_dimension(&before),
|
||||||
EntityType::Dimension(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
Some(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
||||||
);
|
);
|
||||||
let measurement_scale = if let Some(frame) = map.frame.filter(|_| !angular) {
|
let measurement_scale = if let Some(frame) = map.frame.filter(|_| !angular) {
|
||||||
let Some(mut scale) = persisted_measurement_scale(&self.document, &before) else {
|
let Some(mut scale) = persisted_measurement_scale(&self.document, &before) else {
|
||||||
@@ -1874,7 +1872,7 @@ impl Scene {
|
|||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
match dimension {
|
match &mut **dimension {
|
||||||
Dimension::Linear(linear) => {
|
Dimension::Linear(linear) => {
|
||||||
// The sheet annotation the user placed — the dimension
|
// The sheet annotation the user placed — the dimension
|
||||||
// line's standoff and, when they dragged it, the text — is
|
// line's standoff and, when they dragged it, the text — is
|
||||||
@@ -2104,7 +2102,7 @@ impl Scene {
|
|||||||
arc.base.actual_measurement = arc.measurement();
|
arc.base.actual_measurement = arc.measurement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let measurement = match &*dimension {
|
let measurement = match &**dimension {
|
||||||
Dimension::Linear(linear) => linear_measurement(linear),
|
Dimension::Linear(linear) => linear_measurement(linear),
|
||||||
_ => dimension.measurement(),
|
_ => dimension.measurement(),
|
||||||
};
|
};
|
||||||
@@ -2155,8 +2153,12 @@ impl Scene {
|
|||||||
refreshed
|
refreshed
|
||||||
}
|
}
|
||||||
pub(crate) fn sync_diameter_association_angle(&mut self, dimension: Handle) {
|
pub(crate) fn sync_diameter_association_angle(&mut self, dimension: Handle) {
|
||||||
let chord = match self.document.get_entity(dimension) {
|
let chord = match self
|
||||||
Some(EntityType::Dimension(Dimension::Diameter(diameter))) => diameter.angle_vertex,
|
.document
|
||||||
|
.get_entity(dimension)
|
||||||
|
.and_then(crate::entities::dimension::as_dimension)
|
||||||
|
{
|
||||||
|
Some(Dimension::Diameter(diameter)) => diameter.angle_vertex,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2247,9 +2249,9 @@ mod tests {
|
|||||||
Vector3::ZERO,
|
Vector3::ZERO,
|
||||||
5.0,
|
5.0,
|
||||||
)));
|
)));
|
||||||
let dimension = scene.add_entity(EntityType::Dimension(Dimension::Diameter(
|
let dimension = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Diameter(
|
||||||
DimensionDiameter::new(Vector3::new(5.0, 0.0, 0.0), Vector3::new(-5.0, 0.0, 0.0)),
|
DimensionDiameter::new(Vector3::new(5.0, 0.0, 0.0), Vector3::new(-5.0, 0.0, 0.0)),
|
||||||
)));
|
))));
|
||||||
scene.attach_dimension_association(dimension, vec![Some(circle)]);
|
scene.attach_dimension_association(dimension, vec![Some(circle)]);
|
||||||
let association = scene
|
let association = scene
|
||||||
.document
|
.document
|
||||||
@@ -2270,8 +2272,10 @@ mod tests {
|
|||||||
.expect("diameter association");
|
.expect("diameter association");
|
||||||
|
|
||||||
scene.begin_undo_recording();
|
scene.begin_undo_recording();
|
||||||
let Some(EntityType::Dimension(Dimension::Diameter(diameter))) =
|
let Some(Dimension::Diameter(diameter)) = scene
|
||||||
scene.document.get_entity_mut(dimension)
|
.document
|
||||||
|
.get_entity_mut(dimension)
|
||||||
|
.and_then(crate::entities::dimension::as_dimension_mut)
|
||||||
else {
|
else {
|
||||||
panic!("diameter dimension");
|
panic!("diameter dimension");
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -3206,7 +3206,7 @@ impl Scene {
|
|||||||
if let Some(origin) = model.pattern_origin {
|
if let Some(origin) = model.pattern_origin {
|
||||||
dxf.record_pattern_origin(Vector2::new(origin[0], origin[1]));
|
dxf.record_pattern_origin(Vector2::new(origin[0], origin[1]));
|
||||||
}
|
}
|
||||||
let mut entity = EntityType::Hatch(dxf);
|
let mut entity = EntityType::Hatch(Box::new(dxf));
|
||||||
|
|
||||||
if let Some(layer) = layer {
|
if let Some(layer) = layer {
|
||||||
entity.as_entity_mut().set_layer(layer.to_string());
|
entity.as_entity_mut().set_layer(layer.to_string());
|
||||||
|
|||||||
+3
-3
@@ -64,10 +64,10 @@ impl Scene {
|
|||||||
if let Some(EntityType::Viewport(sheet)) = self.document.get_entity(from.viewport).cloned()
|
if let Some(EntityType::Viewport(sheet)) = self.document.get_entity(from.viewport).cloned()
|
||||||
{
|
{
|
||||||
if let Some(EntityType::Viewport(target)) = self.document.get_entity_mut(to.viewport) {
|
if let Some(EntityType::Viewport(target)) = self.document.get_entity_mut(to.viewport) {
|
||||||
*target = codec::entities::Viewport {
|
*target = Box::new(codec::entities::Viewport {
|
||||||
common: target.common.clone(),
|
common: target.common.clone(),
|
||||||
..sheet
|
..*sheet
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.unopened_layouts.remove(name);
|
self.unopened_layouts.remove(name);
|
||||||
|
|||||||
+5
-5
@@ -4956,7 +4956,7 @@ impl Scene {
|
|||||||
fit_sheet_viewport(&mut vp, min_lim, max_lim);
|
fit_sheet_viewport(&mut vp, min_lim, max_lim);
|
||||||
if let Ok(handle) = self
|
if let Ok(handle) = self
|
||||||
.document
|
.document
|
||||||
.add_entity_to_layout(EntityType::Viewport(vp), layout_name)
|
.add_entity_to_layout(EntityType::Viewport(Box::new(vp)), layout_name)
|
||||||
{
|
{
|
||||||
if let Some(ObjectType::Layout(l)) = self.document.objects.get_mut(&layout_handle) {
|
if let Some(ObjectType::Layout(l)) = self.document.objects.get_mut(&layout_handle) {
|
||||||
l.viewports.retain(|candidate| *candidate != handle);
|
l.viewports.retain(|candidate| *candidate != handle);
|
||||||
@@ -5027,7 +5027,7 @@ impl Scene {
|
|||||||
viewport.status = codec::entities::ViewportStatusFlags::default_on();
|
viewport.status = codec::entities::ViewportStatusFlags::default_on();
|
||||||
if let Ok(handle) = self
|
if let Ok(handle) = self
|
||||||
.document
|
.document
|
||||||
.add_entity_to_layout(EntityType::Viewport(viewport), layout_name)
|
.add_entity_to_layout(EntityType::Viewport(Box::new(viewport)), layout_name)
|
||||||
{
|
{
|
||||||
// The reference zooms the new viewport to the model's extents
|
// The reference zooms the new viewport to the model's extents
|
||||||
// with a margin of under one percent.
|
// with a margin of under one percent.
|
||||||
@@ -13802,7 +13802,7 @@ mod journal_tests {
|
|||||||
let mut annotative = MText::new();
|
let mut annotative = MText::new();
|
||||||
annotative.value = "annotative".to_string();
|
annotative.value = "annotative".to_string();
|
||||||
annotative.is_annotative = true;
|
annotative.is_annotative = true;
|
||||||
let annotative = s.add_entity(EntityType::MText(annotative));
|
let annotative = s.add_entity(EntityType::MText(Box::new(annotative)));
|
||||||
|
|
||||||
let before_points = s.geometry_epoch;
|
let before_points = s.geometry_epoch;
|
||||||
s.invalidate_point_dependencies();
|
s.invalidate_point_dependencies();
|
||||||
@@ -14117,7 +14117,7 @@ mod journal_tests {
|
|||||||
scene.document.layers.add_or_replace(Layer::new("Shadows"));
|
scene.document.layers.add_or_replace(Layer::new("Shadows"));
|
||||||
let mut hatch = Hatch::new();
|
let mut hatch = Hatch::new();
|
||||||
hatch.common.layer = "Shadows".to_string();
|
hatch.common.layer = "Shadows".to_string();
|
||||||
let handle = scene.add_entity(EntityType::Hatch(hatch));
|
let handle = scene.add_entity(EntityType::Hatch(Box::new(hatch)));
|
||||||
let model = scene.model_space_block_handle();
|
let model = scene.model_space_block_handle();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scene
|
scene
|
||||||
@@ -15447,7 +15447,7 @@ mod layout_cache_tests {
|
|||||||
vp.height = 100.0;
|
vp.height = 100.0;
|
||||||
let handle = scene
|
let handle = scene
|
||||||
.document
|
.document
|
||||||
.add_entity_to_layout(codec::EntityType::Viewport(vp), "P1")
|
.add_entity_to_layout(codec::EntityType::Viewport(Box::new(vp)), "P1")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(scene.set_viewport_scale_named_for(handle, "1:50").is_some());
|
assert!(scene.set_viewport_scale_named_for(handle, "1:50").is_some());
|
||||||
assert!(scene.active_viewport.is_none());
|
assert!(scene.active_viewport.is_none());
|
||||||
|
|||||||
+2
-2
@@ -285,7 +285,7 @@ mod viewport_zoom_tests {
|
|||||||
viewport.width = 100.0;
|
viewport.width = 100.0;
|
||||||
viewport.height = 100.0;
|
viewport.height = 100.0;
|
||||||
viewport.view_height = 200.0;
|
viewport.view_height = 200.0;
|
||||||
let handle = scene.add_entity(EntityType::Viewport(viewport));
|
let handle = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||||
scene.active_viewport = Some(handle);
|
scene.active_viewport = Some(handle);
|
||||||
|
|
||||||
let view_height = |scene: &Scene| match scene.document.get_entity(handle) {
|
let view_height = |scene: &Scene| match scene.document.get_entity(handle) {
|
||||||
@@ -337,7 +337,7 @@ mod clip_tests {
|
|||||||
viewport.height = 20.0;
|
viewport.height = 20.0;
|
||||||
viewport.clip_boundary_handle = clip;
|
viewport.clip_boundary_handle = clip;
|
||||||
viewport.status.non_rectangular_clipping = true;
|
viewport.status.non_rectangular_clipping = true;
|
||||||
let viewport = scene.add_entity(EntityType::Viewport(viewport));
|
let viewport = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||||
for (x, y, inside) in [
|
for (x, y, inside) in [
|
||||||
(2.0, 2.0, true),
|
(2.0, 2.0, true),
|
||||||
(8.0, 2.0, true),
|
(8.0, 2.0, true),
|
||||||
|
|||||||
@@ -696,7 +696,7 @@ fn dynamic_dimension_follow_points(
|
|||||||
target.attachment_point = base.attachment_point;
|
target.attachment_point = base.attachment_point;
|
||||||
target.line_spacing_style = base.line_spacing_style;
|
target.line_spacing_style = base.line_spacing_style;
|
||||||
target.line_spacing_factor = base.line_spacing_factor;
|
target.line_spacing_factor = base.line_spacing_factor;
|
||||||
*dimension = rebuilt;
|
*dimension = *rebuilt;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ fn dynamic_dimension_follow_radial(
|
|||||||
let Some(codec::EntityType::Dimension(mut rebuilt)) = rebuilt else {
|
let Some(codec::EntityType::Dimension(mut rebuilt)) = rebuilt else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let unchanged = match (&*dimension, &rebuilt) {
|
let unchanged = match (&*dimension, &*rebuilt) {
|
||||||
(Dimension::Radius(old), Dimension::Radius(new)) => {
|
(Dimension::Radius(old), Dimension::Radius(new)) => {
|
||||||
same(old.angle_vertex, new.angle_vertex)
|
same(old.angle_vertex, new.angle_vertex)
|
||||||
&& same(old.definition_point, new.definition_point)
|
&& same(old.definition_point, new.definition_point)
|
||||||
@@ -808,7 +808,7 @@ fn dynamic_dimension_follow_radial(
|
|||||||
if unchanged {
|
if unchanged {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
match &mut rebuilt {
|
match &mut *rebuilt {
|
||||||
Dimension::Radius(new) => new.leader_length = leader,
|
Dimension::Radius(new) => new.leader_length = leader,
|
||||||
Dimension::Diameter(new) => new.leader_length = leader,
|
Dimension::Diameter(new) => new.leader_length = leader,
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -821,7 +821,7 @@ fn dynamic_dimension_follow_radial(
|
|||||||
target.attachment_point = base.attachment_point;
|
target.attachment_point = base.attachment_point;
|
||||||
target.line_spacing_style = base.line_spacing_style;
|
target.line_spacing_style = base.line_spacing_style;
|
||||||
target.line_spacing_factor = base.line_spacing_factor;
|
target.line_spacing_factor = base.line_spacing_factor;
|
||||||
*dimension = rebuilt;
|
*dimension = *rebuilt;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,7 +881,7 @@ fn dynamic_dimension_follow_angle(
|
|||||||
target.attachment_point = base.attachment_point;
|
target.attachment_point = base.attachment_point;
|
||||||
target.line_spacing_style = base.line_spacing_style;
|
target.line_spacing_style = base.line_spacing_style;
|
||||||
target.line_spacing_factor = base.line_spacing_factor;
|
target.line_spacing_factor = base.line_spacing_factor;
|
||||||
*dimension = rebuilt;
|
*dimension = *rebuilt;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2264,10 +2264,14 @@ impl super::Scene {
|
|||||||
});
|
});
|
||||||
let measured = points.filter(|_| !angular).map(|(first, second)| {
|
let measured = points.filter(|_| !angular).map(|(first, second)| {
|
||||||
let delta = second - first;
|
let delta = second - first;
|
||||||
let axis = match self.document.get_entity(*dimension) {
|
let axis = match self
|
||||||
Some(codec::EntityType::Dimension(codec::entities::Dimension::Linear(
|
.document
|
||||||
linear,
|
.get_entity(*dimension)
|
||||||
))) => Some((linear.rotation.cos(), linear.rotation.sin())),
|
.and_then(crate::entities::dimension::as_dimension)
|
||||||
|
{
|
||||||
|
Some(codec::entities::Dimension::Linear(linear)) => {
|
||||||
|
Some((linear.rotation.cos(), linear.rotation.sin()))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
match (constraint.kind, axis) {
|
match (constraint.kind, axis) {
|
||||||
@@ -2605,7 +2609,7 @@ impl super::Scene {
|
|||||||
// line, which breaks around the text, so the text is centred on
|
// line, which breaks around the text, so the text is centred on
|
||||||
// it rather than lifted above it.
|
// it rather than lifted above it.
|
||||||
let radial = matches!(
|
let radial = matches!(
|
||||||
dimension,
|
&**dimension,
|
||||||
codec::entities::Dimension::Radius(_) | codec::entities::Dimension::Diameter(_)
|
codec::entities::Dimension::Radius(_) | codec::entities::Dimension::Diameter(_)
|
||||||
);
|
);
|
||||||
let centred = !radial || ov::int(xdata, ov::DIMTAD) == Some(0);
|
let centred = !radial || ov::int(xdata, ov::DIMTAD) == Some(0);
|
||||||
@@ -2615,7 +2619,7 @@ impl super::Scene {
|
|||||||
// The reference draws dynamic distance text horizontally; an
|
// The reference draws dynamic distance text horizontally; an
|
||||||
// angle's text keeps its style's alignment.
|
// angle's text keeps its style's alignment.
|
||||||
let angular = matches!(
|
let angular = matches!(
|
||||||
dimension,
|
&**dimension,
|
||||||
codec::entities::Dimension::Angular2Ln(_)
|
codec::entities::Dimension::Angular2Ln(_)
|
||||||
| codec::entities::Dimension::Angular3Pt(_)
|
| codec::entities::Dimension::Angular3Pt(_)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl Scene {
|
|||||||
let viewports: Vec<&Viewport> = viewport_handles
|
let viewports: Vec<&Viewport> = viewport_handles
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|handle| match self.document.get_entity(*handle) {
|
.filter_map(|handle| match self.document.get_entity(*handle) {
|
||||||
Some(EntityType::Viewport(vp)) => Some(vp),
|
Some(EntityType::Viewport(vp)) => Some(&**vp),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.filter(|vp| {
|
.filter(|vp| {
|
||||||
@@ -446,7 +446,7 @@ impl Scene {
|
|||||||
Some(EntityType::Viewport(viewport))
|
Some(EntityType::Viewport(viewport))
|
||||||
if viewport.common.owner_handle == paper_block && viewport.is_on() =>
|
if viewport.common.owner_handle == paper_block && viewport.is_on() =>
|
||||||
{
|
{
|
||||||
Some(viewport)
|
Some(&**viewport)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ impl ObjectKind {
|
|||||||
EntityType::Text(e::Text::with_value("Text", origin).with_height(2.5))
|
EntityType::Text(e::Text::with_value("Text", origin).with_height(2.5))
|
||||||
}
|
}
|
||||||
ObjectKind::MText => {
|
ObjectKind::MText => {
|
||||||
EntityType::MText(e::MText::with_value("MText", origin).with_height(2.5))
|
EntityType::MText(Box::new(e::MText::with_value("MText", origin).with_height(2.5)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,13 +90,13 @@ fn entered_viewport_survives_a_save_and_reload() {
|
|||||||
sheet.id = 1;
|
sheet.id = 1;
|
||||||
sheet.width = 420.0;
|
sheet.width = 420.0;
|
||||||
sheet.height = 297.0;
|
sheet.height = 297.0;
|
||||||
let sheet = scene.add_entity(EntityType::Viewport(sheet));
|
let sheet = scene.add_entity(EntityType::Viewport(Box::new(sheet)));
|
||||||
let mut model = Viewport::new();
|
let mut model = Viewport::new();
|
||||||
model.id = 2;
|
model.id = 2;
|
||||||
model.width = 100.0;
|
model.width = 100.0;
|
||||||
model.height = 80.0;
|
model.height = 80.0;
|
||||||
model.view_height = 80.0;
|
model.view_height = 80.0;
|
||||||
let model = scene.add_entity(EntityType::Viewport(model));
|
let model = scene.add_entity(EntityType::Viewport(Box::new(model)));
|
||||||
assert_ne!(sheet, model);
|
assert_ne!(sheet, model);
|
||||||
|
|
||||||
for entered in [Some(model), None] {
|
for entered in [Some(model), None] {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ fn empty_annotation_scales_is_not_annotative() {
|
|||||||
let mut doc = CadDocument::with_version(DxfVersion::AC1032);
|
let mut doc = CadDocument::with_version(DxfVersion::AC1032);
|
||||||
let mut m = MText::new();
|
let mut m = MText::new();
|
||||||
m.is_annotative = false; // no native flag, no annotative style
|
m.is_annotative = false; // no native flag, no annotative style
|
||||||
let ent = doc.add_entity(EntityType::MText(m)).unwrap();
|
let ent = doc.add_entity(EntityType::MText(Box::new(m))).unwrap();
|
||||||
|
|
||||||
// Build xdict -> "AcDbContextDataManager" -> "ACDB_ANNOTATIONSCALES" (empty).
|
// Build xdict -> "AcDbContextDataManager" -> "ACDB_ANNOTATIONSCALES" (empty).
|
||||||
let mk = |doc: &mut CadDocument, owner: Handle| -> Handle {
|
let mk = |doc: &mut CadDocument, owner: Handle| -> Handle {
|
||||||
@@ -92,7 +92,7 @@ fn ocs_synthesized_mtext_context_survives_dwg_roundtrip() {
|
|||||||
m.insertion_point = Vector3::new(100.0, 200.0, 0.0);
|
m.insertion_point = Vector3::new(100.0, 200.0, 0.0);
|
||||||
m.rectangle_width = 50.0;
|
m.rectangle_width = 50.0;
|
||||||
m.is_annotative = true;
|
m.is_annotative = true;
|
||||||
let ent = doc.add_entity(EntityType::MText(m)).expect("add mtext");
|
let ent = doc.add_entity(EntityType::MText(Box::new(m))).expect("add mtext");
|
||||||
|
|
||||||
let sh = doc.allocate_handle();
|
let sh = doc.allocate_handle();
|
||||||
let mut scale = Scale::new("1:50", 1.0, 50.0);
|
let mut scale = Scale::new("1:50", 1.0, 50.0);
|
||||||
@@ -174,7 +174,7 @@ fn object_scale_membership_add_remove_roundtrips() {
|
|||||||
let mut doc = CadDocument::with_version(DxfVersion::AC1032);
|
let mut doc = CadDocument::with_version(DxfVersion::AC1032);
|
||||||
let mut m = MText::new();
|
let mut m = MText::new();
|
||||||
m.insertion_point = Vector3::new(1.0, 2.0, 0.0);
|
m.insertion_point = Vector3::new(1.0, 2.0, 0.0);
|
||||||
let ent = doc.add_entity(EntityType::MText(m)).unwrap();
|
let ent = doc.add_entity(EntityType::MText(Box::new(m))).unwrap();
|
||||||
|
|
||||||
let mk_scale = |doc: &mut CadDocument, name: &str, d: f64| {
|
let mk_scale = |doc: &mut CadDocument, name: &str, d: f64| {
|
||||||
let h = doc.allocate_handle();
|
let h = doc.allocate_handle();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ fn block_internal_hatch_reaches_export() {
|
|||||||
|
|
||||||
// A blue hatch, wrapped into a block and inserted in model space — the
|
// A blue hatch, wrapped into a block and inserted in model space — the
|
||||||
// minimal shape of "coloured fill nested in a block".
|
// minimal shape of "coloured fill nested in a block".
|
||||||
let h = scene.add_entity(EntityType::Hatch(square_hatch(5)));
|
let h = scene.add_entity(EntityType::Hatch(Box::new(square_hatch(5))));
|
||||||
let identity = codec::types::Transform::identity();
|
let identity = codec::types::Transform::identity();
|
||||||
scene
|
scene
|
||||||
.create_block_from_entities(&[h], "LOGO", &identity, &identity)
|
.create_block_from_entities(&[h], "LOGO", &identity, &identity)
|
||||||
@@ -100,7 +100,7 @@ fn block_internal_hatch_reaches_export() {
|
|||||||
fn pattern_hatch_uses_stored_line_spacing() {
|
fn pattern_hatch_uses_stored_line_spacing() {
|
||||||
let mut scene = Scene::new();
|
let mut scene = Scene::new();
|
||||||
// Spacing 0.5; a big pattern_scale (10) that the catalog path would apply.
|
// Spacing 0.5; a big pattern_scale (10) that the catalog path would apply.
|
||||||
scene.add_entity(EntityType::Hatch(ansi31_stored(0.5, 10.0)));
|
scene.add_entity(EntityType::Hatch(Box::new(ansi31_stored(0.5, 10.0))));
|
||||||
scene.populate_hatches_from_document();
|
scene.populate_hatches_from_document();
|
||||||
|
|
||||||
let hatches = scene.paper_plot_hatches();
|
let hatches = scene.paper_plot_hatches();
|
||||||
@@ -143,7 +143,7 @@ fn far_from_origin_pattern_hatch_still_fills() {
|
|||||||
// the perpendicular index is |k| ≈ 4000·sin45°/0.3 ≈ 9400, well past the
|
// the perpendicular index is |k| ≈ 4000·sin45°/0.3 ≈ 9400, well past the
|
||||||
// 4096 clamp on both ends; the old absolute-index clamp inverts the range
|
// 4096 clamp on both ends; the old absolute-index clamp inverts the range
|
||||||
// (k_lo > k_hi) there and emits nothing.
|
// (k_lo > k_hi) there and emits nothing.
|
||||||
scene.add_entity(EntityType::Hatch(ansi31_stored_at(0.3, 1.0, 4000.0, 0.0)));
|
scene.add_entity(EntityType::Hatch(Box::new(ansi31_stored_at(0.3, 1.0, 4000.0, 0.0))));
|
||||||
scene.populate_hatches_from_document();
|
scene.populate_hatches_from_document();
|
||||||
|
|
||||||
let hatches = scene.paper_plot_hatches();
|
let hatches = scene.paper_plot_hatches();
|
||||||
@@ -188,7 +188,7 @@ fn textbox_boundary_path_is_not_filled() {
|
|||||||
let mut tb = rect_path(0.0, 0.0, 200.0, 50.0);
|
let mut tb = rect_path(0.0, 0.0, 200.0, 50.0);
|
||||||
tb.flags = BoundaryPathFlags::from_bits(8 | 1); // TEXTBOX + EXTERNAL
|
tb.flags = BoundaryPathFlags::from_bits(8 | 1); // TEXTBOX + EXTERNAL
|
||||||
hatch.paths.push(tb);
|
hatch.paths.push(tb);
|
||||||
scene.add_entity(EntityType::Hatch(hatch));
|
scene.add_entity(EntityType::Hatch(Box::new(hatch)));
|
||||||
scene.populate_hatches_from_document();
|
scene.populate_hatches_from_document();
|
||||||
|
|
||||||
let hatches = scene.paper_plot_hatches();
|
let hatches = scene.paper_plot_hatches();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fn copy_dimension_duplicates_its_block() {
|
|||||||
// A linear dimension whose drawn geometry is that baked block.
|
// A linear dimension whose drawn geometry is that baked block.
|
||||||
let mut dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
let mut dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||||
dim.base.block_name = "*D0".to_string();
|
dim.base.block_name = "*D0".to_string();
|
||||||
let dim_h = scene.add_entity(EntityType::Dimension(Dimension::Linear(dim)));
|
let dim_h = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))));
|
||||||
|
|
||||||
// Copy the dimension by (0, 50).
|
// Copy the dimension by (0, 50).
|
||||||
let copies = scene.copy_entities(
|
let copies = scene.copy_entities(
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ fn dim_leader_extends_only_when_requested() {
|
|||||||
base.insertion_point = base.text_middle_point;
|
base.insertion_point = base.text_middle_point;
|
||||||
base.text_user_positioned = true;
|
base.text_user_positioned = true;
|
||||||
base.style_name = "Standard".into();
|
base.style_name = "Standard".into();
|
||||||
let handle = scene.add_entity(EntityType::Dimension(dim));
|
let handle = scene.add_entity(EntityType::Dimension(Box::new(dim)));
|
||||||
for (code, value) in [
|
for (code, value) in [
|
||||||
(ov::DIMTMOVE, XDataValue::Integer16(movement)),
|
(ov::DIMTMOVE, XDataValue::Integer16(movement)),
|
||||||
(ov::DIMTXT, XDataValue::Real(3.5)),
|
(ov::DIMTXT, XDataValue::Real(3.5)),
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ fn dimension_scene(aci: i16) -> Scene {
|
|||||||
|
|
||||||
let mut dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
let mut dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||||
dim.base.block_name = "*D0".to_string();
|
dim.base.block_name = "*D0".to_string();
|
||||||
let h = scene.add_entity(EntityType::Dimension(Dimension::Linear(dim)));
|
let h = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))));
|
||||||
dov::set(
|
dov::set(
|
||||||
&mut scene.document,
|
&mut scene.document,
|
||||||
h,
|
h,
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ fn explode_dimension_linear_golden_segments() {
|
|||||||
let mut d = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
let mut d = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||||
d.definition_point = Vector3::new(5.0, 3.0, 0.0);
|
d.definition_point = Vector3::new(5.0, 3.0, 0.0);
|
||||||
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||||
let pieces = explode_entity(&EntityType::Dimension(Dimension::Linear(d)), &doc);
|
let pieces = explode_entity(&EntityType::Dimension(Box::new(Dimension::Linear(d))), &doc);
|
||||||
// A baked linear dimension explodes to exactly 2 extension lines + 1
|
// A baked linear dimension explodes to exactly 2 extension lines + 1
|
||||||
// dimension line. The arrowheads bake as SOLIDs (see the unit test
|
// dimension line. The arrowheads bake as SOLIDs (see the unit test
|
||||||
// `linear_dim_bakes_filled_arrowheads`), which is why the Lines count is
|
// `linear_dim_bakes_filled_arrowheads`), which is why the Lines count is
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ fn viewport_projection_clips_images_and_respects_frozen_and_nonplot_layers() {
|
|||||||
viewport.view_center = Vector3::new(20.0, 10.0, 0.0);
|
viewport.view_center = Vector3::new(20.0, 10.0, 0.0);
|
||||||
viewport.id = 2;
|
viewport.id = 2;
|
||||||
viewport.status.is_on = true;
|
viewport.status.is_on = true;
|
||||||
let handle = scene.add_entity(EntityType::Viewport(viewport));
|
let handle = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||||
let (_, _, _, images) = scene.viewport_plot_fills();
|
let (_, _, _, images) = scene.viewport_plot_fills();
|
||||||
assert_eq!(images.len(), 1);
|
assert_eq!(images.len(), 1);
|
||||||
let raster = Raster::from_pdf(&export(&[page(images)]), 0);
|
let raster = Raster::from_pdf(&export(&[page(images)]), 0);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ fn text_and_dim_reach_pdf_export() {
|
|||||||
// A linear dimension — its measurement value is synthesized as SDF text too,
|
// A linear dimension — its measurement value is synthesized as SDF text too,
|
||||||
// and dimension text is what #385 was actually filed about.
|
// and dimension text is what #385 was actually filed about.
|
||||||
let dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(40.0, 0.0, 0.0));
|
let dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(40.0, 0.0, 0.0));
|
||||||
let dim_h = scene.add_entity(EntityType::Dimension(Dimension::Linear(dim)));
|
let dim_h = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))));
|
||||||
|
|
||||||
let wires = scene.entity_wires();
|
let wires = scene.entity_wires();
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ fn expand_block_mtext(
|
|||||||
mtext.style = "SHOP".to_string();
|
mtext.style = "SHOP".to_string();
|
||||||
mtext.height = 20.0;
|
mtext.height = 20.0;
|
||||||
mtext.rectangle_width = 0.0;
|
mtext.rectangle_width = 0.0;
|
||||||
let mut sub = EntityType::MText(mtext);
|
let mut sub = EntityType::MText(Box::new(mtext));
|
||||||
sub.common_mut().owner_handle = br_h;
|
sub.common_mut().owner_handle = br_h;
|
||||||
doc.add_entity(sub).unwrap();
|
doc.add_entity(sub).unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ fn viewport_projection_scales_wide_polyline_band_width() {
|
|||||||
viewport.view_center = Vector3::new(50.0, 0.0, 0.0);
|
viewport.view_center = Vector3::new(50.0, 0.0, 0.0);
|
||||||
viewport.id = 2;
|
viewport.id = 2;
|
||||||
viewport.status.is_on = true;
|
viewport.status.is_on = true;
|
||||||
scene.add_entity(EntityType::Viewport(viewport));
|
scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||||
|
|
||||||
let (_paper, model) = scene.plot_wire_groups(None);
|
let (_paper, model) = scene.plot_wire_groups(None);
|
||||||
let band = model
|
let band = model
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ fn fit_all_reaches_an_entity_parked_far_from_the_rest() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fit_all_frames_a_hatch_only_drawing() {
|
fn fit_all_frames_a_hatch_only_drawing() {
|
||||||
let mut scene = Scene::new();
|
let mut scene = Scene::new();
|
||||||
scene.add_entity(EntityType::Hatch(square_hatch(100.0, 200.0, 40.0)));
|
scene.add_entity(EntityType::Hatch(Box::new(square_hatch(100.0, 200.0, 40.0))));
|
||||||
|
|
||||||
scene.fit_all();
|
scene.fit_all();
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ fn fit_all_keeps_a_hatch_outside_the_wires_in_view() {
|
|||||||
}
|
}
|
||||||
// The fill is the outermost thing in the drawing; the wires alone would
|
// The fill is the outermost thing in the drawing; the wires alone would
|
||||||
// frame a 12 x 10 strip and leave it off screen.
|
// frame a 12 x 10 strip and leave it off screen.
|
||||||
scene.add_entity(EntityType::Hatch(square_hatch(500.0, 500.0, 50.0)));
|
scene.add_entity(EntityType::Hatch(Box::new(square_hatch(500.0, 500.0, 50.0))));
|
||||||
|
|
||||||
scene.fit_all();
|
scene.fit_all();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user