Complete geometric tolerance workflow and properties

This commit is contained in:
ramox81 committed 2026-08-26 13:54:20 +03:00
1 parent 8c61d89b1e
commit de294447a9
14 files changed
+1037 -135

No files matched your search

+88 -1
View File
@@ -1901,7 +1901,73 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
}
self.push_undo_snapshot(i, "CHPROP");
if field.starts_with("dim_") {
if field == "tol_text_style" {
use crate::entities::dim_override as dov;
use acadrust::xdata::XDataValue;
let style_handle = self.tabs[i]
.scene
.document
.text_styles
.iter()
.find(|entry| entry.name.eq_ignore_ascii_case(&value))
.map(|entry| entry.handle);
if let Some(style_handle) = style_handle {
for &handle in &handles {
if self.tabs[i].scene.is_layer_locked(handle)
|| !matches!(
self.tabs[i].scene.document.get_entity(handle),
Some(acadrust::EntityType::Tolerance(_))
)
{
continue;
}
dov::set(
&mut self.tabs[i].scene.document,
handle,
dov::DIMTXSTY,
Some(XDataValue::Handle(style_handle)),
);
}
}
} else if field == "tol_dim_style" {
let style = self.tabs[i]
.scene
.document
.dim_styles
.iter()
.find(|entry| entry.name.eq_ignore_ascii_case(&value))
.map(|entry| (entry.handle, entry.name.clone(), entry.annotative));
if let Some((style_handle, style_name, annotative)) = style {
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
for &handle in &handles {
if self.tabs[i].scene.is_layer_locked(handle) {
continue;
}
if let Some(acadrust::EntityType::Tolerance(tolerance)) =
self.tabs[i].scene.document.get_entity_mut(handle)
{
tolerance.dimension_style_handle = Some(style_handle);
tolerance.dimension_style_name = style_name.clone();
} else {
continue;
}
crate::scene::annotative::set_entity_annotative(
&mut self.tabs[i].scene.document,
handle,
annotative,
);
if annotative {
if let Some(scale) = scale {
crate::scene::annotative::create_annotation_context(
&mut self.tabs[i].scene.document,
handle,
scale,
);
}
}
}
}
} else if field.starts_with("dim_") {
for &handle in &handles {
if self.tabs[i].scene.is_layer_locked(handle) {
continue;
@@ -2552,6 +2618,27 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
continue;
}
match field {
"tol_text_height" => {
use crate::entities::dim_override as dov;
let trimmed = val.trim();
if trimmed.is_empty() {
dov::set(
&mut self.tabs[i].scene.document,
handle,
dov::DIMTXT,
None,
);
} else if let Ok(height) = trimmed.parse::<f64>() {
if height > 0.0 {
dov::set(
&mut self.tabs[i].scene.document,
handle,
dov::DIMTXT,
Some(acadrust::xdata::XDataValue::Real(height)),
);
}
}
}
_ if field.starts_with("dim_") => {
if matches!(
self.tabs[i].scene.document.get_entity(handle),
+35
View File
@@ -195,6 +195,7 @@ impl OpenCADStudio {
self.attr_editor_selected = 0;
self.attr_editor_tab = crate::ui::window::attribute_editor::AttrTab::Attribute;
}
Some(GeometricTolerance) => self.geometric_tolerance = None,
// Closing (✕) discards edits made since the last Apply — matching the
// style editors. Committing happens only through the Apply button.
Some(Aliases) => self.alias_editor_rows.clear(),
@@ -3706,6 +3707,40 @@ impl OpenCADStudio {
self.refresh_properties();
Task::none()
}
Message::ToleranceDialogField(field) => {
if let Some(state) = self.geometric_tolerance.as_mut() {
state.apply_field(field);
}
Task::none()
}
Message::ToleranceDialogToggle(toggle) => {
if let Some(state) = self.geometric_tolerance.as_mut() {
state.apply_toggle(toggle);
}
Task::none()
}
Message::ToleranceDialogApply => {
self.apply_tolerance_dialog_edit();
Task::none()
}
Message::ToleranceDialogOk => {
let editing = self
.geometric_tolerance
.as_ref()
.and_then(|state| state.editing)
.is_some();
if editing {
if self.apply_tolerance_dialog_edit() {
self.geometric_tolerance = None;
self.active_modal = None;
self.reset_modal_geometry();
}
} else {
self.begin_tolerance_placement();
self.reset_modal_geometry();
}
Task::none()
}
Message::SetLinearFormat(code) => {
self.units_popup_open = false;
let i = self.active_tab;