|
@@ -86,7 +86,7 @@ export const repPointRef = (
|
|
|
data: LineData,
|
|
data: LineData,
|
|
|
delId: string,
|
|
delId: string,
|
|
|
repId: string,
|
|
repId: string,
|
|
|
- queUpdate = true
|
|
|
|
|
|
|
+ queUpdate = true,
|
|
|
) => {
|
|
) => {
|
|
|
for (let i = 0; i < data.lines.length; i++) {
|
|
for (let i = 0; i < data.lines.length; i++) {
|
|
|
const line = data.lines[i];
|
|
const line = data.lines[i];
|
|
@@ -145,14 +145,14 @@ export const deduplicateLines = (data: LineData) => {
|
|
|
export const getJoinLine = (
|
|
export const getJoinLine = (
|
|
|
data: LineData,
|
|
data: LineData,
|
|
|
line: LineDataLine,
|
|
line: LineDataLine,
|
|
|
- pId: string
|
|
|
|
|
|
|
+ pId: string,
|
|
|
) => {
|
|
) => {
|
|
|
const pointIds = [line.a, line.b];
|
|
const pointIds = [line.a, line.b];
|
|
|
return data.lines
|
|
return data.lines
|
|
|
.filter(
|
|
.filter(
|
|
|
(item) =>
|
|
(item) =>
|
|
|
(item.a === pId || item.b === pId) &&
|
|
(item.a === pId || item.b === pId) &&
|
|
|
- !(pointIds.includes(item.a) && pointIds.includes(item.b))
|
|
|
|
|
|
|
+ !(pointIds.includes(item.a) && pointIds.includes(item.b)),
|
|
|
)
|
|
)
|
|
|
.map((line) => {
|
|
.map((line) => {
|
|
|
const pointIds = pId === line.a ? [line.a, line.b] : [line.b, line.a];
|
|
const pointIds = pId === line.a ? [line.a, line.b] : [line.b, line.a];
|
|
@@ -232,7 +232,7 @@ export const genMoveLineHandler = (
|
|
|
lineId: string,
|
|
lineId: string,
|
|
|
snapConfig: ReturnType<typeof useSnapConfig>,
|
|
snapConfig: ReturnType<typeof useSnapConfig>,
|
|
|
snapResult: SnapResultInfo,
|
|
snapResult: SnapResultInfo,
|
|
|
- ctx = getInitCtx()
|
|
|
|
|
|
|
+ ctx = getInitCtx(),
|
|
|
) => {
|
|
) => {
|
|
|
const line = data.lines.find((line) => line.id === lineId)!;
|
|
const line = data.lines.find((line) => line.id === lineId)!;
|
|
|
const pointIds = [line.a, line.b];
|
|
const pointIds = [line.a, line.b];
|
|
@@ -283,10 +283,10 @@ export const genMoveLineHandler = (
|
|
|
let isAlong = !invSelectLineDire;
|
|
let isAlong = !invSelectLineDire;
|
|
|
if (!isAlong && alongSelectLineDire) {
|
|
if (!isAlong && alongSelectLineDire) {
|
|
|
const invMoveAngle = Math.abs(
|
|
const invMoveAngle = Math.abs(
|
|
|
- vector2IncludedAngle(moveDire, invSelectLineDire!)
|
|
|
|
|
|
|
+ vector2IncludedAngle(moveDire, invSelectLineDire!),
|
|
|
);
|
|
);
|
|
|
const alongMoveAngle = Math.abs(
|
|
const alongMoveAngle = Math.abs(
|
|
|
- vector2IncludedAngle(moveDire, alongSelectLineDire!)
|
|
|
|
|
|
|
+ vector2IncludedAngle(moveDire, alongSelectLineDire!),
|
|
|
);
|
|
);
|
|
|
isAlong = alongMoveAngle! < invMoveAngle!;
|
|
isAlong = alongMoveAngle! < invMoveAngle!;
|
|
|
}
|
|
}
|
|
@@ -313,8 +313,8 @@ export const genMoveLineHandler = (
|
|
|
(dire) =>
|
|
(dire) =>
|
|
|
dire !== info.selectLineDire &&
|
|
dire !== info.selectLineDire &&
|
|
|
!zeroEq(
|
|
!zeroEq(
|
|
|
- rangMod(vector2IncludedAngle(dire, info.selectLineDire), Math.PI)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ rangMod(vector2IncludedAngle(dire, info.selectLineDire), Math.PI),
|
|
|
|
|
+ ),
|
|
|
);
|
|
);
|
|
|
return { ...info, needSplit, needVertical, joinPoints };
|
|
return { ...info, needSplit, needVertical, joinPoints };
|
|
|
};
|
|
};
|
|
@@ -379,14 +379,17 @@ export const genMoveLineHandler = (
|
|
|
const uNdx = ndx === 1 ? 0 : 1;
|
|
const uNdx = ndx === 1 ? 0 : 1;
|
|
|
const move = new Vector2(
|
|
const move = new Vector2(
|
|
|
points[ndx].x - initPoints[ndx].x,
|
|
points[ndx].x - initPoints[ndx].x,
|
|
|
- points[ndx].y - initPoints[ndx].y
|
|
|
|
|
|
|
+ points[ndx].y - initPoints[ndx].y,
|
|
|
);
|
|
);
|
|
|
if (!snapLines[uNdx]) {
|
|
if (!snapLines[uNdx]) {
|
|
|
assignPos(points[uNdx], move.add(initPoints[uNdx]));
|
|
assignPos(points[uNdx], move.add(initPoints[uNdx]));
|
|
|
} else {
|
|
} else {
|
|
|
assignPos(
|
|
assignPos(
|
|
|
points[uNdx],
|
|
points[uNdx],
|
|
|
- lineIntersection(getVectorLine(lineDire, points[ndx]), snapLines[uNdx])!
|
|
|
|
|
|
|
+ lineIntersection(
|
|
|
|
|
+ getVectorLine(lineDire, points[ndx]),
|
|
|
|
|
+ snapLines[uNdx],
|
|
|
|
|
+ )!,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -394,7 +397,7 @@ export const genMoveLineHandler = (
|
|
|
const move = (finalPoss: Pos[]) => {
|
|
const move = (finalPoss: Pos[]) => {
|
|
|
if (!inited) {
|
|
if (!inited) {
|
|
|
const moveDires = finalPoss.map((pos, ndx) =>
|
|
const moveDires = finalPoss.map((pos, ndx) =>
|
|
|
- lineVector([initPoints[ndx], pos])
|
|
|
|
|
|
|
+ lineVector([initPoints[ndx], pos]),
|
|
|
);
|
|
);
|
|
|
inited = true;
|
|
inited = true;
|
|
|
init(moveDires);
|
|
init(moveDires);
|
|
@@ -421,7 +424,7 @@ export const genMoveLineHandler = (
|
|
|
const getSnapRefPoint = (
|
|
const getSnapRefPoint = (
|
|
|
point: Pos,
|
|
point: Pos,
|
|
|
refPoints: Pos[],
|
|
refPoints: Pos[],
|
|
|
- line: Pos[] | null
|
|
|
|
|
|
|
+ line: Pos[] | null,
|
|
|
) => {
|
|
) => {
|
|
|
for (const refPoint of refPoints) {
|
|
for (const refPoint of refPoints) {
|
|
|
if (
|
|
if (
|
|
@@ -452,7 +455,7 @@ export const genMoveLineHandler = (
|
|
|
refPoint = getSnapRefPoint(
|
|
refPoint = getSnapRefPoint(
|
|
|
points[0],
|
|
points[0],
|
|
|
refInfos[0]?.joinPoints,
|
|
refInfos[0]?.joinPoints,
|
|
|
- snapLines[0]
|
|
|
|
|
|
|
+ snapLines[0],
|
|
|
);
|
|
);
|
|
|
if (refPoint) {
|
|
if (refPoint) {
|
|
|
ndx = 0;
|
|
ndx = 0;
|
|
@@ -463,7 +466,7 @@ export const genMoveLineHandler = (
|
|
|
refPoint = getSnapRefPoint(
|
|
refPoint = getSnapRefPoint(
|
|
|
points[1],
|
|
points[1],
|
|
|
refInfos[1]?.joinPoints,
|
|
refInfos[1]?.joinPoints,
|
|
|
- snapLines[1]
|
|
|
|
|
|
|
+ snapLines[1],
|
|
|
);
|
|
);
|
|
|
if (refPoint) {
|
|
if (refPoint) {
|
|
|
ndx = 1;
|
|
ndx = 1;
|
|
@@ -510,10 +513,10 @@ export const useLineDataSnapInfos = (type: "line" | "lineChunk") => {
|
|
|
snapInfos = getSnapInfos({
|
|
snapInfos = getSnapInfos({
|
|
|
...lineData.value,
|
|
...lineData.value,
|
|
|
lines: lineData.value.lines.filter(
|
|
lines: lineData.value.lines.filter(
|
|
|
- (item) => !(pointIds.includes(item.a) || pointIds.includes(item.b))
|
|
|
|
|
|
|
+ (item) => !(pointIds.includes(item.a) || pointIds.includes(item.b)),
|
|
|
),
|
|
),
|
|
|
points: lineData.value.points.filter(
|
|
points: lineData.value.points.filter(
|
|
|
- (item) => !pointIds.includes(item.id)
|
|
|
|
|
|
|
+ (item) => !pointIds.includes(item.id),
|
|
|
),
|
|
),
|
|
|
});
|
|
});
|
|
|
snapInfos.forEach((item) => {
|
|
snapInfos.forEach((item) => {
|
|
@@ -536,7 +539,7 @@ export const updateLineLength = (
|
|
|
line: LineDataLine,
|
|
line: LineDataLine,
|
|
|
length: number,
|
|
length: number,
|
|
|
flex?: "a" | "b" | "both",
|
|
flex?: "a" | "b" | "both",
|
|
|
- vector?: Pos
|
|
|
|
|
|
|
+ vector?: Pos,
|
|
|
) => {
|
|
) => {
|
|
|
const points = [
|
|
const points = [
|
|
|
lineData.points.find((p) => p.id === line.a)!,
|
|
lineData.points.find((p) => p.id === line.a)!,
|
|
@@ -546,10 +549,10 @@ export const updateLineLength = (
|
|
|
|
|
|
|
|
if (!flex) {
|
|
if (!flex) {
|
|
|
const aCount = lineData.lines.filter(
|
|
const aCount = lineData.lines.filter(
|
|
|
- (line) => line.a === points[0].id || line.b === points[0].id
|
|
|
|
|
|
|
+ (line) => line.a === points[0].id || line.b === points[0].id,
|
|
|
).length;
|
|
).length;
|
|
|
const bCount = lineData.lines.filter(
|
|
const bCount = lineData.lines.filter(
|
|
|
- (line) => line.a === points[1].id || line.b === points[1].id
|
|
|
|
|
|
|
+ (line) => line.a === points[1].id || line.b === points[1].id,
|
|
|
).length;
|
|
).length;
|
|
|
if (aCount === bCount || (aCount > 1 && bCount > 1)) {
|
|
if (aCount === bCount || (aCount > 1 && bCount > 1)) {
|
|
|
flex = "both";
|
|
flex = "both";
|
|
@@ -565,7 +568,7 @@ export const updateLineLength = (
|
|
|
const l1 = getVectorLine(
|
|
const l1 = getVectorLine(
|
|
|
moveVector.clone().multiplyScalar(-1),
|
|
moveVector.clone().multiplyScalar(-1),
|
|
|
center,
|
|
center,
|
|
|
- length / 2
|
|
|
|
|
|
|
+ length / 2,
|
|
|
);
|
|
);
|
|
|
const l2 = getVectorLine(moveVector, center, length / 2);
|
|
const l2 = getVectorLine(moveVector, center, length / 2);
|
|
|
npoints = [l1[1], l2[1]];
|
|
npoints = [l1[1], l2[1]];
|
|
@@ -575,7 +578,7 @@ export const updateLineLength = (
|
|
|
const line = getVectorLine(
|
|
const line = getVectorLine(
|
|
|
mNdx === 1 ? moveVector : moveVector.multiplyScalar(-1),
|
|
mNdx === 1 ? moveVector : moveVector.multiplyScalar(-1),
|
|
|
points[fNdx],
|
|
points[fNdx],
|
|
|
- length
|
|
|
|
|
|
|
+ length,
|
|
|
);
|
|
);
|
|
|
const nPoints: Pos[] = [];
|
|
const nPoints: Pos[] = [];
|
|
|
nPoints[fNdx] = points[fNdx];
|
|
nPoints[fNdx] = points[fNdx];
|
|
@@ -590,7 +593,7 @@ export const useLineDescribes = (
|
|
|
line: Ref<LineDataLine>,
|
|
line: Ref<LineDataLine>,
|
|
|
type: "line" | "lineChunk",
|
|
type: "line" | "lineChunk",
|
|
|
fixedStroke = false,
|
|
fixedStroke = false,
|
|
|
- fixedStrokeOptions: number[] = []
|
|
|
|
|
|
|
+ fixedStrokeOptions: number[] = [],
|
|
|
) => {
|
|
) => {
|
|
|
const d: any = useComponentDescribes(line, ["stroke", "strokeWidth"], {});
|
|
const d: any = useComponentDescribes(line, ["stroke", "strokeWidth"], {});
|
|
|
const store = useStore();
|
|
const store = useStore();
|
|
@@ -605,30 +608,37 @@ export const useLineDescribes = (
|
|
|
watch(
|
|
watch(
|
|
|
d,
|
|
d,
|
|
|
(d) => {
|
|
(d) => {
|
|
|
- d.strokeWidth.label = ui18n.t('shape.wall.strokeWidth');
|
|
|
|
|
|
|
+ d.strokeWidth.label = ui18n.t("shape.wall.strokeWidth");
|
|
|
d.strokeWidth.props = {
|
|
d.strokeWidth.props = {
|
|
|
...d.strokeWidth.props,
|
|
...d.strokeWidth.props,
|
|
|
proportion: true,
|
|
proportion: true,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
- { immediate: true }
|
|
|
|
|
|
|
+ { immediate: true },
|
|
|
);
|
|
);
|
|
|
} else {
|
|
} else {
|
|
|
- useInstallStrokeWidthDescribe(d, line, fixedStrokeOptions, undefined, undefined, ui18n.t('sys.line.strokeWidth'));
|
|
|
|
|
|
|
+ useInstallStrokeWidthDescribe(
|
|
|
|
|
+ d,
|
|
|
|
|
+ line,
|
|
|
|
|
+ fixedStrokeOptions,
|
|
|
|
|
+ undefined,
|
|
|
|
|
+ undefined,
|
|
|
|
|
+ ui18n.t("sys.line.strokeWidth"),
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
watch(
|
|
watch(
|
|
|
d,
|
|
d,
|
|
|
(d) => {
|
|
(d) => {
|
|
|
- if (type === 'line') {
|
|
|
|
|
- d.stroke.label = ui18n.t('sys.color');
|
|
|
|
|
|
|
+ d.stroke.label = ui18n.t("sys.color");
|
|
|
|
|
+ if (type === "line") {
|
|
|
d.stroke.props = {
|
|
d.stroke.props = {
|
|
|
- colors: ['#000000', '#cccccc', null]
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ colors: ["#000000", "#cccccc", null],
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
d.length = {
|
|
d.length = {
|
|
|
type: "inputNum",
|
|
type: "inputNum",
|
|
|
- label: ui18n.t('line.length'),
|
|
|
|
|
|
|
+ label: ui18n.t("line.length"),
|
|
|
"layout-type": "row",
|
|
"layout-type": "row",
|
|
|
props: {
|
|
props: {
|
|
|
proportion: true,
|
|
proportion: true,
|
|
@@ -647,12 +657,12 @@ export const useLineDescribes = (
|
|
|
line.value,
|
|
line.value,
|
|
|
val,
|
|
val,
|
|
|
undefined,
|
|
undefined,
|
|
|
- setLineVector
|
|
|
|
|
|
|
+ setLineVector,
|
|
|
);
|
|
);
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
- { immediate: true }
|
|
|
|
|
|
|
+ { immediate: true },
|
|
|
);
|
|
);
|
|
|
return d as Ref<PropertyDescribes>;
|
|
return d as Ref<PropertyDescribes>;
|
|
|
};
|
|
};
|
|
@@ -667,7 +677,7 @@ export const useDrawLinePoint = (
|
|
|
point: LineData["points"][0];
|
|
point: LineData["points"][0];
|
|
|
oldIcons: LineIconData[];
|
|
oldIcons: LineIconData[];
|
|
|
newIcons: LineIconData[];
|
|
newIcons: LineIconData[];
|
|
|
- }) => void
|
|
|
|
|
|
|
+ }) => void,
|
|
|
) => {
|
|
) => {
|
|
|
const mode = useMode();
|
|
const mode = useMode();
|
|
|
let __leave: (() => void) | null;
|
|
let __leave: (() => void) | null;
|
|
@@ -698,7 +708,7 @@ export const useDrawLinePoint = (
|
|
|
const icons = computed(() =>
|
|
const icons = computed(() =>
|
|
|
store
|
|
store
|
|
|
.getTypeItems("lineIcon")
|
|
.getTypeItems("lineIcon")
|
|
|
- .filter((item) => item.lineId === line.value.id)
|
|
|
|
|
|
|
+ .filter((item) => item.lineId === line.value.id),
|
|
|
);
|
|
);
|
|
|
const drawStore = useDrawIngData();
|
|
const drawStore = useDrawIngData();
|
|
|
const cursor = useCursor();
|
|
const cursor = useCursor();
|
|
@@ -762,21 +772,21 @@ export const useDrawLinePoint = (
|
|
|
newIcons: drawStore.lineIcon!,
|
|
newIcons: drawStore.lineIcon!,
|
|
|
});
|
|
});
|
|
|
leave();
|
|
leave();
|
|
|
- })
|
|
|
|
|
|
|
+ }),
|
|
|
),
|
|
),
|
|
|
watch(
|
|
watch(
|
|
|
pos,
|
|
pos,
|
|
|
(pos) => {
|
|
(pos) => {
|
|
|
pos && afterUpdate(pos);
|
|
pos && afterUpdate(pos);
|
|
|
},
|
|
},
|
|
|
- { immediate: true }
|
|
|
|
|
|
|
+ { immediate: true },
|
|
|
),
|
|
),
|
|
|
() => {
|
|
() => {
|
|
|
drawProps.value = undefined;
|
|
drawProps.value = undefined;
|
|
|
snapInfos.clear();
|
|
snapInfos.clear();
|
|
|
snap.clear();
|
|
snap.clear();
|
|
|
isStop = true;
|
|
isStop = true;
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -789,8 +799,8 @@ export const useDrawLinePoint = (
|
|
|
(hasDraw, _, onCleanup) => {
|
|
(hasDraw, _, onCleanup) => {
|
|
|
hasDraw ? onCleanup(enterDraw()) : leave();
|
|
hasDraw ? onCleanup(enterDraw()) : leave();
|
|
|
},
|
|
},
|
|
|
- { immediate: true }
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ { immediate: true },
|
|
|
|
|
+ ),
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|