forked from 1b-agent/opencadstudio-upstream
Merge remote-tracking branch 'origin/main' into codex/sheet-set-manager
# Conflicts: # Cargo.lock # src/app/control/actions.rs # src/ui/window/field_dialog.rs
This commit is contained in:
commit
1696316e1f
95 files changed
+4269
-722
No files matched your search
@@ -378,3 +378,68 @@ fn display_name() -> Option<String> {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
None
|
||||
}
|
||||
|
||||
/// Copy each attribute definition's field onto the matching attribute of a
|
||||
/// new block reference (block placeholders resolve against the reference).
|
||||
/// Returns the attributes that received a field.
|
||||
pub fn attach_attribute_fields(document: &mut CadDocument, insert: Handle) -> Vec<Handle> {
|
||||
let context = OcsFieldContext(None);
|
||||
document.attach_attribute_fields(insert, &context)
|
||||
}
|
||||
|
||||
/// Whether any attribute definition of `block` hosts a field.
|
||||
pub fn block_has_attribute_fields(document: &CadDocument, block: &str) -> bool {
|
||||
let Some(record) = document.block_records.iter().find(|r| r.name.eq_ignore_ascii_case(block)) else {
|
||||
return false;
|
||||
};
|
||||
record.entity_handles.iter().filter_map(|h| document.get_entity(*h)).any(|e| {
|
||||
matches!(e, codec::entities::EntityType::AttributeDefinition(_)) && hosts_field(document, e)
|
||||
})
|
||||
}
|
||||
|
||||
/// Give plot-time fields (PlotDate) the plot's time; returns the hosts whose
|
||||
/// text changed.
|
||||
pub fn stamp_plot_fields(document: &mut CadDocument) -> Vec<Handle> {
|
||||
// The context reads a snapshot of the whole drawing; most drawings hold
|
||||
// no field, and a large one should not be copied for every plot.
|
||||
let has_fields = document
|
||||
.objects
|
||||
.values()
|
||||
.any(|object| matches!(object, codec::objects::ObjectType::Field(_)));
|
||||
if !has_fields {
|
||||
return Vec::new();
|
||||
}
|
||||
let snapshot = document.clone();
|
||||
let context = PlotContext(OcsFieldContext(Some(&snapshot)));
|
||||
document.stamp_plot_fields(&context)
|
||||
}
|
||||
|
||||
/// The app context while a plot is produced.
|
||||
struct PlotContext<'a>(OcsFieldContext<'a>);
|
||||
|
||||
impl FieldContext for PlotContext<'_> {
|
||||
fn now_julian(&self) -> f64 {
|
||||
self.0.now_julian()
|
||||
}
|
||||
fn file_times(&self) -> Option<(f64, f64)> {
|
||||
self.0.file_times()
|
||||
}
|
||||
fn plotting(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn login(&self) -> Option<String> {
|
||||
self.0.login()
|
||||
}
|
||||
fn getvar(&self, name: &str) -> Option<String> {
|
||||
self.0.getvar(name)
|
||||
}
|
||||
fn file_size(&self) -> Option<u64> {
|
||||
self.0.file_size()
|
||||
}
|
||||
fn date_locale(&self) -> codec::fields::DateLocale {
|
||||
self.0.date_locale()
|
||||
}
|
||||
fn getenv(&self, name: &str) -> Option<String> {
|
||||
self.0.getenv(name)
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,8 @@ fn embedded_name(value: Option<&codec::entities::EmbeddedEntity>) -> &'static st
|
||||
Some(codec::entities::EmbeddedEntity::Ellipse(_)) => "Ellipse",
|
||||
Some(codec::entities::EmbeddedEntity::Spline(_)) => "Spline",
|
||||
Some(codec::entities::EmbeddedEntity::LwPolyline(_)) => "Polyline",
|
||||
// A 2D / 3D polyline profile the modeler keeps as a wire body.
|
||||
Some(codec::entities::EmbeddedEntity::Body { .. }) => "Polyline",
|
||||
Some(codec::entities::EmbeddedEntity::Region(_)) => "Region",
|
||||
Some(codec::entities::EmbeddedEntity::Ray(_)) => "Ray",
|
||||
Some(codec::entities::EmbeddedEntity::XLine(_)) => "XLine",
|
||||
|
||||
@@ -51,7 +51,7 @@ fn point_render(pt: &Point, pdmode: i16, s: f64) -> RenderEntity {
|
||||
object: RenderObject::Lines(vec![]),
|
||||
snap_pts: vec![(snap, SnapHint::Node)],
|
||||
tangent_geoms: vec![],
|
||||
key_vertices: vec![[wx, wy, wz]],
|
||||
key_vertices: vec![],
|
||||
fill_tris: vec![],
|
||||
};
|
||||
}
|
||||
@@ -63,7 +63,8 @@ fn point_render(pt: &Point, pdmode: i16, s: f64) -> RenderEntity {
|
||||
key_vertices: if pt.thickness.abs() > 1.0e-10 {
|
||||
vec![[wx, wy, wz], [top.x, top.y, top.z]]
|
||||
} else {
|
||||
vec![[wx, wy, wz]]
|
||||
// Snaps as a Node only, never as an endpoint.
|
||||
vec![]
|
||||
},
|
||||
fill_tris: vec![],
|
||||
}
|
||||
|
||||
@@ -447,6 +447,8 @@ fn embedded_name(entity: Option<&codec::entities::EmbeddedEntity>) -> &'static s
|
||||
Some(codec::entities::EmbeddedEntity::Ellipse(_)) => "Ellipse",
|
||||
Some(codec::entities::EmbeddedEntity::Spline(_)) => "Spline",
|
||||
Some(codec::entities::EmbeddedEntity::LwPolyline(_)) => "Polyline",
|
||||
// A 2D / 3D polyline profile the modeler keeps as a wire body.
|
||||
Some(codec::entities::EmbeddedEntity::Body { .. }) => "Polyline",
|
||||
Some(codec::entities::EmbeddedEntity::Region(_)) => "Region",
|
||||
Some(codec::entities::EmbeddedEntity::Ray(_)) => "Ray",
|
||||
Some(codec::entities::EmbeddedEntity::XLine(_)) => "XLine",
|
||||
|
||||
Reference in new issue
Block a user