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 <noreply@anthropic.com>
This commit is contained in:
1 parent
56c04408d6
commit
f537aff75c
430 files changed
+9925
-8540
No files matched your search
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user