feat: do not break polygon on point delete inside line editor (#9580)
* feat: do not break polygon on point delete inside line editor * fix: polygon point highlighting when selected point == 0
This commit is contained in:
parent
87c87a9fb1
commit
fc3e062074
@ -1290,24 +1290,19 @@ export class LinearElementEditor {
|
|||||||
app.state.editingLinearElement?.lastUncommittedPoint ===
|
app.state.editingLinearElement?.lastUncommittedPoint ===
|
||||||
element.points[element.points.length - 1];
|
element.points[element.points.length - 1];
|
||||||
|
|
||||||
const isPolygon = isLineElement(element) && element.polygon;
|
|
||||||
|
|
||||||
// break polygon if deleting start/end point
|
|
||||||
if (
|
|
||||||
isPolygon &&
|
|
||||||
// don't disable polygon if cleaning up uncommitted point
|
|
||||||
!isUncommittedPoint &&
|
|
||||||
(pointIndices.includes(0) ||
|
|
||||||
pointIndices.includes(element.points.length - 1))
|
|
||||||
) {
|
|
||||||
app.scene.mutateElement(element, { polygon: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextPoints = element.points.filter((_, idx) => {
|
const nextPoints = element.points.filter((_, idx) => {
|
||||||
return !pointIndices.includes(idx);
|
return !pointIndices.includes(idx);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isUncommittedPoint && isLineElement(element) && element.polygon) {
|
const isPolygon = isLineElement(element) && element.polygon;
|
||||||
|
|
||||||
|
// keep polygon intact if deleting start/end point or uncommitted point
|
||||||
|
if (
|
||||||
|
isPolygon &&
|
||||||
|
(isUncommittedPoint ||
|
||||||
|
pointIndices.includes(0) ||
|
||||||
|
pointIndices.includes(element.points.length - 1))
|
||||||
|
) {
|
||||||
nextPoints[0] = pointFrom(
|
nextPoints[0] = pointFrom(
|
||||||
nextPoints[nextPoints.length - 1][0],
|
nextPoints[nextPoints.length - 1][0],
|
||||||
nextPoints[nextPoints.length - 1][1],
|
nextPoints[nextPoints.length - 1][1],
|
||||||
|
@ -459,18 +459,27 @@ const renderLinearPointHandles = (
|
|||||||
|
|
||||||
const isOverlappingPoint =
|
const isOverlappingPoint =
|
||||||
idx > 0 &&
|
idx > 0 &&
|
||||||
(idx !== points.length - 1 ||
|
(idx !== points.length - 1 || !_isLineElement || !element.polygon) &&
|
||||||
appState.editingLinearElement ||
|
|
||||||
!_isLineElement ||
|
|
||||||
!element.polygon) &&
|
|
||||||
pointsEqual(
|
pointsEqual(
|
||||||
point,
|
point,
|
||||||
idx === points.length - 1 ? points[0] : points[idx - 1],
|
idx === points.length - 1 ? points[0] : points[idx - 1],
|
||||||
2 / appState.zoom.value,
|
2 / appState.zoom.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSelected =
|
let isSelected =
|
||||||
!!appState.editingLinearElement?.selectedPointsIndices?.includes(idx);
|
!!appState.editingLinearElement?.selectedPointsIndices?.includes(idx);
|
||||||
|
// when element is a polygon, highlight the last point as well if first
|
||||||
|
// point is selected since they overlap and the last point tends to be
|
||||||
|
// rendered on top
|
||||||
|
if (
|
||||||
|
_isLineElement &&
|
||||||
|
element.polygon &&
|
||||||
|
!isSelected &&
|
||||||
|
idx === element.points.length - 1 &&
|
||||||
|
!!appState.editingLinearElement?.selectedPointsIndices?.includes(0)
|
||||||
|
) {
|
||||||
|
isSelected = true;
|
||||||
|
}
|
||||||
|
|
||||||
renderSingleLinearPoint(
|
renderSingleLinearPoint(
|
||||||
context,
|
context,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user