|
@@ -6,7 +6,6 @@ import {
|
|
|
getLineEdges,
|
|
getLineEdges,
|
|
|
LEJInfo,
|
|
LEJInfo,
|
|
|
LEJLine,
|
|
LEJLine,
|
|
|
- lineLen,
|
|
|
|
|
lineVector,
|
|
lineVector,
|
|
|
Pos,
|
|
Pos,
|
|
|
verticalVector,
|
|
verticalVector,
|
|
@@ -20,10 +19,7 @@ import { computed, nextTick, reactive, Ref, watch } from "vue";
|
|
|
import { getLineIconEndpoints } from "../../../line-icon";
|
|
import { getLineIconEndpoints } from "../../../line-icon";
|
|
|
import { useDrawIngData } from "@/core/hook/use-draw";
|
|
import { useDrawIngData } from "@/core/hook/use-draw";
|
|
|
import { polygonDifference, polygonDifferenceOnly } from "@/utils/math-clip";
|
|
import { polygonDifference, polygonDifferenceOnly } from "@/utils/math-clip";
|
|
|
-import {
|
|
|
|
|
- useViewerInvertTransform,
|
|
|
|
|
- useViewerInvertTransformConfig,
|
|
|
|
|
-} from "@/core/hook/use-viewer";
|
|
|
|
|
|
|
+import { useFixedScale } from "@/core/hook/use-viewer";
|
|
|
|
|
|
|
|
export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
|
const minAngle = MathUtils.degToRad(0.1);
|
|
const minAngle = MathUtils.degToRad(0.1);
|
|
@@ -32,9 +28,9 @@ export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
|
type JInfo = { lej: LEJInfo | undefined; diffPolygons?: Pos[][] };
|
|
type JInfo = { lej: LEJInfo | undefined; diffPolygons?: Pos[][] };
|
|
|
const joinInfos = reactive({}) as Record<string, Record<string, JInfo>>;
|
|
const joinInfos = reactive({}) as Record<string, Record<string, JInfo>>;
|
|
|
|
|
|
|
|
- const inv = useViewerInvertTransformConfig();
|
|
|
|
|
|
|
+ const scale = useFixedScale();
|
|
|
const getWidth = (width: number, fixed: boolean) =>
|
|
const getWidth = (width: number, fixed: boolean) =>
|
|
|
- fixed ? width * inv.value.scaleX : width;
|
|
|
|
|
|
|
+ fixed ? width * scale.value : width;
|
|
|
|
|
|
|
|
const getInfoKey = (line: LEJLine) =>
|
|
const getInfoKey = (line: LEJLine) =>
|
|
|
line.points.reduce((t, p) => round(p.x, 3) + round(p.y, 3) + t, "") +
|
|
line.points.reduce((t, p) => round(p.x, 3) + round(p.y, 3) + t, "") +
|
|
@@ -47,11 +43,11 @@ export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
|
) => {
|
|
) => {
|
|
|
const origin = {
|
|
const origin = {
|
|
|
points: getLinePoints(data, originLine),
|
|
points: getLinePoints(data, originLine),
|
|
|
- width: getWidth(originLine.strokeWidth, originLine.fixed)
|
|
|
|
|
|
|
+ width: getWidth(originLine.strokeWidth, originLine.fixed),
|
|
|
};
|
|
};
|
|
|
const target = {
|
|
const target = {
|
|
|
points: getLinePoints(data, targetLine),
|
|
points: getLinePoints(data, targetLine),
|
|
|
- width: getWidth(targetLine.strokeWidth, targetLine.fixed)
|
|
|
|
|
|
|
+ width: getWidth(targetLine.strokeWidth, targetLine.fixed),
|
|
|
};
|
|
};
|
|
|
const { originNdx } = getLEJJoinNdxs(origin.points, target.points);
|
|
const { originNdx } = getLEJJoinNdxs(origin.points, target.points);
|
|
|
const lej = getLineEdgeJoinInfo(origin, target, minAngle, palAngle);
|
|
const lej = getLineEdgeJoinInfo(origin, target, minAngle, palAngle);
|
|
@@ -69,7 +65,7 @@ export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
|
const getLEJPolygon = (data: LineData, originLine: LineDataLine) => {
|
|
const getLEJPolygon = (data: LineData, originLine: LineDataLine) => {
|
|
|
const origin = {
|
|
const origin = {
|
|
|
points: getLinePoints(data, originLine),
|
|
points: getLinePoints(data, originLine),
|
|
|
- width: getWidth(originLine.strokeWidth, originLine.fixed)
|
|
|
|
|
|
|
+ width: getWidth(originLine.strokeWidth, originLine.fixed),
|
|
|
};
|
|
};
|
|
|
if (!origin.points[0] || !origin.points[1]) return [];
|
|
if (!origin.points[0] || !origin.points[1]) return [];
|
|
|
const key = getInfoKey(origin);
|
|
const key = getInfoKey(origin);
|
|
@@ -149,7 +145,7 @@ export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
|
} else {
|
|
} else {
|
|
|
const key = getInfoKey({
|
|
const key = getInfoKey({
|
|
|
points: getLinePoints(data, lines[0]),
|
|
points: getLinePoints(data, lines[0]),
|
|
|
- width: getWidth(lines[0].strokeWidth, lines[0].fixed)
|
|
|
|
|
|
|
+ width: getWidth(lines[0].strokeWidth, lines[0].fixed),
|
|
|
});
|
|
});
|
|
|
if (!(key in joinInfos)) {
|
|
if (!(key in joinInfos)) {
|
|
|
joinInfos[key] = {};
|
|
joinInfos[key] = {};
|
|
@@ -165,7 +161,7 @@ export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
|
|
|
|
|
|
|
|
const genLEJLine = (lineData: LineData, line: LineDataLine) => ({
|
|
const genLEJLine = (lineData: LineData, line: LineDataLine) => ({
|
|
|
points: getLinePoints(lineData, line),
|
|
points: getLinePoints(lineData, line),
|
|
|
- width: getWidth(line.strokeWidth, line.fixed)
|
|
|
|
|
|
|
+ width: getWidth(line.strokeWidth, line.fixed),
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const init = (data: LineData) => {
|
|
const init = (data: LineData) => {
|
|
@@ -363,12 +359,15 @@ export const useGetDiffLineIconPolygons = (
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const inv = useViewerInvertTransformConfig()
|
|
|
|
|
- const getWidth = (line: LineDataLine) => line.fixed ? line.strokeWidth * inv.value.scaleX : line.strokeWidth
|
|
|
|
|
|
|
+ const scale = useFixedScale();
|
|
|
|
|
+ const width = computed(() =>
|
|
|
|
|
+ line.fixed ? line.strokeWidth * scale.value : line.strokeWidth
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
const interPolygons = computed(() => {
|
|
const interPolygons = computed(() => {
|
|
|
return interLines.value.map((il) => {
|
|
return interLines.value.map((il) => {
|
|
|
const interLine = il.points;
|
|
const interLine = il.points;
|
|
|
- const topOffset = linevv.value.clone().multiplyScalar(getWidth(line));
|
|
|
|
|
|
|
+ const topOffset = linevv.value.clone().multiplyScalar(width.value);
|
|
|
const botOffset = topOffset.clone().multiplyScalar(-1);
|
|
const botOffset = topOffset.clone().multiplyScalar(-1);
|
|
|
return [
|
|
return [
|
|
|
topOffset.clone().add(interLine[0]),
|
|
topOffset.clone().add(interLine[0]),
|
|
@@ -381,9 +380,6 @@ export const useGetDiffLineIconPolygons = (
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
diff: (polygon: Pos[]) => {
|
|
diff: (polygon: Pos[]) => {
|
|
|
- if (interPolygons.value.length) {
|
|
|
|
|
- console.log(polygonDifference(polygon, interPolygons.value))
|
|
|
|
|
- }
|
|
|
|
|
const result = interPolygons.value.length
|
|
const result = interPolygons.value.length
|
|
|
? polygonDifference(polygon, interPolygons.value)
|
|
? polygonDifference(polygon, interPolygons.value)
|
|
|
: [polygon];
|
|
: [polygon];
|