@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.6
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 +1 -8
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
- package/dist/_virtual/filterBoxWorker.js +1 -8
- package/dist/_virtual/highlightWorker.js +1 -8
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
- 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 +12 -5
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
- package/dist/constant/annotation.js +1 -127
- package/dist/constant/annotationTask.js +1 -30
- package/dist/constant/defaultConfig.js +1 -266
- package/dist/constant/keyCode.js +1 -38
- package/dist/constant/style.js +1 -98
- package/dist/constant/tool.js +1 -236
- package/dist/core/index.js +1 -150
- package/dist/core/pointCloud/OrbitControls.js +1 -665
- package/dist/core/pointCloud/PCDLoader.js +2 -260
- package/dist/core/pointCloud/annotation.js +1 -215
- package/dist/core/pointCloud/cache.js +1 -53
- package/dist/core/pointCloud/index.js +5 -991
- package/dist/core/pointCloud/matrix.js +1 -138
- package/dist/core/scheduler.js +1 -233
- package/dist/core/toolOperation/LineToolOperation.js +1 -1434
- package/dist/core/toolOperation/ScribbleTool.js +1 -292
- package/dist/core/toolOperation/TextToolOperation.js +1 -131
- package/dist/core/toolOperation/ViewOperation.js +1 -556
- package/dist/core/toolOperation/basicToolOperation.js +1 -881
- package/dist/core/toolOperation/checkOperation.js +1 -208
- package/dist/core/toolOperation/cuboidOperation.js +1 -754
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
- package/dist/core/toolOperation/eventListener.js +1 -37
- package/dist/core/toolOperation/measureOperation.js +1 -41
- package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
- package/dist/core/toolOperation/pointOperation.js +1 -696
- package/dist/core/toolOperation/polygonOperation.js +1 -1251
- package/dist/core/toolOperation/rectOperation.js +1 -1233
- package/dist/core/toolOperation/segmentByRect.js +1 -174
- package/dist/core/toolOperation/tagOperation.js +3 -201
- package/dist/core/toolOperation/textAttributeClass.js +16 -182
- package/dist/index.js +1 -185
- package/dist/locales/constants.js +1 -24
- package/dist/locales/en_US/message.js +1 -25
- package/dist/locales/index.js +1 -19
- package/dist/locales/zh_CN/message.js +1 -25
- package/dist/newCore/CanvasScheduler.js +1 -35
- package/dist/types/core/pointCloud/index.d.ts +2 -2
- package/dist/utils/ActionsHistory.js +1 -84
- package/dist/utils/ImgUtils.js +1 -23
- package/dist/utils/MathUtils.js +2 -385
- package/dist/utils/VectorUtils.js +1 -25
- package/dist/utils/tool/AttributeUtils.js +1 -218
- package/dist/utils/tool/AxisUtils.js +1 -340
- package/dist/utils/tool/CanvasUtils.js +1 -62
- package/dist/utils/tool/CommonToolUtils.js +1 -174
- package/dist/utils/tool/CuboidUtils.js +1 -704
- package/dist/utils/tool/DblClickEventListener.js +1 -102
- package/dist/utils/tool/DrawUtils.js +3 -492
- package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
- package/dist/utils/tool/ImgPosUtils.js +1 -58
- package/dist/utils/tool/LineToolUtils.js +1 -261
- package/dist/utils/tool/MarkerUtils.js +1 -56
- package/dist/utils/tool/PolygonUtils.js +1 -460
- package/dist/utils/tool/RectUtils.js +1 -155
- package/dist/utils/tool/RenderDomClass.js +7 -57
- package/dist/utils/tool/RenderDomUtils.js +4 -21
- package/dist/utils/tool/StyleUtils.js +1 -31
- package/dist/utils/tool/TagUtils.js +1 -129
- package/dist/utils/tool/UnitUtils.js +1 -12
- package/dist/utils/tool/ZoomUtils.js +1 -72
- package/dist/utils/tool/polygonTool.js +1 -133
- package/dist/utils/uuid.js +1 -26
- package/es/_virtual/MathUtilsWorker.js +1 -6
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
- package/es/_virtual/filterBoxWorker.js +1 -6
- package/es/_virtual/highlightWorker.js +1 -6
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
- package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
- package/es/constant/annotation.js +1 -113
- package/es/constant/annotationTask.js +1 -25
- package/es/constant/defaultConfig.js +1 -260
- package/es/constant/keyCode.js +1 -36
- package/es/constant/style.js +1 -74
- package/es/constant/tool.js +1 -220
- package/es/core/index.js +1 -148
- package/es/core/pointCloud/OrbitControls.js +1 -661
- package/es/core/pointCloud/PCDLoader.js +2 -256
- package/es/core/pointCloud/annotation.js +1 -211
- package/es/core/pointCloud/cache.js +1 -49
- package/es/core/pointCloud/index.js +5 -962
- package/es/core/pointCloud/matrix.js +1 -109
- package/es/core/scheduler.js +1 -228
- package/es/core/toolOperation/LineToolOperation.js +1 -1421
- package/es/core/toolOperation/ScribbleTool.js +1 -290
- package/es/core/toolOperation/TextToolOperation.js +1 -129
- package/es/core/toolOperation/ViewOperation.js +1 -549
- package/es/core/toolOperation/basicToolOperation.js +1 -877
- package/es/core/toolOperation/checkOperation.js +1 -206
- package/es/core/toolOperation/cuboidOperation.js +1 -752
- package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
- package/es/core/toolOperation/eventListener.js +1 -35
- package/es/core/toolOperation/measureOperation.js +1 -39
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
- package/es/core/toolOperation/pointOperation.js +1 -690
- package/es/core/toolOperation/polygonOperation.js +1 -1245
- package/es/core/toolOperation/rectOperation.js +1 -1228
- package/es/core/toolOperation/segmentByRect.js +1 -172
- package/es/core/toolOperation/tagOperation.js +3 -199
- package/es/core/toolOperation/textAttributeClass.js +16 -180
- package/es/index.js +1 -46
- package/es/locales/constants.js +1 -22
- package/es/locales/en_US/message.js +1 -23
- package/es/locales/index.js +1 -17
- package/es/locales/zh_CN/message.js +1 -23
- package/es/newCore/CanvasScheduler.js +1 -31
- package/es/utils/ActionsHistory.js +1 -78
- package/es/utils/ImgUtils.js +1 -21
- package/es/utils/MathUtils.js +2 -380
- package/es/utils/VectorUtils.js +1 -23
- package/es/utils/tool/AttributeUtils.js +1 -212
- package/es/utils/tool/AxisUtils.js +1 -335
- package/es/utils/tool/CanvasUtils.js +1 -60
- package/es/utils/tool/CommonToolUtils.js +1 -172
- package/es/utils/tool/CuboidUtils.js +1 -680
- package/es/utils/tool/DblClickEventListener.js +1 -100
- package/es/utils/tool/DrawUtils.js +3 -490
- package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
- package/es/utils/tool/ImgPosUtils.js +1 -56
- package/es/utils/tool/LineToolUtils.js +1 -255
- package/es/utils/tool/MarkerUtils.js +1 -54
- package/es/utils/tool/PolygonUtils.js +1 -458
- package/es/utils/tool/RectUtils.js +1 -153
- package/es/utils/tool/RenderDomClass.js +7 -55
- package/es/utils/tool/RenderDomUtils.js +4 -19
- package/es/utils/tool/StyleUtils.js +1 -29
- package/es/utils/tool/TagUtils.js +1 -127
- package/es/utils/tool/UnitUtils.js +1 -10
- package/es/utils/tool/ZoomUtils.js +1 -70
- package/es/utils/tool/polygonTool.js +1 -126
- package/es/utils/uuid.js +1 -24
- package/package.json +3 -4
- package/LICENSE +0 -203
- package/dist/core/pointCloud/segmentation.js +0 -144
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
- package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
- 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/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
- package/es/core/pointCloud/segmentation.js +0 -120
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
- package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
- package/es/core/toolOperation/scribbleTool2.js +0 -249
|
@@ -1,56 +1 @@
|
|
|
1
|
-
class
|
|
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
|
+
class x{static getInitImgPos(n,t,h=0,c=1,r=!1){(h===90||h===270)&&(t={width:t.height,height:t.width});const d=n.width*c/t.width,i=n.height*c/t.height;let o=r?1:Math.min(d,i);const e={x:(n.width-t.width*o)/2,y:(n.height-t.height*o)/2},s=t.width*o,w=t.height*o;return r&&(o=1),{zoom:o,currentPos:e,imgInfo:{width:s,height:w}}}static getBasicRecPos(n,t,h,c=.9,r=1,d=!1){if(t&&n){const{x:i,y:o,height:e,width:s}=t;let w=h.height/e;s/e>h.width/h.height&&(w=h.width/s);const l=d?1:w*c*r,f={x:h.width/2,y:h.height/2},g={x:(i+s/2)*l,y:(o+e/2)*l};return{currentPos:{x:f.x-g.x,y:f.y-g.y},innerZoom:l}}return!1}}export{x as default};
|
|
@@ -1,255 +1 @@
|
|
|
1
|
-
import
|
|
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
|
+
import{EToolName as B,ELineTypes as R}from"../../constant/tool.js";import{createSmoothCurvePointsFromPointList as N}from"./polygonTool.js";import M from"./PolygonUtils.js";import O from"../MathUtils.js";var F=Object.defineProperty,S=Object.defineProperties,W=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,E=(t,n,o)=>n in t?F(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,x=(t,n)=>{for(var o in n||(n={}))q.call(n,o)&&E(t,o,n[o]);if(b)for(var o of b(n))V.call(n,o)&&E(t,o,n[o]);return t},C=(t,n)=>S(t,W(n)),D;(function(t){t[t.Create=0]="Create",t[t.Active=1]="Active",t[t.Edit=1]="Edit",t[t.None=2]="None"})(D||(D={}));var I;(function(t){t.ActiveArea="#B3B8FF"})(I||(I={}));const L=16,G=3,f=class{static isInLine(t,n,o,i=3){const{length:r}=O.getFootOfPerpendicular(t,n,o);return r<i}};let p=f;p.setSpecialEdgeStyle=t=>{t.lineCap="butt",t.setLineDash([10,10])},p.setReferenceCtx=t=>{t.lineCap="butt",t.setLineDash([6])},p.calcOptimalIntersection=(t,n,o,i,r)=>{let c,y=Infinity,a;if(t.find((g,e)=>{if(e===0)return;const s=f.isInLine(n.pointA,g,t[e-1]),l=f.isInLine(n.pointB,g,t[e-1]);return s&&l}))return{point:o};if(t.forEach((g,e)=>{if(e===0)return;const s={pointA:t[e-1],pointB:g},l=f.lineIntersection(n,s);if(l&&n){const{onLine2:P,onLine1:h,x:m,y:_}=l,v=f.calcDistance(o,l);if(f.isOnLine(n.pointB.x,n.pointB.y,g.x,g.y,t[e-1].x,t[e-1].y)){if(f.calcDistance(o,l)<i/r){const T=n.pointB,{footPoint:A,length:w}=O.getFootOfPerpendicular(T,s.pointA,s.pointB,!0);if(w!==void 0){const j=f.calcDistance(s.pointA,A),U=f.calcDistance(s.pointB,A);a={point:A,minDistance:w},w===Infinity&&(a.point=j>U?s.pointB:s.pointA)}}return}v<y&&P&&h&&(y=v,c={x:m,y:_})}}),c)return{point:c,minDistance:y};if(a)return a},p.lineIntersection=(t,n)=>{let o=!1,i=!1;const r=f.getAxisDiff(t),c=f.getAxisDiff(n),y=c.y*r.x-c.x*r.y;if(y===0)return!1;let a=t.pointA.y-n.pointA.y,u=t.pointA.x-n.pointA.x;const g=(n.pointB.x-n.pointA.x)*a-(n.pointB.y-n.pointA.y)*u,e=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*u;a=g/y,u=e/y,a>0&&a<1&&(o=!0),u>0&&u<1&&(i=!0);const s=t.pointA.x+a*(t.pointB.x-t.pointA.x),l=t.pointA.y+a*(t.pointB.y-t.pointA.y);return{x:s,y:l,onLine1:o,onLine2:i}},p.getAxisDiff=t=>({x:t.pointB.x-t.pointA.x,y:t.pointB.y-t.pointA.y}),p.calcDistance=(t,n)=>Math.sqrt(Math.pow(Math.abs(t.x-n.x),2)+Math.pow(Math.abs(t.y-n.y),2)),p.drawCurveLine=(t,n,o,i=!0,r=!1,c)=>{const y=N(n,L);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=o.color,i&&(t.lineWidth=o.lineWidth),r&&f.setReferenceCtx(t),n.forEach((a,u)=>{const g=a==null?void 0:a.specialEdge,e=y.splice(0,L+1);t.save(),t.beginPath(),c===u&&(t.lineWidth=4),e.forEach(({x:s,y:l},P)=>{const h=P>0?"lineTo":"moveTo";g&&f.setSpecialEdgeStyle(t),t[h](s,l)}),t.stroke(),t.restore()}),t.restore()},p.calcTwoPointDistance=(t,n)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),p.pointOverTarget=(t,n,o,i,r,c,y,a,u,g)=>{const e=t;if(!n)return t;if(o===B.Polygon){const s=f.getPolygonPointList(i,r);if(s.length===0||M.isInPolygon(t,s))return e;const P=s.concat(s[0]).map(d=>u(d)),h=u(n),m=u(t),_={pointA:h,pointB:m},v=f.calcOptimalIntersection(P,_,h,y,a);if(v){const d=g(v==null?void 0:v.point);e.x=d.x,e.y=d.y}else return n;return e}if(o===B.Rect){const{x:s,y:l,width:P,height:h}=i;return e.x=O.withinRange(e.x,[s,s+P]),e.y=O.withinRange(e.y,[l,l+h]),e}return e.x=O.withinRange(e.x,[0,c.width]),e.y=O.withinRange(e.y,[0,c.height]),e},p.getPolygonPointList=(t,n)=>{const{pointList:o}=t,{lineType:i}=n;return i===R.Line?o:M.createSmoothCurvePoints(o.reduce((r,c)=>[...r,c.x,c.y],[]),.5,!0,20)},p.isOnLine=(t,n,o,i,r,c)=>Math.abs((a=>(i-n)/(o-t)*(a-t)+n)(r)-c)<1e-6&&r>=t&&r<=o,p.inArea=({top:t,left:n,right:o,bottom:i},{x:r,y:c})=>c>=t&&c<=i&&r>=n&&r<=o,p.getVHPoint=(t,n,o,i)=>{const r=f.getAngle(t,o);return Math.abs(r)<45?C(x({},n),{y:i.y}):C(x({},n),{x:i.x})},p.getAngle=(t,n)=>{const o=n.x-t.x,i=n.y-t.y;return 360*Math.atan(i/o)/(2*Math.PI)};export{I as EColor,D as EStatus,G as POINT_RADIUS,L as SEGMENT_NUMBER,p as default};
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{cloneDeep as c}from"lodash";import f from"./AttributeUtils.js";class u{static getMarkerShowText(t,r=[]){return f.getAttributeShowText(t,r)}}u.getAuxiliaryLineByMarkerList=(o,t)=>{var r;const s=c(o),l=[];let e=s.shift();for(;e;)(r=e.target)==null||r.forEach(n=>{const i=s.find(a=>a.value===n);i&&(e==null?void 0:e[t])&&l.push({start:e[t],end:i[t]})}),e=s.shift();return l},u.getAuxiliaryLineCoord=(o,t)=>{const r=[];return o.forEach(s=>{const{start:l,end:e}=s,n=t.find(a=>a.label===l);if(!n)return;const i=t.find(a=>a.label===e);!i||r.push({start:{x:n.x,y:n.y},end:{x:i.x,y:i.y}})}),r};export{u as default};
|