forked from 1b-agent/opencadstudio-upstream
fix(section): preserve selected slice depth
This commit is contained in:
1 parent
0ad31ece6f
commit
035d31e201
2 files changed
+57
-18
No files matched your search
+19
-18
@@ -1443,24 +1443,25 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
}
|
||||
}
|
||||
// One-shot action — apply immediately.
|
||||
let unchanged = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.get_entity(popup.handle)
|
||||
.is_some_and(|entity| match (item.action, entity) {
|
||||
(GripMenuAction::ShowFit, acadrust::EntityType::Spline(spline)) => {
|
||||
!spline.cv_frame_visible
|
||||
&& crate::entities::spline::uses_fit_method(spline)
|
||||
}
|
||||
(
|
||||
GripMenuAction::ShowControlVertices,
|
||||
acadrust::EntityType::Spline(spline),
|
||||
) => {
|
||||
spline.cv_frame_visible
|
||||
|| !crate::entities::spline::uses_fit_method(spline)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
let unchanged = item.label.starts_with('✓')
|
||||
|| self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.get_entity(popup.handle)
|
||||
.is_some_and(|entity| match (item.action, entity) {
|
||||
(GripMenuAction::ShowFit, acadrust::EntityType::Spline(spline)) => {
|
||||
!spline.cv_frame_visible
|
||||
&& crate::entities::spline::uses_fit_method(spline)
|
||||
}
|
||||
(
|
||||
GripMenuAction::ShowControlVertices,
|
||||
acadrust::EntityType::Spline(spline),
|
||||
) => {
|
||||
spline.cv_frame_visible
|
||||
|| !crate::entities::spline::uses_fit_method(spline)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
if unchanged {
|
||||
return Task::none();
|
||||
}
|
||||
|
||||
@@ -2179,6 +2179,12 @@ impl Grippable for ExtendedEntity {
|
||||
GripMenuAction::SectionVolume => "Volume",
|
||||
_ => return,
|
||||
};
|
||||
let ExtendedEntityData::SectionObject(data) = &self.data else {
|
||||
return;
|
||||
};
|
||||
if section_kind(self, data) == value {
|
||||
return;
|
||||
}
|
||||
apply_section_prop(self, "ext_section_state", value);
|
||||
}
|
||||
}
|
||||
@@ -2198,3 +2204,35 @@ impl Transformable for ExtendedEntity {
|
||||
apply_transform(self, transform);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::entities::EntityCommon;
|
||||
use acadrust::types::Color;
|
||||
|
||||
#[test]
|
||||
fn reselecting_slice_keeps_its_depth() {
|
||||
let mut entity = ExtendedEntity {
|
||||
common: EntityCommon::new(),
|
||||
data: ExtendedEntityData::SectionObject(SectionObjectData {
|
||||
state: 1,
|
||||
flags: 5,
|
||||
name: String::new(),
|
||||
vertical_direction: Vector3::UNIT_Z,
|
||||
top_height: 1.0,
|
||||
bottom_height: 1.0,
|
||||
indicator_alpha: 70,
|
||||
indicator_color: Color::from_index(9),
|
||||
back_line_vertices: Vec::new(),
|
||||
vertices: vec![Vector3::ZERO, Vector3::new(60.0, 0.0, 0.0)],
|
||||
settings_handle: Handle::NULL,
|
||||
}),
|
||||
};
|
||||
set_section_slice_metadata(&mut entity, true, 0.25);
|
||||
|
||||
entity.apply_grip_menu(SECTION_GRIP_STATE, GripMenuAction::SectionSlice);
|
||||
|
||||
assert_eq!(section_slice_depth(&entity), Some(0.25));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user