@labelbee/lb-annotation 1.14.0-alpha.2 → 1.14.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/MathUtilsWorker.js +8 -1
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +35 -2
- package/dist/_virtual/filterBoxWorker.js +8 -1
- package/dist/_virtual/highlightWorker.js +8 -1
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +5 -7
- package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +5 -12
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editLV.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editQING.svg.js +5 -1
- package/dist/constant/annotation.js +127 -1
- package/dist/constant/annotationTask.js +30 -1
- package/dist/constant/defaultConfig.js +266 -1
- package/dist/constant/keyCode.js +38 -1
- package/dist/constant/style.js +98 -1
- package/dist/constant/tool.js +236 -1
- package/dist/core/index.js +150 -1
- package/dist/core/pointCloud/OrbitControls.js +665 -1
- package/dist/core/pointCloud/PCDLoader.js +260 -2
- package/dist/core/pointCloud/annotation.js +215 -1
- package/dist/core/pointCloud/cache.js +53 -1
- package/dist/core/pointCloud/index.js +991 -5
- package/dist/core/pointCloud/matrix.js +138 -1
- package/dist/core/pointCloud/segmentation.js +144 -0
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +26 -0
- package/dist/core/pointCloud/selector/Sse3dSelector.js +16 -0
- package/dist/core/scheduler.js +233 -1
- package/dist/core/toolOperation/LineToolOperation.js +1434 -1
- package/dist/core/toolOperation/ScribbleTool.js +292 -1
- package/dist/core/toolOperation/TextToolOperation.js +131 -1
- package/dist/core/toolOperation/ViewOperation.js +556 -1
- package/dist/core/toolOperation/basicToolOperation.js +881 -1
- package/dist/core/toolOperation/checkOperation.js +208 -1
- package/dist/core/toolOperation/cuboidOperation.js +754 -1
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +152 -7
- package/dist/core/toolOperation/eventListener.js +37 -1
- package/dist/core/toolOperation/measureOperation.js +41 -1
- package/dist/core/toolOperation/pointCloud2dOperation.js +365 -1
- package/dist/core/toolOperation/pointOperation.js +696 -1
- package/dist/core/toolOperation/polygonOperation.js +1251 -1
- package/dist/core/toolOperation/rectOperation.js +1233 -1
- package/dist/core/toolOperation/segmentByRect.js +174 -1
- package/dist/core/toolOperation/tagOperation.js +201 -3
- package/dist/core/toolOperation/textAttributeClass.js +182 -16
- package/dist/index.js +185 -1
- package/dist/locales/constants.js +24 -1
- package/dist/locales/en_US/message.js +25 -1
- package/dist/locales/index.js +19 -1
- package/dist/locales/zh_CN/message.js +25 -1
- package/dist/newCore/CanvasScheduler.js +35 -1
- package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
- package/dist/utils/ActionsHistory.js +84 -1
- package/dist/utils/ImgUtils.js +23 -1
- package/dist/utils/MathUtils.js +385 -2
- package/dist/utils/VectorUtils.js +25 -1
- package/dist/utils/tool/AttributeUtils.js +218 -1
- package/dist/utils/tool/AxisUtils.js +340 -1
- package/dist/utils/tool/CanvasUtils.js +62 -1
- package/dist/utils/tool/CommonToolUtils.js +174 -1
- package/dist/utils/tool/CuboidUtils.js +704 -1
- package/dist/utils/tool/DblClickEventListener.js +102 -1
- package/dist/utils/tool/DrawUtils.js +492 -3
- package/dist/utils/tool/EnhanceCommonToolUtils.js +53 -1
- package/dist/utils/tool/ImgPosUtils.js +58 -1
- package/dist/utils/tool/LineToolUtils.js +261 -1
- package/dist/utils/tool/MarkerUtils.js +56 -1
- package/dist/utils/tool/PolygonUtils.js +460 -1
- package/dist/utils/tool/RectUtils.js +155 -1
- package/dist/utils/tool/RenderDomClass.js +57 -7
- package/dist/utils/tool/RenderDomUtils.js +21 -4
- package/dist/utils/tool/StyleUtils.js +31 -1
- package/dist/utils/tool/TagUtils.js +129 -1
- package/dist/utils/tool/UnitUtils.js +12 -1
- package/dist/utils/tool/ZoomUtils.js +72 -1
- package/dist/utils/tool/polygonTool.js +133 -1
- package/dist/utils/uuid.js +26 -1
- package/es/_virtual/MathUtilsWorker.js +6 -1
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -2
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/_virtual/filterBoxWorker.js +6 -1
- package/es/_virtual/highlightWorker.js +6 -1
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -1
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -7
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -12
- package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editLV.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editQING.svg.js +3 -1
- package/es/constant/annotation.js +113 -1
- package/es/constant/annotationTask.js +25 -1
- package/es/constant/defaultConfig.js +260 -1
- package/es/constant/keyCode.js +36 -1
- package/es/constant/style.js +74 -1
- package/es/constant/tool.js +220 -1
- package/es/core/index.js +148 -1
- package/es/core/pointCloud/OrbitControls.js +661 -1
- package/es/core/pointCloud/PCDLoader.js +256 -2
- package/es/core/pointCloud/annotation.js +211 -1
- package/es/core/pointCloud/cache.js +49 -1
- package/es/core/pointCloud/index.js +962 -5
- package/es/core/pointCloud/matrix.js +109 -1
- package/es/core/pointCloud/segmentation.js +120 -0
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +24 -0
- package/es/core/pointCloud/selector/Sse3dSelector.js +14 -0
- package/es/core/scheduler.js +228 -1
- package/es/core/toolOperation/LineToolOperation.js +1421 -1
- package/es/core/toolOperation/ScribbleTool.js +290 -1
- package/es/core/toolOperation/TextToolOperation.js +129 -1
- package/es/core/toolOperation/ViewOperation.js +549 -1
- package/es/core/toolOperation/basicToolOperation.js +877 -1
- package/es/core/toolOperation/checkOperation.js +206 -1
- package/es/core/toolOperation/cuboidOperation.js +752 -1
- package/es/core/toolOperation/cuboidToggleButtonClass.js +150 -7
- package/es/core/toolOperation/eventListener.js +35 -1
- package/es/core/toolOperation/measureOperation.js +39 -1
- package/es/core/toolOperation/pointCloud2dOperation.js +359 -1
- package/es/core/toolOperation/pointOperation.js +690 -1
- package/es/core/toolOperation/polygonOperation.js +1245 -1
- package/es/core/toolOperation/rectOperation.js +1228 -1
- package/es/core/toolOperation/scribbleTool2.js +249 -0
- package/es/core/toolOperation/segmentByRect.js +172 -1
- package/es/core/toolOperation/tagOperation.js +199 -3
- package/es/core/toolOperation/textAttributeClass.js +180 -16
- package/es/index.js +46 -1
- package/es/locales/constants.js +22 -1
- package/es/locales/en_US/message.js +23 -1
- package/es/locales/index.js +17 -1
- package/es/locales/zh_CN/message.js +23 -1
- package/es/newCore/CanvasScheduler.js +31 -1
- package/es/utils/ActionsHistory.js +78 -1
- package/es/utils/ImgUtils.js +21 -1
- package/es/utils/MathUtils.js +380 -2
- package/es/utils/VectorUtils.js +23 -1
- package/es/utils/tool/AttributeUtils.js +212 -1
- package/es/utils/tool/AxisUtils.js +335 -1
- package/es/utils/tool/CanvasUtils.js +60 -1
- package/es/utils/tool/CommonToolUtils.js +172 -1
- package/es/utils/tool/CuboidUtils.js +680 -1
- package/es/utils/tool/DblClickEventListener.js +100 -1
- package/es/utils/tool/DrawUtils.js +490 -3
- package/es/utils/tool/EnhanceCommonToolUtils.js +48 -1
- package/es/utils/tool/ImgPosUtils.js +56 -1
- package/es/utils/tool/LineToolUtils.js +255 -1
- package/es/utils/tool/MarkerUtils.js +54 -1
- package/es/utils/tool/PolygonUtils.js +458 -1
- package/es/utils/tool/RectUtils.js +153 -1
- package/es/utils/tool/RenderDomClass.js +55 -7
- package/es/utils/tool/RenderDomUtils.js +19 -4
- package/es/utils/tool/StyleUtils.js +29 -1
- package/es/utils/tool/TagUtils.js +127 -1
- package/es/utils/tool/UnitUtils.js +10 -1
- package/es/utils/tool/ZoomUtils.js +70 -1
- package/es/utils/tool/polygonTool.js +126 -1
- package/es/utils/uuid.js +24 -1
- package/package.json +7 -5
|
@@ -1 +1,56 @@
|
|
|
1
|
-
class
|
|
1
|
+
class ImgPosUtils {
|
|
2
|
+
static getInitImgPos(canvasSize, imgSize, rotate = 0, zoomRatio = 1, isOriginalSize = false) {
|
|
3
|
+
if (rotate === 90 || rotate === 270) {
|
|
4
|
+
imgSize = {
|
|
5
|
+
width: imgSize.height,
|
|
6
|
+
height: imgSize.width
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const wScale = canvasSize.width * zoomRatio / imgSize.width;
|
|
10
|
+
const hScale = canvasSize.height * zoomRatio / imgSize.height;
|
|
11
|
+
let scale = isOriginalSize ? 1 : Math.min(wScale, hScale);
|
|
12
|
+
const currentPos = {
|
|
13
|
+
x: (canvasSize.width - imgSize.width * scale) / 2,
|
|
14
|
+
y: (canvasSize.height - imgSize.height * scale) / 2
|
|
15
|
+
};
|
|
16
|
+
const width = imgSize.width * scale;
|
|
17
|
+
const height = imgSize.height * scale;
|
|
18
|
+
if (isOriginalSize) {
|
|
19
|
+
scale = 1;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
zoom: scale,
|
|
23
|
+
currentPos,
|
|
24
|
+
imgInfo: {width, height}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
static getBasicRecPos(imgNode, basicRect, size, shrinkRatio = 0.9, zoomRatio = 1, isOriginalSize = false) {
|
|
28
|
+
if (basicRect && imgNode) {
|
|
29
|
+
const {x, y, height, width} = basicRect;
|
|
30
|
+
let initZoom = size.height / height;
|
|
31
|
+
if (width / height > size.width / size.height) {
|
|
32
|
+
initZoom = size.width / width;
|
|
33
|
+
}
|
|
34
|
+
const zoom = isOriginalSize ? 1 : initZoom * shrinkRatio * zoomRatio;
|
|
35
|
+
const viewCenter = {
|
|
36
|
+
x: size.width / 2,
|
|
37
|
+
y: size.height / 2
|
|
38
|
+
};
|
|
39
|
+
const imgCenter = {
|
|
40
|
+
x: (x + width / 2) * zoom,
|
|
41
|
+
y: (y + height / 2) * zoom
|
|
42
|
+
};
|
|
43
|
+
const currentPos = {
|
|
44
|
+
x: viewCenter.x - imgCenter.x,
|
|
45
|
+
y: viewCenter.y - imgCenter.y
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
currentPos,
|
|
49
|
+
innerZoom: zoom
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ImgPosUtils as default };
|
|
@@ -1 +1,255 @@
|
|
|
1
|
-
import{EToolName
|
|
1
|
+
import { EToolName, ELineTypes } from '../../constant/tool.js';
|
|
2
|
+
import { createSmoothCurvePointsFromPointList } from './polygonTool.js';
|
|
3
|
+
import PolygonUtils from './PolygonUtils.js';
|
|
4
|
+
import MathUtils from '../MathUtils.js';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defProps = Object.defineProperties;
|
|
8
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var EStatus;
|
|
26
|
+
(function(EStatus2) {
|
|
27
|
+
EStatus2[EStatus2["Create"] = 0] = "Create";
|
|
28
|
+
EStatus2[EStatus2["Active"] = 1] = "Active";
|
|
29
|
+
EStatus2[EStatus2["Edit"] = 1] = "Edit";
|
|
30
|
+
EStatus2[EStatus2["None"] = 2] = "None";
|
|
31
|
+
})(EStatus || (EStatus = {}));
|
|
32
|
+
var EColor;
|
|
33
|
+
(function(EColor2) {
|
|
34
|
+
EColor2["ActiveArea"] = "#B3B8FF";
|
|
35
|
+
})(EColor || (EColor = {}));
|
|
36
|
+
const SEGMENT_NUMBER = 16;
|
|
37
|
+
const POINT_RADIUS = 3;
|
|
38
|
+
const _LineToolUtils = class {
|
|
39
|
+
static isInLine(checkPoint, point1, point2, scope = 3) {
|
|
40
|
+
const {length} = MathUtils.getFootOfPerpendicular(checkPoint, point1, point2);
|
|
41
|
+
if (length < scope) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
let LineToolUtils = _LineToolUtils;
|
|
48
|
+
LineToolUtils.setSpecialEdgeStyle = (ctx) => {
|
|
49
|
+
ctx.lineCap = "butt";
|
|
50
|
+
ctx.setLineDash([10, 10]);
|
|
51
|
+
};
|
|
52
|
+
LineToolUtils.setReferenceCtx = (ctx) => {
|
|
53
|
+
ctx.lineCap = "butt";
|
|
54
|
+
ctx.setLineDash([6]);
|
|
55
|
+
};
|
|
56
|
+
LineToolUtils.calcOptimalIntersection = (pointList, matchLine, matchPoint, pointRadius, zoom) => {
|
|
57
|
+
let optimalIntersection;
|
|
58
|
+
let minDistance = Infinity;
|
|
59
|
+
let scopeIntersection;
|
|
60
|
+
const matchLineOnExistLine = pointList.find((p, index) => {
|
|
61
|
+
if (index === 0) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const pointAOnLine = _LineToolUtils.isInLine(matchLine.pointA, p, pointList[index - 1]);
|
|
65
|
+
const pointBOnLine = _LineToolUtils.isInLine(matchLine.pointB, p, pointList[index - 1]);
|
|
66
|
+
return pointAOnLine && pointBOnLine;
|
|
67
|
+
});
|
|
68
|
+
if (matchLineOnExistLine) {
|
|
69
|
+
return {point: matchPoint};
|
|
70
|
+
}
|
|
71
|
+
pointList.forEach((point, index) => {
|
|
72
|
+
if (index === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const line2 = {
|
|
76
|
+
pointA: pointList[index - 1],
|
|
77
|
+
pointB: point
|
|
78
|
+
};
|
|
79
|
+
const intersection = _LineToolUtils.lineIntersection(matchLine, line2);
|
|
80
|
+
if (intersection && matchLine) {
|
|
81
|
+
const {onLine2, onLine1, x, y} = intersection;
|
|
82
|
+
const distance = _LineToolUtils.calcDistance(matchPoint, intersection);
|
|
83
|
+
const matchPointInLine = _LineToolUtils.isOnLine(matchLine.pointB.x, matchLine.pointB.y, point.x, point.y, pointList[index - 1].x, pointList[index - 1].y);
|
|
84
|
+
if (matchPointInLine) {
|
|
85
|
+
const intersectionDistance = _LineToolUtils.calcDistance(matchPoint, intersection);
|
|
86
|
+
if (intersectionDistance < pointRadius / zoom) {
|
|
87
|
+
const cPoint = matchLine.pointB;
|
|
88
|
+
const {footPoint, length} = MathUtils.getFootOfPerpendicular(cPoint, line2.pointA, line2.pointB, true);
|
|
89
|
+
if (length !== void 0) {
|
|
90
|
+
const distPointA = _LineToolUtils.calcDistance(line2.pointA, footPoint);
|
|
91
|
+
const distPointB = _LineToolUtils.calcDistance(line2.pointB, footPoint);
|
|
92
|
+
scopeIntersection = {
|
|
93
|
+
point: footPoint,
|
|
94
|
+
minDistance: length
|
|
95
|
+
};
|
|
96
|
+
if (length === Infinity) {
|
|
97
|
+
scopeIntersection.point = distPointA > distPointB ? line2.pointB : line2.pointA;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (distance < minDistance && onLine2 && onLine1) {
|
|
104
|
+
minDistance = distance;
|
|
105
|
+
optimalIntersection = {
|
|
106
|
+
x,
|
|
107
|
+
y
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (optimalIntersection) {
|
|
113
|
+
return {point: optimalIntersection, minDistance};
|
|
114
|
+
}
|
|
115
|
+
if (scopeIntersection) {
|
|
116
|
+
return scopeIntersection;
|
|
117
|
+
}
|
|
118
|
+
return void 0;
|
|
119
|
+
};
|
|
120
|
+
LineToolUtils.lineIntersection = (lineA, lineB) => {
|
|
121
|
+
let onLine1 = false;
|
|
122
|
+
let onLine2 = false;
|
|
123
|
+
const lineADiff = _LineToolUtils.getAxisDiff(lineA);
|
|
124
|
+
const lineBDiff = _LineToolUtils.getAxisDiff(lineB);
|
|
125
|
+
const denominator = lineBDiff.y * lineADiff.x - lineBDiff.x * lineADiff.y;
|
|
126
|
+
if (denominator === 0) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
let a = lineA.pointA.y - lineB.pointA.y;
|
|
130
|
+
let b = lineA.pointA.x - lineB.pointA.x;
|
|
131
|
+
const numerator1 = (lineB.pointB.x - lineB.pointA.x) * a - (lineB.pointB.y - lineB.pointA.y) * b;
|
|
132
|
+
const numerator2 = (lineA.pointB.x - lineA.pointA.x) * a - (lineA.pointB.y - lineA.pointA.y) * b;
|
|
133
|
+
a = numerator1 / denominator;
|
|
134
|
+
b = numerator2 / denominator;
|
|
135
|
+
if (a > 0 && a < 1) {
|
|
136
|
+
onLine1 = true;
|
|
137
|
+
}
|
|
138
|
+
if (b > 0 && b < 1) {
|
|
139
|
+
onLine2 = true;
|
|
140
|
+
}
|
|
141
|
+
const x = lineA.pointA.x + a * (lineA.pointB.x - lineA.pointA.x);
|
|
142
|
+
const y = lineA.pointA.y + a * (lineA.pointB.y - lineA.pointA.y);
|
|
143
|
+
return {x, y, onLine1, onLine2};
|
|
144
|
+
};
|
|
145
|
+
LineToolUtils.getAxisDiff = (line) => {
|
|
146
|
+
return {
|
|
147
|
+
x: line.pointB.x - line.pointA.x,
|
|
148
|
+
y: line.pointB.y - line.pointA.y
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
LineToolUtils.calcDistance = (point1, point2) => {
|
|
152
|
+
return Math.sqrt(Math.pow(Math.abs(point1.x - point2.x), 2) + Math.pow(Math.abs(point1.y - point2.y), 2));
|
|
153
|
+
};
|
|
154
|
+
LineToolUtils.drawCurveLine = (ctx, points, config, applyLineWidth = true, isReference = false, hoverEdgeIndex) => {
|
|
155
|
+
const pointList = createSmoothCurvePointsFromPointList(points, SEGMENT_NUMBER);
|
|
156
|
+
ctx.save();
|
|
157
|
+
ctx.lineCap = "round";
|
|
158
|
+
ctx.lineJoin = "round";
|
|
159
|
+
ctx.strokeStyle = config.color;
|
|
160
|
+
if (applyLineWidth) {
|
|
161
|
+
ctx.lineWidth = config.lineWidth;
|
|
162
|
+
}
|
|
163
|
+
if (isReference) {
|
|
164
|
+
_LineToolUtils.setReferenceCtx(ctx);
|
|
165
|
+
}
|
|
166
|
+
points.forEach((point, index) => {
|
|
167
|
+
const specialEdge = point == null ? void 0 : point.specialEdge;
|
|
168
|
+
const curveLinePoints = pointList.splice(0, SEGMENT_NUMBER + 1);
|
|
169
|
+
ctx.save();
|
|
170
|
+
ctx.beginPath();
|
|
171
|
+
if (hoverEdgeIndex === index) {
|
|
172
|
+
ctx.lineWidth = 4;
|
|
173
|
+
}
|
|
174
|
+
curveLinePoints.forEach(({x, y}, pointIndex) => {
|
|
175
|
+
const fn = pointIndex > 0 ? "lineTo" : "moveTo";
|
|
176
|
+
if (specialEdge) {
|
|
177
|
+
_LineToolUtils.setSpecialEdgeStyle(ctx);
|
|
178
|
+
}
|
|
179
|
+
ctx[fn](x, y);
|
|
180
|
+
});
|
|
181
|
+
ctx.stroke();
|
|
182
|
+
ctx.restore();
|
|
183
|
+
});
|
|
184
|
+
ctx.restore();
|
|
185
|
+
};
|
|
186
|
+
LineToolUtils.calcTwoPointDistance = (pointA, pointB) => Math.sqrt(Math.pow(pointA.x - pointB.x, 2) + Math.pow(pointA.y - pointB.y, 2));
|
|
187
|
+
LineToolUtils.pointOverTarget = (axis, preAxis, dependToolName, dependData, dependConfig, imageSize, pointRadius, zoom, getRenderAxis, getAbsAxis) => {
|
|
188
|
+
const absAxis = axis;
|
|
189
|
+
if (!preAxis) {
|
|
190
|
+
return axis;
|
|
191
|
+
}
|
|
192
|
+
if (dependToolName === EToolName.Polygon) {
|
|
193
|
+
const polygonPointList = _LineToolUtils.getPolygonPointList(dependData, dependConfig);
|
|
194
|
+
if (polygonPointList.length === 0) {
|
|
195
|
+
return absAxis;
|
|
196
|
+
}
|
|
197
|
+
const inPolygon = PolygonUtils.isInPolygon(axis, polygonPointList);
|
|
198
|
+
if (inPolygon) {
|
|
199
|
+
return absAxis;
|
|
200
|
+
}
|
|
201
|
+
const pointList = polygonPointList.concat(polygonPointList[0]).map((i) => getRenderAxis(i));
|
|
202
|
+
const pointA = getRenderAxis(preAxis);
|
|
203
|
+
const pointB = getRenderAxis(axis);
|
|
204
|
+
const line1 = {
|
|
205
|
+
pointA,
|
|
206
|
+
pointB
|
|
207
|
+
};
|
|
208
|
+
const intersection = _LineToolUtils.calcOptimalIntersection(pointList, line1, pointA, pointRadius, zoom);
|
|
209
|
+
if (intersection) {
|
|
210
|
+
const intersectionAbsAxis = getAbsAxis(intersection == null ? void 0 : intersection.point);
|
|
211
|
+
absAxis.x = intersectionAbsAxis.x;
|
|
212
|
+
absAxis.y = intersectionAbsAxis.y;
|
|
213
|
+
} else {
|
|
214
|
+
return preAxis;
|
|
215
|
+
}
|
|
216
|
+
return absAxis;
|
|
217
|
+
}
|
|
218
|
+
if (dependToolName === EToolName.Rect) {
|
|
219
|
+
const {x, y, width, height} = dependData;
|
|
220
|
+
absAxis.x = MathUtils.withinRange(absAxis.x, [x, x + width]);
|
|
221
|
+
absAxis.y = MathUtils.withinRange(absAxis.y, [y, y + height]);
|
|
222
|
+
return absAxis;
|
|
223
|
+
}
|
|
224
|
+
absAxis.x = MathUtils.withinRange(absAxis.x, [0, imageSize.width]);
|
|
225
|
+
absAxis.y = MathUtils.withinRange(absAxis.y, [0, imageSize.height]);
|
|
226
|
+
return absAxis;
|
|
227
|
+
};
|
|
228
|
+
LineToolUtils.getPolygonPointList = (dependData, dependConfig) => {
|
|
229
|
+
const {pointList} = dependData;
|
|
230
|
+
const {lineType} = dependConfig;
|
|
231
|
+
return lineType === ELineTypes.Line ? pointList : PolygonUtils.createSmoothCurvePoints(pointList.reduce((acc, cur) => {
|
|
232
|
+
return [...acc, cur.x, cur.y];
|
|
233
|
+
}, []), 0.5, true, 20);
|
|
234
|
+
};
|
|
235
|
+
LineToolUtils.isOnLine = (x, y, endX, endY, px, py) => {
|
|
236
|
+
const f = (someX) => {
|
|
237
|
+
return (endY - y) / (endX - x) * (someX - x) + y;
|
|
238
|
+
};
|
|
239
|
+
return Math.abs(f(px) - py) < 1e-6 && px >= x && px <= endX;
|
|
240
|
+
};
|
|
241
|
+
LineToolUtils.inArea = ({top, left, right, bottom}, {x, y}) => y >= top && y <= bottom && x >= left && x <= right;
|
|
242
|
+
LineToolUtils.getVHPoint = (lastPoint, nextPoint, absNextPoint, renderLastPoint) => {
|
|
243
|
+
const angle = _LineToolUtils.getAngle(lastPoint, absNextPoint);
|
|
244
|
+
if (Math.abs(angle) < 45) {
|
|
245
|
+
return __spreadProps(__spreadValues({}, nextPoint), {y: renderLastPoint.y});
|
|
246
|
+
}
|
|
247
|
+
return __spreadProps(__spreadValues({}, nextPoint), {x: renderLastPoint.x});
|
|
248
|
+
};
|
|
249
|
+
LineToolUtils.getAngle = (startPoint, endPoint) => {
|
|
250
|
+
const diffX = endPoint.x - startPoint.x;
|
|
251
|
+
const diffY = endPoint.y - startPoint.y;
|
|
252
|
+
return 360 * Math.atan(diffY / diffX) / (2 * Math.PI);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export { EColor, EStatus, POINT_RADIUS, SEGMENT_NUMBER, LineToolUtils as default };
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
import{cloneDeep
|
|
1
|
+
import { cloneDeep } from 'lodash';
|
|
2
|
+
import AttributeUtils from './AttributeUtils.js';
|
|
3
|
+
|
|
4
|
+
class MarkerUtils {
|
|
5
|
+
static getMarkerShowText(marker, markerList = []) {
|
|
6
|
+
return AttributeUtils.getAttributeShowText(marker, markerList);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
MarkerUtils.getAuxiliaryLineByMarkerList = (markerList, attr) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const queue = cloneDeep(markerList);
|
|
12
|
+
const auxiliaryLines = [];
|
|
13
|
+
let currentNode = queue.shift();
|
|
14
|
+
while (currentNode) {
|
|
15
|
+
(_a = currentNode.target) == null ? void 0 : _a.forEach((element) => {
|
|
16
|
+
const targetMarkerListItem = queue.find((i) => i.value === element);
|
|
17
|
+
if (targetMarkerListItem && (currentNode == null ? void 0 : currentNode[attr])) {
|
|
18
|
+
auxiliaryLines.push({
|
|
19
|
+
start: currentNode[attr],
|
|
20
|
+
end: targetMarkerListItem[attr]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
currentNode = queue.shift();
|
|
25
|
+
}
|
|
26
|
+
return auxiliaryLines;
|
|
27
|
+
};
|
|
28
|
+
MarkerUtils.getAuxiliaryLineCoord = (auxiliaryLines, pointList) => {
|
|
29
|
+
const result = [];
|
|
30
|
+
auxiliaryLines.forEach((line) => {
|
|
31
|
+
const {start, end} = line;
|
|
32
|
+
const startPoint = pointList.find((item) => item.label === start);
|
|
33
|
+
if (!startPoint) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const targetPoint = pointList.find((item) => item.label === end);
|
|
37
|
+
if (!targetPoint) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
result.push({
|
|
41
|
+
start: {
|
|
42
|
+
x: startPoint.x,
|
|
43
|
+
y: startPoint.y
|
|
44
|
+
},
|
|
45
|
+
end: {
|
|
46
|
+
x: targetPoint.x,
|
|
47
|
+
y: targetPoint.y
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { MarkerUtils as default };
|