forked from 1b-agent/opencadstudio-upstream
review(#1653): upstream pins, registered expression xdata, table apply refreshes sweeps
- Cargo: drop the fork patches; codec 8e93175, kernel 0665fc9, graph 3b91e67 in every manifest and lock. - A swept surface's expression link is written through set_entity_xdata, so OCS_SWEEP_EXPRESSION has its APPID record and the record its handle. - Applying the whole named-parameter table also rebuilds the swept surfaces linked to expressions, not only a single-row edit. - swept_surface_entity keeps its doc comment. - The native-constraint tests find a scope's network through its own dictionary, where it is now stored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
2d1f45eeb3
commit
ac086def56
10 files changed
+38
-40
No files matched your search
Generated
+4
-4
@@ -4205,7 +4205,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "opencadcodec"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/ramox81/cadcodec.git?rev=64fe2a6#64fe2a6f8896d674d606ded65f4c9cc4b581ac66"
|
||||
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=8e93175#8e9317506f1522bad52920f7398223c1e3538860"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.13.1",
|
||||
@@ -4228,7 +4228,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "opencadgraph"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=ca3e6a2#ca3e6a20d70210d1422feec536e0c2422bfadfd0"
|
||||
source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=3b91e67#3b91e67d7b2b19812f42249b59eb0646fa91e862"
|
||||
dependencies = [
|
||||
"opencadkernel",
|
||||
"serde_json",
|
||||
@@ -4237,7 +4237,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "opencadkernel"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ramox81/cadkernel.git?rev=23138fc#23138fcd3ef251c5624164a2311b8b264e22341e"
|
||||
source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=0665fc9#0665fc99dd3db6622557bd5773996f319a51ac38"
|
||||
dependencies = [
|
||||
"cavalier_contours",
|
||||
"opencadcodec",
|
||||
@@ -4248,7 +4248,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "opencadkernel-constraints"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ramox81/cadkernel.git?rev=23138fc#23138fcd3ef251c5624164a2311b8b264e22341e"
|
||||
source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=0665fc9#0665fc99dd3db6622557bd5773996f319a51ac38"
|
||||
dependencies = [
|
||||
"nalgebra",
|
||||
]
|
||||
|
||||
+4
-11
@@ -34,10 +34,10 @@ rfd = "0.17"
|
||||
clap = { version = "4", features = ["derive", "string"] }
|
||||
env_logger = "0.11"
|
||||
log = "0.4"
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", features = ["serde"] }
|
||||
kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "3f3781a", features = ["acis", "offset"] }
|
||||
kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "3f3781a" }
|
||||
graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "ca3e6a2" }
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", features = ["serde"] }
|
||||
kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "0665fc9", features = ["acis", "offset"] }
|
||||
kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "0665fc9" }
|
||||
graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "3b91e67" }
|
||||
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
||||
flate2 = "1"
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] }
|
||||
@@ -181,10 +181,3 @@ harness = false
|
||||
[[test]]
|
||||
name = "integration"
|
||||
path = "tests/integration.rs"
|
||||
|
||||
[patch."https://github.com/HakanSeven12/opencadkernel.git"]
|
||||
opencadkernel = { git = "https://github.com/ramox81/cadkernel.git", rev = "23138fc" }
|
||||
opencadkernel-constraints = { git = "https://github.com/ramox81/cadkernel.git", rev = "23138fc" }
|
||||
|
||||
[patch."https://github.com/HakanSeven12/opencadcodec.git"]
|
||||
opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "64fe2a6" }
|
||||
@@ -15,7 +15,7 @@ serde_json = { version = "1", optional = true }
|
||||
# Pulled in only by the `host` feature, which adds the `opencadcodec`-typed
|
||||
# `HostApi` runtime surface. The default crate stays dependency-free so engine
|
||||
# crates and external tooling can depend on the manifest/ribbon contract cheaply.
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", optional = true, features = ["serde"] }
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", optional = true, features = ["serde"] }
|
||||
|
||||
# Runtime IPC and serialization (host feature only).
|
||||
interprocess = { version = "2", optional = true }
|
||||
@@ -39,7 +39,7 @@ serde_json = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
cargo-lock = "11"
|
||||
# opencadcodec is scanned at build time to generate the embedded type registry.
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", features = ["serde"] }
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", features = ["serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1"
|
||||
@@ -8,7 +8,7 @@ publish = false
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "063c106", features = ["serde"] }
|
||||
codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "8e93175", features = ["serde"] }
|
||||
bincode = "1.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
console_error_panic_hook = "0.1"
|
||||
|
||||
Generated
+1
-1
@@ -1264,7 +1264,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "opencadcodec"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=063c106#063c10671fe7833d562f772159771318c7a0ebb9"
|
||||
source = "git+https://github.com/HakanSeven12/opencadcodec.git?rev=8e93175#8e9317506f1522bad52920f7398223c1e3538860"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
|
||||
@@ -417,6 +417,7 @@ impl OpenCADStudio {
|
||||
let pending = self.begin_undo(i, "Apply named parameters", touched.len(), true);
|
||||
self.tabs[i].scene.record_undo_named_parameters_before();
|
||||
self.tabs[i].scene.named_parameters = table;
|
||||
self.tabs[i].scene.refresh_expression_sweeps();
|
||||
self.tabs[i].dirty = true;
|
||||
if !touched.is_empty() {
|
||||
let changes: Vec<(Handle, crate::scene::ChangeKind)> = touched
|
||||
|
||||
@@ -539,9 +539,14 @@ impl OpenCADStudio {
|
||||
continue;
|
||||
}
|
||||
let created = if surface {
|
||||
let mut entity = sweep_model::swept_surface_entity(&record);
|
||||
sweep_model::link_sweep_expressions(&mut entity, &expressions);
|
||||
self.add_surface_model(entity, body)
|
||||
let created =
|
||||
self.add_surface_model(sweep_model::swept_surface_entity(&record), body);
|
||||
sweep_model::link_sweep_expressions(
|
||||
&mut self.tabs[i].scene.document,
|
||||
created,
|
||||
&expressions,
|
||||
);
|
||||
created
|
||||
} else {
|
||||
self.add_solid_model(
|
||||
empty_solid3d(),
|
||||
|
||||
@@ -3189,14 +3189,8 @@ mod tests {
|
||||
}
|
||||
|
||||
fn native_group_handle(document: &CadDocument, owner: Handle) -> Handle {
|
||||
let dict = document
|
||||
.extension_dictionary_handle(owner)
|
||||
.expect("extension dictionary should exist");
|
||||
let Some(ObjectType::Dictionary(dictionary)) = document.objects.get(&dict) else {
|
||||
panic!("expected owner's extension dictionary object to exist");
|
||||
};
|
||||
let network_handle = dictionary
|
||||
.get(NETWORK_DICTIONARY_KEY)
|
||||
// The scope's network sits under a dictionary of its own.
|
||||
let network_handle = native_scope_network_handle(document, owner)
|
||||
.expect("ACAD_ASSOCNETWORK entry should exist");
|
||||
let Some(ObjectType::Associative(AssociativeObject {
|
||||
data: AssociativeData::Network(network),
|
||||
|
||||
@@ -315,22 +315,26 @@ pub fn swept_with_options(profile: &EntityType, path: &EntityType, mode: Extrude
|
||||
kernel::acis::rebuild_sweep_with_mode(&record, mode == ExtrudeMode::Surface).ok()
|
||||
}
|
||||
|
||||
/// Preserve native construction parameters alongside the sheet's saved B-rep.
|
||||
/// The application name of the expressions a swept surface stays linked to.
|
||||
pub const SWEEP_EXPRESSION_APP: &str = "OCS_SWEEP_EXPRESSION";
|
||||
|
||||
/// Links a swept surface to its scale and twist expressions (kept as the
|
||||
/// surface's own data, so they are saved with the drawing).
|
||||
pub fn link_sweep_expressions(entity: &mut EntityType, expressions: &[Option<String>; 2]) {
|
||||
if expressions.iter().all(Option::is_none) { return; }
|
||||
let mut record = codec::xdata::ExtendedDataRecord::new(SWEEP_EXPRESSION_APP);
|
||||
/// surface's own data, under a registered application, so they are saved
|
||||
/// with the drawing).
|
||||
pub fn link_sweep_expressions(
|
||||
document: &mut codec::CadDocument,
|
||||
handle: codec::Handle,
|
||||
expressions: &[Option<String>; 2],
|
||||
) {
|
||||
if handle.is_null() || expressions.iter().all(Option::is_none) { return; }
|
||||
let mut values = Vec::new();
|
||||
for (name, expression) in ["ScaleFactor", "TwistAngle"].iter().zip(expressions) {
|
||||
if let Some(expression) = expression {
|
||||
record.add_value(codec::xdata::XDataValue::String(name.to_string()));
|
||||
record.add_value(codec::xdata::XDataValue::String(expression.clone()));
|
||||
values.push(codec::xdata::XDataValue::String(name.to_string()));
|
||||
values.push(codec::xdata::XDataValue::String(expression.clone()));
|
||||
}
|
||||
}
|
||||
entity.common_mut().extended_data.add_record(record);
|
||||
crate::scene::view::dispatch::set_entity_xdata(document, handle, SWEEP_EXPRESSION_APP, Some(values));
|
||||
}
|
||||
|
||||
/// The scale and twist expressions a swept surface is linked to.
|
||||
@@ -382,6 +386,7 @@ pub fn surface_sweep_record(entity: &EntityType) -> Option<SolidHistorySweep> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Preserve native construction parameters alongside the sheet's saved B-rep.
|
||||
pub fn swept_surface_entity(record: &SolidHistorySweep) -> EntityType {
|
||||
let mut surface = Surface::new(SurfaceKind::Swept);
|
||||
if let Ok(point) = kernel::acis::sweep_history_reference_point(record) {
|
||||
|
||||
+2
-2
@@ -1161,9 +1161,9 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
for (handle, expressions) in links {
|
||||
let Some(entity) = self.document.get_entity_mut(handle) else { continue };
|
||||
let Some(entity) = self.document.get_entity(handle) else { continue };
|
||||
if crate::scene::model::sweep_model::sweep_expressions(entity).is_some() { continue; }
|
||||
crate::scene::model::sweep_model::link_sweep_expressions(entity, &expressions);
|
||||
crate::scene::model::sweep_model::link_sweep_expressions(&mut self.document, handle, &expressions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user