@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.5
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/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,704 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _ = require('lodash');
|
|
6
|
-
var annotation = require('../../constant/annotation.js');
|
|
7
|
-
var AxisUtils = require('./AxisUtils.js');
|
|
8
|
-
var VectorUtils = require('../VectorUtils.js');
|
|
9
|
-
var LineToolUtils = require('./LineToolUtils.js');
|
|
10
|
-
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __defProps = Object.defineProperties;
|
|
13
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
14
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
18
|
-
var __spreadValues = (a, b) => {
|
|
19
|
-
for (var prop in b || (b = {}))
|
|
20
|
-
if (__hasOwnProp.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
if (__getOwnPropSymbols)
|
|
23
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
-
if (__propIsEnum.call(b, prop))
|
|
25
|
-
__defNormalProp(a, prop, b[prop]);
|
|
26
|
-
}
|
|
27
|
-
return a;
|
|
28
|
-
};
|
|
29
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
30
|
-
function getPlanePointsBasicInfo({tr, tl, br}) {
|
|
31
|
-
return {
|
|
32
|
-
width: Math.abs(tr.x - tl.x),
|
|
33
|
-
height: Math.abs(br.y - tr.y),
|
|
34
|
-
centerPoints: {
|
|
35
|
-
x: (tl.x + br.x) / 2,
|
|
36
|
-
y: (tl.y + br.y) / 2
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function getCuboidBasicInfo({
|
|
41
|
-
frontPoints,
|
|
42
|
-
backPoints
|
|
43
|
-
}) {
|
|
44
|
-
const {width: frontWidth, height: frontHeight, centerPoints: frontCenter} = getPlanePointsBasicInfo(frontPoints);
|
|
45
|
-
const {width: backWidth, height: backHeight, centerPoints: backCenter} = getPlanePointsBasicInfo(backPoints);
|
|
46
|
-
return {
|
|
47
|
-
frontCenter,
|
|
48
|
-
backCenter,
|
|
49
|
-
frontWidth,
|
|
50
|
-
frontHeight,
|
|
51
|
-
backWidth,
|
|
52
|
-
backHeight,
|
|
53
|
-
isLeftSide: backCenter.x < frontCenter.x
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getPlainPointsByDiagonalPoints(p1, p2) {
|
|
57
|
-
return {
|
|
58
|
-
tl: {
|
|
59
|
-
x: Math.min(p1.x, p2.x),
|
|
60
|
-
y: Math.min(p1.y, p2.y)
|
|
61
|
-
},
|
|
62
|
-
tr: {
|
|
63
|
-
x: Math.max(p1.x, p2.x),
|
|
64
|
-
y: Math.min(p1.y, p2.y)
|
|
65
|
-
},
|
|
66
|
-
bl: {
|
|
67
|
-
x: Math.min(p1.x, p2.x),
|
|
68
|
-
y: Math.max(p1.y, p2.y)
|
|
69
|
-
},
|
|
70
|
-
br: {
|
|
71
|
-
x: Math.max(p1.x, p2.x),
|
|
72
|
-
y: Math.max(p1.y, p2.y)
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function getMaxExternalQuadrilateral(points) {
|
|
77
|
-
const minX = Object.values(points).reduce((acc, coord) => coord.x < acc ? coord.x : acc, Number.MAX_SAFE_INTEGER);
|
|
78
|
-
const maxX = Object.values(points).reduce((acc, coord) => coord.x > acc ? coord.x : acc, 0);
|
|
79
|
-
const minY = Object.values(points).reduce((acc, coord) => coord.y < acc ? coord.y : acc, Number.MAX_SAFE_INTEGER);
|
|
80
|
-
const maxY = Object.values(points).reduce((acc, coord) => coord.y > acc ? coord.y : acc, 0);
|
|
81
|
-
return {
|
|
82
|
-
tl: {
|
|
83
|
-
x: minX,
|
|
84
|
-
y: minY
|
|
85
|
-
},
|
|
86
|
-
tr: {
|
|
87
|
-
x: maxX,
|
|
88
|
-
y: minY
|
|
89
|
-
},
|
|
90
|
-
bl: {
|
|
91
|
-
x: minX,
|
|
92
|
-
y: maxY
|
|
93
|
-
},
|
|
94
|
-
br: {
|
|
95
|
-
x: maxX,
|
|
96
|
-
y: maxY
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function judgeCuboidLineIsRowOrColumn(pointList) {
|
|
101
|
-
const [firstPosition, secondPosition] = pointList;
|
|
102
|
-
if (annotation.CUBOID_ROW[firstPosition.position] === secondPosition.position) {
|
|
103
|
-
return annotation.ECuboidLineDirection.Row;
|
|
104
|
-
}
|
|
105
|
-
if (annotation.CUBOID_COLUMN[firstPosition.position] === secondPosition.position) {
|
|
106
|
-
return annotation.ECuboidLineDirection.Column;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function getPointsByBottomRightPoint({
|
|
110
|
-
coord,
|
|
111
|
-
points
|
|
112
|
-
}) {
|
|
113
|
-
const {width, height} = getPlanePointsBasicInfo(points);
|
|
114
|
-
return {
|
|
115
|
-
br: coord,
|
|
116
|
-
tr: {
|
|
117
|
-
x: coord.x,
|
|
118
|
-
y: coord.y - height
|
|
119
|
-
},
|
|
120
|
-
tl: {
|
|
121
|
-
x: coord.x - width,
|
|
122
|
-
y: coord.y - height
|
|
123
|
-
},
|
|
124
|
-
bl: {
|
|
125
|
-
x: coord.x - width,
|
|
126
|
-
y: coord.y
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function getPointsByBottomLeftPoint({
|
|
131
|
-
coord,
|
|
132
|
-
points
|
|
133
|
-
}) {
|
|
134
|
-
const {width, height} = getPlanePointsBasicInfo(points);
|
|
135
|
-
return {
|
|
136
|
-
bl: coord,
|
|
137
|
-
tr: {
|
|
138
|
-
x: coord.x + width,
|
|
139
|
-
y: coord.y - height
|
|
140
|
-
},
|
|
141
|
-
tl: {
|
|
142
|
-
x: coord.x,
|
|
143
|
-
y: coord.y - height
|
|
144
|
-
},
|
|
145
|
-
br: {
|
|
146
|
-
x: coord.x + width,
|
|
147
|
-
y: coord.y
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function getCuboidShowingSideLine({
|
|
152
|
-
frontPoints,
|
|
153
|
-
backPoints
|
|
154
|
-
}) {
|
|
155
|
-
const {isLeftSide} = getCuboidBasicInfo({frontPoints, backPoints});
|
|
156
|
-
if (isLeftSide) {
|
|
157
|
-
return {
|
|
158
|
-
top: {
|
|
159
|
-
p1: frontPoints.tl,
|
|
160
|
-
p2: backPoints.tl
|
|
161
|
-
},
|
|
162
|
-
bottom: {
|
|
163
|
-
p1: frontPoints.bl,
|
|
164
|
-
p2: backPoints.bl
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
top: {
|
|
170
|
-
p1: frontPoints.tr,
|
|
171
|
-
p2: backPoints.tr
|
|
172
|
-
},
|
|
173
|
-
bottom: {
|
|
174
|
-
p1: frontPoints.br,
|
|
175
|
-
p2: backPoints.br
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function getPointsByIntersection({
|
|
180
|
-
frontPoints,
|
|
181
|
-
backPoints
|
|
182
|
-
}) {
|
|
183
|
-
const {isLeftSide} = getCuboidBasicInfo({frontPoints, backPoints});
|
|
184
|
-
let newBackPoints = __spreadValues({}, backPoints);
|
|
185
|
-
const sideLine = getCuboidShowingSideLine({frontPoints, backPoints});
|
|
186
|
-
const intersectionPoint = LineToolUtils["default"].lineIntersection({pointA: sideLine.bottom.p1, pointB: sideLine.bottom.p2}, {pointA: sideLine.top.p1, pointB: sideLine.top.p2});
|
|
187
|
-
if (isLeftSide) {
|
|
188
|
-
const newBRPoint = LineToolUtils["default"].lineIntersection({pointA: backPoints.bl, pointB: backPoints.br}, {pointA: frontPoints.br, pointB: intersectionPoint});
|
|
189
|
-
if (newBRPoint) {
|
|
190
|
-
newBackPoints = __spreadProps(__spreadValues({}, backPoints), {
|
|
191
|
-
br: newBRPoint,
|
|
192
|
-
tr: {
|
|
193
|
-
x: newBRPoint.x,
|
|
194
|
-
y: backPoints.tl.y
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
const newBLPoint = LineToolUtils["default"].lineIntersection({pointA: backPoints.bl, pointB: backPoints.br}, {pointA: frontPoints.bl, pointB: intersectionPoint});
|
|
200
|
-
if (newBLPoint) {
|
|
201
|
-
newBackPoints = __spreadProps(__spreadValues({}, backPoints), {
|
|
202
|
-
bl: newBLPoint,
|
|
203
|
-
tl: {
|
|
204
|
-
x: newBLPoint.x,
|
|
205
|
-
y: backPoints.tr.y
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
backPoints: newBackPoints
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
function getBackPointsByFrontPoints({
|
|
215
|
-
frontPoints,
|
|
216
|
-
backPoints
|
|
217
|
-
}) {
|
|
218
|
-
const {isLeftSide, frontHeight, backHeight} = getCuboidBasicInfo({frontPoints, backPoints});
|
|
219
|
-
let newBackPoints = __spreadValues({}, backPoints);
|
|
220
|
-
if (isLeftSide) {
|
|
221
|
-
newBackPoints = getPointsByBottomLeftPoint({coord: backPoints.bl, points: frontPoints});
|
|
222
|
-
} else {
|
|
223
|
-
newBackPoints = getPointsByBottomRightPoint({coord: backPoints.br, points: frontPoints});
|
|
224
|
-
}
|
|
225
|
-
if (frontHeight > backHeight) {
|
|
226
|
-
newBackPoints = getPointsByIntersection({frontPoints, backPoints}).backPoints;
|
|
227
|
-
}
|
|
228
|
-
return {frontPoints, backPoints: newBackPoints};
|
|
229
|
-
}
|
|
230
|
-
function getFrontPointsByBackPoints({
|
|
231
|
-
frontPoints,
|
|
232
|
-
backPoints
|
|
233
|
-
}) {
|
|
234
|
-
const {isLeftSide, frontHeight, backHeight, frontWidth, backWidth} = getCuboidBasicInfo({
|
|
235
|
-
frontPoints,
|
|
236
|
-
backPoints
|
|
237
|
-
});
|
|
238
|
-
let newFrontPoints = __spreadValues({}, frontPoints);
|
|
239
|
-
let newBackPoints = backPoints;
|
|
240
|
-
if (isLeftSide || backWidth > frontWidth) {
|
|
241
|
-
newFrontPoints = getPointsByBottomLeftPoint({coord: frontPoints.bl, points: backPoints});
|
|
242
|
-
} else {
|
|
243
|
-
newFrontPoints = getPointsByBottomRightPoint({coord: frontPoints.br, points: backPoints});
|
|
244
|
-
}
|
|
245
|
-
if (frontHeight > backHeight) {
|
|
246
|
-
newFrontPoints.tl.y = frontPoints.tl.y;
|
|
247
|
-
newFrontPoints.tr.y = frontPoints.tr.y;
|
|
248
|
-
newBackPoints = getPointsByIntersection({backPoints, frontPoints}).backPoints;
|
|
249
|
-
}
|
|
250
|
-
if (frontWidth >= backWidth) {
|
|
251
|
-
Object.keys(newFrontPoints).forEach((key) => {
|
|
252
|
-
newFrontPoints[key].x = frontPoints[key].x;
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
frontPoints: newFrontPoints,
|
|
257
|
-
backPoints: newBackPoints
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function getCuboidAllSideLine({frontPoints, backPoints}) {
|
|
261
|
-
return [
|
|
262
|
-
{
|
|
263
|
-
p1: frontPoints.bl,
|
|
264
|
-
p2: backPoints.bl
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
p1: frontPoints.tl,
|
|
268
|
-
p2: backPoints.tl
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
p1: frontPoints.tr,
|
|
272
|
-
p2: backPoints.tr
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
p1: frontPoints.br,
|
|
276
|
-
p2: backPoints.br
|
|
277
|
-
}
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
function getHighlightLines(cuboid) {
|
|
281
|
-
const {frontPoints, backPoints} = cuboid;
|
|
282
|
-
const {isLeftSide} = getCuboidBasicInfo(cuboid);
|
|
283
|
-
const frontLine = [
|
|
284
|
-
{
|
|
285
|
-
p1: frontPoints.tl,
|
|
286
|
-
p2: frontPoints.tr,
|
|
287
|
-
positions: [
|
|
288
|
-
{
|
|
289
|
-
plain: annotation.ECuboidPlain.Front,
|
|
290
|
-
position: annotation.ECuboidPosition.TL
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
plain: annotation.ECuboidPlain.Front,
|
|
294
|
-
position: annotation.ECuboidPosition.TR
|
|
295
|
-
}
|
|
296
|
-
]
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
p1: frontPoints.tr,
|
|
300
|
-
p2: frontPoints.br,
|
|
301
|
-
plain: annotation.ECuboidPlain.Front,
|
|
302
|
-
positions: [
|
|
303
|
-
{
|
|
304
|
-
plain: annotation.ECuboidPlain.Front,
|
|
305
|
-
position: annotation.ECuboidPosition.TR
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
plain: annotation.ECuboidPlain.Front,
|
|
309
|
-
position: annotation.ECuboidPosition.BR
|
|
310
|
-
}
|
|
311
|
-
]
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
p1: frontPoints.br,
|
|
315
|
-
p2: frontPoints.bl,
|
|
316
|
-
plain: annotation.ECuboidPlain.Front,
|
|
317
|
-
positions: [
|
|
318
|
-
{
|
|
319
|
-
plain: annotation.ECuboidPlain.Front,
|
|
320
|
-
position: annotation.ECuboidPosition.BR
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
plain: annotation.ECuboidPlain.Front,
|
|
324
|
-
position: annotation.ECuboidPosition.BL
|
|
325
|
-
}
|
|
326
|
-
]
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
p1: frontPoints.bl,
|
|
330
|
-
p2: frontPoints.tl,
|
|
331
|
-
plain: annotation.ECuboidPlain.Front,
|
|
332
|
-
positions: [
|
|
333
|
-
{
|
|
334
|
-
plain: annotation.ECuboidPlain.Front,
|
|
335
|
-
position: annotation.ECuboidPosition.BL
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
plain: annotation.ECuboidPlain.Front,
|
|
339
|
-
position: annotation.ECuboidPosition.TL
|
|
340
|
-
}
|
|
341
|
-
]
|
|
342
|
-
}
|
|
343
|
-
];
|
|
344
|
-
if (isLeftSide) {
|
|
345
|
-
return [
|
|
346
|
-
...frontLine,
|
|
347
|
-
{
|
|
348
|
-
p1: backPoints.tl,
|
|
349
|
-
p2: backPoints.bl,
|
|
350
|
-
positions: [
|
|
351
|
-
{
|
|
352
|
-
plain: annotation.ECuboidPlain.Back,
|
|
353
|
-
position: annotation.ECuboidPosition.TL
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
plain: annotation.ECuboidPlain.Back,
|
|
357
|
-
position: annotation.ECuboidPosition.BL
|
|
358
|
-
}
|
|
359
|
-
]
|
|
360
|
-
}
|
|
361
|
-
];
|
|
362
|
-
}
|
|
363
|
-
return [
|
|
364
|
-
...frontLine,
|
|
365
|
-
{
|
|
366
|
-
p1: backPoints.tr,
|
|
367
|
-
p2: backPoints.br,
|
|
368
|
-
positions: [
|
|
369
|
-
{
|
|
370
|
-
plain: annotation.ECuboidPlain.Back,
|
|
371
|
-
position: annotation.ECuboidPosition.TR
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
plain: annotation.ECuboidPlain.Back,
|
|
375
|
-
position: annotation.ECuboidPosition.BR
|
|
376
|
-
}
|
|
377
|
-
]
|
|
378
|
-
}
|
|
379
|
-
];
|
|
380
|
-
}
|
|
381
|
-
function getHighlightPoints(cuboid) {
|
|
382
|
-
const {backPoints} = cuboid;
|
|
383
|
-
const {isLeftSide} = getCuboidBasicInfo(cuboid);
|
|
384
|
-
const frontPointsData = Object.entries(cuboid.frontPoints).map(([position, point]) => ({
|
|
385
|
-
positions: [
|
|
386
|
-
{
|
|
387
|
-
plain: annotation.ECuboidPlain.Front,
|
|
388
|
-
position
|
|
389
|
-
}
|
|
390
|
-
],
|
|
391
|
-
point
|
|
392
|
-
}));
|
|
393
|
-
if (isLeftSide) {
|
|
394
|
-
return [
|
|
395
|
-
{point: backPoints.tl, positions: [{position: annotation.ECuboidPosition.TL, plain: annotation.ECuboidPlain.Back}]},
|
|
396
|
-
{point: backPoints.bl, positions: [{position: annotation.ECuboidPosition.BL, plain: annotation.ECuboidPlain.Back}]},
|
|
397
|
-
...frontPointsData
|
|
398
|
-
];
|
|
399
|
-
}
|
|
400
|
-
return [
|
|
401
|
-
{point: backPoints.tr, positions: [{position: annotation.ECuboidPosition.TR, plain: annotation.ECuboidPlain.Back}]},
|
|
402
|
-
{point: backPoints.br, positions: [{position: annotation.ECuboidPosition.BR, plain: annotation.ECuboidPlain.Back}]},
|
|
403
|
-
...frontPointsData
|
|
404
|
-
];
|
|
405
|
-
}
|
|
406
|
-
function getCuboidHoverRange(cuboid) {
|
|
407
|
-
const {frontPoints, backPoints} = cuboid;
|
|
408
|
-
const {backCenter, frontCenter, frontHeight, frontWidth, backHeight, backWidth, isLeftSide} = getCuboidBasicInfo(cuboid);
|
|
409
|
-
const diffWidth = Math.abs(frontWidth - backWidth);
|
|
410
|
-
const diffHeight = Math.abs(frontHeight - backHeight);
|
|
411
|
-
const diffCenterX = Math.abs(frontCenter.x - backCenter.x);
|
|
412
|
-
const diffCenterY = Math.abs(frontCenter.y - backCenter.y);
|
|
413
|
-
const isOverX = diffCenterX > diffWidth;
|
|
414
|
-
const isOverY = diffCenterY > diffHeight;
|
|
415
|
-
const isNested = !(isOverX || isOverY);
|
|
416
|
-
if (isNested) {
|
|
417
|
-
return [frontPoints.tl, frontPoints.tr, frontPoints.br, frontPoints.bl];
|
|
418
|
-
}
|
|
419
|
-
if (isOverY && !isOverX) {
|
|
420
|
-
return [frontPoints.tl, backPoints.tl, backPoints.tr, frontPoints.tr, frontPoints.br, frontPoints.bl];
|
|
421
|
-
}
|
|
422
|
-
if (isOverX && !isOverY) {
|
|
423
|
-
if (isLeftSide) {
|
|
424
|
-
return [frontPoints.tl, frontPoints.tr, frontPoints.br, frontPoints.bl, backPoints.bl, backPoints.tl];
|
|
425
|
-
}
|
|
426
|
-
return [frontPoints.tl, frontPoints.tr, backPoints.tr, backPoints.br, frontPoints.br, frontPoints.bl];
|
|
427
|
-
}
|
|
428
|
-
if (isOverX && isOverY) {
|
|
429
|
-
if (isLeftSide) {
|
|
430
|
-
return [backPoints.tl, backPoints.tr, frontPoints.tr, frontPoints.br, frontPoints.bl, backPoints.bl];
|
|
431
|
-
}
|
|
432
|
-
return [frontPoints.tl, backPoints.tl, backPoints.tr, backPoints.br, frontPoints.br, frontPoints.bl];
|
|
433
|
-
}
|
|
434
|
-
return [];
|
|
435
|
-
}
|
|
436
|
-
function getNewPointsAfterOffset({
|
|
437
|
-
offset,
|
|
438
|
-
frontPoints,
|
|
439
|
-
backPoints,
|
|
440
|
-
positions
|
|
441
|
-
}) {
|
|
442
|
-
let newFrontPoints = _.cloneDeep(frontPoints);
|
|
443
|
-
let newBackPoints = _.cloneDeep(backPoints);
|
|
444
|
-
if ((positions == null ? void 0 : positions.length) === 2) {
|
|
445
|
-
const isFrontPlain = positions.every((v) => v.plain === annotation.ECuboidPlain.Front);
|
|
446
|
-
const isBackPlain = !isFrontPlain;
|
|
447
|
-
const lineDirection = judgeCuboidLineIsRowOrColumn([positions[0], positions[1]]);
|
|
448
|
-
const forbidX = lineDirection === annotation.ECuboidLineDirection.Row;
|
|
449
|
-
const forbidY = lineDirection === annotation.ECuboidLineDirection.Column;
|
|
450
|
-
let newOffset = offset;
|
|
451
|
-
if (forbidX) {
|
|
452
|
-
newOffset = {
|
|
453
|
-
x: 0,
|
|
454
|
-
y: offset.y
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
if (forbidY) {
|
|
458
|
-
newOffset = {
|
|
459
|
-
y: 0,
|
|
460
|
-
x: offset.x
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
if (isFrontPlain) {
|
|
464
|
-
positions == null ? void 0 : positions.forEach(({position}) => {
|
|
465
|
-
const points = newFrontPoints;
|
|
466
|
-
const movePoint = points[position];
|
|
467
|
-
points[position] = {
|
|
468
|
-
x: movePoint.x + newOffset.x,
|
|
469
|
-
y: movePoint.y + newOffset.y
|
|
470
|
-
};
|
|
471
|
-
});
|
|
472
|
-
newFrontPoints = getMaxExternalQuadrilateral(newFrontPoints);
|
|
473
|
-
newBackPoints = getMaxExternalQuadrilateral(newBackPoints);
|
|
474
|
-
}
|
|
475
|
-
if (isBackPlain) {
|
|
476
|
-
Object.keys(newBackPoints).forEach((key) => {
|
|
477
|
-
newBackPoints[key] = {
|
|
478
|
-
x: newBackPoints[key].x + newOffset.x,
|
|
479
|
-
y: newBackPoints[key].y + newOffset.y
|
|
480
|
-
};
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
const getNewPlainPoints = isFrontPlain ? getBackPointsByFrontPoints : getFrontPointsByBackPoints;
|
|
484
|
-
const {frontPoints: newFrontPoints2, backPoints: newBackPoints2} = getNewPlainPoints({
|
|
485
|
-
frontPoints: newFrontPoints,
|
|
486
|
-
backPoints: newBackPoints
|
|
487
|
-
});
|
|
488
|
-
newFrontPoints = newFrontPoints2;
|
|
489
|
-
newBackPoints = newBackPoints2;
|
|
490
|
-
}
|
|
491
|
-
return {
|
|
492
|
-
frontPoints: newFrontPoints,
|
|
493
|
-
backPoints: newBackPoints
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
function moveCuboidByCuboid({offset, cuboid}) {
|
|
497
|
-
const {frontPoints, backPoints} = cuboid;
|
|
498
|
-
const newFrontPoints = Object.entries(frontPoints).reduce((acc, [key, point]) => {
|
|
499
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
500
|
-
[key]: {
|
|
501
|
-
x: point.x + offset.x,
|
|
502
|
-
y: point.y + offset.y
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}, {});
|
|
506
|
-
const newBackPoints = Object.entries(backPoints).reduce((acc, [key, point]) => {
|
|
507
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
508
|
-
[key]: {
|
|
509
|
-
x: point.x + offset.x,
|
|
510
|
-
y: point.y + offset.y
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
}, {});
|
|
514
|
-
return {
|
|
515
|
-
frontPoints: newFrontPoints,
|
|
516
|
-
backPoints: newBackPoints
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
function moveCuboidByLine({
|
|
520
|
-
offset,
|
|
521
|
-
cuboid,
|
|
522
|
-
positions
|
|
523
|
-
}) {
|
|
524
|
-
const {frontPoints, backPoints} = cuboid;
|
|
525
|
-
return getNewPointsAfterOffset({
|
|
526
|
-
offset,
|
|
527
|
-
frontPoints,
|
|
528
|
-
backPoints,
|
|
529
|
-
positions
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
function moveCuboidByPoints({
|
|
533
|
-
offset,
|
|
534
|
-
cuboid,
|
|
535
|
-
positions
|
|
536
|
-
}) {
|
|
537
|
-
if (!(positions == null ? void 0 : positions[0])) {
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
const {frontPoints, backPoints} = cuboid;
|
|
541
|
-
const pointPosition = positions[0];
|
|
542
|
-
const isFrontPlain = pointPosition.plain === annotation.ECuboidPlain.Front;
|
|
543
|
-
const movePoints = isFrontPlain ? frontPoints : backPoints;
|
|
544
|
-
let movePoint = movePoints[pointPosition.position];
|
|
545
|
-
const diagonalPoint = movePoints[annotation.DIAGONAL_POINT[pointPosition.position]];
|
|
546
|
-
if (!movePoint || !diagonalPoint) {
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
movePoint = VectorUtils.add(movePoint, offset);
|
|
550
|
-
const newPlainsPoints = getPlainPointsByDiagonalPoints(movePoint, diagonalPoint);
|
|
551
|
-
const getNewPlainPoints = isFrontPlain ? getBackPointsByFrontPoints : getFrontPointsByBackPoints;
|
|
552
|
-
let payload = {
|
|
553
|
-
frontPoints,
|
|
554
|
-
backPoints: newPlainsPoints
|
|
555
|
-
};
|
|
556
|
-
if (isFrontPlain) {
|
|
557
|
-
payload = {
|
|
558
|
-
frontPoints: newPlainsPoints,
|
|
559
|
-
backPoints
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
return getNewPlainPoints(payload);
|
|
563
|
-
}
|
|
564
|
-
function getCuboidDragMove({
|
|
565
|
-
offset,
|
|
566
|
-
cuboid,
|
|
567
|
-
dragTarget,
|
|
568
|
-
positions
|
|
569
|
-
}) {
|
|
570
|
-
switch (dragTarget) {
|
|
571
|
-
case annotation.EDragTarget.Cuboid: {
|
|
572
|
-
const newCuboidPoints = moveCuboidByCuboid({offset, cuboid});
|
|
573
|
-
return __spreadValues(__spreadValues({}, cuboid), newCuboidPoints);
|
|
574
|
-
}
|
|
575
|
-
case annotation.EDragTarget.Line: {
|
|
576
|
-
const newCuboidPoints = moveCuboidByLine({offset, cuboid, positions});
|
|
577
|
-
return __spreadValues(__spreadValues({}, cuboid), newCuboidPoints);
|
|
578
|
-
}
|
|
579
|
-
case annotation.EDragTarget.Point: {
|
|
580
|
-
const newCuboidPoints = moveCuboidByPoints({cuboid, offset, positions});
|
|
581
|
-
if (newCuboidPoints) {
|
|
582
|
-
return __spreadValues(__spreadValues({}, cuboid), newCuboidPoints);
|
|
583
|
-
}
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
default: {
|
|
587
|
-
console.error("No DragTarget");
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function getPointListsByDirection({
|
|
593
|
-
direction,
|
|
594
|
-
frontPoints,
|
|
595
|
-
backPoints
|
|
596
|
-
}) {
|
|
597
|
-
if (direction && frontPoints && backPoints) {
|
|
598
|
-
let points = frontPoints;
|
|
599
|
-
switch (direction) {
|
|
600
|
-
case annotation.ECuboidDirection.Back:
|
|
601
|
-
points = backPoints;
|
|
602
|
-
break;
|
|
603
|
-
case annotation.ECuboidDirection.Left:
|
|
604
|
-
points = {
|
|
605
|
-
bl: backPoints.bl,
|
|
606
|
-
br: frontPoints.bl,
|
|
607
|
-
tl: backPoints.tl,
|
|
608
|
-
tr: frontPoints.tl
|
|
609
|
-
};
|
|
610
|
-
break;
|
|
611
|
-
case annotation.ECuboidDirection.Right:
|
|
612
|
-
points = {
|
|
613
|
-
bl: backPoints.br,
|
|
614
|
-
br: frontPoints.br,
|
|
615
|
-
tl: backPoints.tr,
|
|
616
|
-
tr: frontPoints.tr
|
|
617
|
-
};
|
|
618
|
-
break;
|
|
619
|
-
case annotation.ECuboidDirection.Top:
|
|
620
|
-
points = {
|
|
621
|
-
bl: backPoints.tl,
|
|
622
|
-
br: frontPoints.tl,
|
|
623
|
-
tl: backPoints.tr,
|
|
624
|
-
tr: frontPoints.tr
|
|
625
|
-
};
|
|
626
|
-
break;
|
|
627
|
-
default:
|
|
628
|
-
points = frontPoints;
|
|
629
|
-
break;
|
|
630
|
-
}
|
|
631
|
-
return AxisUtils["default"].transformPlain2PointList(points);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
function getToggleDirectionButtonOffset({
|
|
635
|
-
cuboid,
|
|
636
|
-
currentPos,
|
|
637
|
-
zoom
|
|
638
|
-
}) {
|
|
639
|
-
const {frontPoints} = cuboid;
|
|
640
|
-
const toggleSize = {
|
|
641
|
-
width: 40,
|
|
642
|
-
height: 74
|
|
643
|
-
};
|
|
644
|
-
const frontPointsCenter = {
|
|
645
|
-
x: (frontPoints.bl.x + frontPoints.tl.x) / 2,
|
|
646
|
-
y: (frontPoints.bl.y + frontPoints.tl.y) / 2
|
|
647
|
-
};
|
|
648
|
-
const leftOffset = toggleSize.width + 10;
|
|
649
|
-
const topOffset = toggleSize.height / 2;
|
|
650
|
-
const moveCoordinate = {
|
|
651
|
-
x: frontPointsCenter.x,
|
|
652
|
-
y: frontPointsCenter.y
|
|
653
|
-
};
|
|
654
|
-
const coordinate = AxisUtils["default"].getOffsetCoordinate(moveCoordinate, currentPos, zoom);
|
|
655
|
-
return {
|
|
656
|
-
left: coordinate.x - leftOffset,
|
|
657
|
-
top: coordinate.y - topOffset
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
function getCuboidTextAttributeOffset({
|
|
661
|
-
cuboid,
|
|
662
|
-
currentPos,
|
|
663
|
-
zoom,
|
|
664
|
-
leftOffset = 16,
|
|
665
|
-
topOffset = 2
|
|
666
|
-
}) {
|
|
667
|
-
const {frontPoints} = cuboid;
|
|
668
|
-
const moveCoordinate = {
|
|
669
|
-
x: frontPoints.bl.x,
|
|
670
|
-
y: frontPoints.bl.y
|
|
671
|
-
};
|
|
672
|
-
const coordinate = AxisUtils["default"].getOffsetCoordinate(moveCoordinate, currentPos, zoom);
|
|
673
|
-
return {
|
|
674
|
-
left: coordinate.x + leftOffset,
|
|
675
|
-
top: coordinate.y + topOffset
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
function isCuboidWithInLimits({cuboid, config}) {
|
|
679
|
-
const {minHeight, minWidth} = config;
|
|
680
|
-
const {width, height} = getPlanePointsBasicInfo(cuboid.frontPoints);
|
|
681
|
-
return width >= minWidth && height >= minHeight;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
exports.getBackPointsByFrontPoints = getBackPointsByFrontPoints;
|
|
685
|
-
exports.getCuboidAllSideLine = getCuboidAllSideLine;
|
|
686
|
-
exports.getCuboidBasicInfo = getCuboidBasicInfo;
|
|
687
|
-
exports.getCuboidDragMove = getCuboidDragMove;
|
|
688
|
-
exports.getCuboidHoverRange = getCuboidHoverRange;
|
|
689
|
-
exports.getCuboidShowingSideLine = getCuboidShowingSideLine;
|
|
690
|
-
exports.getCuboidTextAttributeOffset = getCuboidTextAttributeOffset;
|
|
691
|
-
exports.getFrontPointsByBackPoints = getFrontPointsByBackPoints;
|
|
692
|
-
exports.getHighlightLines = getHighlightLines;
|
|
693
|
-
exports.getHighlightPoints = getHighlightPoints;
|
|
694
|
-
exports.getMaxExternalQuadrilateral = getMaxExternalQuadrilateral;
|
|
695
|
-
exports.getNewPointsAfterOffset = getNewPointsAfterOffset;
|
|
696
|
-
exports.getPlainPointsByDiagonalPoints = getPlainPointsByDiagonalPoints;
|
|
697
|
-
exports.getPlanePointsBasicInfo = getPlanePointsBasicInfo;
|
|
698
|
-
exports.getPointListsByDirection = getPointListsByDirection;
|
|
699
|
-
exports.getPointsByBottomLeftPoint = getPointsByBottomLeftPoint;
|
|
700
|
-
exports.getPointsByBottomRightPoint = getPointsByBottomRightPoint;
|
|
701
|
-
exports.getPointsByIntersection = getPointsByIntersection;
|
|
702
|
-
exports.getToggleDirectionButtonOffset = getToggleDirectionButtonOffset;
|
|
703
|
-
exports.isCuboidWithInLimits = isCuboidWithInLimits;
|
|
704
|
-
exports.judgeCuboidLineIsRowOrColumn = judgeCuboidLineIsRowOrColumn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),annotation=require("../../constant/annotation.js"),AxisUtils=require("./AxisUtils.js"),VectorUtils=require("../VectorUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,n)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,__spreadValues=(i,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(i,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(i,n,t[n]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));function getPlanePointsBasicInfo({tr:i,tl:t,br:n}){return{width:Math.abs(i.x-t.x),height:Math.abs(n.y-i.y),centerPoints:{x:(t.x+n.x)/2,y:(t.y+n.y)/2}}}function getCuboidBasicInfo({frontPoints:i,backPoints:t}){const{width:n,height:o,centerPoints:r}=getPlanePointsBasicInfo(i),{width:e,height:s,centerPoints:l}=getPlanePointsBasicInfo(t);return{frontCenter:r,backCenter:l,frontWidth:n,frontHeight:o,backWidth:e,backHeight:s,isLeftSide:l.x<r.x}}function getPlainPointsByDiagonalPoints(i,t){return{tl:{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y)},tr:{x:Math.max(i.x,t.x),y:Math.min(i.y,t.y)},bl:{x:Math.min(i.x,t.x),y:Math.max(i.y,t.y)},br:{x:Math.max(i.x,t.x),y:Math.max(i.y,t.y)}}}function getMaxExternalQuadrilateral(i){const t=Object.values(i).reduce((e,s)=>s.x<e?s.x:e,Number.MAX_SAFE_INTEGER),n=Object.values(i).reduce((e,s)=>s.x>e?s.x:e,0),o=Object.values(i).reduce((e,s)=>s.y<e?s.y:e,Number.MAX_SAFE_INTEGER),r=Object.values(i).reduce((e,s)=>s.y>e?s.y:e,0);return{tl:{x:t,y:o},tr:{x:n,y:o},bl:{x:t,y:r},br:{x:n,y:r}}}function judgeCuboidLineIsRowOrColumn(i){const[t,n]=i;if(annotation.CUBOID_ROW[t.position]===n.position)return annotation.ECuboidLineDirection.Row;if(annotation.CUBOID_COLUMN[t.position]===n.position)return annotation.ECuboidLineDirection.Column}function getPointsByBottomRightPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{br:i,tr:{x:i.x,y:i.y-o},tl:{x:i.x-n,y:i.y-o},bl:{x:i.x-n,y:i.y}}}function getPointsByBottomLeftPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{bl:i,tr:{x:i.x+n,y:i.y-o},tl:{x:i.x,y:i.y-o},br:{x:i.x+n,y:i.y}}}function getCuboidShowingSideLine({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});return n?{top:{p1:i.tl,p2:t.tl},bottom:{p1:i.bl,p2:t.bl}}:{top:{p1:i.tr,p2:t.tr},bottom:{p1:i.br,p2:t.br}}}function getPointsByIntersection({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let o=__spreadValues({},t);const r=getCuboidShowingSideLine({frontPoints:i,backPoints:t}),e=LineToolUtils.default.lineIntersection({pointA:r.bottom.p1,pointB:r.bottom.p2},{pointA:r.top.p1,pointB:r.top.p2});if(n){const s=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.br,pointB:e});s&&(o=__spreadProps(__spreadValues({},t),{br:s,tr:{x:s.x,y:t.tl.y}}))}else{const s=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.bl,pointB:e});s&&(o=__spreadProps(__spreadValues({},t),{bl:s,tl:{x:s.x,y:t.tr.y}}))}return{backPoints:o}}function getBackPointsByFrontPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:r}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let e=__spreadValues({},t);return n?e=getPointsByBottomLeftPoint({coord:t.bl,points:i}):e=getPointsByBottomRightPoint({coord:t.br,points:i}),o>r&&(e=getPointsByIntersection({frontPoints:i,backPoints:t}).backPoints),{frontPoints:i,backPoints:e}}function getFrontPointsByBackPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:r,frontWidth:e,backWidth:s}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let l=__spreadValues({},i),a=t;return n||s>e?l=getPointsByBottomLeftPoint({coord:i.bl,points:t}):l=getPointsByBottomRightPoint({coord:i.br,points:t}),o>r&&(l.tl.y=i.tl.y,l.tr.y=i.tr.y,a=getPointsByIntersection({backPoints:t,frontPoints:i}).backPoints),e>=s&&Object.keys(l).forEach(u=>{l[u].x=i[u].x}),{frontPoints:l,backPoints:a}}function getCuboidAllSideLine({frontPoints:i,backPoints:t}){return[{p1:i.bl,p2:t.bl},{p1:i.tl,p2:t.tl},{p1:i.tr,p2:t.tr},{p1:i.br,p2:t.br}]}function getHighlightLines(i){const{frontPoints:t,backPoints:n}=i,{isLeftSide:o}=getCuboidBasicInfo(i),r=[{p1:t.tl,p2:t.tr,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR}]},{p1:t.tr,p2:t.br,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR}]},{p1:t.br,p2:t.bl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL}]},{p1:t.bl,p2:t.tl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL}]}];return o?[...r,{p1:n.tl,p2:n.bl,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BL}]}]:[...r,{p1:n.tr,p2:n.br,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BR}]}]}function getHighlightPoints(i){const{backPoints:t}=i,{isLeftSide:n}=getCuboidBasicInfo(i),o=Object.entries(i.frontPoints).map(([r,e])=>({positions:[{plain:annotation.ECuboidPlain.Front,position:r}],point:e}));return n?[{point:t.tl,positions:[{position:annotation.ECuboidPosition.TL,plain:annotation.ECuboidPlain.Back}]},{point:t.bl,positions:[{position:annotation.ECuboidPosition.BL,plain:annotation.ECuboidPlain.Back}]},...o]:[{point:t.tr,positions:[{position:annotation.ECuboidPosition.TR,plain:annotation.ECuboidPlain.Back}]},{point:t.br,positions:[{position:annotation.ECuboidPosition.BR,plain:annotation.ECuboidPlain.Back}]},...o]}function getCuboidHoverRange(i){const{frontPoints:t,backPoints:n}=i,{backCenter:o,frontCenter:r,frontHeight:e,frontWidth:s,backHeight:l,backWidth:a,isLeftSide:u}=getCuboidBasicInfo(i),p=Math.abs(s-a),c=Math.abs(e-l),d=Math.abs(r.x-o.x),x=Math.abs(r.y-o.y),f=d>p,b=x>c;return f||b?b&&!f?[t.tl,n.tl,n.tr,t.tr,t.br,t.bl]:f&&!b?u?[t.tl,t.tr,t.br,t.bl,n.bl,n.tl]:[t.tl,t.tr,n.tr,n.br,t.br,t.bl]:f&&b?u?[n.tl,n.tr,t.tr,t.br,t.bl,n.bl]:[t.tl,n.tl,n.tr,n.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function getNewPointsAfterOffset({offset:i,frontPoints:t,backPoints:n,positions:o}){let r=_.cloneDeep(t),e=_.cloneDeep(n);if((o==null?void 0:o.length)===2){const s=o.every(b=>b.plain===annotation.ECuboidPlain.Front),l=!s,a=judgeCuboidLineIsRowOrColumn([o[0],o[1]]),u=a===annotation.ECuboidLineDirection.Row,p=a===annotation.ECuboidLineDirection.Column;let c=i;u&&(c={x:0,y:i.y}),p&&(c={y:0,x:i.x}),s&&(o==null||o.forEach(({position:b})=>{const g=r,y=g[b];g[b]={x:y.x+c.x,y:y.y+c.y}}),r=getMaxExternalQuadrilateral(r),e=getMaxExternalQuadrilateral(e)),l&&Object.keys(e).forEach(b=>{e[b]={x:e[b].x+c.x,y:e[b].y+c.y}});const d=s?getBackPointsByFrontPoints:getFrontPointsByBackPoints,{frontPoints:x,backPoints:f}=d({frontPoints:r,backPoints:e});r=x,e=f}return{frontPoints:r,backPoints:e}}function moveCuboidByCuboid({offset:i,cuboid:t}){const{frontPoints:n,backPoints:o}=t,r=Object.entries(n).reduce((s,[l,a])=>__spreadProps(__spreadValues({},s),{[l]:{x:a.x+i.x,y:a.y+i.y}}),{}),e=Object.entries(o).reduce((s,[l,a])=>__spreadProps(__spreadValues({},s),{[l]:{x:a.x+i.x,y:a.y+i.y}}),{});return{frontPoints:r,backPoints:e}}function moveCuboidByLine({offset:i,cuboid:t,positions:n}){const{frontPoints:o,backPoints:r}=t;return getNewPointsAfterOffset({offset:i,frontPoints:o,backPoints:r,positions:n})}function moveCuboidByPoints({offset:i,cuboid:t,positions:n}){if(!(n==null?void 0:n[0]))return;const{frontPoints:o,backPoints:r}=t,e=n[0],s=e.plain===annotation.ECuboidPlain.Front,l=s?o:r;let a=l[e.position];const u=l[annotation.DIAGONAL_POINT[e.position]];if(!a||!u)return;a=VectorUtils.add(a,i);const p=getPlainPointsByDiagonalPoints(a,u),c=s?getBackPointsByFrontPoints:getFrontPointsByBackPoints;let d={frontPoints:o,backPoints:p};return s&&(d={frontPoints:p,backPoints:r}),c(d)}function getCuboidDragMove({offset:i,cuboid:t,dragTarget:n,positions:o}){switch(n){case annotation.EDragTarget.Cuboid:{const r=moveCuboidByCuboid({offset:i,cuboid:t});return __spreadValues(__spreadValues({},t),r)}case annotation.EDragTarget.Line:{const r=moveCuboidByLine({offset:i,cuboid:t,positions:o});return __spreadValues(__spreadValues({},t),r)}case annotation.EDragTarget.Point:{const r=moveCuboidByPoints({cuboid:t,offset:i,positions:o});if(r)return __spreadValues(__spreadValues({},t),r);break}default:{console.error("No DragTarget");break}}}function getPointListsByDirection({direction:i,frontPoints:t,backPoints:n}){if(i&&t&&n){let o=t;switch(i){case annotation.ECuboidDirection.Back:o=n;break;case annotation.ECuboidDirection.Left:o={bl:n.bl,br:t.bl,tl:n.tl,tr:t.tl};break;case annotation.ECuboidDirection.Right:o={bl:n.br,br:t.br,tl:n.tr,tr:t.tr};break;case annotation.ECuboidDirection.Top:o={bl:n.tl,br:t.tl,tl:n.tr,tr:t.tr};break;default:o=t;break}return AxisUtils.default.transformPlain2PointList(o)}}function getToggleDirectionButtonOffset({cuboid:i,currentPos:t,zoom:n}){const{frontPoints:o}=i,r={width:40,height:74},e={x:(o.bl.x+o.tl.x)/2,y:(o.bl.y+o.tl.y)/2},s=r.width+10,l=r.height/2,a={x:e.x,y:e.y},u=AxisUtils.default.getOffsetCoordinate(a,t,n);return{left:u.x-s,top:u.y-l}}function getCuboidTextAttributeOffset({cuboid:i,currentPos:t,zoom:n,leftOffset:o=16,topOffset:r=2}){const{frontPoints:e}=i,s={x:e.bl.x,y:e.bl.y},l=AxisUtils.default.getOffsetCoordinate(s,t,n);return{left:l.x+o,top:l.y+r}}function isCuboidWithInLimits({cuboid:i,config:t}){const{minHeight:n,minWidth:o}=t,{width:r,height:e}=getPlanePointsBasicInfo(i.frontPoints);return r>=o&&e>=n}exports.getBackPointsByFrontPoints=getBackPointsByFrontPoints,exports.getCuboidAllSideLine=getCuboidAllSideLine,exports.getCuboidBasicInfo=getCuboidBasicInfo,exports.getCuboidDragMove=getCuboidDragMove,exports.getCuboidHoverRange=getCuboidHoverRange,exports.getCuboidShowingSideLine=getCuboidShowingSideLine,exports.getCuboidTextAttributeOffset=getCuboidTextAttributeOffset,exports.getFrontPointsByBackPoints=getFrontPointsByBackPoints,exports.getHighlightLines=getHighlightLines,exports.getHighlightPoints=getHighlightPoints,exports.getMaxExternalQuadrilateral=getMaxExternalQuadrilateral,exports.getNewPointsAfterOffset=getNewPointsAfterOffset,exports.getPlainPointsByDiagonalPoints=getPlainPointsByDiagonalPoints,exports.getPlanePointsBasicInfo=getPlanePointsBasicInfo,exports.getPointListsByDirection=getPointListsByDirection,exports.getPointsByBottomLeftPoint=getPointsByBottomLeftPoint,exports.getPointsByBottomRightPoint=getPointsByBottomRightPoint,exports.getPointsByIntersection=getPointsByIntersection,exports.getToggleDirectionButtonOffset=getToggleDirectionButtonOffset,exports.isCuboidWithInLimits=isCuboidWithInLimits,exports.judgeCuboidLineIsRowOrColumn=judgeCuboidLineIsRowOrColumn;
|