feat(cad): integrate standard codec coverage

Render, edit, query, select, and explode newly decoded standard entity variants. Pin acadifc de8d6b5 and preserve None color semantics.
This commit is contained in:
Hakan Seven 2026-07-26 19:30:43 +03:00
commit 731df4a725
19 changed files with 484 additions and 72 deletions

View file

@ -62,33 +62,31 @@ impl Scene {
let eye_dir = cam.rotation * glam::Vec3::Z;
let height = cam.ortho_size() * 2.0;
let width = height; // caller can adjust; rough square
acadrust::tables::View {
handle: acadrust::types::Handle::NULL,
name: name.to_string(),
center: Vector3 {
x: cam.target.x as f64,
y: cam.target.y as f64,
z: 0.0,
},
target: Vector3 {
x: cam.target.x as f64,
y: cam.target.y as f64,
z: cam.target.z as f64,
},
direction: Vector3 {
x: eye_dir.x as f64,
y: eye_dir.y as f64,
z: eye_dir.z as f64,
},
height: height as f64,
width: width as f64,
lens_length: 50.0,
front_clip: 0.0,
back_clip: 0.0,
twist_angle: 0.0,
// OCS saves an orthographic model view, not a perspective camera.
perspective: false,
}
let mut view = acadrust::tables::View::new(name);
view.center = Vector3 {
x: cam.target.x as f64,
y: cam.target.y as f64,
z: 0.0,
};
view.target = Vector3 {
x: cam.target.x as f64,
y: cam.target.y as f64,
z: cam.target.z as f64,
};
view.direction = Vector3 {
x: eye_dir.x as f64,
y: eye_dir.y as f64,
z: eye_dir.z as f64,
};
view.height = height as f64;
view.width = width as f64;
view.lens_length = 50.0;
view.front_clip = 0.0;
view.back_clip = 0.0;
view.twist_angle = 0.0;
// OCS saves an orthographic model view, not a perspective camera.
view.perspective = false;
view
}
/// Zoom the model-space camera in/out by a percentage.

View file

@ -37,7 +37,7 @@ fn section_arrow_dir_from_views(
s: &acadrust::entities::SectionSymbol,
) -> Option<[f64; 2]> {
use acadrust::types::Handle as AHandle;
if s.view_rep_handle == 0 {
if s.view_rep_handle.is_null() {
return None;
}
// A view's active viewport, via its border entity among the ViewRep refs.
@ -47,7 +47,7 @@ fn section_arrow_dir_from_views(
_ => None,
}
};
let parent_vr = AHandle::from(s.view_rep_handle);
let parent_vr = s.view_rep_handle;
let parent_refs = document.view_rep_refs.get(&parent_vr)?;
let parent_vp_h = parent_refs.iter().find_map(border_vp)?;
let sect_vr = parent_refs

View file

@ -298,7 +298,8 @@ impl ImageModel {
/// the frame is degenerate or nothing in the blob decodes, so the caller
/// falls back to the frame placeholder.
pub fn from_ole2frame(ole: &acadrust::entities::Ole2Frame) -> Option<Self> {
let (pixels, width, height) = super::ole_pres::decode(&ole.binary_data)?;
let payload = ole.encoded_payload();
let (pixels, width, height) = super::ole_pres::decode(&payload)?;
// Frame rectangle in WCS. `upper_left`/`lower_right` name the diagonal;
// normalise to left/right/top/bottom so the bitmap sits upright.

View file

@ -55,7 +55,7 @@ impl Scene {
if self.selected.is_empty() {
return 0;
}
let pairs: rustc_hash::FxHashSet<(&'static str, String)> = self
let pairs: rustc_hash::FxHashSet<(&str, String)> = self
.selected
.iter()
.filter_map(|h| self.document.get_entity(*h))
@ -182,13 +182,13 @@ impl Scene {
/// Returns the sorted set of entity-type names present in the active
/// layout. Used to populate the Quick Select "Object type" dropdown
/// with only the types that actually exist in the drawing.
pub fn entity_type_names_in_layout(&self) -> Vec<&'static str> {
pub fn entity_type_names_in_layout(&self) -> Vec<String> {
use crate::entities::traits::entity_type_name;
let mut names: std::collections::BTreeSet<&'static str> =
let mut names: std::collections::BTreeSet<String> =
std::collections::BTreeSet::new();
for h in self.current_layout_entity_handles() {
if let Some(e) = self.document.get_entity(h) {
names.insert(entity_type_name(e));
names.insert(entity_type_name(e).to_string());
}
}
names.into_iter().collect()
@ -311,6 +311,7 @@ impl Scene {
use acadrust::types::Color;
match c {
Color::ByLayer => "ByLayer".to_string(),
Color::None => "None".to_string(),
Color::ByBlock => "ByBlock".to_string(),
Color::Index(i) => i.to_string(),
Color::Rgb { r, g, b } => format!("{},{},{}", r, g, b),