forked from 1b-agent/opencadstudio-upstream
feat(hatch): add and remove boundary vertices from the grip menu
A non-associative hatch's boundary vertex grips now offer Add Vertex and Remove Vertex next to Stretch, on polyline boundaries and on boundaries made of line edges alike. Add Vertex inserts the vertex after the picked one, halfway along the next segment (on the arc for a bulged polyline segment, splitting its bulge), and lets it be placed like any grip. Remove Vertex drops it while keeping at least a triangle. Line-edge boundaries used to show two grips at every corner (one line's end, the next one's start), so dragging one opened the loop; each corner is now one grip that moves both ends. The automation grip_menu_pick action chooses an entry of the open grip menu, so these edits can be scripted and checked. Fixes #1058 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
4518569b61
commit
6490a625f2
4 files changed
+368
-134
No files matched your search
@@ -55,6 +55,16 @@ fn polyline_add_vertex_target(entity: &AcadEntityType, grip_id: usize) -> Option
|
||||
AcadEntityType::Polyline3D(polyline) if grip_id < polyline.vertices.len() => {
|
||||
Some((grip_id + 1, polyline.vertices.len()))
|
||||
}
|
||||
// A hatch boundary vertex: the new vertex is the next grip.
|
||||
AcadEntityType::Hatch(hatch) => {
|
||||
use crate::entities::traits::Grippable;
|
||||
use crate::scene::model::object::GripMenuAction;
|
||||
hatch
|
||||
.grip_menu(grip_id)
|
||||
.iter()
|
||||
.any(|item| matches!(item.action, GripMenuAction::AddVertex))
|
||||
.then(|| (grip_id + 1, hatch.grips().len()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -65,6 +75,9 @@ fn polyline_vertex_count(entity: &AcadEntityType) -> Option<usize> {
|
||||
AcadEntityType::Polyline(polyline) => Some(polyline.vertices.len()),
|
||||
AcadEntityType::Polyline2D(polyline) => Some(polyline.vertices.len()),
|
||||
AcadEntityType::Polyline3D(polyline) => Some(polyline.vertices.len()),
|
||||
AcadEntityType::Hatch(hatch) => {
|
||||
Some(crate::entities::traits::Grippable::grips(hatch).len())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user