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
+40
-40
@@ -1,5 +1,5 @@
|
||||
use acadrust::entities::{BoundaryEdge, Hatch};
|
||||
use cadkernel::geom2d::{
|
||||
use codec::entities::{BoundaryEdge, Hatch};
|
||||
use kernel::geom2d::{
|
||||
Arc as KernelArc, Curve as KernelCurve, Ellipse as KernelEllipse,
|
||||
EllipseArc as KernelEllipseArc, Line as KernelLine, NurbsCurve as KernelNurbs,
|
||||
Parameterization, Polyline as KernelPolyline, PolylineVertex as KernelVertex,
|
||||
@@ -28,20 +28,20 @@ pub(crate) fn boundary_area(h: &Hatch) -> f64 {
|
||||
path_areas.push(path_area.abs());
|
||||
rings.push(crate::scene::hatch_path_ring(path).unwrap_or_default());
|
||||
}
|
||||
let depths = cadkernel::geom2d::ring_nesting_depths(&rings);
|
||||
let depths = kernel::geom2d::ring_nesting_depths(&rings);
|
||||
path_areas
|
||||
.into_iter()
|
||||
.zip(depths)
|
||||
.filter_map(|(area, depth)| match h.style {
|
||||
acadrust::entities::HatchStyleType::Normal => {
|
||||
codec::entities::HatchStyleType::Normal => {
|
||||
Some(if depth % 2 == 0 { area } else { -area })
|
||||
}
|
||||
acadrust::entities::HatchStyleType::Outer if depth <= 1 => {
|
||||
codec::entities::HatchStyleType::Outer if depth <= 1 => {
|
||||
Some(if depth == 0 { area } else { -area })
|
||||
}
|
||||
acadrust::entities::HatchStyleType::Outer => None,
|
||||
acadrust::entities::HatchStyleType::Ignore if depth == 0 => Some(area),
|
||||
acadrust::entities::HatchStyleType::Ignore => None,
|
||||
codec::entities::HatchStyleType::Outer => None,
|
||||
codec::entities::HatchStyleType::Ignore if depth == 0 => Some(area),
|
||||
codec::entities::HatchStyleType::Ignore => None,
|
||||
})
|
||||
.sum::<f64>()
|
||||
.abs()
|
||||
@@ -186,7 +186,7 @@ fn boundary_centroid(h: &Hatch) -> Option<(f64, f64)> {
|
||||
/// Pattern lines loaded from DXF/DWG are rendered prebaked, so their metadata
|
||||
/// scale is not applied again by the renderer.
|
||||
pub(crate) fn scale_pattern_geometry(
|
||||
pattern: &mut acadrust::entities::HatchPattern,
|
||||
pattern: &mut codec::entities::HatchPattern,
|
||||
factor: f64,
|
||||
) {
|
||||
let (origin_x, origin_y) = (0.0, 0.0);
|
||||
@@ -204,7 +204,7 @@ pub(crate) fn scale_pattern_geometry(
|
||||
/// Rotate a catalog pattern about its intrinsic coordinate origin.
|
||||
/// This keeps the line angle, base point and world-space offset in sync.
|
||||
pub(crate) fn rotate_pattern_geometry(
|
||||
pattern: &mut acadrust::entities::HatchPattern,
|
||||
pattern: &mut codec::entities::HatchPattern,
|
||||
angle: f64,
|
||||
) {
|
||||
let (sin, cos) = angle.sin_cos();
|
||||
@@ -225,7 +225,7 @@ pub(crate) fn rotate_pattern_geometry(
|
||||
|
||||
/// Move every stored line by the same amount, preserving the pattern phase.
|
||||
pub(crate) fn translate_pattern_geometry(
|
||||
pattern: &mut acadrust::entities::HatchPattern,
|
||||
pattern: &mut codec::entities::HatchPattern,
|
||||
dx: f64,
|
||||
dy: f64,
|
||||
) {
|
||||
@@ -238,30 +238,30 @@ pub(crate) fn translate_pattern_geometry(
|
||||
/// Read the hatch background colour from its `HATCHBACKGROUNDCOLOR` extended
|
||||
/// data (group 1071, packed true colour: high byte = colour method, low three =
|
||||
/// RGB). `None` when unset or not a true-colour value.
|
||||
pub fn background_color(h: &Hatch) -> Option<acadrust::types::Color> {
|
||||
pub fn background_color(h: &Hatch) -> Option<codec::types::Color> {
|
||||
let rec = h.common.extended_data.get_record("HATCHBACKGROUNDCOLOR")?;
|
||||
let raw = rec.values.iter().find_map(|v| match v {
|
||||
acadrust::xdata::XDataValue::Integer32(n) => Some(*n as u32),
|
||||
codec::xdata::XDataValue::Integer32(n) => Some(*n as u32),
|
||||
_ => None,
|
||||
})?;
|
||||
match (raw >> 24) & 0xFF {
|
||||
// Colour-method byte: C0 = ByLayer, C1 = ByBlock, C2 = true colour,
|
||||
// C3 = ACI index.
|
||||
0xC0 => Some(acadrust::types::Color::ByLayer),
|
||||
0xC1 => Some(acadrust::types::Color::ByBlock),
|
||||
0xC2 => Some(acadrust::types::Color::Rgb {
|
||||
0xC0 => Some(codec::types::Color::ByLayer),
|
||||
0xC1 => Some(codec::types::Color::ByBlock),
|
||||
0xC2 => Some(codec::types::Color::Rgb {
|
||||
r: ((raw >> 16) & 0xFF) as u8,
|
||||
g: ((raw >> 8) & 0xFF) as u8,
|
||||
b: (raw & 0xFF) as u8,
|
||||
}),
|
||||
0xC3 => Some(acadrust::types::Color::Index((raw & 0xFF) as u8)),
|
||||
0xC3 => Some(codec::types::Color::Index((raw & 0xFF) as u8)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Pack an RGB colour into a `HATCHBACKGROUNDCOLOR` group-1071 true-colour word.
|
||||
pub fn pack_background_color(c: &acadrust::types::Color) -> i32 {
|
||||
use acadrust::types::Color;
|
||||
pub fn pack_background_color(c: &codec::types::Color) -> i32 {
|
||||
use codec::types::Color;
|
||||
(match c {
|
||||
Color::ByLayer => 0xC0000000u32,
|
||||
Color::ByBlock => 0xC1000000u32,
|
||||
@@ -275,8 +275,8 @@ pub fn pack_background_color(c: &acadrust::types::Color) -> i32 {
|
||||
|
||||
/// Replace (or insert) the hatch's `HATCHBACKGROUNDCOLOR` extended-data record,
|
||||
/// preserving every other application's records.
|
||||
pub fn set_background_color(h: &mut Hatch, c: &acadrust::types::Color) {
|
||||
use acadrust::xdata::{ExtendedDataRecord, XDataValue};
|
||||
pub fn set_background_color(h: &mut Hatch, c: &codec::types::Color) {
|
||||
use codec::xdata::{ExtendedDataRecord, XDataValue};
|
||||
const APP: &str = "HATCHBACKGROUNDCOLOR";
|
||||
let kept: Vec<ExtendedDataRecord> = h
|
||||
.common
|
||||
@@ -298,7 +298,7 @@ pub fn set_background_color(h: &mut Hatch, c: &acadrust::types::Color) {
|
||||
/// Remove the hatch's `HATCHBACKGROUNDCOLOR` extended-data record (background
|
||||
/// off), preserving every other application's records.
|
||||
pub fn clear_background_color(h: &mut Hatch) {
|
||||
use acadrust::xdata::ExtendedDataRecord;
|
||||
use codec::xdata::ExtendedDataRecord;
|
||||
const APP: &str = "HATCHBACKGROUNDCOLOR";
|
||||
let kept: Vec<ExtendedDataRecord> = h
|
||||
.common
|
||||
@@ -343,18 +343,18 @@ fn associative_property(h: &Hatch) -> Property {
|
||||
|
||||
fn properties(h: &Hatch) -> Vec<PropSection> {
|
||||
let pattern_type = match h.pattern_type {
|
||||
acadrust::entities::HatchPatternType::Predefined => "Predefined",
|
||||
acadrust::entities::HatchPatternType::UserDefined => "User Defined",
|
||||
acadrust::entities::HatchPatternType::Custom => "Custom",
|
||||
codec::entities::HatchPatternType::Predefined => "Predefined",
|
||||
codec::entities::HatchPatternType::UserDefined => "User Defined",
|
||||
codec::entities::HatchPatternType::Custom => "Custom",
|
||||
};
|
||||
let style = match h.style {
|
||||
acadrust::entities::HatchStyleType::Normal => "Normal",
|
||||
acadrust::entities::HatchStyleType::Outer => "Outer",
|
||||
acadrust::entities::HatchStyleType::Ignore => "Ignore",
|
||||
codec::entities::HatchStyleType::Normal => "Normal",
|
||||
codec::entities::HatchStyleType::Outer => "Outer",
|
||||
codec::entities::HatchStyleType::Ignore => "Ignore",
|
||||
};
|
||||
let area = boundary_area(h);
|
||||
let g = &h.gradient_color;
|
||||
let default_col = acadrust::types::Color::Index(7);
|
||||
let default_col = codec::types::Color::Index(7);
|
||||
let grad_c1 = g.colors.first().map(|e| e.color).unwrap_or(default_col);
|
||||
let grad_c2 = g.colors.get(1).map(|e| e.color).unwrap_or(default_col);
|
||||
let bg_on = background_color(h).is_some();
|
||||
@@ -499,7 +499,7 @@ fn properties(h: &Hatch) -> Vec<PropSection> {
|
||||
));
|
||||
if matches!(
|
||||
h.pattern_type,
|
||||
acadrust::entities::HatchPatternType::UserDefined
|
||||
codec::entities::HatchPatternType::UserDefined
|
||||
) {
|
||||
pattern_props.push(spacing_row);
|
||||
pattern_props.push(double_row);
|
||||
@@ -555,7 +555,7 @@ fn properties(h: &Hatch) -> Vec<PropSection> {
|
||||
}
|
||||
|
||||
fn apply_geom_prop(h: &mut Hatch, field: &str, value: &str) {
|
||||
use acadrust::entities::{HatchPatternType, HatchStyleType};
|
||||
use codec::entities::{HatchPatternType, HatchStyleType};
|
||||
// Non-numeric fields (bool toggles / enum choices) — handled before the
|
||||
// f64 parse below, which would otherwise reject their string values.
|
||||
match field {
|
||||
@@ -566,7 +566,7 @@ fn apply_geom_prop(h: &mut Hatch, field: &str, value: &str) {
|
||||
if background_color(h).is_some() {
|
||||
clear_background_color(h);
|
||||
} else {
|
||||
set_background_color(h, &acadrust::types::Color::ByLayer);
|
||||
set_background_color(h, &codec::types::Color::ByLayer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -611,7 +611,7 @@ fn apply_geom_prop(h: &mut Hatch, field: &str, value: &str) {
|
||||
match requested {
|
||||
HatchPatternType::UserDefined => {
|
||||
// Rebuild user-defined geometry from its parameters.
|
||||
h.pattern = acadrust::entities::HatchPattern::new("_USER");
|
||||
h.pattern = codec::entities::HatchPattern::new("_USER");
|
||||
}
|
||||
HatchPatternType::Predefined => {
|
||||
if let Some(entry) =
|
||||
@@ -700,7 +700,7 @@ fn apply_geom_prop(h: &mut Hatch, field: &str, value: &str) {
|
||||
h.pattern_scale = v;
|
||||
if matches!(
|
||||
h.pattern_type,
|
||||
acadrust::entities::HatchPatternType::UserDefined
|
||||
codec::entities::HatchPatternType::UserDefined
|
||||
) {
|
||||
h.pattern.lines.clear();
|
||||
h.pattern.name = "_USER".to_string();
|
||||
@@ -709,11 +709,11 @@ fn apply_geom_prop(h: &mut Hatch, field: &str, value: &str) {
|
||||
// Origin rows are relative offsets and return to zero after commit.
|
||||
"origin_x" => {
|
||||
let origin = h.pattern_origin();
|
||||
h.set_pattern_origin(acadrust::types::Vector2::new(origin.x + v, origin.y));
|
||||
h.set_pattern_origin(codec::types::Vector2::new(origin.x + v, origin.y));
|
||||
}
|
||||
"origin_y" => {
|
||||
let origin = h.pattern_origin();
|
||||
h.set_pattern_origin(acadrust::types::Vector2::new(origin.x, origin.y + v));
|
||||
h.set_pattern_origin(codec::types::Vector2::new(origin.x, origin.y + v));
|
||||
}
|
||||
"iso_pen_width" if v > 0.0 => {
|
||||
let old = h.pattern_scale;
|
||||
@@ -731,7 +731,7 @@ fn apply_transform(h: &mut Hatch, t: &EntityTransform) {
|
||||
crate::scene::view::transform::apply_standard_entity_transform(h, t, |entity, p1, p2| {
|
||||
// Keep boundary directions, angles, and sweeps consistent.
|
||||
let t = crate::scene::view::transform::reflection_about_xy_line(p1, p2);
|
||||
acadrust::entities::Entity::apply_transform(entity, &t);
|
||||
codec::entities::Entity::apply_transform(entity, &t);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ impl Grippable for Hatch {
|
||||
GripApply::Translate(delta) => (delta.x, delta.y),
|
||||
};
|
||||
let origin = self.pattern_origin();
|
||||
self.set_pattern_origin(acadrust::types::Vector2::new(origin.x + dx, origin.y + dy));
|
||||
self.set_pattern_origin(codec::types::Vector2::new(origin.x + dx, origin.y + dy));
|
||||
return;
|
||||
}
|
||||
id += 1;
|
||||
@@ -989,7 +989,7 @@ impl Grippable for Hatch {
|
||||
boundary_centroid(self),
|
||||
self.pattern.lines.first().map(|line| (line.base_point.x, line.base_point.y)),
|
||||
) {
|
||||
self.set_pattern_origin(acadrust::types::Vector2::new(gx, gy));
|
||||
self.set_pattern_origin(codec::types::Vector2::new(gx, gy));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1055,7 +1055,7 @@ impl FallbackTess for Hatch {
|
||||
continue;
|
||||
};
|
||||
let local = curve
|
||||
.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE);
|
||||
.tessellate_angle(kernel::tessellation::DEFAULT_ANGLE);
|
||||
if local.len() < 2 {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user