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
@@ -7,7 +7,7 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt;
|
||||
|
||||
use acadrust::types::Handle;
|
||||
use codec::types::Handle;
|
||||
use iced::widget::{button, checkbox, column, container, pick_list, row, scrollable, text, text_input, Space};
|
||||
use iced::{Border, Element, Fill, Length, Theme};
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
//! edits, undo and repaint live in the update handler (`Message::AttrEditorApply`).
|
||||
|
||||
use crate::app::Message;
|
||||
use acadrust::entities::{HorizontalAlignment, VerticalAlignment};
|
||||
use acadrust::types::{Color as AcadColor, LineWeight};
|
||||
use codec::entities::{HorizontalAlignment, VerticalAlignment};
|
||||
use codec::types::{Color as AcadColor, LineWeight};
|
||||
use iced::widget::{
|
||||
button, checkbox, column, container, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
use iced::widget::{
|
||||
button, checkbox, column, combo_box, container, mouse_area, pick_list, row, stack, text,
|
||||
text_editor, text_input, Space,
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::dock::{DockMsg, PanelId};
|
||||
use acadrust::objects::SolidHistoryOperation;
|
||||
use acadrust::{CadDocument, EntityType, Handle};
|
||||
use codec::objects::SolidHistoryOperation;
|
||||
use codec::{CadDocument, EntityType, Handle};
|
||||
use iced::widget::{button, column, container, mouse_area, row, scrollable, text, tooltip};
|
||||
use iced::{Background, Border, Element, Fill, Length, Theme};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
use iced::widget::{button, checkbox, column, container, row, text, text_input, Space};
|
||||
use iced::{Border, Element, Fill, Length, Theme};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::app::{LayerStateLayerFlag, LayerStateProperty, Message};
|
||||
use crate::ui::properties::{lw_options, LwItem};
|
||||
use acadrust::{LayerState, LayerStateMask};
|
||||
use codec::{LayerState, LayerStateMask};
|
||||
use iced::widget::{
|
||||
button, checkbox, column, container, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
@@ -12,7 +12,7 @@ use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
struct TransparencyItem(Option<acadrust::types::Transparency>);
|
||||
struct TransparencyItem(Option<codec::types::Transparency>);
|
||||
|
||||
impl fmt::Display for TransparencyItem {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@@ -23,11 +23,11 @@ impl fmt::Display for TransparencyItem {
|
||||
}
|
||||
}
|
||||
|
||||
fn transparency_options(current: Option<acadrust::types::Transparency>) -> Vec<TransparencyItem> {
|
||||
fn transparency_options(current: Option<codec::types::Transparency>) -> Vec<TransparencyItem> {
|
||||
let mut options = vec![TransparencyItem(None)];
|
||||
for percent in (0..=90).step_by(10) {
|
||||
options.push(TransparencyItem(Some(
|
||||
acadrust::types::Transparency::from_percent(percent as f64 / 100.0),
|
||||
codec::types::Transparency::from_percent(percent as f64 / 100.0),
|
||||
)));
|
||||
}
|
||||
let current = TransparencyItem(current);
|
||||
@@ -400,7 +400,7 @@ fn editor_header<'a>() -> Element<'a, Message> {
|
||||
|
||||
fn editor_layer_row<'a>(
|
||||
index: usize,
|
||||
layer: &'a acadrust::LayerStateLayer,
|
||||
layer: &'a codec::LayerStateLayer,
|
||||
color_open: bool,
|
||||
linetypes: Vec<String>,
|
||||
) -> Element<'a, Message> {
|
||||
|
||||
@@ -4,11 +4,11 @@ use crate::app::Message;
|
||||
use crate::ui::properties::{lw_options, LinetypeItem, LwItem};
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::ROW_H;
|
||||
use acadrust::tables::layer::Layer as DocLayer;
|
||||
use acadrust::tables::Table;
|
||||
use acadrust::types::aci_table::aci_to_rgb;
|
||||
use acadrust::types::{Color as AcadColor, LineWeight};
|
||||
use acadrust::Handle;
|
||||
use codec::tables::layer::Layer as DocLayer;
|
||||
use codec::tables::Table;
|
||||
use codec::types::aci_table::aci_to_rgb;
|
||||
use codec::types::{Color as AcadColor, LineWeight};
|
||||
use codec::Handle;
|
||||
use iced::widget::{
|
||||
button, column, combo_box, container, mouse_area, row, scrollable, text, text_input, tooltip,
|
||||
};
|
||||
|
||||
@@ -18,8 +18,8 @@ use crate::scene::named_parameters::ParameterTable;
|
||||
use crate::scene::Scene;
|
||||
use crate::t;
|
||||
use crate::ui::style::common::muted_style;
|
||||
use acadrust::types::Handle;
|
||||
use acadrust::EntityType;
|
||||
use codec::types::Handle;
|
||||
use codec::EntityType;
|
||||
use iced::widget::tooltip::Position as TipPos;
|
||||
use iced::widget::{button, column, container, row, scrollable, text, text_input, tooltip, Space};
|
||||
use iced::{Background, Element, Length, Theme};
|
||||
@@ -392,10 +392,10 @@ mod tests {
|
||||
ConstraintKind, ParametricRef, ParametricScope,
|
||||
};
|
||||
let mut scene = Scene::new();
|
||||
let line = scene.add_entity(acadrust::EntityType::Line(
|
||||
acadrust::entities::Line::from_points(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
let line = scene.add_entity(codec::EntityType::Line(
|
||||
codec::entities::Line::from_points(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
),
|
||||
));
|
||||
scene
|
||||
@@ -426,7 +426,7 @@ mod tests {
|
||||
#[test]
|
||||
fn entity_label_reports_erased_for_a_dangling_handle() {
|
||||
let scene = Scene::new();
|
||||
let label = entity_label(&scene, acadrust::types::Handle::new(999));
|
||||
let label = entity_label(&scene, codec::types::Handle::new(999));
|
||||
assert!(label.starts_with("(erased "), "got {label}");
|
||||
}
|
||||
}
|
||||
@@ -526,7 +526,7 @@ pub fn view_attach<'a>(
|
||||
#[derive(Clone)]
|
||||
pub struct LayerTarget {
|
||||
pub name: String,
|
||||
pub handle: acadrust::Handle,
|
||||
pub handle: codec::Handle,
|
||||
pub layers: Vec<String>,
|
||||
pub hidden: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -158,13 +158,13 @@ pub struct PageSetupImportDraft {
|
||||
pub file: String,
|
||||
/// Each setup with whether it is ticked for import. The settings are
|
||||
/// carried along so the source file is read once.
|
||||
pub setups: Vec<(String, acadrust::objects::PlotSettings, bool)>,
|
||||
pub setups: Vec<(String, codec::objects::PlotSettings, bool)>,
|
||||
/// Why the file gave nothing, when it did not.
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl PageSetupImportDraft {
|
||||
pub fn selected(&self) -> impl Iterator<Item = (&str, &acadrust::objects::PlotSettings)> {
|
||||
pub fn selected(&self) -> impl Iterator<Item = (&str, &codec::objects::PlotSettings)> {
|
||||
self.setups
|
||||
.iter()
|
||||
.filter(|(_, _, on)| *on)
|
||||
@@ -178,7 +178,7 @@ pub enum PageSetupImportMsg {
|
||||
/// Ask for the drawing to import from.
|
||||
Pick,
|
||||
/// The drawing was read (or could not be): its name and page setups.
|
||||
Loaded(Result<(String, Vec<(String, acadrust::objects::PlotSettings)>), String>),
|
||||
Loaded(Result<(String, Vec<(String, codec::objects::PlotSettings)>), String>),
|
||||
/// Tick or untick one setup.
|
||||
Toggle(String),
|
||||
/// Tick or untick every setup.
|
||||
|
||||
@@ -1033,7 +1033,7 @@ mod tests {
|
||||
tag: "v1.4.0".to_string(),
|
||||
api_version: 4,
|
||||
acadrust_source: Some(
|
||||
"git+https://github.com/HakanSeven12/cadcodec.git?rev=94df2c3#94df2c3f87fa051b16ffc3923f80e9247c85c5fd".to_string(),
|
||||
"git+https://github.com/HakanSeven12/opencadcodec.git?rev=94df2c3#94df2c3f87fa051b16ffc3923f80e9247c85c5fd".to_string(),
|
||||
),
|
||||
acadrust_declared: true,
|
||||
acadrust_compatible: true,
|
||||
@@ -1045,7 +1045,7 @@ mod tests {
|
||||
tag: "v2.0.0".to_string(),
|
||||
api_version: 4,
|
||||
acadrust_source: Some(
|
||||
"git+https://github.com/HakanSeven12/cadcodec.git?rev=0908da7#0908da7b6e4f702a6c78359a57f53e2b79cf39eb".to_string(),
|
||||
"git+https://github.com/HakanSeven12/opencadcodec.git?rev=0908da7#0908da7b6e4f702a6c78359a57f53e2b79cf39eb".to_string(),
|
||||
),
|
||||
acadrust_declared: true,
|
||||
acadrust_compatible: false,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
use iced::widget::{
|
||||
button, column, combo_box, container, pick_list, row, text, text_input, Space,
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::io::xref::collect_entries_with_prev;
|
||||
use crate::io::xref_model::{normalize_lexical, Pathtype, RefKind, RefStatus, RefType, ReferenceEntry};
|
||||
use crate::ui::ROW_H;
|
||||
use crate::ui::style::common::muted_style;
|
||||
use acadrust::CadDocument;
|
||||
use codec::CadDocument;
|
||||
use iced::widget::{button, column, container, mouse_area, row, scrollable, text, tooltip};
|
||||
use iced::Padding;
|
||||
use iced::{Background, Border, Element, Fill, Length, Theme};
|
||||
@@ -1135,8 +1135,8 @@ impl XrefManagerPanel {
|
||||
/// directly — mirrors the three [`collect_entries`] scans so nested entries
|
||||
/// (foreign handles) classify correctly even on handle collisions.
|
||||
fn direct_identities(doc: &CadDocument) -> HashSet<(u64, String)> {
|
||||
use acadrust::entities::UnderlayType;
|
||||
use acadrust::objects::ObjectType;
|
||||
use codec::entities::UnderlayType;
|
||||
use codec::objects::ObjectType;
|
||||
|
||||
let mut ids: HashSet<(u64, String)> = HashSet::new();
|
||||
for br in doc.block_records.iter() {
|
||||
@@ -2175,17 +2175,17 @@ fn reference_preview(entry: &ReferenceEntry) -> Option<image::RgbaImage> {
|
||||
fn find_image_def(
|
||||
doc: &CadDocument,
|
||||
key: u64,
|
||||
) -> Option<&acadrust::objects::ImageDefinition> {
|
||||
doc.objects.get(&acadrust::types::Handle::from(key)).and_then(|o| match o {
|
||||
acadrust::objects::ObjectType::ImageDefinition(def) => Some(def),
|
||||
) -> Option<&codec::objects::ImageDefinition> {
|
||||
doc.objects.get(&codec::types::Handle::from(key)).and_then(|o| match o {
|
||||
codec::objects::ObjectType::ImageDefinition(def) => Some(def),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn find_image_display_size(doc: &CadDocument, key: u64) -> Option<(f64, f64)> {
|
||||
let handle = acadrust::types::Handle::from(key);
|
||||
let handle = codec::types::Handle::from(key);
|
||||
for entity in doc.entities() {
|
||||
if let acadrust::EntityType::RasterImage(img) = entity {
|
||||
if let codec::EntityType::RasterImage(img) = entity {
|
||||
if img.definition_handle == Some(handle) {
|
||||
let w = (img.u_vector.x.powi(2) + img.u_vector.y.powi(2) + img.u_vector.z.powi(2)).sqrt();
|
||||
let h = (img.v_vector.x.powi(2) + img.v_vector.y.powi(2) + img.v_vector.z.powi(2)).sqrt();
|
||||
@@ -2442,10 +2442,10 @@ mod tests {
|
||||
assert!(!panel.display_rows().iter().any(|r| r.is_nested));
|
||||
}
|
||||
|
||||
fn preview_doc2(dir: &std::path::Path) -> acadrust::CadDocument {
|
||||
fn preview_doc2(dir: &std::path::Path) -> codec::CadDocument {
|
||||
// Two referenced images → genuine multi-select.
|
||||
use acadrust::objects::{ImageDefinition, ObjectType};
|
||||
let mut doc = acadrust::CadDocument::new();
|
||||
use codec::objects::{ImageDefinition, ObjectType};
|
||||
let mut doc = codec::CadDocument::new();
|
||||
for (i, name) in ["a.png", "b.png"].iter().enumerate() {
|
||||
let img = image::RgbaImage::from_pixel(8, 8, image::Rgba([9, 9, 9, 255]));
|
||||
img.save(dir.join(name)).unwrap();
|
||||
@@ -2454,37 +2454,37 @@ mod tests {
|
||||
let mut def = ImageDefinition::with_dimensions(path.clone(), 8, 8);
|
||||
def.handle = h;
|
||||
doc.objects.insert(h, ObjectType::ImageDefinition(def));
|
||||
let mut ent = acadrust::entities::RasterImage::new(
|
||||
let mut ent = codec::entities::RasterImage::new(
|
||||
&path,
|
||||
acadrust::types::Vector3::ZERO,
|
||||
codec::types::Vector3::ZERO,
|
||||
8.0 + i as f64,
|
||||
8.0,
|
||||
);
|
||||
ent.definition_handle = Some(h);
|
||||
doc.add_entity(acadrust::EntityType::RasterImage(ent)).unwrap();
|
||||
doc.add_entity(codec::EntityType::RasterImage(ent)).unwrap();
|
||||
}
|
||||
doc
|
||||
}
|
||||
|
||||
fn preview_doc(dir: &std::path::Path, name: &str) -> acadrust::CadDocument {
|
||||
fn preview_doc(dir: &std::path::Path, name: &str) -> codec::CadDocument {
|
||||
// Referenced 8x8 PNG under `dir`; the entry resolves Loaded.
|
||||
use acadrust::objects::{ImageDefinition, ObjectType};
|
||||
use codec::objects::{ImageDefinition, ObjectType};
|
||||
let img = image::RgbaImage::from_pixel(8, 8, image::Rgba([9, 9, 9, 255]));
|
||||
img.save(dir.join(name)).unwrap();
|
||||
let img_path = dir.join(name).to_string_lossy().into_owned();
|
||||
let mut doc = acadrust::CadDocument::new();
|
||||
let mut doc = codec::CadDocument::new();
|
||||
let h = doc.allocate_handle();
|
||||
let mut def = ImageDefinition::with_dimensions(img_path.clone(), 8, 8);
|
||||
def.handle = h;
|
||||
doc.objects.insert(h, ObjectType::ImageDefinition(def));
|
||||
let mut ent = acadrust::entities::RasterImage::new(
|
||||
let mut ent = codec::entities::RasterImage::new(
|
||||
&img_path,
|
||||
acadrust::types::Vector3::ZERO,
|
||||
codec::types::Vector3::ZERO,
|
||||
8.0,
|
||||
8.0,
|
||||
);
|
||||
ent.definition_handle = Some(h);
|
||||
doc.add_entity(acadrust::EntityType::RasterImage(ent)).unwrap();
|
||||
doc.add_entity(codec::EntityType::RasterImage(ent)).unwrap();
|
||||
doc
|
||||
}
|
||||
|
||||
@@ -2558,8 +2558,8 @@ mod tests {
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("plan.dwg"), b"not-a-real-dwg").unwrap();
|
||||
let mut doc = acadrust::CadDocument::new();
|
||||
let mut br = acadrust::tables::BlockRecord::new("PLAN");
|
||||
let mut doc = codec::CadDocument::new();
|
||||
let mut br = codec::tables::BlockRecord::new("PLAN");
|
||||
br.flags.is_xref = true;
|
||||
br.xref_path = dir.join("plan.dwg").to_string_lossy().into_owned();
|
||||
br.handle = doc.allocate_handle();
|
||||
@@ -2596,7 +2596,7 @@ mod tests {
|
||||
.objects
|
||||
.iter()
|
||||
.find_map(|(h, o)| match o {
|
||||
acadrust::objects::ObjectType::ImageDefinition(_) => Some(h.value()),
|
||||
codec::objects::ObjectType::ImageDefinition(_) => Some(h.value()),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
Reference in new issue
Block a user