forked from 1b-agent/opencadstudio-upstream
feat: node graph overlay; move to opencadcodec/opencadkernel/opencadgraph
The codec and kernel repositories and crates are renamed opencadcodec and opencadkernel. Inside OCS they are depended on under short keys, so code reads `codec::`, `kernel::` and the new `graph::` (opencadgraph, the node graph engine). File-format and protocol spellings stay as they were: the ACIS product id `acadrust`, the ACADRUST_* switches and the plugin version keys `acadrust_version` / `acadrust_source`. A button left of MCP on the command line opens a translucent node graph over the viewport, with a palette of object, input, math, logic, list, text and geometry nodes added by click or drag. An object node owns drawing entities and its rows are the Properties panel's own rows for them: the single-object page is extracted from refresh_properties as entity_property_sections, values use the control protocol's property_json, and writes go through set_property_value with a property target override, so the panel, MCP and the graph share one read/write path. A list reaching an object row makes one entity per element. Each graph action is one undo step; the canvas pans and zooms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
56c04408d6
commit
f537aff75c
430 files changed
+9925
-8540
No files matched your search
+49
-49
@@ -34,7 +34,7 @@ impl OpenCADStudio {
|
||||
pub(in crate::app) fn copy_entities_to_clipboard(
|
||||
&mut self,
|
||||
i: usize,
|
||||
handles: &[acadrust::Handle],
|
||||
handles: &[codec::Handle],
|
||||
base: glam::DVec3,
|
||||
) -> usize {
|
||||
// Clone + dep-capture live in the shared kernel; storage stays here.
|
||||
@@ -113,7 +113,7 @@ impl OpenCADStudio {
|
||||
.collect();
|
||||
if nums.len() >= 2 {
|
||||
let z = nums.get(2).copied().unwrap_or(0.0);
|
||||
let pt = acadrust::types::Vector3::new(nums[0], nums[1], z);
|
||||
let pt = codec::types::Vector3::new(nums[0], nums[1], z);
|
||||
let is_paper = self.tabs[i].scene.current_layout != "Model";
|
||||
self.push_undo_snapshot(i, "BASE");
|
||||
if is_paper {
|
||||
@@ -576,7 +576,7 @@ impl OpenCADStudio {
|
||||
.iter()
|
||||
.filter_map(|h| doc.get_entity(*h))
|
||||
.filter_map(|e| match e {
|
||||
acadrust::EntityType::AttributeDefinition(a) => {
|
||||
codec::EntityType::AttributeDefinition(a) => {
|
||||
Some((a.tag.clone(), a.default_value.clone()))
|
||||
}
|
||||
_ => None,
|
||||
@@ -589,7 +589,7 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| match entity {
|
||||
acadrust::EntityType::Insert(insert)
|
||||
codec::EntityType::Insert(insert)
|
||||
if insert.block_name.eq_ignore_ascii_case(&block)
|
||||
&& !self.tabs[i].scene.is_layer_locked(insert.common.handle) =>
|
||||
{
|
||||
@@ -607,7 +607,7 @@ impl OpenCADStudio {
|
||||
let mut synced = 0usize;
|
||||
let mut changes = Vec::new();
|
||||
for handle in inserts {
|
||||
let Some(acadrust::EntityType::Insert(ins)) =
|
||||
let Some(codec::EntityType::Insert(ins)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
else {
|
||||
continue;
|
||||
@@ -621,7 +621,7 @@ impl OpenCADStudio {
|
||||
.any(|a| a.tag.eq_ignore_ascii_case(tag))
|
||||
{
|
||||
ins.attributes
|
||||
.push(acadrust::entities::AttributeEntity::new(
|
||||
.push(codec::entities::AttributeEntity::new(
|
||||
tag.clone(),
|
||||
default.clone(),
|
||||
));
|
||||
@@ -726,11 +726,11 @@ impl OpenCADStudio {
|
||||
"XCLIP" => {
|
||||
use crate::command::CadCommand;
|
||||
use crate::modules::insert::xclip::XclipCommand;
|
||||
let inserts: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let inserts: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter(|(_, e)| matches!(e, acadrust::EntityType::Insert(_)))
|
||||
.filter(|(_, e)| matches!(e, codec::EntityType::Insert(_)))
|
||||
.map(|(h, _)| *h)
|
||||
.collect();
|
||||
let command = if inserts.is_empty() {
|
||||
@@ -1017,7 +1017,7 @@ impl OpenCADStudio {
|
||||
self.tabs[i].xref_unloaded.remove(key);
|
||||
self.tabs[i].xref_stat_cache.remove(key);
|
||||
}
|
||||
let handles: rustc_hash::FxHashSet<acadrust::types::Handle> = self.tabs
|
||||
let handles: rustc_hash::FxHashSet<codec::types::Handle> = self.tabs
|
||||
[i]
|
||||
.scene
|
||||
.document
|
||||
@@ -1604,7 +1604,7 @@ impl OpenCADStudio {
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter_map(|(_, e)| match e {
|
||||
acadrust::EntityType::Insert(ins) => Some(ins.block_name.clone()),
|
||||
codec::EntityType::Insert(ins) => Some(ins.block_name.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
@@ -1717,13 +1717,13 @@ mod tests {
|
||||
let mut app = fresh_app();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let i = app.active_tab;
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
line.start = acadrust::types::Vector3::ZERO;
|
||||
line.end = acadrust::types::Vector3::new(10.0, 0.0, 0.0);
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.start = codec::types::Vector3::ZERO;
|
||||
line.end = codec::types::Vector3::new(10.0, 0.0, 0.0);
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.define_block_from_owned_entities(
|
||||
vec![acadrust::EntityType::Line(line)],
|
||||
vec![codec::EntityType::Line(line)],
|
||||
"Widget",
|
||||
glam::DVec3::ZERO,
|
||||
)
|
||||
@@ -1742,13 +1742,13 @@ mod tests {
|
||||
app.refresh_block_palette();
|
||||
assert!(app.block_palette.blocks.is_empty());
|
||||
let i = app.active_tab;
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
line.start = acadrust::types::Vector3::ZERO;
|
||||
line.end = acadrust::types::Vector3::new(10.0, 0.0, 0.0);
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.start = codec::types::Vector3::ZERO;
|
||||
line.end = codec::types::Vector3::new(10.0, 0.0, 0.0);
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.define_block_from_owned_entities(
|
||||
vec![acadrust::EntityType::Line(line)],
|
||||
vec![codec::EntityType::Line(line)],
|
||||
"Widget",
|
||||
glam::DVec3::ZERO,
|
||||
)
|
||||
@@ -1813,7 +1813,7 @@ mod tests {
|
||||
|
||||
fn add_dwg_xref(app: &mut OpenCADStudio, name: &str, saved: &str) {
|
||||
let i = app.active_tab;
|
||||
let mut br = acadrust::tables::BlockRecord::new(name);
|
||||
let mut br = codec::tables::BlockRecord::new(name);
|
||||
br.flags.is_xref = true;
|
||||
br.xref_path = saved.to_string();
|
||||
br.handle = app.tabs[i].scene.document.allocate_handle();
|
||||
@@ -1851,7 +1851,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn xref_overlay_on_image_errors() {
|
||||
use acadrust::objects::{ImageDefinition, ObjectType};
|
||||
use codec::objects::{ImageDefinition, ObjectType};
|
||||
let mut app = fresh_app();
|
||||
let i = app.active_tab;
|
||||
let h = app.tabs[i].scene.document.allocate_handle();
|
||||
@@ -1863,9 +1863,9 @@ mod tests {
|
||||
.objects
|
||||
.insert(h, ObjectType::ImageDefinition(def));
|
||||
// Reference it so collect_entries lists it.
|
||||
let mut img = acadrust::entities::RasterImage::new(
|
||||
let mut img = codec::entities::RasterImage::new(
|
||||
"img.png",
|
||||
acadrust::types::Vector3::ZERO,
|
||||
codec::types::Vector3::ZERO,
|
||||
8.0,
|
||||
8.0,
|
||||
);
|
||||
@@ -1873,7 +1873,7 @@ mod tests {
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.add_entity(acadrust::EntityType::RasterImage(img))
|
||||
.add_entity(codec::EntityType::RasterImage(img))
|
||||
.unwrap();
|
||||
let out = run_capture(&mut app, "XREF Overlay img.png");
|
||||
assert!(
|
||||
@@ -1887,7 +1887,7 @@ mod tests {
|
||||
// CLI mirror of the palette F7 guard: reloading an image row reports
|
||||
// the drawing-only error, leaves its unloaded flag untouched, and
|
||||
// does not follow with a spurious no-match error.
|
||||
use acadrust::objects::{ImageDefinition, ObjectType};
|
||||
use codec::objects::{ImageDefinition, ObjectType};
|
||||
let mut app = fresh_app();
|
||||
let i = app.active_tab;
|
||||
let h = app.tabs[i].scene.document.allocate_handle();
|
||||
@@ -1898,9 +1898,9 @@ mod tests {
|
||||
.document
|
||||
.objects
|
||||
.insert(h, ObjectType::ImageDefinition(def));
|
||||
let mut img = acadrust::entities::RasterImage::new(
|
||||
let mut img = codec::entities::RasterImage::new(
|
||||
"img.png",
|
||||
acadrust::types::Vector3::ZERO,
|
||||
codec::types::Vector3::ZERO,
|
||||
8.0,
|
||||
8.0,
|
||||
);
|
||||
@@ -1908,7 +1908,7 @@ mod tests {
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.add_entity(acadrust::EntityType::RasterImage(img))
|
||||
.add_entity(codec::EntityType::RasterImage(img))
|
||||
.unwrap();
|
||||
app.tabs[i].current_path = Some(std::path::PathBuf::from("C:/Drawings/host.dwg"));
|
||||
app.tabs[i].xref_unloaded.add(h.value());
|
||||
@@ -1956,7 +1956,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn xref_detach_nested_guard_errors() {
|
||||
use acadrust::tables::BlockRecord;
|
||||
use codec::tables::BlockRecord;
|
||||
// Host file on disk containing its own xref "INNER".
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"ocs_xref_nested_{}_{}",
|
||||
@@ -1967,7 +1967,7 @@ mod tests {
|
||||
.as_nanos()
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let mut host_doc = acadrust::CadDocument::new();
|
||||
let mut host_doc = codec::CadDocument::new();
|
||||
let mut inner = BlockRecord::new("INNER");
|
||||
inner.flags.is_xref = true;
|
||||
inner.xref_path = "inner.dwg".to_string();
|
||||
@@ -1997,15 +1997,15 @@ mod tests {
|
||||
.as_nanos()
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let mut xref_doc = acadrust::CadDocument::new();
|
||||
let mut xref_doc = codec::CadDocument::new();
|
||||
xref_doc
|
||||
.layers
|
||||
.add(acadrust::tables::Layer::new("WALLS"))
|
||||
.add(codec::tables::Layer::new("WALLS"))
|
||||
.unwrap();
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.common.layer = "WALLS".to_string();
|
||||
xref_doc
|
||||
.add_entity(acadrust::EntityType::Line(line))
|
||||
.add_entity(codec::EntityType::Line(line))
|
||||
.unwrap();
|
||||
let bytes = crate::io::save_to_bytes(&xref_doc, "dwg", xref_doc.version).unwrap();
|
||||
let xref_path = dir.join("plan.dwg");
|
||||
@@ -2035,12 +2035,12 @@ mod tests {
|
||||
.as_nanos()
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let mut xref_doc = acadrust::CadDocument::new();
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
let mut xref_doc = codec::CadDocument::new();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.common.plotstyle_flags = 0b11;
|
||||
line.common.plotstyle_handle = Some(xref_doc.allocate_handle());
|
||||
xref_doc
|
||||
.add_entity(acadrust::EntityType::Line(line))
|
||||
.add_entity(codec::EntityType::Line(line))
|
||||
.unwrap();
|
||||
let bytes = crate::io::save_to_bytes(&xref_doc, "dwg", xref_doc.version).unwrap();
|
||||
let xref_path = dir.join("plan.dwg");
|
||||
@@ -2060,7 +2060,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn xref_bind_pdf_errors() {
|
||||
use acadrust::objects::{ObjectType, UnderlayDefinition};
|
||||
use codec::objects::{ObjectType, UnderlayDefinition};
|
||||
let mut app = fresh_app();
|
||||
let i = app.active_tab;
|
||||
let h = app.tabs[i].scene.document.allocate_handle();
|
||||
@@ -2081,7 +2081,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn xref_bind_nested_guard_errors() {
|
||||
use acadrust::tables::BlockRecord;
|
||||
use codec::tables::BlockRecord;
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"ocs_xref_bind_nested_{}_{}",
|
||||
std::process::id(),
|
||||
@@ -2091,7 +2091,7 @@ mod tests {
|
||||
.as_nanos()
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let mut host_doc = acadrust::CadDocument::new();
|
||||
let mut host_doc = codec::CadDocument::new();
|
||||
let mut inner = BlockRecord::new("INNER");
|
||||
inner.flags.is_xref = true;
|
||||
inner.xref_path = "inner.dwg".to_string();
|
||||
@@ -2275,15 +2275,15 @@ mod tests {
|
||||
.as_nanos()
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let mut xref_doc = acadrust::CadDocument::new();
|
||||
let mut xref_doc = codec::CadDocument::new();
|
||||
xref_doc
|
||||
.layers
|
||||
.add(acadrust::tables::Layer::new("WALLS"))
|
||||
.add(codec::tables::Layer::new("WALLS"))
|
||||
.unwrap();
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.common.layer = "WALLS".to_string();
|
||||
xref_doc
|
||||
.add_entity(acadrust::EntityType::Line(line))
|
||||
.add_entity(codec::EntityType::Line(line))
|
||||
.unwrap();
|
||||
let bytes = crate::io::save_to_bytes(&xref_doc, "dwg", xref_doc.version).unwrap();
|
||||
let xref_path = dir.join("plan.dwg");
|
||||
@@ -2333,12 +2333,12 @@ mod tests {
|
||||
let mut app = fresh_app();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let i = app.active_tab;
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
line.end = acadrust::types::Vector3::new(10.0, 0.0, 0.0);
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.end = codec::types::Vector3::new(10.0, 0.0, 0.0);
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.define_block_from_owned_entities(
|
||||
vec![acadrust::EntityType::Line(line)],
|
||||
vec![codec::EntityType::Line(line)],
|
||||
"Widget",
|
||||
glam::DVec3::ZERO,
|
||||
)
|
||||
@@ -2350,12 +2350,12 @@ mod tests {
|
||||
app.tabs
|
||||
.push(crate::app::document::DocumentTab::new_drawing(99));
|
||||
let other = app.tabs.len() - 1;
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
line.end = acadrust::types::Vector3::new(50.0, 0.0, 0.0);
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.end = codec::types::Vector3::new(50.0, 0.0, 0.0);
|
||||
app.tabs[other]
|
||||
.scene
|
||||
.define_block_from_owned_entities(
|
||||
vec![acadrust::EntityType::Line(line)],
|
||||
vec![codec::EntityType::Line(line)],
|
||||
"Widget",
|
||||
glam::DVec3::ZERO,
|
||||
)
|
||||
|
||||
+30
-30
@@ -1,6 +1,6 @@
|
||||
use super::*;
|
||||
|
||||
fn selected_edge_body(app: &OpenCADStudio, tab: usize) -> Option<acadrust::Handle> {
|
||||
fn selected_edge_body(app: &OpenCADStudio, tab: usize) -> Option<codec::Handle> {
|
||||
let scene = &app.tabs.get(tab)?.scene;
|
||||
let selected = scene.selected_handles_in_order();
|
||||
let [handle] = selected.as_slice() else {
|
||||
@@ -9,7 +9,7 @@ fn selected_edge_body(app: &OpenCADStudio, tab: usize) -> Option<acadrust::Handl
|
||||
|
||||
if matches!(
|
||||
scene.document.get_entity(*handle),
|
||||
Some(acadrust::EntityType::Solid3D(_) | acadrust::EntityType::Surface(_))
|
||||
Some(codec::EntityType::Solid3D(_) | codec::EntityType::Surface(_))
|
||||
) {
|
||||
Some(*handle)
|
||||
} else {
|
||||
@@ -20,7 +20,7 @@ fn selected_edge_body(app: &OpenCADStudio, tab: usize) -> Option<acadrust::Handl
|
||||
fn solid_edge_sources(
|
||||
app: &mut OpenCADStudio,
|
||||
tab: usize,
|
||||
) -> Vec<(acadrust::Handle, cadkernel::brep::Body)> {
|
||||
) -> Vec<(codec::Handle, kernel::brep::Body)> {
|
||||
let handles = app.tabs[tab]
|
||||
.scene
|
||||
.document
|
||||
@@ -28,7 +28,7 @@ fn solid_edge_sources(
|
||||
.filter_map(|entity| {
|
||||
matches!(
|
||||
entity,
|
||||
acadrust::EntityType::Solid3D(_) | acadrust::EntityType::Surface(_)
|
||||
codec::EntityType::Solid3D(_) | codec::EntityType::Surface(_)
|
||||
)
|
||||
.then_some(entity.common().handle)
|
||||
})
|
||||
@@ -146,7 +146,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
cmd if cmd.starts_with("JUSTIFYTEXT ") => {
|
||||
let opt = cmd.split_whitespace().nth(1).unwrap_or("").to_uppercase();
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -164,7 +164,7 @@ impl OpenCADStudio {
|
||||
);
|
||||
return Some(Task::none());
|
||||
}
|
||||
use acadrust::entities::{
|
||||
use codec::entities::{
|
||||
AttachmentPoint as AP, TextHorizontalAlignment as TH,
|
||||
TextVerticalAlignment as TV,
|
||||
};
|
||||
@@ -213,7 +213,7 @@ impl OpenCADStudio {
|
||||
.find(|e| e.common().handle == *h)
|
||||
{
|
||||
match e {
|
||||
acadrust::EntityType::Text(t) => {
|
||||
codec::EntityType::Text(t) => {
|
||||
let mut changed = false;
|
||||
if let Some(a) = text_align {
|
||||
t.horizontal_alignment = a;
|
||||
@@ -228,7 +228,7 @@ impl OpenCADStudio {
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
acadrust::EntityType::MText(m) => {
|
||||
codec::EntityType::MText(m) => {
|
||||
if let Some(a) = mtext_ap {
|
||||
m.attachment_point = a;
|
||||
n += 1;
|
||||
@@ -269,7 +269,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
cmd if cmd.starts_with("TCASE ") => {
|
||||
let opt = cmd.split_whitespace().nth(1).unwrap_or("").to_uppercase();
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -315,11 +315,11 @@ impl OpenCADStudio {
|
||||
.find(|e| e.common().handle == *h)
|
||||
{
|
||||
match e {
|
||||
acadrust::EntityType::Text(t) => {
|
||||
codec::EntityType::Text(t) => {
|
||||
t.value = conv(&t.value);
|
||||
n += 1;
|
||||
}
|
||||
acadrust::EntityType::MText(m) => {
|
||||
codec::EntityType::MText(m) => {
|
||||
m.value = conv(&m.value);
|
||||
n += 1;
|
||||
}
|
||||
@@ -353,14 +353,14 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("TEXTMASK ") => {
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter(|(_, e)| {
|
||||
matches!(
|
||||
e,
|
||||
acadrust::EntityType::Text(_) | acadrust::EntityType::MText(_)
|
||||
codec::EntityType::Text(_) | codec::EntityType::MText(_)
|
||||
)
|
||||
})
|
||||
.map(|(h, _)| *h)
|
||||
@@ -388,20 +388,20 @@ impl OpenCADStudio {
|
||||
continue; // no geometry for this object
|
||||
}
|
||||
let pad = ((max[1] - min[1]) * 0.15).max(0.0);
|
||||
let c1 = acadrust::types::Vector3::new(
|
||||
let c1 = codec::types::Vector3::new(
|
||||
(min[0] - pad) as f64,
|
||||
(min[1] - pad) as f64,
|
||||
min[2] as f64,
|
||||
);
|
||||
let c2 = acadrust::types::Vector3::new(
|
||||
let c2 = codec::types::Vector3::new(
|
||||
(max[0] + pad) as f64,
|
||||
(max[1] + pad) as f64,
|
||||
min[2] as f64,
|
||||
);
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.add_entity_clone(acadrust::EntityType::Wipeout(
|
||||
acadrust::entities::Wipeout::from_corners(c1, c2),
|
||||
.add_entity_clone(codec::EntityType::Wipeout(
|
||||
codec::entities::Wipeout::from_corners(c1, c2),
|
||||
));
|
||||
n += 1;
|
||||
}
|
||||
@@ -436,11 +436,11 @@ impl OpenCADStudio {
|
||||
return Some(Task::none());
|
||||
}
|
||||
};
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter(|(_, e)| matches!(e, acadrust::EntityType::Text(_)))
|
||||
.filter(|(_, e)| matches!(e, codec::EntityType::Text(_)))
|
||||
.map(|(h, _)| *h)
|
||||
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
|
||||
.collect();
|
||||
@@ -464,7 +464,7 @@ impl OpenCADStudio {
|
||||
if cur_w <= 1e-9 {
|
||||
continue;
|
||||
}
|
||||
if let Some(acadrust::EntityType::Text(t)) = self.tabs[i]
|
||||
if let Some(codec::EntityType::Text(t)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities_mut()
|
||||
@@ -533,12 +533,12 @@ impl OpenCADStudio {
|
||||
}
|
||||
};
|
||||
|
||||
let mut texts: Vec<(acadrust::Handle, f64, f64)> = self.tabs[i]
|
||||
let mut texts: Vec<(codec::Handle, f64, f64)> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter_map(|(h, e)| match e {
|
||||
acadrust::EntityType::Text(t)
|
||||
codec::EntityType::Text(t)
|
||||
if !self.tabs[i].scene.is_layer_locked(*h) =>
|
||||
{
|
||||
Some((*h, t.insertion_point.x, t.insertion_point.y))
|
||||
@@ -569,7 +569,7 @@ impl OpenCADStudio {
|
||||
let mut num = start;
|
||||
|
||||
for (h, _, _) in &texts {
|
||||
if let Some(acadrust::EntityType::Text(t)) = self.tabs[i]
|
||||
if let Some(codec::EntityType::Text(t)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities_mut()
|
||||
@@ -624,7 +624,7 @@ impl OpenCADStudio {
|
||||
.objects
|
||||
.iter()
|
||||
.find_map(|(handle, object)| match object {
|
||||
acadrust::objects::ObjectType::MultiLeaderStyle(style)
|
||||
codec::objects::ObjectType::MultiLeaderStyle(style)
|
||||
if style.name.eq_ignore_ascii_case(&name) =>
|
||||
{
|
||||
let mut style = style.clone();
|
||||
@@ -1215,7 +1215,7 @@ impl OpenCADStudio {
|
||||
self.command_line.push_info(&cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd));
|
||||
} else {
|
||||
let replacements: Vec<(acadrust::Handle, Vec<acadrust::EntityType>)> = entities
|
||||
let replacements: Vec<(codec::Handle, Vec<codec::EntityType>)> = entities
|
||||
.iter()
|
||||
.filter_map(|(h, e)| {
|
||||
let pieces = explode_entity(e, &self.tabs[i].scene.document);
|
||||
@@ -1293,7 +1293,7 @@ impl OpenCADStudio {
|
||||
.map(|e| (h, e))
|
||||
})
|
||||
.collect();
|
||||
let initial_edges: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let initial_edges: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.into_iter()
|
||||
@@ -1361,8 +1361,8 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("ARCTEXT ") => {
|
||||
use acadrust::entities::Text;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::Text;
|
||||
use codec::types::Vector3;
|
||||
let text = cmd.strip_prefix("ARCTEXT").unwrap_or("").trim().to_string();
|
||||
if text.is_empty() {
|
||||
self.command_line.push_info(
|
||||
@@ -1376,7 +1376,7 @@ impl OpenCADStudio {
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.find_map(|(_, e)| match e {
|
||||
acadrust::EntityType::Arc(a) => Some(a.clone()),
|
||||
codec::EntityType::Arc(a) => Some(a.clone()),
|
||||
_ => None,
|
||||
});
|
||||
let Some(arc) = arc else {
|
||||
@@ -1406,7 +1406,7 @@ impl OpenCADStudio {
|
||||
let t = Text::with_value(ch.to_string(), pos)
|
||||
.with_height(height)
|
||||
.with_rotation(ang + std::f64::consts::FRAC_PI_2);
|
||||
self.tabs[i].scene.add_entity(acadrust::EntityType::Text(t));
|
||||
self.tabs[i].scene.add_entity(codec::EntityType::Text(t));
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line
|
||||
|
||||
+39
-39
@@ -29,7 +29,7 @@ impl OpenCADStudio {
|
||||
Lock(usize, usize, bool),
|
||||
Block(usize, usize, String),
|
||||
Formula(usize, usize, String),
|
||||
Field(usize, usize, acadrust::Handle),
|
||||
Field(usize, usize, codec::Handle),
|
||||
}
|
||||
let words: Vec<&str> = rest.split_whitespace().collect();
|
||||
let integer = |index: usize| {
|
||||
@@ -120,7 +120,7 @@ impl OpenCADStudio {
|
||||
TableAction::Field(
|
||||
row,
|
||||
column,
|
||||
acadrust::Handle::new(handle),
|
||||
codec::Handle::new(handle),
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl OpenCADStudio {
|
||||
);
|
||||
return Some(Task::none());
|
||||
};
|
||||
let selected_handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected_handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -174,7 +174,7 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "TABLE EDIT");
|
||||
let mut changed = false;
|
||||
for handle in &selected_handles {
|
||||
let Some(acadrust::EntityType::Table(table)) =
|
||||
let Some(codec::EntityType::Table(table)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(*handle)
|
||||
else {
|
||||
continue;
|
||||
@@ -182,7 +182,7 @@ impl OpenCADStudio {
|
||||
match &action {
|
||||
TableAction::Cell(row, column, text) => {
|
||||
if let Some(cell) = table.cell_mut(*row, *column) {
|
||||
use acadrust::entities::table::CellStateFlags;
|
||||
use codec::entities::table::CellStateFlags;
|
||||
if !cell.state.intersects(
|
||||
CellStateFlags::CONTENT_LOCKED
|
||||
| CellStateFlags::CONTENT_READ_ONLY,
|
||||
@@ -229,7 +229,7 @@ impl OpenCADStudio {
|
||||
&& *c1 < table.column_count()
|
||||
&& *c2 < table.column_count() =>
|
||||
{
|
||||
table.merge_cells(acadrust::entities::table::CellRange::new(
|
||||
table.merge_cells(codec::entities::table::CellRange::new(
|
||||
(*r1).min(*r2),
|
||||
(*c1).min(*c2),
|
||||
(*r1).max(*r2),
|
||||
@@ -253,7 +253,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
TableAction::Lock(row, column, locked) => {
|
||||
if let Some(cell) = table.cell_mut(*row, *column) {
|
||||
use acadrust::entities::table::CellStateFlags;
|
||||
use codec::entities::table::CellStateFlags;
|
||||
cell.state.set(CellStateFlags::CONTENT_LOCKED, *locked);
|
||||
cell.state.set(CellStateFlags::FORMAT_LOCKED, *locked);
|
||||
changed = true;
|
||||
@@ -263,7 +263,7 @@ impl OpenCADStudio {
|
||||
if let (Some(handle), Some(cell)) =
|
||||
(block_handle, table.cell_mut(*row, *column))
|
||||
{
|
||||
use acadrust::entities::table::{
|
||||
use codec::entities::table::{
|
||||
CellContent, CellStateFlags, CellType,
|
||||
};
|
||||
if !cell.state.intersects(
|
||||
@@ -279,7 +279,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
TableAction::Formula(row, column, expression) => {
|
||||
if let Some(cell) = table.cell_mut(*row, *column) {
|
||||
use acadrust::entities::table::CellStateFlags;
|
||||
use codec::entities::table::CellStateFlags;
|
||||
if !cell.state.intersects(
|
||||
CellStateFlags::CONTENT_LOCKED
|
||||
| CellStateFlags::CONTENT_READ_ONLY,
|
||||
@@ -297,7 +297,7 @@ impl OpenCADStudio {
|
||||
TableAction::Field(row, column, field_handle) => {
|
||||
let mut attached = false;
|
||||
if let Some(cell) = table.cell_mut(*row, *column) {
|
||||
use acadrust::entities::table::{
|
||||
use codec::entities::table::{
|
||||
CellContent, CellStateFlags, CellType,
|
||||
};
|
||||
if !cell.state.intersects(
|
||||
@@ -371,7 +371,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
let mut count = 0usize;
|
||||
for entity in self.tabs[i].scene.document.entities_mut() {
|
||||
if let acadrust::EntityType::Viewport(vp) = entity {
|
||||
if let codec::EntityType::Viewport(vp) = entity {
|
||||
vp.status.ucs_icon_visible = visible;
|
||||
if sub == "NOORIGIN" || sub == "ORIGIN" {
|
||||
vp.status.ucs_icon_at_origin = at_origin;
|
||||
@@ -391,7 +391,7 @@ impl OpenCADStudio {
|
||||
self.show_ucs_icon = visible;
|
||||
self.ribbon.set_ucs_icon(visible);
|
||||
for entity in self.tabs[i].scene.document.entities_mut() {
|
||||
if let acadrust::EntityType::Viewport(vp) = entity {
|
||||
if let codec::EntityType::Viewport(vp) = entity {
|
||||
vp.status.ucs_icon_visible = visible;
|
||||
}
|
||||
}
|
||||
@@ -611,11 +611,11 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("XDATA ") => {
|
||||
use acadrust::xdata::{ExtendedDataRecord, XDataValue};
|
||||
use codec::xdata::{ExtendedDataRecord, XDataValue};
|
||||
let rest = cmd.trim_start_matches("XDATA").trim();
|
||||
let parts: Vec<&str> = rest.splitn(3, char::is_whitespace).collect();
|
||||
let sub = parts.first().map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
let selected_handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected_handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -960,7 +960,7 @@ impl OpenCADStudio {
|
||||
.split_once(' ')
|
||||
.map(|(_, r)| r.trim().to_uppercase())
|
||||
.unwrap_or_default();
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -977,7 +977,7 @@ impl OpenCADStudio {
|
||||
let mut changed = 0usize;
|
||||
self.push_undo_snapshot(i, "UNDERLAY");
|
||||
for h in &handles {
|
||||
if let Some(acadrust::EntityType::Underlay(ul)) = self.tabs[i]
|
||||
if let Some(codec::EntityType::Underlay(ul)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities_mut()
|
||||
@@ -1007,7 +1007,7 @@ impl OpenCADStudio {
|
||||
"CLIP" => match arg {
|
||||
"ON" => {
|
||||
ul.flags |=
|
||||
acadrust::entities::UnderlayDisplayFlags::CLIPPING;
|
||||
codec::entities::UnderlayDisplayFlags::CLIPPING;
|
||||
changed += 1;
|
||||
}
|
||||
"OFF" => {
|
||||
@@ -1063,7 +1063,7 @@ impl OpenCADStudio {
|
||||
// annotative objects. With no preselection, gather one through the
|
||||
// regular selection engine before applying the action.
|
||||
action @ ("OBJECTSCALE ADD" | "OBJECTSCALE DELETE") => {
|
||||
let selected: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1181,13 +1181,13 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("HYPERLINK ") => {
|
||||
use acadrust::xdata::XDataValue;
|
||||
use codec::xdata::XDataValue;
|
||||
let url = cmd.strip_prefix("HYPERLINK").unwrap_or("").trim().to_string();
|
||||
if url.is_empty() {
|
||||
self.command_line.push_info(crate::t!("Usage: HYPERLINK <url> (select objects first)").as_ref());
|
||||
return Some(Task::none());
|
||||
}
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1242,7 +1242,7 @@ impl OpenCADStudio {
|
||||
let parts: Vec<&str> = rest.splitn(2, char::is_whitespace).collect();
|
||||
let action = parts.first().map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
let arg = parts.get(1).copied().unwrap_or("").trim();
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1261,7 +1261,7 @@ impl OpenCADStudio {
|
||||
let mut changed = 0usize;
|
||||
let mut changed_handles = Vec::new();
|
||||
for h in &handles {
|
||||
if let Some(acadrust::EntityType::RasterImage(img)) = self.tabs[i]
|
||||
if let Some(codec::EntityType::RasterImage(img)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities_mut()
|
||||
@@ -1539,7 +1539,7 @@ impl OpenCADStudio {
|
||||
// Reset every alternate scale representation to the position of
|
||||
// the representation visible at the current annotation scale.
|
||||
"ANNORESET" => {
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1627,8 +1627,8 @@ impl OpenCADStudio {
|
||||
.push_error(crate::t!("DATALINK: the CSV file is empty.").as_ref());
|
||||
return Some(Task::none());
|
||||
}
|
||||
use acadrust::entities::TableBuilder;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::TableBuilder;
|
||||
use codec::types::Vector3;
|
||||
let mut table = TableBuilder::new(nrows, ncols)
|
||||
.at(Vector3::new(0.0, 0.0, 0.0))
|
||||
.row_height(0.5)
|
||||
@@ -1643,7 +1643,7 @@ impl OpenCADStudio {
|
||||
let current_style = doc.header.current_table_style_name.clone();
|
||||
table.table_style_handle = doc.objects.iter().find_map(|(handle, object)| {
|
||||
match object {
|
||||
acadrust::objects::ObjectType::TableStyle(style)
|
||||
codec::objects::ObjectType::TableStyle(style)
|
||||
if style.name.eq_ignore_ascii_case(¤t_style) =>
|
||||
{
|
||||
Some(*handle)
|
||||
@@ -1673,12 +1673,12 @@ impl OpenCADStudio {
|
||||
.trim_start_matches("DATALINKUPDATE")
|
||||
.trim()
|
||||
.eq_ignore_ascii_case("WRITE");
|
||||
let selected: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.into_iter()
|
||||
.filter_map(|(handle, entity)| {
|
||||
matches!(entity, acadrust::EntityType::Table(_)).then_some(handle)
|
||||
matches!(entity, codec::EntityType::Table(_)).then_some(handle)
|
||||
})
|
||||
.collect();
|
||||
let table_handles = if selected.is_empty() {
|
||||
@@ -1687,7 +1687,7 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| {
|
||||
matches!(entity, acadrust::EntityType::Table(_))
|
||||
matches!(entity, codec::EntityType::Table(_))
|
||||
.then_some(entity.common().handle)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
@@ -1696,7 +1696,7 @@ impl OpenCADStudio {
|
||||
};
|
||||
let mut jobs = Vec::new();
|
||||
for handle in &table_handles {
|
||||
let Some(acadrust::EntityType::Table(table)) =
|
||||
let Some(codec::EntityType::Table(table)) =
|
||||
self.tabs[i].scene.document.get_entity(*handle)
|
||||
else {
|
||||
continue;
|
||||
@@ -1720,7 +1720,7 @@ impl OpenCADStudio {
|
||||
let mut written = 0usize;
|
||||
let mut errors = Vec::new();
|
||||
for (table_handle, link_handle) in &jobs {
|
||||
let Some(acadrust::EntityType::Table(table)) =
|
||||
let Some(codec::EntityType::Table(table)) =
|
||||
self.tabs[i].scene.document.get_entity(*table_handle)
|
||||
else {
|
||||
continue;
|
||||
@@ -1764,11 +1764,11 @@ impl OpenCADStudio {
|
||||
return Some(Task::none());
|
||||
}
|
||||
self.push_undo_snapshot(i, "DATALINKUPDATE");
|
||||
use acadrust::entities::table::CellStateFlags;
|
||||
use codec::entities::table::CellStateFlags;
|
||||
let mut changed_handles = Vec::new();
|
||||
for (table_handle, link_handle, rows) in updates {
|
||||
let columns = rows.iter().map(Vec::len).max().unwrap_or(0);
|
||||
let Some(acadrust::EntityType::Table(table)) =
|
||||
let Some(codec::EntityType::Table(table)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(table_handle)
|
||||
else {
|
||||
continue;
|
||||
@@ -1843,11 +1843,11 @@ impl OpenCADStudio {
|
||||
}
|
||||
self.push_undo_snapshot(i, "LANDXMLIMPORT");
|
||||
for [x, y, z] in &pts {
|
||||
let mut p = acadrust::entities::Point::new();
|
||||
p.location = acadrust::types::Vector3::new(*x, *y, *z);
|
||||
let mut p = codec::entities::Point::new();
|
||||
p.location = codec::types::Vector3::new(*x, *y, *z);
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.add_entity_clone(acadrust::EntityType::Point(p));
|
||||
.add_entity_clone(codec::EntityType::Point(p));
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line.push_output(crate::tf!(
|
||||
@@ -1949,7 +1949,7 @@ pub(crate) fn parse_csv_table(text: &str) -> Vec<Vec<String>> {
|
||||
rows
|
||||
}
|
||||
|
||||
pub(crate) fn table_to_csv(table: &acadrust::entities::Table) -> String {
|
||||
pub(crate) fn table_to_csv(table: &codec::entities::Table) -> String {
|
||||
fn escape(value: &str) -> String {
|
||||
if value.contains([',', '"', '\r', '\n']) {
|
||||
format!("\"{}\"", value.replace('"', "\"\""))
|
||||
@@ -2040,7 +2040,7 @@ mod tests {
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let i = app.active_tab;
|
||||
|
||||
let stale = acadrust::Handle::new(0xDEAD);
|
||||
let stale = codec::Handle::new(0xDEAD);
|
||||
app.tabs[i].scene.meshes.insert(stale, stale_mesh());
|
||||
let epoch_before = app.tabs[i].scene.geometry_epoch;
|
||||
|
||||
@@ -2065,7 +2065,7 @@ mod tests {
|
||||
let i = app.active_tab;
|
||||
|
||||
let seed = |app: &mut OpenCADStudio, i: usize| {
|
||||
let stale = acadrust::Handle::new(0xBEEF);
|
||||
let stale = codec::Handle::new(0xBEEF);
|
||||
app.tabs[i].scene.meshes.insert(stale, stale_mesh());
|
||||
stale
|
||||
};
|
||||
|
||||
+50
-50
@@ -23,7 +23,7 @@ impl OpenCADStudio {
|
||||
.objects
|
||||
.iter()
|
||||
.filter_map(|(handle, object)| match object {
|
||||
acadrust::objects::ObjectType::MLineStyle(style) => {
|
||||
codec::objects::ObjectType::MLineStyle(style) => {
|
||||
Some((*handle, style.clone()))
|
||||
}
|
||||
_ => None,
|
||||
@@ -110,7 +110,7 @@ impl OpenCADStudio {
|
||||
.trim_start_matches("ATTEDIT")
|
||||
.trim();
|
||||
let parts: Vec<&str> = rest.splitn(2, char::is_whitespace).collect();
|
||||
let selected_handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected_handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -122,7 +122,7 @@ impl OpenCADStudio {
|
||||
} else {
|
||||
let mut found_any = false;
|
||||
for sh in &selected_handles {
|
||||
if let Some(acadrust::EntityType::Insert(ins)) = self.tabs[i]
|
||||
if let Some(codec::EntityType::Insert(ins)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
@@ -166,7 +166,7 @@ impl OpenCADStudio {
|
||||
if self.tabs[i].scene.is_layer_locked(*sh) {
|
||||
continue;
|
||||
}
|
||||
if let Some(acadrust::EntityType::Insert(ins)) = self.tabs[i]
|
||||
if let Some(codec::EntityType::Insert(ins)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities_mut()
|
||||
@@ -225,7 +225,7 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| {
|
||||
matches!(entity, acadrust::EntityType::AttributeDefinition(_))
|
||||
matches!(entity, codec::EntityType::AttributeDefinition(_))
|
||||
.then_some(entity.common().handle)
|
||||
})
|
||||
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
|
||||
@@ -233,7 +233,7 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "ATTDISP");
|
||||
let mut count = 0usize;
|
||||
for handle in handles {
|
||||
if let Some(acadrust::EntityType::AttributeDefinition(ad)) =
|
||||
if let Some(codec::EntityType::AttributeDefinition(ad)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
match sub.as_str() {
|
||||
@@ -488,7 +488,7 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| match entity {
|
||||
acadrust::EntityType::Face3D(face) => {
|
||||
codec::EntityType::Face3D(face) => {
|
||||
Some((face.common.handle, face.clone()))
|
||||
}
|
||||
_ => None,
|
||||
@@ -549,12 +549,12 @@ impl OpenCADStudio {
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|handle| {
|
||||
let Some(acadrust::EntityType::Line(line)) =
|
||||
let Some(codec::EntityType::Line(line)) =
|
||||
self.tabs[i].scene.document.get_entity(*handle)
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
acadrust::entities::CenterMarkAssociation::read(&line.common.extended_data)
|
||||
codec::entities::CenterMarkAssociation::read(&line.common.extended_data)
|
||||
.is_some()
|
||||
})
|
||||
.collect();
|
||||
@@ -793,7 +793,7 @@ impl OpenCADStudio {
|
||||
let normal = working_plane.z.normalize_or(glam::DVec3::Z);
|
||||
let elevation = working_plane.origin.dot(normal);
|
||||
let storage = crate::entities::curve::ocs_plane(
|
||||
acadrust::types::Vector3::new(normal.x, normal.y, normal.z),
|
||||
codec::types::Vector3::new(normal.x, normal.y, normal.z),
|
||||
elevation,
|
||||
);
|
||||
let plane = crate::command::WorkingPlane::new(
|
||||
@@ -837,7 +837,7 @@ impl OpenCADStudio {
|
||||
)
|
||||
});
|
||||
let (scale, angle) = match entity {
|
||||
Some(acadrust::EntityType::Hatch(hatch)) => (
|
||||
Some(codec::EntityType::Hatch(hatch)) => (
|
||||
hatch.pattern_scale as f32,
|
||||
hatch.pattern_angle.to_degrees() as f32,
|
||||
),
|
||||
@@ -1131,7 +1131,7 @@ impl OpenCADStudio {
|
||||
self.command_line.push_output("No constraints found.");
|
||||
return None;
|
||||
}
|
||||
let dimensions: Vec<acadrust::Handle> = ids
|
||||
let dimensions: Vec<codec::Handle> = ids
|
||||
.iter()
|
||||
.filter_map(|id| before.dimensions.get(id).copied())
|
||||
.collect();
|
||||
@@ -1456,7 +1456,7 @@ impl OpenCADStudio {
|
||||
annotational,
|
||||
decimals,
|
||||
);
|
||||
if let Some(acadrust::EntityType::Dimension(mut dimension)) =
|
||||
if let Some(codec::EntityType::Dimension(mut dimension)) =
|
||||
self.tabs[i].scene.document.get_entity(handle).cloned()
|
||||
{
|
||||
let before = self.tabs[i].scene.document.get_entity_arc(handle);
|
||||
@@ -1472,7 +1472,7 @@ impl OpenCADStudio {
|
||||
dimension.base_mut().common.layer =
|
||||
crate::scene::parametric_constraints::DYNAMIC_DIMENSION_LAYER
|
||||
.to_string();
|
||||
dimension.base_mut().common.color = acadrust::types::Color::Rgb {
|
||||
dimension.base_mut().common.color = codec::types::Color::Rgb {
|
||||
r: 103,
|
||||
g: 109,
|
||||
b: 118,
|
||||
@@ -1480,7 +1480,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.update_entity(acadrust::EntityType::Dimension(dimension));
|
||||
.update_entity(codec::EntityType::Dimension(dimension));
|
||||
}
|
||||
let set = self.tabs[i].scene.parametric_constraint_set_mut(scope);
|
||||
let id = set.add(kind, refs, Some(DrivingValue::Named(name)));
|
||||
@@ -1554,7 +1554,7 @@ impl OpenCADStudio {
|
||||
return Some(self.apply_cmd_result(CmdResult::AddHorizontalConstraint {
|
||||
kind,
|
||||
selection: HorizontalConstraintSelection::Reference(reference),
|
||||
direction: acadrust::types::Vector3::new(
|
||||
direction: codec::types::Vector3::new(
|
||||
direction.x,
|
||||
direction.y,
|
||||
direction.z,
|
||||
@@ -2105,7 +2105,7 @@ impl OpenCADStudio {
|
||||
.filter(|handle| {
|
||||
matches!(
|
||||
self.tabs[i].scene.document.get_entity(*handle),
|
||||
Some(acadrust::EntityType::Solid3D(_))
|
||||
Some(codec::EntityType::Solid3D(_))
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -2166,12 +2166,12 @@ impl OpenCADStudio {
|
||||
matches!(
|
||||
scene.document.get_entity(*handle),
|
||||
Some(
|
||||
acadrust::EntityType::Solid3D(_)
|
||||
| acadrust::EntityType::Region(_)
|
||||
| acadrust::EntityType::Surface(_)
|
||||
| acadrust::EntityType::Mesh(_)
|
||||
| acadrust::EntityType::PolygonMesh(_)
|
||||
| acadrust::EntityType::PolyfaceMesh(_)
|
||||
codec::EntityType::Solid3D(_)
|
||||
| codec::EntityType::Region(_)
|
||||
| codec::EntityType::Surface(_)
|
||||
| codec::EntityType::Mesh(_)
|
||||
| codec::EntityType::PolygonMesh(_)
|
||||
| codec::EntityType::PolyfaceMesh(_)
|
||||
)
|
||||
)
|
||||
})
|
||||
@@ -2180,9 +2180,9 @@ impl OpenCADStudio {
|
||||
matches!(
|
||||
scene.document.get_entity(*handle),
|
||||
Some(
|
||||
acadrust::EntityType::Mesh(_)
|
||||
| acadrust::EntityType::PolygonMesh(_)
|
||||
| acadrust::EntityType::PolyfaceMesh(_)
|
||||
codec::EntityType::Mesh(_)
|
||||
| codec::EntityType::PolygonMesh(_)
|
||||
| codec::EntityType::PolyfaceMesh(_)
|
||||
)
|
||||
)
|
||||
});
|
||||
@@ -2218,12 +2218,12 @@ impl OpenCADStudio {
|
||||
.find(|(_, entity)| {
|
||||
matches!(
|
||||
entity,
|
||||
acadrust::EntityType::Line(_)
|
||||
| acadrust::EntityType::Arc(_)
|
||||
| acadrust::EntityType::Circle(_)
|
||||
| acadrust::EntityType::Ellipse(_)
|
||||
| acadrust::EntityType::LwPolyline(_)
|
||||
| acadrust::EntityType::Spline(_)
|
||||
codec::EntityType::Line(_)
|
||||
| codec::EntityType::Arc(_)
|
||||
| codec::EntityType::Circle(_)
|
||||
| codec::EntityType::Ellipse(_)
|
||||
| codec::EntityType::LwPolyline(_)
|
||||
| codec::EntityType::Spline(_)
|
||||
)
|
||||
})
|
||||
.map(|(handle, entity)| (handle, entity.clone()));
|
||||
@@ -2246,18 +2246,18 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
return Some(iced::Task::none());
|
||||
}
|
||||
use acadrust::entities::Region;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::Region;
|
||||
use codec::types::Vector3;
|
||||
let mut regions = Vec::new();
|
||||
let mut sources = Vec::new();
|
||||
for (handle, e) in self.tabs[i].scene.selected_entities().iter() {
|
||||
if !matches!(e, acadrust::EntityType::Region(_)) {
|
||||
if !matches!(e, codec::EntityType::Region(_)) {
|
||||
let Some((plane, loops, true)) =
|
||||
crate::scene::model::presspull_model::profile_geometry(e)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let Some(body) = cadkernel::brep::planar_region(plane, &loops) else {
|
||||
let Some(body) = kernel::brep::planar_region(plane, &loops) else {
|
||||
continue;
|
||||
};
|
||||
let mut region = Region::new();
|
||||
@@ -2276,7 +2276,7 @@ impl OpenCADStudio {
|
||||
.filter(|(handle, _)| !sources.contains(handle))
|
||||
.filter_map(|(_, entity)| crate::entities::curve::entity_curve(entity))
|
||||
.collect();
|
||||
let open_plane = cadkernel::space::common_curve_plane(&open_curves, 1.0e-6);
|
||||
let open_plane = kernel::space::common_curve_plane(&open_curves, 1.0e-6);
|
||||
let open_plane_rejected = !open_curves.is_empty() && open_plane.is_none();
|
||||
if let Some(plane) = open_plane {
|
||||
let working_plane = crate::command::WorkingPlane::new(
|
||||
@@ -2314,7 +2314,7 @@ impl OpenCADStudio {
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let Some(body) = cadkernel::brep::planar_region(plane, &[curves]) else {
|
||||
let Some(body) = kernel::brep::planar_region(plane, &[curves]) else {
|
||||
continue;
|
||||
};
|
||||
let mut region = Region::new();
|
||||
@@ -2427,10 +2427,10 @@ impl OpenCADStudio {
|
||||
.filter_map(|entity| {
|
||||
matches!(
|
||||
entity,
|
||||
acadrust::EntityType::Solid3D(_)
|
||||
| acadrust::EntityType::Surface(_)
|
||||
| acadrust::EntityType::Region(_)
|
||||
| acadrust::EntityType::Body(_)
|
||||
codec::EntityType::Solid3D(_)
|
||||
| codec::EntityType::Surface(_)
|
||||
| codec::EntityType::Region(_)
|
||||
| codec::EntityType::Body(_)
|
||||
)
|
||||
.then_some(entity.common().handle)
|
||||
})
|
||||
@@ -2452,10 +2452,10 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| {
|
||||
let acadrust::EntityType::Extended(extended) = entity else {
|
||||
let codec::EntityType::Extended(extended) = entity else {
|
||||
return None;
|
||||
};
|
||||
let acadrust::entities::ExtendedEntityData::SectionObject(data) =
|
||||
let codec::entities::ExtendedEntityData::SectionObject(data) =
|
||||
&extended.data
|
||||
else {
|
||||
return None;
|
||||
@@ -2583,8 +2583,8 @@ impl OpenCADStudio {
|
||||
matches!(
|
||||
scene.document.get_entity(*handle),
|
||||
Some(
|
||||
acadrust::EntityType::Solid3D(_)
|
||||
| acadrust::EntityType::Surface(_)
|
||||
codec::EntityType::Solid3D(_)
|
||||
| codec::EntityType::Surface(_)
|
||||
)
|
||||
)
|
||||
})
|
||||
@@ -2641,7 +2641,7 @@ impl OpenCADStudio {
|
||||
1 => ([0.0, v, 0.0], [0.0, 0.0, 1.0], [0.0, 1.0, 0.0]),
|
||||
_ => ([0.0, 0.0, v], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]),
|
||||
};
|
||||
let plane = cadkernel::space::Plane::orthonormal(origin, x, normal)
|
||||
let plane = kernel::space::Plane::orthonormal(origin, x, normal)
|
||||
.expect("fixed world axes define a plane");
|
||||
let side = glam::DVec3::from_array(origin)
|
||||
+ glam::DVec3::from_array(normal) * if keep_low { -1.0 } else { 1.0 };
|
||||
@@ -2680,7 +2680,7 @@ impl OpenCADStudio {
|
||||
let editable = (sel.len() == 1).then(|| sel[0].0).filter(|h| {
|
||||
self.tabs[i].scene.document.get_entity(*h).is_some_and(|e| {
|
||||
super::super::text_inline::read_text_field(e).is_some()
|
||||
|| matches!(e, acadrust::EntityType::Leader(_))
|
||||
|| matches!(e, codec::EntityType::Leader(_))
|
||||
})
|
||||
});
|
||||
if let Some(h) = editable {
|
||||
@@ -2759,7 +2759,7 @@ mod region_tests {
|
||||
.map(|entity| {
|
||||
(
|
||||
entity.common().handle,
|
||||
matches!(entity, acadrust::EntityType::Circle(_)),
|
||||
matches!(entity, codec::EntityType::Circle(_)),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
@@ -2780,7 +2780,7 @@ mod region_tests {
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
.filter(|entity| matches!(entity, acadrust::EntityType::Region(_)))
|
||||
.filter(|entity| matches!(entity, codec::EntityType::Region(_)))
|
||||
.count();
|
||||
assert_eq!(region_count, 1);
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
for e in self.tabs[i].scene.document.entities() {
|
||||
if let acadrust::EntityType::RasterImage(img) = e {
|
||||
if let codec::EntityType::RasterImage(img) = e {
|
||||
if !img.file_path.trim().is_empty() {
|
||||
deps.push(img.file_path.clone());
|
||||
}
|
||||
|
||||
+130
-130
@@ -4,7 +4,7 @@ impl OpenCADStudio {
|
||||
/// Align every selected object or complete group by one edge or center.
|
||||
fn align_selected_bounds(&mut self, i: usize, command: &str) {
|
||||
use crate::command::EntityTransform;
|
||||
use cadkernel::space::BoundsAlignment;
|
||||
use kernel::space::BoundsAlignment;
|
||||
use glam::DVec3;
|
||||
|
||||
let (alignment, label) = match command {
|
||||
@@ -58,7 +58,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
let extents: Vec<_> = bounds.iter().map(|(_, bounds)| *bounds).collect();
|
||||
let offsets = cadkernel::space::align_aabbs_2d(&extents, alignment)
|
||||
let offsets = kernel::space::align_aabbs_2d(&extents, alignment)
|
||||
.expect("validated at least two finite bounds");
|
||||
let pending = self.begin_undo(i, label, handles.len(), true);
|
||||
for ((unit, _), [dx, dy]) in bounds.iter().zip(offsets) {
|
||||
@@ -207,7 +207,7 @@ impl OpenCADStudio {
|
||||
*type_counts
|
||||
.entry(crate::entities::names::dxf_name(e))
|
||||
.or_default() += 1;
|
||||
if let acadrust::EntityType::Insert(ins) = e {
|
||||
if let codec::EntityType::Insert(ins) = e {
|
||||
*block_counts.entry(ins.block_name.clone()).or_default() += 1;
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ impl OpenCADStudio {
|
||||
use crate::modules::draw::modify::join::JoinCommand;
|
||||
// Pickfirst: with objects already selected, join them right
|
||||
// away instead of asking for a selection again.
|
||||
let selected: Vec<acadrust::Handle> =
|
||||
let selected: Vec<codec::Handle> =
|
||||
self.tabs[i].scene.selected.iter().copied().collect();
|
||||
if selected.len() >= 2 {
|
||||
let task =
|
||||
@@ -325,8 +325,8 @@ impl OpenCADStudio {
|
||||
.filter_map(|e| {
|
||||
let h = e.common().handle.value();
|
||||
match e {
|
||||
acadrust::EntityType::LwPolyline(_)
|
||||
| acadrust::EntityType::Polyline2D(_) => Some((
|
||||
codec::EntityType::LwPolyline(_)
|
||||
| codec::EntityType::Polyline2D(_) => Some((
|
||||
h,
|
||||
PeditTarget {
|
||||
is_poly: true,
|
||||
@@ -335,7 +335,7 @@ impl OpenCADStudio {
|
||||
mesh_closed: None,
|
||||
},
|
||||
)),
|
||||
acadrust::EntityType::Line(_) | acadrust::EntityType::Arc(_) => {
|
||||
codec::EntityType::Line(_) | codec::EntityType::Arc(_) => {
|
||||
Some((
|
||||
h,
|
||||
PeditTarget {
|
||||
@@ -346,7 +346,7 @@ impl OpenCADStudio {
|
||||
},
|
||||
))
|
||||
}
|
||||
acadrust::EntityType::PolygonMesh(mesh) => Some((
|
||||
codec::EntityType::PolygonMesh(mesh) => Some((
|
||||
h,
|
||||
PeditTarget {
|
||||
is_poly: true,
|
||||
@@ -364,7 +364,7 @@ impl OpenCADStudio {
|
||||
.collect();
|
||||
// Pickfirst: an already-selected polyline (or line/arc, via
|
||||
// the convert prompt) skips the select step.
|
||||
let preselected: Vec<acadrust::Handle> =
|
||||
let preselected: Vec<codec::Handle> =
|
||||
self.tabs[i].scene.selected.iter().copied().collect();
|
||||
let header = &self.tabs[i].scene.document.header;
|
||||
let cmd_obj = PeditCommand::new(
|
||||
@@ -387,12 +387,12 @@ impl OpenCADStudio {
|
||||
let targets = document
|
||||
.entities()
|
||||
.filter_map(|entity| {
|
||||
let acadrust::EntityType::MLine(mline) = entity else {
|
||||
let codec::EntityType::MLine(mline) = entity else {
|
||||
return None;
|
||||
};
|
||||
let style = crate::entities::mline::resolved_mline_style(mline, document)
|
||||
.cloned()
|
||||
.unwrap_or_else(acadrust::objects::MLineStyle::standard);
|
||||
.unwrap_or_else(codec::objects::MLineStyle::standard);
|
||||
Some((
|
||||
entity.common().handle.value(),
|
||||
MlineEditTarget {
|
||||
@@ -412,7 +412,7 @@ impl OpenCADStudio {
|
||||
let mut cmd_obj = SplineditCommand::new().with_delete_source(self.delete_objects != 0);
|
||||
let selected: Vec<_> = self.tabs[i].scene.selected.iter().copied().collect();
|
||||
if let [handle] = selected.as_slice() {
|
||||
if let Some(entity @ acadrust::EntityType::Spline(_)) =
|
||||
if let Some(entity @ codec::EntityType::Spline(_)) =
|
||||
self.tabs[i].scene.document.get_entity(*handle).cloned()
|
||||
{
|
||||
if self.reject_locked_edit(i, *handle) { return Some(Task::none()); }
|
||||
@@ -444,7 +444,7 @@ impl OpenCADStudio {
|
||||
let selected: Vec<_> =
|
||||
self.tabs[i].scene.selected_entities().into_iter().collect();
|
||||
if selected.len() == 1 {
|
||||
if let Some(acadrust::EntityType::Insert(_)) =
|
||||
if let Some(codec::EntityType::Insert(_)) =
|
||||
selected.first().map(|(_, e)| e)
|
||||
{
|
||||
let handle = selected[0].0;
|
||||
@@ -470,7 +470,7 @@ impl OpenCADStudio {
|
||||
let selected: Vec<_> =
|
||||
self.tabs[i].scene.selected_entities().into_iter().collect();
|
||||
if selected.len() == 1 {
|
||||
if let Some(acadrust::EntityType::Insert(_)) =
|
||||
if let Some(codec::EntityType::Insert(_)) =
|
||||
selected.first().map(|(_, e)| e)
|
||||
{
|
||||
let handle = selected[0].0;
|
||||
@@ -487,7 +487,7 @@ impl OpenCADStudio {
|
||||
|
||||
cmd if cmd.starts_with("BEDIT_BEGIN:") => {
|
||||
use crate::modules::draw::modify::block_edit::BlockEditSession;
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
|
||||
let handle_u64: u64 = cmd["BEDIT_BEGIN:".len()..].parse().unwrap_or(0);
|
||||
let insert_handle = Handle::new(handle_u64);
|
||||
@@ -496,7 +496,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
let block_name = match self.tabs[i].scene.document.get_entity(insert_handle) {
|
||||
Some(acadrust::EntityType::Insert(ins)) => ins.block_name.clone(),
|
||||
Some(codec::EntityType::Insert(ins)) => ins.block_name.clone(),
|
||||
_ => {
|
||||
self.command_line
|
||||
.push_error(crate::t!("BEDIT: selected object is not a block reference.").as_ref());
|
||||
@@ -563,7 +563,7 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| match entity {
|
||||
acadrust::EntityType::Insert(reference)
|
||||
codec::EntityType::Insert(reference)
|
||||
if reference.block_name.eq_ignore_ascii_case(&block_name)
|
||||
&& !reference.attributes.is_empty() =>
|
||||
{
|
||||
@@ -735,7 +735,7 @@ impl OpenCADStudio {
|
||||
let _ = self.tabs[i].scene.document.add_entity(entity);
|
||||
}
|
||||
for (handle, attributes) in session.reference_attributes {
|
||||
if let Some(acadrust::EntityType::Insert(reference)) =
|
||||
if let Some(codec::EntityType::Insert(reference)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
{
|
||||
reference.attributes = attributes;
|
||||
@@ -765,7 +765,7 @@ impl OpenCADStudio {
|
||||
use crate::modules::draw::modify::refedit::{
|
||||
apply_insert_transform, RefEditSession,
|
||||
};
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
|
||||
let handle_u64: u64 = cmd["REFEDIT_BEGIN:".len()..].parse().unwrap_or(0);
|
||||
let insert_handle = Handle::new(handle_u64);
|
||||
@@ -775,7 +775,7 @@ impl OpenCADStudio {
|
||||
|
||||
// Get INSERT entity.
|
||||
let insert = match self.tabs[i].scene.document.get_entity(insert_handle) {
|
||||
Some(acadrust::EntityType::Insert(ins)) => ins.clone(),
|
||||
Some(codec::EntityType::Insert(ins)) => ins.clone(),
|
||||
_ => {
|
||||
self.command_line
|
||||
.push_error(crate::t!("REFEDIT: selected object is not an INSERT.").as_ref());
|
||||
@@ -791,7 +791,7 @@ impl OpenCADStudio {
|
||||
let sz = insert.z_scale();
|
||||
let forward = insert.get_transform();
|
||||
let inverse = {
|
||||
use acadrust::types::{Matrix3, Matrix4, Transform};
|
||||
use codec::types::{Matrix3, Matrix4, Transform};
|
||||
let ocs_t =
|
||||
Matrix4::from_matrix3(Matrix3::arbitrary_axis(insert.normal).transpose());
|
||||
let t_inv = Matrix4::translation(
|
||||
@@ -836,9 +836,9 @@ impl OpenCADStudio {
|
||||
.filter(|e| {
|
||||
!matches!(
|
||||
e,
|
||||
acadrust::EntityType::Block(_)
|
||||
| acadrust::EntityType::BlockEnd(_)
|
||||
| acadrust::EntityType::AttributeDefinition(_)
|
||||
codec::EntityType::Block(_)
|
||||
| codec::EntityType::BlockEnd(_)
|
||||
| codec::EntityType::AttributeDefinition(_)
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
@@ -871,8 +871,8 @@ impl OpenCADStudio {
|
||||
let mut temp_handles = Vec::new();
|
||||
for mut entity in block_entities {
|
||||
apply_insert_transform(&mut entity, &session);
|
||||
entity.common_mut().handle = acadrust::Handle::NULL;
|
||||
entity.common_mut().owner_handle = acadrust::Handle::NULL;
|
||||
entity.common_mut().handle = codec::Handle::NULL;
|
||||
entity.common_mut().owner_handle = codec::Handle::NULL;
|
||||
let h = self.tabs[i].scene.add_entity(entity);
|
||||
temp_handles.push(h);
|
||||
}
|
||||
@@ -933,7 +933,7 @@ impl OpenCADStudio {
|
||||
// offset entities carry handles at or above the watermark) —
|
||||
// those must fold into the block too, not stay behind in
|
||||
// model space (#423).
|
||||
let working: Vec<acadrust::Handle> = {
|
||||
let working: Vec<codec::Handle> = {
|
||||
let space = self.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let drawn = self.tabs[i].scene.document.entities().filter(|e| {
|
||||
let c = e.common();
|
||||
@@ -950,7 +950,7 @@ impl OpenCADStudio {
|
||||
};
|
||||
|
||||
// Collect the edited temp entities.
|
||||
let new_entities: Vec<acadrust::EntityType> = working
|
||||
let new_entities: Vec<codec::EntityType> = working
|
||||
.iter()
|
||||
.filter_map(|h| self.tabs[i].scene.document.get_entity(*h).cloned())
|
||||
.collect();
|
||||
@@ -964,7 +964,7 @@ impl OpenCADStudio {
|
||||
.map(|mut entity| {
|
||||
apply_insert_inverse_transform(&mut entity, &session);
|
||||
let mut entity = normalize_entity_for_block(entity);
|
||||
entity.common_mut().handle = acadrust::Handle::NULL;
|
||||
entity.common_mut().handle = codec::Handle::NULL;
|
||||
entity.common_mut().owner_handle = session.br_handle;
|
||||
entity
|
||||
})
|
||||
@@ -1021,7 +1021,7 @@ impl OpenCADStudio {
|
||||
};
|
||||
// Remove the working set without modifying the block — the
|
||||
// temp copies plus anything created during the session (#423).
|
||||
let working: Vec<acadrust::Handle> = {
|
||||
let working: Vec<codec::Handle> = {
|
||||
let space = self.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let drawn = self.tabs[i].scene.document.entities().filter(|e| {
|
||||
let c = e.common();
|
||||
@@ -1047,7 +1047,7 @@ impl OpenCADStudio {
|
||||
"ALIGN" => {
|
||||
use crate::modules::draw::modify::align::AlignCommand;
|
||||
|
||||
let selected: Vec<acadrust::Handle> =
|
||||
let selected: Vec<codec::Handle> =
|
||||
self.tabs[i].scene.selected.iter().copied().collect();
|
||||
|
||||
let cmd = AlignCommand::with_selection(selected);
|
||||
@@ -1131,7 +1131,7 @@ impl OpenCADStudio {
|
||||
|
||||
// ── FLATTEN — move selected (or all) entities to Z=0 ─────────────
|
||||
"FLATTEN" => {
|
||||
let handles: Vec<acadrust::Handle> = {
|
||||
let handles: Vec<codec::Handle> = {
|
||||
let scene = &self.tabs[i].scene;
|
||||
let sel = self.tabs[i].scene.selected_entities();
|
||||
if sel.is_empty() {
|
||||
@@ -1201,7 +1201,7 @@ impl OpenCADStudio {
|
||||
let prop = parts.first().map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
let val = parts.get(1).map(|s| s.trim()).unwrap_or("").to_uppercase();
|
||||
|
||||
let matched: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let matched: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
@@ -1316,7 +1316,7 @@ impl OpenCADStudio {
|
||||
} else {
|
||||
let search_lc = search.to_lowercase();
|
||||
let mut count = 0usize;
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
@@ -1475,7 +1475,7 @@ impl OpenCADStudio {
|
||||
// A dimension template also carries its dimension style, adopted
|
||||
// as the current DIMSTYLE so the cloned dimension matches (#239).
|
||||
match e {
|
||||
acadrust::EntityType::Dimension(d) => Some(d.base().style_name.clone()),
|
||||
codec::EntityType::Dimension(d) => Some(d.base().style_name.clone()),
|
||||
_ => None,
|
||||
},
|
||||
)
|
||||
@@ -1536,7 +1536,7 @@ impl OpenCADStudio {
|
||||
.layers
|
||||
.get(&layer)
|
||||
.map(|l| l.handle)
|
||||
.unwrap_or(acadrust::types::Handle::NULL);
|
||||
.unwrap_or(codec::types::Handle::NULL);
|
||||
let lt_handle = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
@@ -1544,7 +1544,7 @@ impl OpenCADStudio {
|
||||
.iter()
|
||||
.find(|x| x.name.eq_ignore_ascii_case(&linetype))
|
||||
.map(|x| x.handle)
|
||||
.unwrap_or(acadrust::types::Handle::NULL);
|
||||
.unwrap_or(codec::types::Handle::NULL);
|
||||
{
|
||||
let header = &mut self.tabs[i].scene.document.header;
|
||||
header.current_layer_name = layer.clone();
|
||||
@@ -1565,7 +1565,7 @@ impl OpenCADStudio {
|
||||
.iter()
|
||||
.find(|s| s.name.eq_ignore_ascii_case(ds))
|
||||
.map(|s| s.handle)
|
||||
.unwrap_or(acadrust::types::Handle::NULL);
|
||||
.unwrap_or(codec::types::Handle::NULL);
|
||||
let header = &mut self.tabs[i].scene.document.header;
|
||||
header.current_dimstyle_name = ds.clone();
|
||||
header.current_dimstyle_handle = ds_handle;
|
||||
@@ -1622,8 +1622,8 @@ impl OpenCADStudio {
|
||||
/// Map a template entity to the draw-command verb that creates the same kind of
|
||||
/// object, or `None` when there is no interactive creator for it. Used by
|
||||
/// ADDSELECTED (issue #239).
|
||||
fn add_selected_verb(entity: &acadrust::EntityType) -> Option<&'static str> {
|
||||
use acadrust::EntityType;
|
||||
fn add_selected_verb(entity: &codec::EntityType) -> Option<&'static str> {
|
||||
use codec::EntityType;
|
||||
Some(match entity {
|
||||
EntityType::Point(_) => "POINT",
|
||||
EntityType::Line(_) => "LINE",
|
||||
@@ -1644,7 +1644,7 @@ fn add_selected_verb(entity: &acadrust::EntityType) -> Option<&'static str> {
|
||||
// Dimensions launch the matching dimension command by their stored type
|
||||
// (issue #239). Angular 2-line and 3-point both use DIMANGULAR.
|
||||
EntityType::Dimension(d) => {
|
||||
use acadrust::entities::DimensionType;
|
||||
use codec::entities::DimensionType;
|
||||
match d.base().dimension_type {
|
||||
DimensionType::Linear => "DIMLINEAR",
|
||||
DimensionType::Aligned => "DIMALIGNED",
|
||||
@@ -1660,10 +1660,10 @@ fn add_selected_verb(entity: &acadrust::EntityType) -> Option<&'static str> {
|
||||
})
|
||||
}
|
||||
|
||||
fn entity_list_details(entity: &acadrust::EntityType) -> String {
|
||||
fn entity_list_details(entity: &codec::EntityType) -> String {
|
||||
use std::f64::consts::PI;
|
||||
match entity {
|
||||
acadrust::EntityType::Line(l) => crate::tf!(
|
||||
codec::EntityType::Line(l) => crate::tf!(
|
||||
"from ({:.4},{:.4},{:.4}) to ({:.4},{:.4},{:.4}) len={:.4}",
|
||||
l.start.x,
|
||||
l.start.y,
|
||||
@@ -1676,7 +1676,7 @@ fn entity_list_details(entity: &acadrust::EntityType) -> String {
|
||||
+ (l.end.z - l.start.z).powi(2))
|
||||
.sqrt()
|
||||
).into_owned(),
|
||||
acadrust::EntityType::Circle(c) => crate::tf!(
|
||||
codec::EntityType::Circle(c) => crate::tf!(
|
||||
"center ({:.4},{:.4},{:.4}) r={:.4} area={:.4}",
|
||||
c.center.x,
|
||||
c.center.y,
|
||||
@@ -1684,7 +1684,7 @@ fn entity_list_details(entity: &acadrust::EntityType) -> String {
|
||||
c.radius,
|
||||
PI * c.radius * c.radius
|
||||
).into_owned(),
|
||||
acadrust::EntityType::Arc(a) => crate::tf!(
|
||||
codec::EntityType::Arc(a) => crate::tf!(
|
||||
"center ({:.4},{:.4},{:.4}) r={:.4} start={:.2}° end={:.2}°",
|
||||
a.center.x,
|
||||
a.center.y,
|
||||
@@ -1693,24 +1693,24 @@ fn entity_list_details(entity: &acadrust::EntityType) -> String {
|
||||
a.start_angle.to_degrees(),
|
||||
a.end_angle.to_degrees()
|
||||
).into_owned(),
|
||||
acadrust::EntityType::LwPolyline(p) => crate::tf!(
|
||||
codec::EntityType::LwPolyline(p) => crate::tf!(
|
||||
"{} vertices closed={} elevation={:.4}",
|
||||
p.vertices.len(),
|
||||
p.is_closed,
|
||||
p.elevation
|
||||
).into_owned(),
|
||||
acadrust::EntityType::Text(t) => crate::tf!(
|
||||
codec::EntityType::Text(t) => crate::tf!(
|
||||
"\"{}\" h={:.4} at ({:.4},{:.4})",
|
||||
t.value, t.height, t.insertion_point.x, t.insertion_point.y
|
||||
).into_owned(),
|
||||
acadrust::EntityType::MText(t) => crate::tf!(
|
||||
codec::EntityType::MText(t) => crate::tf!(
|
||||
"\"{}\" h={:.4} at ({:.4},{:.4})",
|
||||
t.value.chars().take(40).collect::<String>(),
|
||||
t.height,
|
||||
t.insertion_point.x,
|
||||
t.insertion_point.y
|
||||
).into_owned(),
|
||||
acadrust::EntityType::Insert(ins) => crate::tf!(
|
||||
codec::EntityType::Insert(ins) => crate::tf!(
|
||||
"block=\"{}\" at ({:.4},{:.4},{:.4}) scale=({:.4},{:.4},{:.4}) rot={:.2}°",
|
||||
ins.block_name,
|
||||
ins.insert_point.x,
|
||||
@@ -1721,13 +1721,13 @@ fn entity_list_details(entity: &acadrust::EntityType) -> String {
|
||||
ins.z_scale(),
|
||||
ins.rotation.to_degrees()
|
||||
).into_owned(),
|
||||
acadrust::EntityType::Spline(s) => crate::tf!(
|
||||
codec::EntityType::Spline(s) => crate::tf!(
|
||||
"{} ctrl pts degree={} closed={}",
|
||||
s.control_points.len(),
|
||||
s.degree,
|
||||
s.flags.closed
|
||||
).into_owned(),
|
||||
acadrust::EntityType::Ellipse(e) => crate::tf!(
|
||||
codec::EntityType::Ellipse(e) => crate::tf!(
|
||||
"center ({:.4},{:.4}) major_len={:.4} ratio={:.4}",
|
||||
e.center.x,
|
||||
e.center.y,
|
||||
@@ -1738,40 +1738,40 @@ fn entity_list_details(entity: &acadrust::EntityType) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn flatten_entity_z(entity: &acadrust::EntityType) -> Option<acadrust::EntityType> {
|
||||
use acadrust::types::Vector3;
|
||||
fn flatten_entity_z(entity: &codec::EntityType) -> Option<codec::EntityType> {
|
||||
use codec::types::Vector3;
|
||||
|
||||
let flattened = match entity {
|
||||
acadrust::EntityType::Circle(_)
|
||||
| acadrust::EntityType::Arc(_)
|
||||
| acadrust::EntityType::Ellipse(_)
|
||||
| acadrust::EntityType::LwPolyline(_)
|
||||
| acadrust::EntityType::Polyline2D(_) => flatten_curve_entity(entity)?,
|
||||
acadrust::EntityType::Line(source) => {
|
||||
codec::EntityType::Circle(_)
|
||||
| codec::EntityType::Arc(_)
|
||||
| codec::EntityType::Ellipse(_)
|
||||
| codec::EntityType::LwPolyline(_)
|
||||
| codec::EntityType::Polyline2D(_) => flatten_curve_entity(entity)?,
|
||||
codec::EntityType::Line(source) => {
|
||||
let mut line = source.clone();
|
||||
line.start = flatten_point(line.start)?;
|
||||
line.end = flatten_point(line.end)?;
|
||||
line.thickness = 0.0;
|
||||
line.normal = Vector3::UNIT_Z;
|
||||
acadrust::EntityType::Line(line)
|
||||
codec::EntityType::Line(line)
|
||||
}
|
||||
acadrust::EntityType::Polyline(source) => {
|
||||
codec::EntityType::Polyline(source) => {
|
||||
let mut polyline = source.clone();
|
||||
for vertex in &mut polyline.vertices {
|
||||
vertex.location = flatten_point(vertex.location)?;
|
||||
}
|
||||
acadrust::EntityType::Polyline(polyline)
|
||||
codec::EntityType::Polyline(polyline)
|
||||
}
|
||||
acadrust::EntityType::Polyline3D(source) => {
|
||||
codec::EntityType::Polyline3D(source) => {
|
||||
let mut polyline = source.clone();
|
||||
polyline.elevation = 0.0;
|
||||
polyline.normal = Vector3::UNIT_Z;
|
||||
for vertex in &mut polyline.vertices {
|
||||
vertex.position = flatten_point(vertex.position)?;
|
||||
}
|
||||
acadrust::EntityType::Polyline3D(polyline)
|
||||
codec::EntityType::Polyline3D(polyline)
|
||||
}
|
||||
acadrust::EntityType::Text(source) if positive_z_normal(source.normal) => {
|
||||
codec::EntityType::Text(source) if positive_z_normal(source.normal) => {
|
||||
let mut text = source.clone();
|
||||
text.insertion_point = flatten_point(text.insertion_point)?;
|
||||
if let Some(alignment) = text.alignment_point {
|
||||
@@ -1779,22 +1779,22 @@ fn flatten_entity_z(entity: &acadrust::EntityType) -> Option<acadrust::EntityTyp
|
||||
}
|
||||
text.thickness = 0.0;
|
||||
text.normal = Vector3::UNIT_Z;
|
||||
acadrust::EntityType::Text(text)
|
||||
codec::EntityType::Text(text)
|
||||
}
|
||||
acadrust::EntityType::MText(source) if positive_z_normal(source.normal) => {
|
||||
codec::EntityType::MText(source) if positive_z_normal(source.normal) => {
|
||||
let mut text = source.clone();
|
||||
text.insertion_point = flatten_point(text.insertion_point)?;
|
||||
text.normal = Vector3::UNIT_Z;
|
||||
acadrust::EntityType::MText(text)
|
||||
codec::EntityType::MText(text)
|
||||
}
|
||||
acadrust::EntityType::Point(source) => {
|
||||
codec::EntityType::Point(source) => {
|
||||
let mut point = source.clone();
|
||||
point.location = flatten_point(point.location)?;
|
||||
point.thickness = 0.0;
|
||||
point.normal = Vector3::UNIT_Z;
|
||||
acadrust::EntityType::Point(point)
|
||||
codec::EntityType::Point(point)
|
||||
}
|
||||
acadrust::EntityType::Spline(source) => {
|
||||
codec::EntityType::Spline(source) => {
|
||||
let mut spline = source.clone();
|
||||
for point in &mut spline.control_points {
|
||||
*point = flatten_point(*point)?;
|
||||
@@ -1806,9 +1806,9 @@ fn flatten_entity_z(entity: &acadrust::EntityType) -> Option<acadrust::EntityTyp
|
||||
spline.end_tangent = flatten_vector(spline.end_tangent)?;
|
||||
spline.normal = Vector3::UNIT_Z;
|
||||
spline.flags.planar = true;
|
||||
acadrust::EntityType::Spline(spline)
|
||||
codec::EntityType::Spline(spline)
|
||||
}
|
||||
acadrust::EntityType::Solid(source) => {
|
||||
codec::EntityType::Solid(source) => {
|
||||
let corners = crate::entities::solid::wcs_corners(source);
|
||||
let mut solid = source.clone();
|
||||
solid.first_corner = flatten_array(corners[0])?;
|
||||
@@ -1817,15 +1817,15 @@ fn flatten_entity_z(entity: &acadrust::EntityType) -> Option<acadrust::EntityTyp
|
||||
solid.fourth_corner = flatten_array(corners[3])?;
|
||||
solid.normal = Vector3::UNIT_Z;
|
||||
solid.thickness = 0.0;
|
||||
acadrust::EntityType::Solid(solid)
|
||||
codec::EntityType::Solid(solid)
|
||||
}
|
||||
acadrust::EntityType::Face3D(source) => {
|
||||
codec::EntityType::Face3D(source) => {
|
||||
let mut face = source.clone();
|
||||
face.first_corner = flatten_point(face.first_corner)?;
|
||||
face.second_corner = flatten_point(face.second_corner)?;
|
||||
face.third_corner = flatten_point(face.third_corner)?;
|
||||
face.fourth_corner = flatten_point(face.fourth_corner)?;
|
||||
acadrust::EntityType::Face3D(face)
|
||||
codec::EntityType::Face3D(face)
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
@@ -1833,19 +1833,19 @@ fn flatten_entity_z(entity: &acadrust::EntityType) -> Option<acadrust::EntityTyp
|
||||
(flattened != *entity).then_some(flattened)
|
||||
}
|
||||
|
||||
fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::EntityType> {
|
||||
use acadrust::types::{Vector2, Vector3};
|
||||
use cadkernel::geom2d::Curve;
|
||||
fn flatten_curve_entity(entity: &codec::EntityType) -> Option<codec::EntityType> {
|
||||
use codec::types::{Vector2, Vector3};
|
||||
use kernel::geom2d::Curve;
|
||||
|
||||
match entity {
|
||||
acadrust::EntityType::Ellipse(source)
|
||||
codec::EntityType::Ellipse(source)
|
||||
if source.center.z == 0.0
|
||||
&& source.major_axis.z == 0.0
|
||||
&& source.normal == Vector3::UNIT_Z =>
|
||||
{
|
||||
return None;
|
||||
}
|
||||
acadrust::EntityType::LwPolyline(source)
|
||||
codec::EntityType::LwPolyline(source)
|
||||
if !z_axis_normal(source.normal)
|
||||
&& (source.constant_width != 0.0
|
||||
|| source
|
||||
@@ -1855,7 +1855,7 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
{
|
||||
return None;
|
||||
}
|
||||
acadrust::EntityType::Polyline2D(source)
|
||||
codec::EntityType::Polyline2D(source)
|
||||
if !z_axis_normal(source.normal)
|
||||
&& (source.start_width != 0.0
|
||||
|| source.end_width != 0.0
|
||||
@@ -1866,7 +1866,7 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
{
|
||||
return None;
|
||||
}
|
||||
acadrust::EntityType::LwPolyline(source) if source.vertices.len() < 2 => {
|
||||
codec::EntityType::LwPolyline(source) if source.vertices.len() < 2 => {
|
||||
let plane = crate::entities::curve::ocs_plane(source.normal, source.elevation);
|
||||
let mut polyline = source.clone();
|
||||
for vertex in &mut polyline.vertices {
|
||||
@@ -1879,9 +1879,9 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
polyline.elevation = 0.0;
|
||||
polyline.thickness = 0.0;
|
||||
polyline.normal = Vector3::UNIT_Z;
|
||||
return Some(acadrust::EntityType::LwPolyline(polyline));
|
||||
return Some(codec::EntityType::LwPolyline(polyline));
|
||||
}
|
||||
acadrust::EntityType::Polyline2D(source) if source.vertices.len() < 2 => {
|
||||
codec::EntityType::Polyline2D(source) if source.vertices.len() < 2 => {
|
||||
let plane = crate::entities::curve::ocs_plane(source.normal, source.elevation);
|
||||
let mut polyline = source.clone();
|
||||
for vertex in &mut polyline.vertices {
|
||||
@@ -1894,22 +1894,22 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
polyline.elevation = 0.0;
|
||||
polyline.thickness = 0.0;
|
||||
polyline.normal = Vector3::UNIT_Z;
|
||||
return Some(acadrust::EntityType::Polyline2D(polyline));
|
||||
return Some(codec::EntityType::Polyline2D(polyline));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let curve = crate::entities::curve::entity_curve_xy(entity)?;
|
||||
match (entity, curve) {
|
||||
(acadrust::EntityType::Circle(source), Curve::Circle(curve)) => {
|
||||
(codec::EntityType::Circle(source), Curve::Circle(curve)) => {
|
||||
let mut circle = source.clone();
|
||||
circle.center = Vector3::new(curve.centre[0], curve.centre[1], 0.0);
|
||||
circle.radius = curve.radius;
|
||||
circle.thickness = 0.0;
|
||||
circle.normal = Vector3::UNIT_Z;
|
||||
Some(acadrust::EntityType::Circle(circle))
|
||||
Some(codec::EntityType::Circle(circle))
|
||||
}
|
||||
(acadrust::EntityType::Arc(source), Curve::Arc(curve)) => {
|
||||
(codec::EntityType::Arc(source), Curve::Arc(curve)) => {
|
||||
let mut arc = source.clone();
|
||||
arc.center = Vector3::new(curve.centre[0], curve.centre[1], 0.0);
|
||||
arc.radius = curve.radius;
|
||||
@@ -1917,18 +1917,18 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
arc.end_angle = curve.end_angle;
|
||||
arc.thickness = 0.0;
|
||||
arc.normal = Vector3::UNIT_Z;
|
||||
Some(acadrust::EntityType::Arc(arc))
|
||||
Some(codec::EntityType::Arc(arc))
|
||||
}
|
||||
(acadrust::EntityType::Circle(source), Curve::Ellipse(curve)) => {
|
||||
(codec::EntityType::Circle(source), Curve::Ellipse(curve)) => {
|
||||
flattened_ellipse(source.common.clone(), curve)
|
||||
}
|
||||
(acadrust::EntityType::Arc(source), Curve::Ellipse(curve)) => {
|
||||
(codec::EntityType::Arc(source), Curve::Ellipse(curve)) => {
|
||||
flattened_ellipse(source.common.clone(), curve)
|
||||
}
|
||||
(acadrust::EntityType::Ellipse(source), Curve::Ellipse(curve)) => {
|
||||
(codec::EntityType::Ellipse(source), Curve::Ellipse(curve)) => {
|
||||
flattened_ellipse(source.common.clone(), curve)
|
||||
}
|
||||
(acadrust::EntityType::LwPolyline(source), Curve::Polyline(curve)) => {
|
||||
(codec::EntityType::LwPolyline(source), Curve::Polyline(curve)) => {
|
||||
if curve.vertices.len() != source.vertices.len() {
|
||||
return None;
|
||||
}
|
||||
@@ -1940,9 +1940,9 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
polyline.elevation = 0.0;
|
||||
polyline.thickness = 0.0;
|
||||
polyline.normal = Vector3::UNIT_Z;
|
||||
Some(acadrust::EntityType::LwPolyline(polyline))
|
||||
Some(codec::EntityType::LwPolyline(polyline))
|
||||
}
|
||||
(acadrust::EntityType::Polyline2D(source), Curve::Polyline(curve)) => {
|
||||
(codec::EntityType::Polyline2D(source), Curve::Polyline(curve)) => {
|
||||
if curve.vertices.len() != source.vertices.len() {
|
||||
return None;
|
||||
}
|
||||
@@ -1955,23 +1955,23 @@ fn flatten_curve_entity(entity: &acadrust::EntityType) -> Option<acadrust::Entit
|
||||
polyline.elevation = 0.0;
|
||||
polyline.thickness = 0.0;
|
||||
polyline.normal = Vector3::UNIT_Z;
|
||||
Some(acadrust::EntityType::Polyline2D(polyline))
|
||||
Some(codec::EntityType::Polyline2D(polyline))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn flattened_ellipse(
|
||||
common: acadrust::entities::EntityCommon,
|
||||
curve: cadkernel::geom2d::EllipseArc,
|
||||
) -> Option<acadrust::EntityType> {
|
||||
use acadrust::types::Vector3;
|
||||
common: codec::entities::EntityCommon,
|
||||
curve: kernel::geom2d::EllipseArc,
|
||||
) -> Option<codec::EntityType> {
|
||||
use codec::types::Vector3;
|
||||
|
||||
let geometry = curve.ellipse;
|
||||
if !geometry.major_radius.is_finite() || geometry.major_radius <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
let mut ellipse = acadrust::entities::Ellipse::new();
|
||||
let mut ellipse = codec::entities::Ellipse::new();
|
||||
ellipse.common = common;
|
||||
ellipse.center = Vector3::new(geometry.centre[0], geometry.centre[1], 0.0);
|
||||
ellipse.major_axis = Vector3::new(
|
||||
@@ -1983,36 +1983,36 @@ fn flattened_ellipse(
|
||||
ellipse.start_parameter = curve.start_parameter;
|
||||
ellipse.end_parameter = curve.end_parameter;
|
||||
ellipse.normal = Vector3::UNIT_Z;
|
||||
Some(acadrust::EntityType::Ellipse(ellipse))
|
||||
Some(codec::EntityType::Ellipse(ellipse))
|
||||
}
|
||||
|
||||
fn flatten_point(point: acadrust::types::Vector3) -> Option<acadrust::types::Vector3> {
|
||||
fn flatten_point(point: codec::types::Vector3) -> Option<codec::types::Vector3> {
|
||||
flatten_array([point.x, point.y, point.z])
|
||||
}
|
||||
|
||||
fn flatten_array(point: [f64; 3]) -> Option<acadrust::types::Vector3> {
|
||||
use cadkernel::space::Plane;
|
||||
fn flatten_array(point: [f64; 3]) -> Option<codec::types::Vector3> {
|
||||
use kernel::space::Plane;
|
||||
|
||||
let point = Plane::XY.point_at(Plane::XY.project(point)?);
|
||||
Some(acadrust::types::Vector3::new(point[0], point[1], point[2]))
|
||||
Some(codec::types::Vector3::new(point[0], point[1], point[2]))
|
||||
}
|
||||
|
||||
fn flatten_vector(vector: acadrust::types::Vector3) -> Option<acadrust::types::Vector3> {
|
||||
use cadkernel::space::Plane;
|
||||
fn flatten_vector(vector: codec::types::Vector3) -> Option<codec::types::Vector3> {
|
||||
use kernel::space::Plane;
|
||||
|
||||
let vector = Plane::XY.vector_at(Plane::XY.project_vector([
|
||||
vector.x, vector.y, vector.z,
|
||||
])?);
|
||||
Some(acadrust::types::Vector3::new(
|
||||
Some(codec::types::Vector3::new(
|
||||
vector[0], vector[1], vector[2],
|
||||
))
|
||||
}
|
||||
|
||||
fn positive_z_normal(normal: acadrust::types::Vector3) -> bool {
|
||||
fn positive_z_normal(normal: codec::types::Vector3) -> bool {
|
||||
normal.x == 0.0 && normal.y == 0.0 && normal.z > 0.0
|
||||
}
|
||||
|
||||
fn z_axis_normal(normal: acadrust::types::Vector3) -> bool {
|
||||
fn z_axis_normal(normal: codec::types::Vector3) -> bool {
|
||||
normal.x == 0.0 && normal.y == 0.0 && normal.z != 0.0
|
||||
}
|
||||
|
||||
@@ -2044,7 +2044,7 @@ impl OpenCADStudio {
|
||||
if sel.len() == 1 {
|
||||
let (h, e) = sel[0];
|
||||
match e {
|
||||
acadrust::EntityType::Insert(ins) if !ins.attributes.is_empty() => Some(h),
|
||||
codec::EntityType::Insert(ins) if !ins.attributes.is_empty() => Some(h),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
@@ -2152,15 +2152,15 @@ impl ArithParser {
|
||||
#[cfg(test)]
|
||||
mod flatten_tests {
|
||||
use super::flatten_entity_z;
|
||||
use acadrust::types::Vector3;
|
||||
use acadrust::EntityType;
|
||||
use codec::types::Vector3;
|
||||
use codec::EntityType;
|
||||
|
||||
#[test]
|
||||
fn flattens_3d_polyline_vertices() {
|
||||
let mut pl = acadrust::entities::Polyline3D::new();
|
||||
let mut pl = codec::entities::Polyline3D::new();
|
||||
for z in [5.0, -2.0, 7.5] {
|
||||
pl.vertices
|
||||
.push(acadrust::entities::Vertex3DPolyline::new(Vector3::new(1.0, 2.0, z)));
|
||||
.push(codec::entities::Vertex3DPolyline::new(Vector3::new(1.0, 2.0, z)));
|
||||
}
|
||||
pl.elevation = 5.0;
|
||||
|
||||
@@ -2178,9 +2178,9 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn flattens_2d_polyline_vertices_and_elevation() {
|
||||
let mut pl = acadrust::entities::Polyline2D::new();
|
||||
let mut pl = codec::entities::Polyline2D::new();
|
||||
pl.vertices
|
||||
.push(acadrust::entities::Vertex2D::new(Vector3::new(3.0, 4.0, 9.0)));
|
||||
.push(codec::entities::Vertex2D::new(Vector3::new(3.0, 4.0, 9.0)));
|
||||
pl.elevation = 9.0;
|
||||
|
||||
let entity = EntityType::Polyline2D(pl);
|
||||
@@ -2196,7 +2196,7 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn flattens_solid_corners() {
|
||||
let solid = acadrust::entities::Solid::new(
|
||||
let solid = codec::entities::Solid::new(
|
||||
Vector3::new(0.0, 0.0, 1.0),
|
||||
Vector3::new(1.0, 0.0, 2.0),
|
||||
Vector3::new(1.0, 1.0, 3.0),
|
||||
@@ -2217,7 +2217,7 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn reports_unsupported_entities_as_not_moved() {
|
||||
let entity = EntityType::Ray(acadrust::entities::Ray::new(
|
||||
let entity = EntityType::Ray(codec::entities::Ray::new(
|
||||
Vector3::new(0.0, 0.0, 5.0),
|
||||
Vector3::new(1.0, 0.0, 0.0),
|
||||
));
|
||||
@@ -2226,7 +2226,7 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn still_flattens_a_line() {
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.start = Vector3::new(0.0, 0.0, 3.0);
|
||||
line.end = Vector3::new(1.0, 1.0, 4.0);
|
||||
let entity = EntityType::Line(line);
|
||||
@@ -2237,7 +2237,7 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn already_flat_line_is_not_moved() {
|
||||
let mut line = acadrust::entities::Line::new();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.start = Vector3::new(0.0, 0.0, 0.0);
|
||||
line.end = Vector3::new(1.0, 1.0, 0.0);
|
||||
let entity = EntityType::Line(line);
|
||||
@@ -2246,7 +2246,7 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn tilted_circle_projects_to_ellipse() {
|
||||
let mut circle = acadrust::entities::Circle::from_center_radius(
|
||||
let mut circle = codec::entities::Circle::from_center_radius(
|
||||
Vector3::new(2.0, 3.0, 4.0),
|
||||
5.0,
|
||||
);
|
||||
@@ -2266,7 +2266,7 @@ mod flatten_tests {
|
||||
|
||||
#[test]
|
||||
fn tilted_solid_uses_world_projection() {
|
||||
let mut solid = acadrust::entities::Solid::new(
|
||||
let mut solid = codec::entities::Solid::new(
|
||||
Vector3::new(0.0, 0.0, 2.0),
|
||||
Vector3::new(1.0, 0.0, 2.0),
|
||||
Vector3::new(1.0, 1.0, 2.0),
|
||||
@@ -2297,10 +2297,10 @@ mod flatten_tests {
|
||||
#[cfg(test)]
|
||||
mod align_selected_bounds_tests {
|
||||
use super::*;
|
||||
use acadrust::entities::{EntityType, Line};
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::{EntityType, Line};
|
||||
use codec::types::Vector3;
|
||||
|
||||
fn add_line(app: &mut OpenCADStudio, x1: f64, y1: f64, x2: f64, y2: f64) -> acadrust::Handle {
|
||||
fn add_line(app: &mut OpenCADStudio, x1: f64, y1: f64, x2: f64, y2: f64) -> codec::Handle {
|
||||
app.tabs[app.active_tab]
|
||||
.scene
|
||||
.add_entity(EntityType::Line(Line::from_points(
|
||||
@@ -2309,14 +2309,14 @@ mod align_selected_bounds_tests {
|
||||
)))
|
||||
}
|
||||
|
||||
fn line_start_x(app: &OpenCADStudio, handle: acadrust::Handle) -> f64 {
|
||||
fn line_start_x(app: &OpenCADStudio, handle: codec::Handle) -> f64 {
|
||||
match app.tabs[app.active_tab].scene.document.get_entity(handle) {
|
||||
Some(EntityType::Line(l)) => l.start.x.min(l.end.x),
|
||||
other => panic!("expected a Line, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn line_max_y(app: &OpenCADStudio, handle: acadrust::Handle) -> f64 {
|
||||
fn line_max_y(app: &OpenCADStudio, handle: codec::Handle) -> f64 {
|
||||
match app.tabs[app.active_tab].scene.document.get_entity(handle) {
|
||||
Some(EntityType::Line(l)) => l.start.y.max(l.end.y),
|
||||
other => panic!("expected a Line, got {other:?}"),
|
||||
|
||||
@@ -5,7 +5,7 @@ impl OpenCADStudio {
|
||||
match cmd {
|
||||
// ── LAYER management ─────────────────────────────────────────
|
||||
cmd if cmd == "LAYER" || cmd.starts_with("LAYER ") || cmd.starts_with("LA ") => {
|
||||
use acadrust::tables::Layer;
|
||||
use codec::tables::Layer;
|
||||
let raw_rest = if cmd.starts_with("LAYER ") {
|
||||
cmd.trim_start_matches("LAYER ").trim()
|
||||
} else if cmd.starts_with("LA ") {
|
||||
@@ -127,7 +127,7 @@ impl OpenCADStudio {
|
||||
if let Ok(idx) = color_str.parse::<i16>() {
|
||||
if let Some(l) = self.tabs[i].scene.document.layers.get_mut(&layer_name)
|
||||
{
|
||||
l.color = acadrust::types::Color::from_index(idx);
|
||||
l.color = codec::types::Color::from_index(idx);
|
||||
l.color_name = None;
|
||||
l.book_name = None;
|
||||
self.push_undo_snapshot(i, "LAYER COLOR");
|
||||
@@ -186,8 +186,8 @@ impl OpenCADStudio {
|
||||
// ── UCS management (inline `UCS <option> …`) ─────────────────────
|
||||
cmd if cmd.starts_with("UCS ") => {
|
||||
use super::super::helpers::{ucs_rotated_z, ucs_to_wcs, ucs_z_axis};
|
||||
use acadrust::tables::Ucs;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::tables::Ucs;
|
||||
use codec::types::Vector3;
|
||||
let parts: Vec<&str> = cmd.splitn(4, ' ').collect();
|
||||
let sub = parts.get(1).map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
let mut active_changed = false;
|
||||
@@ -263,9 +263,9 @@ impl OpenCADStudio {
|
||||
{
|
||||
let removed_handle = removed.handle;
|
||||
for entity in self.tabs[i].scene.document.entities_mut() {
|
||||
if let acadrust::EntityType::Viewport(viewport) = entity {
|
||||
if let codec::EntityType::Viewport(viewport) = entity {
|
||||
if viewport.ucs_handle == removed_handle {
|
||||
viewport.ucs_handle = acadrust::Handle::NULL;
|
||||
viewport.ucs_handle = codec::Handle::NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,9 +276,9 @@ impl OpenCADStudio {
|
||||
if active_matches {
|
||||
if let Some(active) = self.tabs[i].active_ucs.as_mut() {
|
||||
active.name = "*ACTIVE*".to_string();
|
||||
active.handle = acadrust::Handle::NULL;
|
||||
active.named_ucs_handle = acadrust::Handle::NULL;
|
||||
active.base_ucs_handle = acadrust::Handle::NULL;
|
||||
active.handle = codec::Handle::NULL;
|
||||
active.named_ucs_handle = codec::Handle::NULL;
|
||||
active.base_ucs_handle = codec::Handle::NULL;
|
||||
}
|
||||
active_changed = true;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ impl OpenCADStudio {
|
||||
.and_then(|token| {
|
||||
u64::from_str_radix(token.trim().trim_start_matches("0x"), 16).ok()
|
||||
})
|
||||
.map(acadrust::Handle::new)
|
||||
.map(codec::Handle::new)
|
||||
.zip(
|
||||
parts
|
||||
.get(3)
|
||||
@@ -384,7 +384,7 @@ impl OpenCADStudio {
|
||||
.and_then(|token| {
|
||||
u64::from_str_radix(token.trim().trim_start_matches("0x"), 16).ok()
|
||||
})
|
||||
.map(acadrust::Handle::new);
|
||||
.map(codec::Handle::new);
|
||||
match target {
|
||||
// Bare `UCS OBJECT` starts the pick; the click
|
||||
// comes back through this arm with the handle.
|
||||
@@ -880,7 +880,7 @@ impl OpenCADStudio {
|
||||
// ── DimStyle management ───────────────────────────────────────
|
||||
// TABLESTYLE — Table Style Manager.
|
||||
cmd if cmd == "TABLESTYLE" || cmd == "TS" || cmd.starts_with("TABLESTYLE ") => {
|
||||
use acadrust::objects::{ObjectType, TableStyle};
|
||||
use codec::objects::{ObjectType, TableStyle};
|
||||
let raw_rest = cmd.split_once(' ').map(|(_, r)| r.trim()).unwrap_or("");
|
||||
let parts: Vec<&str> = raw_rest.split_whitespace().collect();
|
||||
let sub = parts.first().map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
@@ -930,7 +930,7 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "TABLESTYLE NEW");
|
||||
let mut style = TableStyle::standard();
|
||||
style.name = name.clone();
|
||||
let nh = acadrust::Handle::new(
|
||||
let nh = codec::Handle::new(
|
||||
self.tabs[i].scene.document.next_handle(),
|
||||
);
|
||||
style.handle = nh;
|
||||
@@ -960,7 +960,7 @@ impl OpenCADStudio {
|
||||
// MLSTYLE SET <name> — set current multiline style
|
||||
// MLSTYLE DEL <name> — delete a style (not Standard)
|
||||
cmd if cmd == "MLSTYLE" || cmd.starts_with("MLSTYLE ") => {
|
||||
use acadrust::objects::{MLineStyle, ObjectType};
|
||||
use codec::objects::{MLineStyle, ObjectType};
|
||||
let raw_rest = cmd.split_once(' ').map(|(_, r)| r.trim()).unwrap_or("");
|
||||
let parts: Vec<&str> = raw_rest.split_whitespace().collect();
|
||||
let sub = parts.first().map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
@@ -1009,7 +1009,7 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "MLSTYLE NEW");
|
||||
let mut style = MLineStyle::standard();
|
||||
style.name = name.clone();
|
||||
let nh = acadrust::Handle::new(
|
||||
let nh = codec::Handle::new(
|
||||
self.tabs[i].scene.document.next_handle(),
|
||||
);
|
||||
style.handle = nh;
|
||||
@@ -1089,7 +1089,7 @@ impl OpenCADStudio {
|
||||
|| cmd.starts_with("DIMSTYLE ")
|
||||
|| cmd.starts_with("DDIM ") =>
|
||||
{
|
||||
use acadrust::tables::DimStyle;
|
||||
use codec::tables::DimStyle;
|
||||
let raw_rest = cmd.split_once(' ').map(|(_, r)| r.trim()).unwrap_or("");
|
||||
let parts: Vec<&str> = raw_rest.split_whitespace().collect();
|
||||
let sub = parts.get(0).map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
@@ -1222,7 +1222,7 @@ impl OpenCADStudio {
|
||||
|
||||
// ── MLeader Style management ──────────────────────────────────
|
||||
cmd if cmd == "MLEADERSTYLE" || cmd.starts_with("MLEADERSTYLE ") => {
|
||||
use acadrust::objects::{MultiLeaderStyle, ObjectType};
|
||||
use codec::objects::{MultiLeaderStyle, ObjectType};
|
||||
let raw_rest = cmd.trim_start_matches("MLEADERSTYLE").trim();
|
||||
let parts: Vec<&str> = raw_rest.split_whitespace().collect();
|
||||
let sub = parts.first().map(|s| s.to_uppercase()).unwrap_or_default();
|
||||
@@ -1442,7 +1442,7 @@ impl OpenCADStudio {
|
||||
"STYLE NEW",
|
||||
std::slice::from_ref(&name),
|
||||
);
|
||||
let style = acadrust::tables::TextStyle::new(&name);
|
||||
let style = codec::tables::TextStyle::new(&name);
|
||||
let _ = self.tabs[i].scene.document.text_styles.add(style);
|
||||
self.tabs[i].dirty = true;
|
||||
self.commit_text_style_undo(i, undo);
|
||||
@@ -1568,7 +1568,7 @@ impl OpenCADStudio {
|
||||
/// mean, because a few pixels of cursor travel cover a long way in
|
||||
/// world space.
|
||||
fn open_sketch(&mut self, i: usize) {
|
||||
let opened_with: std::collections::HashSet<acadrust::Handle> = self.tabs[i]
|
||||
let opened_with: std::collections::HashSet<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
@@ -1601,7 +1601,7 @@ impl OpenCADStudio {
|
||||
.push_error(crate::t!("No sketch is open.").as_ref());
|
||||
return;
|
||||
};
|
||||
let created: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let created: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
|
||||
@@ -150,7 +150,7 @@ impl OpenCADStudio {
|
||||
);
|
||||
return Some(Task::none());
|
||||
}
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
@@ -413,7 +413,7 @@ impl OpenCADStudio {
|
||||
.layers
|
||||
.get(&layer)
|
||||
.map(|l| l.handle)
|
||||
.unwrap_or(acadrust::types::Handle::NULL);
|
||||
.unwrap_or(codec::types::Handle::NULL);
|
||||
self.tabs[i].scene.document.header.current_layer_name = layer.clone();
|
||||
self.tabs[i].scene.document.header.current_layer_handle = handle;
|
||||
self.tabs[i].active_layer = layer.clone();
|
||||
@@ -818,11 +818,11 @@ impl OpenCADStudio {
|
||||
|
||||
// Model framing follows model units; sheet framing stays in paper units.
|
||||
let sheets = self.tabs[i].scene.sheet_viewport_handles();
|
||||
let scaled: std::collections::HashSet<acadrust::Handle> = handles.iter().copied().collect();
|
||||
let scaled: std::collections::HashSet<codec::Handle> = handles.iter().copied().collect();
|
||||
let mut reframed = 0usize;
|
||||
for entity in self.tabs[i].scene.document.entities_mut() {
|
||||
let handle = entity.common().handle;
|
||||
let acadrust::entities::EntityType::Viewport(vp) = entity else {
|
||||
let codec::entities::EntityType::Viewport(vp) = entity else {
|
||||
continue;
|
||||
};
|
||||
let is_sheet = !scaled.contains(&handle) && sheets.contains(&handle);
|
||||
|
||||
@@ -824,7 +824,7 @@ mod marquee_cancel_tests {
|
||||
use crate::app::{GripPendingValue, OpenCADStudio};
|
||||
use crate::scene::model::object::GripMenuAction;
|
||||
use crate::scene::pick::grip::GripEdit;
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
use iced::time::Instant;
|
||||
|
||||
fn fresh() -> OpenCADStudio {
|
||||
|
||||
@@ -48,7 +48,7 @@ impl OpenCADStudio {
|
||||
let i = self.active_tab;
|
||||
let mut existing: Vec<(String, String)> = Vec::new();
|
||||
for object in self.tabs[i].scene.document.objects.values() {
|
||||
if let acadrust::objects::ObjectType::UnderlayDefinition(def) = object {
|
||||
if let codec::objects::ObjectType::UnderlayDefinition(def) = object {
|
||||
let name = file_stem(&def.file_path);
|
||||
if !existing.iter().any(|(n, _)| *n == name) {
|
||||
existing.push((name, def.file_path.clone()));
|
||||
@@ -77,7 +77,7 @@ impl OpenCADStudio {
|
||||
/// shown.
|
||||
pub(in crate::app) fn open_underlay_layers_dialog(&mut self, i: usize) {
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let selected: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -85,10 +85,10 @@ impl OpenCADStudio {
|
||||
.collect();
|
||||
let mut targets: Vec<LayerTarget> = Vec::new();
|
||||
for entity in document.entities() {
|
||||
let acadrust::EntityType::Underlay(u) = entity else {
|
||||
let codec::EntityType::Underlay(u) = entity else {
|
||||
continue;
|
||||
};
|
||||
if u.underlay_type != acadrust::entities::UnderlayType::Pdf {
|
||||
if u.underlay_type != codec::entities::UnderlayType::Pdf {
|
||||
continue;
|
||||
}
|
||||
let Some(def) = crate::entities::underlay::definition(u, document) else {
|
||||
@@ -156,7 +156,7 @@ impl OpenCADStudio {
|
||||
let changed: Vec<LayerTarget> = targets
|
||||
.into_iter()
|
||||
.filter(|t| match self.tabs[i].scene.document.get_entity(t.handle) {
|
||||
Some(acadrust::EntityType::Underlay(u)) => hidden_layers(u) != t.hidden,
|
||||
Some(codec::EntityType::Underlay(u)) => hidden_layers(u) != t.hidden,
|
||||
_ => false,
|
||||
})
|
||||
.collect();
|
||||
@@ -172,7 +172,7 @@ impl OpenCADStudio {
|
||||
.get(LAYER_OVERRIDE_APP)
|
||||
.map(|a| a.handle.value());
|
||||
for target in &changed {
|
||||
if let Some(acadrust::EntityType::Underlay(u)) =
|
||||
if let Some(codec::EntityType::Underlay(u)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(target.handle)
|
||||
{
|
||||
let data = &mut u.common.extended_data;
|
||||
@@ -181,9 +181,9 @@ impl OpenCADStudio {
|
||||
}
|
||||
data.remove_record(LAYER_OVERRIDE_APP);
|
||||
if !target.hidden.is_empty() {
|
||||
let mut record = acadrust::xdata::ExtendedDataRecord::new(LAYER_OVERRIDE_APP);
|
||||
let mut record = codec::xdata::ExtendedDataRecord::new(LAYER_OVERRIDE_APP);
|
||||
for name in &target.hidden {
|
||||
record.add_value(acadrust::xdata::XDataValue::String(name.clone()));
|
||||
record.add_value(codec::xdata::XDataValue::String(name.clone()));
|
||||
}
|
||||
data.add_record(record);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ pub(crate) enum PdfImportSource {
|
||||
|
||||
impl OpenCADStudio {
|
||||
pub(crate) fn run_pdf_import(&mut self, i: usize, source: PdfImportSource) {
|
||||
use acadrust::objects::ObjectType;
|
||||
use codec::objects::ObjectType;
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let (underlay, path, page, area, mode, handle) = match &source {
|
||||
PdfImportSource::Underlay(request) => {
|
||||
let Some(acadrust::EntityType::Underlay(underlay)) =
|
||||
let Some(codec::EntityType::Underlay(underlay)) =
|
||||
document.get_entity(request.underlay)
|
||||
else {
|
||||
return;
|
||||
@@ -93,10 +93,10 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "PDFIMPORT");
|
||||
let scene = &mut self.tabs[i].scene;
|
||||
if result.dashed && !scene.document.line_types.contains(pdf_import::DASH_LINETYPE) {
|
||||
let mut lt = acadrust::tables::LineType::new(pdf_import::DASH_LINETYPE);
|
||||
let mut lt = codec::tables::LineType::new(pdf_import::DASH_LINETYPE);
|
||||
lt.handle = scene.document.allocate_handle();
|
||||
lt.add_element(acadrust::tables::LineTypeElement::dash(0.8));
|
||||
lt.add_element(acadrust::tables::LineTypeElement::space(0.2));
|
||||
lt.add_element(codec::tables::LineTypeElement::dash(0.8));
|
||||
lt.add_element(codec::tables::LineTypeElement::space(0.2));
|
||||
lt.pattern_length = 1.0;
|
||||
let _ = scene.document.line_types.add(lt);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ impl OpenCADStudio {
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let mut raster = acadrust::entities::RasterImage::with_size(
|
||||
let mut raster = codec::entities::RasterImage::with_size(
|
||||
file.to_string_lossy().as_ref(),
|
||||
image.insertion,
|
||||
image.width as f64,
|
||||
@@ -127,14 +127,14 @@ impl OpenCADStudio {
|
||||
);
|
||||
raster.u_vector = image.u;
|
||||
raster.v_vector = image.v;
|
||||
raster.flags = acadrust::entities::ImageDisplayFlags::SHOW_IMAGE
|
||||
| acadrust::entities::ImageDisplayFlags::USE_CLIPPING_BOUNDARY;
|
||||
raster.flags = codec::entities::ImageDisplayFlags::SHOW_IMAGE
|
||||
| codec::entities::ImageDisplayFlags::USE_CLIPPING_BOUNDARY;
|
||||
raster.common.layer = image.layer.clone();
|
||||
result.entities.push(acadrust::EntityType::RasterImage(raster));
|
||||
result.entities.push(codec::EntityType::RasterImage(raster));
|
||||
}
|
||||
for (name, color) in &result.layers {
|
||||
if !scene.document.layers.contains(name) {
|
||||
let mut layer = acadrust::tables::Layer::new(name.as_str());
|
||||
let mut layer = codec::tables::Layer::new(name.as_str());
|
||||
layer.handle = scene.document.allocate_handle();
|
||||
layer.color = *color;
|
||||
let _ = scene.document.layers.add(layer);
|
||||
@@ -142,7 +142,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
for (name, font) in &result.text_styles {
|
||||
if !scene.document.text_styles.contains(name) {
|
||||
let mut style = acadrust::tables::TextStyle::new(name.as_str());
|
||||
let mut style = codec::tables::TextStyle::new(name.as_str());
|
||||
style.handle = scene.document.allocate_handle();
|
||||
style.font_file = font.clone();
|
||||
let _ = scene.document.text_styles.add(style);
|
||||
@@ -161,12 +161,12 @@ impl OpenCADStudio {
|
||||
.define_block_from_owned_entities(result.entities, &name, glam::DVec3::ZERO)
|
||||
.is_ok()
|
||||
{
|
||||
let mut insert = acadrust::entities::Insert::new(
|
||||
let mut insert = codec::entities::Insert::new(
|
||||
name,
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
);
|
||||
insert.common.layer = current_layer;
|
||||
scene.add_entity(acadrust::EntityType::Insert(insert));
|
||||
scene.add_entity(codec::EntityType::Insert(insert));
|
||||
}
|
||||
} else {
|
||||
for entity in result.entities {
|
||||
@@ -189,7 +189,7 @@ impl OpenCADStudio {
|
||||
// Drop the definition once nothing references it.
|
||||
let definition = underlay.definition_handle;
|
||||
let referenced = scene.document.entities().any(|entity| {
|
||||
matches!(entity, acadrust::EntityType::Underlay(other)
|
||||
matches!(entity, codec::EntityType::Underlay(other)
|
||||
if other.definition_handle == definition)
|
||||
});
|
||||
if !referenced {
|
||||
@@ -217,7 +217,7 @@ impl OpenCADStudio {
|
||||
i: usize,
|
||||
label: String,
|
||||
path: &str,
|
||||
pages: Vec<(String, acadrust::EntityType)>,
|
||||
pages: Vec<(String, codec::EntityType)>,
|
||||
) {
|
||||
let pending = self.begin_undo(i, label, pages.len(), false);
|
||||
|
||||
@@ -227,7 +227,7 @@ impl OpenCADStudio {
|
||||
path,
|
||||
&page,
|
||||
);
|
||||
if let acadrust::EntityType::Underlay(underlay) = &mut entity {
|
||||
if let codec::EntityType::Underlay(underlay) = &mut entity {
|
||||
underlay.definition_handle = definition;
|
||||
}
|
||||
self.commit_entity_handle(entity);
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
//! underlays, its buttons edit them.
|
||||
|
||||
use super::*;
|
||||
use acadrust::entities::{Underlay, UnderlayDisplayFlags, UnderlayType};
|
||||
use codec::entities::{Underlay, UnderlayDisplayFlags, UnderlayType};
|
||||
use crate::ui::ribbon::{UnderlayContext, UnderlayTabMsg};
|
||||
|
||||
impl OpenCADStudio {
|
||||
/// The selected PDF underlays, or nothing when anything else is selected.
|
||||
fn selected_pdf_underlays(&self, i: usize) -> Vec<(acadrust::Handle, Underlay)> {
|
||||
fn selected_pdf_underlays(&self, i: usize) -> Vec<(codec::Handle, Underlay)> {
|
||||
let mut out = Vec::new();
|
||||
for (handle, entity) in self.tabs[i].scene.selected_entities() {
|
||||
match entity {
|
||||
acadrust::EntityType::Underlay(u) if u.underlay_type == UnderlayType::Pdf => {
|
||||
codec::EntityType::Underlay(u) if u.underlay_type == UnderlayType::Pdf => {
|
||||
out.push((handle, u.clone()));
|
||||
}
|
||||
_ => return Vec::new(),
|
||||
@@ -52,7 +52,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
self.push_undo_snapshot(i, label);
|
||||
for handle in &handles {
|
||||
if let Some(acadrust::EntityType::Underlay(u)) =
|
||||
if let Some(codec::EntityType::Underlay(u)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(*handle)
|
||||
{
|
||||
edit(u);
|
||||
|
||||
@@ -31,7 +31,7 @@ impl OpenCADStudio {
|
||||
|| cmd.starts_with("CECOLOR ")
|
||||
|| cmd.starts_with("DDCOLOR ") =>
|
||||
{
|
||||
use acadrust::types::Color;
|
||||
use codec::types::Color;
|
||||
let describe = |c: &Color| match c {
|
||||
Color::ByLayer => "ByLayer".to_string(),
|
||||
Color::ByBlock => "ByBlock".to_string(),
|
||||
@@ -119,9 +119,9 @@ impl OpenCADStudio {
|
||||
.push_info(crate::t!("Usage: LINETYPE SET <name | ByLayer | ByBlock>").as_ref());
|
||||
} else {
|
||||
let canon = if name.eq_ignore_ascii_case("BYLAYER") {
|
||||
Some(("ByLayer".to_string(), acadrust::types::Handle::NULL))
|
||||
Some(("ByLayer".to_string(), codec::types::Handle::NULL))
|
||||
} else if name.eq_ignore_ascii_case("BYBLOCK") {
|
||||
Some(("ByBlock".to_string(), acadrust::types::Handle::NULL))
|
||||
Some(("ByBlock".to_string(), codec::types::Handle::NULL))
|
||||
} else {
|
||||
self.tabs[i]
|
||||
.scene
|
||||
@@ -222,12 +222,12 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|e| match e {
|
||||
acadrust::EntityType::Text(t) => Some(t.style.clone()),
|
||||
acadrust::EntityType::MText(t) => Some(t.style.clone()),
|
||||
acadrust::EntityType::AttributeDefinition(a) => {
|
||||
codec::EntityType::Text(t) => Some(t.style.clone()),
|
||||
codec::EntityType::MText(t) => Some(t.style.clone()),
|
||||
codec::EntityType::AttributeDefinition(a) => {
|
||||
Some(a.text_style.clone())
|
||||
}
|
||||
acadrust::EntityType::AttributeEntity(a) => {
|
||||
codec::EntityType::AttributeEntity(a) => {
|
||||
Some(a.text_style.clone())
|
||||
}
|
||||
_ => None,
|
||||
@@ -271,13 +271,13 @@ impl OpenCADStudio {
|
||||
// through the shared graph. Dangling layouts do not count.
|
||||
let live_blocks: rustc_hash::FxHashSet<String> = {
|
||||
let doc = &self.tabs[i].scene.document;
|
||||
let is_real_layout = |br: &acadrust::BlockRecord| -> bool {
|
||||
let is_real_layout = |br: &codec::BlockRecord| -> bool {
|
||||
let up = br.name.to_ascii_uppercase();
|
||||
up.starts_with("*MODEL_SPACE")
|
||||
|| up.starts_with("*PAPER_SPACE")
|
||||
|| matches!(
|
||||
doc.objects.get(&br.layout),
|
||||
Some(acadrust::objects::ObjectType::Layout(_))
|
||||
Some(codec::objects::ObjectType::Layout(_))
|
||||
)
|
||||
};
|
||||
let children = |name: &str| -> Vec<String> {
|
||||
@@ -448,20 +448,20 @@ impl OpenCADStudio {
|
||||
// Remove draw-order tables whose owning blocks are gone.
|
||||
let mut n_sortents = 0usize;
|
||||
if do_blocks {
|
||||
let live_blocks: rustc_hash::FxHashSet<acadrust::Handle> = self.tabs[i]
|
||||
let live_blocks: rustc_hash::FxHashSet<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.block_records
|
||||
.iter()
|
||||
.map(|br| br.handle)
|
||||
.collect();
|
||||
let orphans: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let orphans: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.objects
|
||||
.iter()
|
||||
.filter_map(|(h, o)| match o {
|
||||
acadrust::objects::ObjectType::SortEntitiesTable(s)
|
||||
codec::objects::ObjectType::SortEntitiesTable(s)
|
||||
if !live_blocks.contains(&s.block_owner_handle) =>
|
||||
{
|
||||
Some(*h)
|
||||
@@ -560,11 +560,11 @@ impl OpenCADStudio {
|
||||
.push_error(crate::t!("CHPROP: no entities selected.").as_ref());
|
||||
} else {
|
||||
// Validate value early to give clear errors
|
||||
let color_val: Option<acadrust::types::Color> = if prop == "COLOR" {
|
||||
let color_val: Option<codec::types::Color> = if prop == "COLOR" {
|
||||
value
|
||||
.parse::<i16>()
|
||||
.ok()
|
||||
.map(acadrust::types::Color::from_index)
|
||||
.map(codec::types::Color::from_index)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -573,12 +573,12 @@ impl OpenCADStudio {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let transparency_val: Option<acadrust::types::Transparency> =
|
||||
let transparency_val: Option<codec::types::Transparency> =
|
||||
if prop == "TRANSPARENCY" {
|
||||
value
|
||||
.parse::<f64>()
|
||||
.ok()
|
||||
.map(acadrust::types::Transparency::from_percent)
|
||||
.map(codec::types::Transparency::from_percent)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -688,7 +688,7 @@ impl OpenCADStudio {
|
||||
let mut index = 0;
|
||||
while index < handles.len() {
|
||||
let children = match self.tabs[i].scene.document.get_entity(handles[index]) {
|
||||
Some(acadrust::EntityType::Insert(insert)) => self.tabs[i].scene.document
|
||||
Some(codec::EntityType::Insert(insert)) => self.tabs[i].scene.document
|
||||
.block_records.get(&insert.block_name)
|
||||
.map(|block| block.entity_handles.clone()).unwrap_or_default(),
|
||||
_ => Vec::new(),
|
||||
@@ -785,60 +785,60 @@ impl OpenCADStudio {
|
||||
removed.insert(candidates[b].0);progress=true;continue;
|
||||
}
|
||||
if overlap {
|
||||
let contained = |circle: &acadrust::entities::Circle, arc: &acadrust::entities::Arc| {
|
||||
let contained = |circle: &codec::entities::Circle, arc: &codec::entities::Arc| {
|
||||
circle.common == arc.common && circle.thickness == arc.thickness
|
||||
&& cadkernel::space::arc_union::circle_contains_arc(
|
||||
&& kernel::space::arc_union::circle_contains_arc(
|
||||
[circle.center.x,circle.center.y,circle.center.z],
|
||||
[circle.normal.x,circle.normal.y,circle.normal.z],circle.radius,
|
||||
cadkernel::space::arc_union::CircularArc { center:[arc.center.x,arc.center.y,arc.center.z],
|
||||
kernel::space::arc_union::CircularArc { center:[arc.center.x,arc.center.y,arc.center.z],
|
||||
normal:[arc.normal.x,arc.normal.y,arc.normal.z],radius:arc.radius,start:arc.start_angle,end:arc.end_angle })
|
||||
};
|
||||
match (&left,&right) {
|
||||
(acadrust::EntityType::Circle(circle),acadrust::EntityType::Arc(arc)) if contained(circle,arc) => {
|
||||
(codec::EntityType::Circle(circle),codec::EntityType::Arc(arc)) if contained(circle,arc) => {
|
||||
removed.insert(candidates[b].0);progress=true;continue;
|
||||
}
|
||||
(acadrust::EntityType::Arc(arc),acadrust::EntityType::Circle(circle)) if contained(circle,arc) => {
|
||||
(codec::EntityType::Arc(arc),codec::EntityType::Circle(circle)) if contained(circle,arc) => {
|
||||
removed.insert(candidates[a].0);progress=true;break;
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
if let (acadrust::EntityType::Arc(l),acadrust::EntityType::Arc(r))=(&left,&right) {
|
||||
use cadkernel::space::arc_union::{CircularArc,ArcUnionKind,circular_arc_union};
|
||||
if let (codec::EntityType::Arc(l),codec::EntityType::Arc(r))=(&left,&right) {
|
||||
use kernel::space::arc_union::{CircularArc,ArcUnionKind,circular_arc_union};
|
||||
if l.common!=r.common || l.thickness!=r.thickness {continue;}
|
||||
let arc=|v:&acadrust::entities::Arc|CircularArc{center:[v.center.x,v.center.y,v.center.z],normal:[v.normal.x,v.normal.y,v.normal.z],radius:v.radius,start:v.start_angle,end:v.end_angle};
|
||||
let arc=|v:&codec::entities::Arc|CircularArc{center:[v.center.x,v.center.y,v.center.z],normal:[v.normal.x,v.normal.y,v.normal.z],radius:v.radius,start:v.start_angle,end:v.end_angle};
|
||||
let Some(union)=circular_arc_union(arc(l),arc(r),tolerance) else {continue;};
|
||||
let allowed=match union.kind {ArcUnionKind::Duplicate=>true,ArcUnionKind::Overlap=>overlap,ArcUnionKind::EndToEnd=>end_to_end};
|
||||
if !allowed {continue;}
|
||||
if let acadrust::EntityType::Arc(source)=&candidates[a].1 {
|
||||
if let codec::EntityType::Arc(source)=&candidates[a].1 {
|
||||
let replacement=if union.full_circle {
|
||||
let mut circle=acadrust::entities::Circle::new();
|
||||
let mut circle=codec::entities::Circle::new();
|
||||
circle.common=source.common.clone();circle.center=source.center.clone();circle.normal=source.normal.clone();circle.radius=source.radius;circle.thickness=source.thickness;
|
||||
acadrust::EntityType::Circle(circle)
|
||||
codec::EntityType::Circle(circle)
|
||||
} else {
|
||||
let mut arc=source.clone();arc.start_angle=union.start;arc.end_angle=union.end;acadrust::EntityType::Arc(arc)
|
||||
let mut arc=source.clone();arc.start_angle=union.start;arc.end_angle=union.end;codec::EntityType::Arc(arc)
|
||||
};
|
||||
candidates[a].1=replacement;
|
||||
}
|
||||
changed.insert(candidates[a].0);removed.insert(candidates[b].0);progress=true;
|
||||
continue;
|
||||
}
|
||||
let (acadrust::EntityType::Line(l),acadrust::EntityType::Line(r))=(&left,&right)
|
||||
let (codec::EntityType::Line(l),codec::EntityType::Line(r))=(&left,&right)
|
||||
else {continue;};
|
||||
if l.common!=r.common||l.thickness!=r.thickness||l.normal!=r.normal {continue;}
|
||||
let point=|p:acadrust::types::Vector3|[p.x,p.y,p.z];
|
||||
let Some(union)=cadkernel::space::line_union(
|
||||
let point=|p:codec::types::Vector3|[p.x,p.y,p.z];
|
||||
let Some(union)=kernel::space::line_union(
|
||||
[point(l.start),point(l.end)],[point(r.start),point(r.end)],tolerance)
|
||||
else {continue;};
|
||||
let allowed=match union.kind {
|
||||
cadkernel::space::LineUnionKind::Duplicate=>true,
|
||||
cadkernel::space::LineUnionKind::Overlap=>overlap,
|
||||
cadkernel::space::LineUnionKind::EndToEnd=>end_to_end,
|
||||
kernel::space::LineUnionKind::Duplicate=>true,
|
||||
kernel::space::LineUnionKind::Overlap=>overlap,
|
||||
kernel::space::LineUnionKind::EndToEnd=>end_to_end,
|
||||
};
|
||||
if !allowed {continue;}
|
||||
if let acadrust::EntityType::Line(line)=&mut candidates[a].1 {
|
||||
line.start=acadrust::types::Vector3::new(union.start[0],union.start[1],union.start[2]);
|
||||
line.end=acadrust::types::Vector3::new(union.end[0],union.end[1],union.end[2]);
|
||||
if let codec::EntityType::Line(line)=&mut candidates[a].1 {
|
||||
line.start=codec::types::Vector3::new(union.start[0],union.start[1],union.start[2]);
|
||||
line.end=codec::types::Vector3::new(union.end[0],union.end[1],union.end[2]);
|
||||
}
|
||||
changed.insert(candidates[a].0);removed.insert(candidates[b].0);progress=true;
|
||||
}
|
||||
@@ -2625,13 +2625,13 @@ impl OpenCADStudio {
|
||||
linetypes.insert(lt.clone());
|
||||
}
|
||||
match e {
|
||||
acadrust::EntityType::Text(t) if !t.style.is_empty() => {
|
||||
codec::EntityType::Text(t) if !t.style.is_empty() => {
|
||||
styles.insert(t.style.clone());
|
||||
}
|
||||
acadrust::EntityType::MText(t) if !t.style.is_empty() => {
|
||||
codec::EntityType::MText(t) if !t.style.is_empty() => {
|
||||
styles.insert(t.style.clone());
|
||||
}
|
||||
acadrust::EntityType::Insert(ins) => {
|
||||
codec::EntityType::Insert(ins) => {
|
||||
blocks.insert(ins.block_name.clone());
|
||||
}
|
||||
_ => {}
|
||||
@@ -2676,7 +2676,7 @@ impl OpenCADStudio {
|
||||
if !layer.is_empty() && doc.layers.get(layer).is_none() {
|
||||
undefined_layers.insert(layer.clone());
|
||||
}
|
||||
if let acadrust::EntityType::Insert(ins) = e {
|
||||
if let codec::EntityType::Insert(ins) = e {
|
||||
if doc.block_records.get(&ins.block_name).is_none() {
|
||||
undefined_blocks.insert(ins.block_name.clone());
|
||||
}
|
||||
@@ -3178,7 +3178,7 @@ impl OpenCADStudio {
|
||||
cmd if cmd.starts_with("SCALETEXT ") => {
|
||||
let rest = cmd.trim_start_matches("SCALETEXT").trim();
|
||||
let parts: Vec<&str> = rest.split_whitespace().collect();
|
||||
let selected_handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected_handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -3210,12 +3210,12 @@ impl OpenCADStudio {
|
||||
continue;
|
||||
}
|
||||
match entity {
|
||||
acadrust::EntityType::Text(t) => {
|
||||
codec::EntityType::Text(t) => {
|
||||
t.height =
|
||||
if use_absolute { val } else { t.height * val };
|
||||
count += 1;
|
||||
}
|
||||
acadrust::EntityType::MText(t) => {
|
||||
codec::EntityType::MText(t) => {
|
||||
t.height =
|
||||
if use_absolute { val } else { t.height * val };
|
||||
count += 1;
|
||||
@@ -3249,8 +3249,8 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
/// RENAME for the remaining name-keyed symbol tables.
|
||||
fn rename_symbol(doc: &mut acadrust::CadDocument, ty: &str, old: &str, new: &str) -> bool {
|
||||
use acadrust::{EntityType, Table, TableEntry};
|
||||
fn rename_symbol(doc: &mut codec::CadDocument, ty: &str, old: &str, new: &str) -> bool {
|
||||
use codec::{EntityType, Table, TableEntry};
|
||||
|
||||
fn rekey<T: TableEntry>(table: &mut Table<T>, old: &str, new: &str) -> bool {
|
||||
if !crate::scene::valid_block_name(new) {
|
||||
|
||||
+69
-69
@@ -3,10 +3,10 @@ use super::*;
|
||||
// Sort tables belong to the block's extension dictionary. Reserve real handles
|
||||
// and reconnect older unattached tables without losing their existing entries.
|
||||
fn ensure_draw_order_table(
|
||||
doc: &mut acadrust::CadDocument,
|
||||
block: acadrust::Handle,
|
||||
) -> acadrust::Handle {
|
||||
use acadrust::objects::{Dictionary, ObjectType, SortEntitiesTable};
|
||||
doc: &mut codec::CadDocument,
|
||||
block: codec::Handle,
|
||||
) -> codec::Handle {
|
||||
use codec::objects::{Dictionary, ObjectType, SortEntitiesTable};
|
||||
|
||||
// Older commands inserted objects using the unreserved next-handle value.
|
||||
// Repair the allocator floor before creating anything beside those objects.
|
||||
@@ -611,7 +611,7 @@ impl OpenCADStudio {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|e| {
|
||||
if let acadrust::EntityType::Viewport(vp) = e {
|
||||
if let codec::EntityType::Viewport(vp) = e {
|
||||
if vp.id > 1 && vp.common.owner_handle == layout_block {
|
||||
Some((
|
||||
vp.id,
|
||||
@@ -710,12 +710,12 @@ impl OpenCADStudio {
|
||||
if !rects.is_empty() {
|
||||
// Remove existing user viewports in this layout first.
|
||||
let layout_block = self.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let to_erase: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let to_erase: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|e| {
|
||||
if let acadrust::EntityType::Viewport(vp) = e {
|
||||
if let codec::EntityType::Viewport(vp) = e {
|
||||
if vp.id > 1 && vp.common.owner_handle == layout_block {
|
||||
Some(vp.common.handle)
|
||||
} else {
|
||||
@@ -740,13 +740,13 @@ impl OpenCADStudio {
|
||||
self.tabs[i].scene.erase_entities(&to_erase);
|
||||
// Create new viewports.
|
||||
for (cx, cz, w, h) in &rects {
|
||||
let mut vp = acadrust::entities::Viewport::new();
|
||||
vp.center = acadrust::types::Vector3::new(*cx, 0.0, *cz);
|
||||
let mut vp = codec::entities::Viewport::new();
|
||||
vp.center = codec::types::Vector3::new(*cx, 0.0, *cz);
|
||||
vp.width = *w;
|
||||
vp.height = *h;
|
||||
vp.id = 2; // commit_entity will assign unique IDs
|
||||
match self.tabs[i].scene.document.add_entity_to_layout(
|
||||
acadrust::EntityType::Viewport(vp),
|
||||
codec::EntityType::Viewport(vp),
|
||||
&layout_name,
|
||||
) {
|
||||
Ok(handle) => {
|
||||
@@ -760,12 +760,12 @@ impl OpenCADStudio {
|
||||
// Re-assign unique IDs (1 + existing max per viewport).
|
||||
let layout_block2 = self.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let mut id_counter = 2_i16;
|
||||
let handles: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let handles: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|e| {
|
||||
if let acadrust::EntityType::Viewport(vp) = e {
|
||||
if let codec::EntityType::Viewport(vp) = e {
|
||||
if vp.id >= 2 && vp.common.owner_handle == layout_block2 {
|
||||
Some(vp.common.handle)
|
||||
} else {
|
||||
@@ -777,7 +777,7 @@ impl OpenCADStudio {
|
||||
})
|
||||
.collect();
|
||||
for h in handles {
|
||||
if let Some(acadrust::EntityType::Viewport(vp)) =
|
||||
if let Some(codec::EntityType::Viewport(vp)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(h)
|
||||
{
|
||||
vp.id = id_counter;
|
||||
@@ -808,7 +808,7 @@ impl OpenCADStudio {
|
||||
let vp_handle = scene.active_viewport.unwrap();
|
||||
// Collect current frozen layer names for display.
|
||||
let frozen_names: Vec<String> = {
|
||||
if let Some(acadrust::EntityType::Viewport(vp)) =
|
||||
if let Some(codec::EntityType::Viewport(vp)) =
|
||||
scene.document.get_entity(vp_handle)
|
||||
{
|
||||
vp.frozen_layers
|
||||
@@ -847,7 +847,7 @@ impl OpenCADStudio {
|
||||
"TEXTTOFRONT" | "TEXTTOBACK" => {
|
||||
let to_front = cmd.ends_with("FRONT");
|
||||
let block_handle = self.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let handles: rustc_hash::FxHashSet<acadrust::Handle> = self.tabs[i]
|
||||
let handles: rustc_hash::FxHashSet<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
@@ -856,9 +856,9 @@ impl OpenCADStudio {
|
||||
(c.owner_handle == block_handle || c.owner_handle.is_null())
|
||||
&& matches!(
|
||||
e,
|
||||
acadrust::EntityType::Text(_)
|
||||
| acadrust::EntityType::MText(_)
|
||||
| acadrust::EntityType::Dimension(_)
|
||||
codec::EntityType::Text(_)
|
||||
| codec::EntityType::MText(_)
|
||||
| codec::EntityType::Dimension(_)
|
||||
)
|
||||
})
|
||||
.map(|e| e.common().handle)
|
||||
@@ -881,7 +881,7 @@ impl OpenCADStudio {
|
||||
|
||||
// HATCHTOBACK ÔÇö move every hatch object in the active space to the back of the draw order.
|
||||
"HATCHTOBACK" => {
|
||||
use acadrust::objects::ObjectType;
|
||||
use codec::objects::ObjectType;
|
||||
let block_handle = self.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let doc_ref = &self.tabs[i].scene.document;
|
||||
|
||||
@@ -912,7 +912,7 @@ impl OpenCADStudio {
|
||||
let has_locked_layers = !locked_layers.is_empty();
|
||||
|
||||
// 3. Single pass over entities in the active space.
|
||||
let mut hatches_to_move: Vec<acadrust::Handle> = Vec::new();
|
||||
let mut hatches_to_move: Vec<codec::Handle> = Vec::new();
|
||||
let mut min_eff = u64::MAX;
|
||||
|
||||
for e in doc_ref.entities() {
|
||||
@@ -921,7 +921,7 @@ impl OpenCADStudio {
|
||||
continue;
|
||||
}
|
||||
let hv = c.handle.value();
|
||||
if matches!(e, acadrust::EntityType::Hatch(_)) {
|
||||
if matches!(e, codec::EntityType::Hatch(_)) {
|
||||
if !has_locked_layers || !locked_layers.contains(c.layer.as_str()) {
|
||||
hatches_to_move.push(c.handle);
|
||||
}
|
||||
@@ -964,7 +964,7 @@ impl OpenCADStudio {
|
||||
self.tabs[i].scene.document.objects.get_mut(&th)
|
||||
{
|
||||
for (h, sort) in &assigns {
|
||||
table.add_entry(*h, acadrust::Handle::new(*sort));
|
||||
table.add_entry(*h, codec::Handle::new(*sort));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,7 +973,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
// 6. Invalidate ONLY draw-depth cache without dropping whole-drawing tessellations or spatial indexes.
|
||||
let changes: Vec<(acadrust::Handle, crate::scene::ChangeKind)> = hatches_to_move
|
||||
let changes: Vec<(codec::Handle, crate::scene::ChangeKind)> = hatches_to_move
|
||||
.iter()
|
||||
.map(|h| (*h, crate::scene::ChangeKind::Modified))
|
||||
.collect();
|
||||
@@ -989,7 +989,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
"DRAWORDER_FRONT" | "DRAWORDER_BACK" | "DRAWORDER_ABOVE" | "DRAWORDER_UNDER" => {
|
||||
let selected: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1020,7 +1020,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
"DRAWORDER" => {
|
||||
let selected: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1031,11 +1031,11 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("DRAWORDER ") => {
|
||||
use acadrust::objects::ObjectType;
|
||||
use codec::objects::ObjectType;
|
||||
let parts: Vec<&str> = cmd.split_whitespace().collect();
|
||||
let option = parts.get(1).unwrap_or(&"").to_uppercase();
|
||||
let i = self.active_tab;
|
||||
let selected: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let selected: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
@@ -1053,7 +1053,7 @@ impl OpenCADStudio {
|
||||
};
|
||||
let references: Vec<_> = parts.iter().skip(2).filter_map(|text| {
|
||||
u64::from_str_radix(text.trim_start_matches("0x").trim_start_matches("0X"), 16)
|
||||
.ok().map(acadrust::Handle::new)
|
||||
.ok().map(codec::Handle::new)
|
||||
}).filter(|handle| !selected.contains(handle)).collect();
|
||||
let relative_assignments = relative_above.and_then(|above| {
|
||||
assign_relative_group_keys(
|
||||
@@ -1077,7 +1077,7 @@ impl OpenCADStudio {
|
||||
// entities land strictly above/below every sibling —
|
||||
// including ones not yet in the table, which sort by
|
||||
// their own handle. (min_eff, max_eff) over siblings.
|
||||
let mut back_assigns: Option<Vec<(acadrust::Handle, u64)>> = None;
|
||||
let mut back_assigns: Option<Vec<(codec::Handle, u64)>> = None;
|
||||
let fb_baseline: Option<(u64, u64)> = if to_front_opt.is_some() {
|
||||
let selected_set: rustc_hash::FxHashSet<u64> =
|
||||
selected.iter().map(|h| h.value()).collect();
|
||||
@@ -1150,7 +1150,7 @@ impl OpenCADStudio {
|
||||
{
|
||||
if let Some(assignments) = &relative_assignments {
|
||||
for (handle, sort) in assignments {
|
||||
table.add_entry(*handle, acadrust::Handle::new(*sort));
|
||||
table.add_entry(*handle, codec::Handle::new(*sort));
|
||||
}
|
||||
self.command_line.push_info(crate::t!("DRAWORDER: selection reordered relative to reference objects.").as_ref());
|
||||
} else if let Some(to_front) = to_front_opt {
|
||||
@@ -1158,11 +1158,11 @@ impl OpenCADStudio {
|
||||
let (_, max_eff) = fb_baseline.unwrap_or((1, 0));
|
||||
for (k, h) in selected.iter().enumerate() {
|
||||
let sort = max_eff.saturating_add(1 + k as u64);
|
||||
table.add_entry(*h, acadrust::Handle::new(sort));
|
||||
table.add_entry(*h, codec::Handle::new(sort));
|
||||
}
|
||||
} else if let Some(assigns) = &back_assigns {
|
||||
for (h, sort) in assigns {
|
||||
table.add_entry(*h, acadrust::Handle::new(*sort));
|
||||
table.add_entry(*h, codec::Handle::new(*sort));
|
||||
}
|
||||
}
|
||||
let dir = if to_front { "front" } else { "back" };
|
||||
@@ -1192,11 +1192,11 @@ impl OpenCADStudio {
|
||||
// SYNCPVIEWPORTS — copy the first selected viewport's display settings
|
||||
// (view direction/target, scale, snap/grid, frozen layers) to the rest.
|
||||
"SYNCPVIEWPORTS" | "VPSYNC" => {
|
||||
let vps: Vec<acadrust::Handle> = self.tabs[i]
|
||||
let vps: Vec<codec::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.selected_entities()
|
||||
.iter()
|
||||
.filter(|(_, e)| matches!(e, acadrust::EntityType::Viewport(_)))
|
||||
.filter(|(_, e)| matches!(e, codec::EntityType::Viewport(_)))
|
||||
.map(|(h, _)| *h)
|
||||
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
|
||||
.collect();
|
||||
@@ -1207,7 +1207,7 @@ impl OpenCADStudio {
|
||||
return Some(Task::none());
|
||||
}
|
||||
let src = match self.tabs[i].scene.document.get_entity(vps[0]) {
|
||||
Some(acadrust::EntityType::Viewport(vp)) => vp.clone(),
|
||||
Some(codec::EntityType::Viewport(vp)) => vp.clone(),
|
||||
_ => {
|
||||
self.command_line
|
||||
.push_error(crate::t!("SYNCPVIEWPORTS: master is not a viewport.").as_ref());
|
||||
@@ -1217,7 +1217,7 @@ impl OpenCADStudio {
|
||||
self.push_undo_snapshot(i, "SYNCPVIEWPORTS");
|
||||
let mut n = 0usize;
|
||||
for h in &vps[1..] {
|
||||
if let Some(acadrust::EntityType::Viewport(vp)) =
|
||||
if let Some(codec::EntityType::Viewport(vp)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(*h)
|
||||
{
|
||||
vp.view_direction = src.view_direction;
|
||||
@@ -1241,7 +1241,7 @@ impl OpenCADStudio {
|
||||
// HIDE — hidden-line view of the active viewport.
|
||||
"HIDE" => {
|
||||
return Some(Task::done(Message::SetRenderMode(
|
||||
acadrust::entities::ViewportRenderMode::HiddenLine,
|
||||
codec::entities::ViewportRenderMode::HiddenLine,
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -1286,13 +1286,13 @@ enum DrawOrderStep {
|
||||
/// 3. Gather reference objects, excluding the moved selection; Enter applies.
|
||||
/// Typed hexadecimal handles may also be accumulated before confirming.
|
||||
pub(crate) struct DrawOrderCommand {
|
||||
selected: Vec<acadrust::Handle>,
|
||||
selected: Vec<codec::Handle>,
|
||||
step: DrawOrderStep,
|
||||
references: Vec<acadrust::Handle>,
|
||||
references: Vec<codec::Handle>,
|
||||
}
|
||||
|
||||
impl DrawOrderCommand {
|
||||
pub(crate) fn new(selected: Vec<acadrust::Handle>) -> Self {
|
||||
pub(crate) fn new(selected: Vec<codec::Handle>) -> Self {
|
||||
let step = if selected.is_empty() {
|
||||
DrawOrderStep::SelectObjects
|
||||
} else {
|
||||
@@ -1301,7 +1301,7 @@ impl DrawOrderCommand {
|
||||
Self { selected, step, references: Vec::new() }
|
||||
}
|
||||
|
||||
pub(crate) fn for_reference_pick(selected: Vec<acadrust::Handle>, above: bool) -> Self {
|
||||
pub(crate) fn for_reference_pick(selected: Vec<codec::Handle>, above: bool) -> Self {
|
||||
Self {
|
||||
selected,
|
||||
step: DrawOrderStep::PickReference { above },
|
||||
@@ -1356,7 +1356,7 @@ impl CadCommand for DrawOrderCommand {
|
||||
matches!(self.step, DrawOrderStep::SelectObjects | DrawOrderStep::PickReference { .. })
|
||||
}
|
||||
|
||||
fn on_selection_complete(&mut self, handles: Vec<acadrust::Handle>) -> crate::command::CmdResult {
|
||||
fn on_selection_complete(&mut self, handles: Vec<codec::Handle>) -> crate::command::CmdResult {
|
||||
if matches!(self.step, DrawOrderStep::PickReference { .. }) {
|
||||
self.references = handles.into_iter().filter(|handle| !self.selected.contains(handle)).collect();
|
||||
} else {
|
||||
@@ -1422,7 +1422,7 @@ impl CadCommand for DrawOrderCommand {
|
||||
for text in t.split_whitespace() {
|
||||
let hex = text.trim_start_matches("0x").trim_start_matches("0X");
|
||||
if let Ok(value) = u64::from_str_radix(hex, 16) {
|
||||
let handle = acadrust::Handle::new(value);
|
||||
let handle = codec::Handle::new(value);
|
||||
if !handle.is_null() && !self.selected.contains(&handle) && !self.references.contains(&handle) {
|
||||
self.references.push(handle);
|
||||
}
|
||||
@@ -1433,7 +1433,7 @@ impl CadCommand for DrawOrderCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: glam::DVec3) -> crate::command::CmdResult {
|
||||
fn on_entity_pick(&mut self, handle: codec::Handle, _pt: glam::DVec3) -> crate::command::CmdResult {
|
||||
if matches!(self.step, DrawOrderStep::PickReference { .. }) && !handle.is_null()
|
||||
&& !self.selected.contains(&handle) && !self.references.contains(&handle) {
|
||||
self.references.push(handle);
|
||||
@@ -1448,13 +1448,13 @@ impl CadCommand for DrawOrderCommand {
|
||||
/// Insert the selected block next to the extremal reference in effective draw
|
||||
/// order. Renumber the ordered siblings to avoid ties or saturated sort keys.
|
||||
fn assign_relative_group_keys(
|
||||
document: &acadrust::CadDocument,
|
||||
block: acadrust::Handle,
|
||||
selected: &[acadrust::Handle],
|
||||
references: &[acadrust::Handle],
|
||||
document: &codec::CadDocument,
|
||||
block: codec::Handle,
|
||||
selected: &[codec::Handle],
|
||||
references: &[codec::Handle],
|
||||
above: bool,
|
||||
) -> Option<Vec<(acadrust::Handle, u64)>> {
|
||||
use acadrust::objects::ObjectType;
|
||||
) -> Option<Vec<(codec::Handle, u64)>> {
|
||||
use codec::objects::ObjectType;
|
||||
let overrides: std::collections::HashMap<_, _> = document.objects.values().find_map(|object| {
|
||||
if let ObjectType::SortEntitiesTable(table) = object {
|
||||
(table.block_owner_handle == block).then(|| table.entries().map(|entry| (entry.entity_handle, entry.sort_handle.value())).collect())
|
||||
@@ -1489,15 +1489,15 @@ fn assign_relative_group_keys(
|
||||
/// shifted by `n` so lifted siblings keep their relative order. Locked-layer
|
||||
/// entities are never moved or lifted.
|
||||
fn assign_back_group_keys(
|
||||
doc: &acadrust::CadDocument,
|
||||
block_handle: acadrust::Handle,
|
||||
group: &[acadrust::Handle],
|
||||
doc: &codec::CadDocument,
|
||||
block_handle: codec::Handle,
|
||||
group: &[codec::Handle],
|
||||
floor: u64,
|
||||
overrides: Option<&rustc_hash::FxHashMap<u64, u64>>,
|
||||
locked_layers: &rustc_hash::FxHashSet<&str>,
|
||||
) -> Vec<(acadrust::Handle, u64)> {
|
||||
) -> Vec<(codec::Handle, u64)> {
|
||||
let n = group.len() as u64;
|
||||
let mut out: Vec<(acadrust::Handle, u64)> = Vec::with_capacity(group.len());
|
||||
let mut out: Vec<(codec::Handle, u64)> = Vec::with_capacity(group.len());
|
||||
if n == 0 {
|
||||
return out;
|
||||
}
|
||||
@@ -1512,7 +1512,7 @@ fn assign_back_group_keys(
|
||||
}
|
||||
let moved: rustc_hash::FxHashSet<u64> = group.iter().map(|h| h.value()).collect();
|
||||
let has_locked = !locked_layers.is_empty();
|
||||
let mut lifts: Vec<(acadrust::Handle, u64)> = Vec::new();
|
||||
let mut lifts: Vec<(codec::Handle, u64)> = Vec::new();
|
||||
for e in doc.entities() {
|
||||
let c = e.common();
|
||||
if c.owner_handle != block_handle && !c.owner_handle.is_null() {
|
||||
@@ -1538,8 +1538,8 @@ fn assign_back_group_keys(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::app::OpenCADStudio;
|
||||
use acadrust::objects::ObjectType;
|
||||
use acadrust::EntityType;
|
||||
use codec::objects::ObjectType;
|
||||
use codec::EntityType;
|
||||
|
||||
|
||||
|
||||
@@ -1651,7 +1651,7 @@ mod tests {
|
||||
fn hatchtoback_ignores_hatches_in_other_spaces() {
|
||||
let mut app = fresh_app();
|
||||
let i = app.active_tab;
|
||||
let other_block = acadrust::Handle::new(0x9999);
|
||||
let other_block = codec::Handle::new(0x9999);
|
||||
let h_foreign = app.tabs[i].scene.add_entity_clone(EntityType::Hatch(Default::default()));
|
||||
if let Some(entity) = app.tabs[i].scene.document.get_entity_mut(h_foreign) {
|
||||
entity.common_mut().owner_handle = other_block;
|
||||
@@ -1758,7 +1758,7 @@ mod tests {
|
||||
layer.flags.locked = true;
|
||||
}
|
||||
|
||||
let mut locked_hatch = acadrust::entities::Hatch::default();
|
||||
let mut locked_hatch = codec::entities::Hatch::default();
|
||||
locked_hatch.common.layer = "LOCKED_LAYER".into();
|
||||
let h_locked_hatch = app.tabs[i].scene.add_entity_clone(EntityType::Hatch(locked_hatch));
|
||||
|
||||
@@ -1844,12 +1844,12 @@ mod tests {
|
||||
// Pin the line to sort key 2: only ONE slot below the floor exists,
|
||||
// but three hatches need to fit behind it.
|
||||
{
|
||||
use acadrust::objects::{ObjectType, SortEntitiesTable};
|
||||
use codec::objects::{ObjectType, SortEntitiesTable};
|
||||
let doc = &mut app.tabs[i].scene.document;
|
||||
let nh = acadrust::Handle::new(doc.next_handle());
|
||||
let nh = codec::Handle::new(doc.next_handle());
|
||||
let mut table = SortEntitiesTable::for_block(block_handle);
|
||||
table.handle = nh;
|
||||
table.add_entry(h_line, acadrust::Handle::new(2));
|
||||
table.add_entry(h_line, codec::Handle::new(2));
|
||||
doc.objects.insert(nh, ObjectType::SortEntitiesTable(table));
|
||||
}
|
||||
|
||||
@@ -1979,12 +1979,12 @@ mod tests {
|
||||
let h_line2 = app.tabs[i].scene.add_entity_clone(EntityType::Line(Default::default()));
|
||||
|
||||
{
|
||||
use acadrust::objects::{ObjectType, SortEntitiesTable};
|
||||
use codec::objects::{ObjectType, SortEntitiesTable};
|
||||
let doc = &mut app.tabs[i].scene.document;
|
||||
let nh = acadrust::Handle::new(doc.next_handle());
|
||||
let nh = codec::Handle::new(doc.next_handle());
|
||||
let mut table = SortEntitiesTable::for_block(block_handle);
|
||||
table.handle = nh;
|
||||
table.add_entry(h_pinned, acadrust::Handle::new(2));
|
||||
table.add_entry(h_pinned, codec::Handle::new(2));
|
||||
doc.objects.insert(nh, ObjectType::SortEntitiesTable(table));
|
||||
}
|
||||
|
||||
@@ -2113,16 +2113,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn draw_order_table_reattaches_orphan_and_advances_object_handles() {
|
||||
use acadrust::objects::SortEntitiesTable;
|
||||
use codec::objects::SortEntitiesTable;
|
||||
|
||||
let mut app = fresh_app();
|
||||
let i = app.active_tab;
|
||||
let block = app.tabs[i].scene.current_layout_block_handle_pub();
|
||||
let entity = app.tabs[i].scene.add_entity_clone(EntityType::Line(Default::default()));
|
||||
let orphan_handle = acadrust::Handle::new(0x10_0000);
|
||||
let orphan_handle = codec::Handle::new(0x10_0000);
|
||||
let mut orphan = SortEntitiesTable::for_block(block);
|
||||
orphan.handle = orphan_handle;
|
||||
orphan.add_entry(entity, acadrust::Handle::new(7));
|
||||
orphan.add_entry(entity, codec::Handle::new(7));
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
|
||||
@@ -7,9 +7,9 @@ use crate::scene::pick::xclip as clip;
|
||||
impl OpenCADStudio {
|
||||
/// A block reference's extents in WCS: its block's objects through the
|
||||
/// insert transform.
|
||||
fn insert_extents(&self, i: usize, insert: acadrust::Handle) -> ([f64; 2], [f64; 2]) {
|
||||
fn insert_extents(&self, i: usize, insert: codec::Handle) -> ([f64; 2], [f64; 2]) {
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let Some(acadrust::EntityType::Insert(ins)) = document.get_entity(insert) else {
|
||||
let Some(codec::EntityType::Insert(ins)) = document.get_entity(insert) else {
|
||||
return ([0.0; 2], [0.0; 2]);
|
||||
};
|
||||
let xform = ins.get_transform();
|
||||
@@ -18,14 +18,14 @@ impl OpenCADStudio {
|
||||
let (a, b) = crate::scene::convert::tess::entity_bounds_in(document, e);
|
||||
for x in [a[0], b[0]] {
|
||||
for y in [a[1], b[1]] {
|
||||
let w = xform.apply(acadrust::types::Vector3::new(x, y, a[2]));
|
||||
let w = xform.apply(codec::types::Vector3::new(x, y, a[2]));
|
||||
lo = [lo[0].min(w.x), lo[1].min(w.y)];
|
||||
hi = [hi[0].max(w.x), hi[1].max(w.y)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if lo[0] > hi[0] {
|
||||
let p = xform.apply(acadrust::types::Vector3::new(0.0, 0.0, 0.0));
|
||||
let p = xform.apply(codec::types::Vector3::new(0.0, 0.0, 0.0));
|
||||
return ([p.x, p.y], [p.x, p.y]);
|
||||
}
|
||||
(lo, hi)
|
||||
@@ -34,7 +34,7 @@ impl OpenCADStudio {
|
||||
pub(in crate::app) fn apply_xclip(
|
||||
&mut self,
|
||||
i: usize,
|
||||
inserts: Vec<acadrust::Handle>,
|
||||
inserts: Vec<codec::Handle>,
|
||||
action: XclipAction,
|
||||
) {
|
||||
self.push_undo_snapshot(i, "XCLIP");
|
||||
@@ -61,23 +61,23 @@ impl OpenCADStudio {
|
||||
let Some(spatial) = clip::filter_handle(doc, *insert) else {
|
||||
continue;
|
||||
};
|
||||
let (Some(acadrust::objects::ObjectType::SpatialFilter(filter)), Some(acadrust::EntityType::Insert(ins))) =
|
||||
let (Some(codec::objects::ObjectType::SpatialFilter(filter)), Some(codec::EntityType::Insert(ins))) =
|
||||
(doc.objects.get(&spatial), doc.get_entity(*insert))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let outline = clip::clip_outline_world(doc, filter, &ins.get_transform());
|
||||
let mut pl = acadrust::entities::LwPolyline::from_points(
|
||||
let mut pl = codec::entities::LwPolyline::from_points(
|
||||
outline
|
||||
.iter()
|
||||
.map(|p| acadrust::types::Vector2::new(p[0], p[1]))
|
||||
.map(|p| codec::types::Vector2::new(p[0], p[1]))
|
||||
.collect(),
|
||||
);
|
||||
pl.is_closed = true;
|
||||
if !current_layer.is_empty() {
|
||||
pl.common.layer = current_layer.clone();
|
||||
}
|
||||
polylines.push(acadrust::EntityType::LwPolyline(pl));
|
||||
polylines.push(codec::EntityType::LwPolyline(pl));
|
||||
}
|
||||
}
|
||||
scene.reseed_derived_caches(*insert);
|
||||
|
||||
@@ -190,13 +190,13 @@ impl OpenCADStudio {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Ok(source) = crate::io::load_file(std::path::Path::new(path)) {
|
||||
let owner = source.header.model_space_block_handle;
|
||||
let entities: Vec<acadrust::EntityType> = source
|
||||
let entities: Vec<codec::EntityType> = source
|
||||
.entities()
|
||||
.filter(|e| e.common().owner_handle == owner)
|
||||
.filter(|e| {
|
||||
!matches!(
|
||||
e,
|
||||
acadrust::EntityType::Block(_) | acadrust::EntityType::BlockEnd(_)
|
||||
codec::EntityType::Block(_) | codec::EntityType::BlockEnd(_)
|
||||
)
|
||||
})
|
||||
.take(MAX_PREVIEW_ENTITIES + 1)
|
||||
@@ -219,7 +219,7 @@ impl OpenCADStudio {
|
||||
&mut self,
|
||||
i: usize,
|
||||
request: XrefAttachRequest,
|
||||
mut entity: acadrust::EntityType,
|
||||
mut entity: codec::EntityType,
|
||||
) {
|
||||
let pending = self.begin_undo(i, "XATTACH", 1, false);
|
||||
let host = self.tabs[i].current_path.clone();
|
||||
@@ -227,7 +227,7 @@ impl OpenCADStudio {
|
||||
if host.is_none() && request.path_type == Pathtype::Relative {
|
||||
self.tabs[i].xref_relative_on_save.insert(name.clone());
|
||||
}
|
||||
if let acadrust::EntityType::Insert(insert) = &mut entity {
|
||||
if let codec::EntityType::Insert(insert) = &mut entity {
|
||||
insert.block_name = name;
|
||||
}
|
||||
// Resolving merged the reference's layers and linetypes — mirror
|
||||
|
||||
Reference in new issue
Block a user