@labelbee/lb-annotation 1.28.0-alpha.2 → 1.28.0-alpha.20

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.
Files changed (42) hide show
  1. package/dist/constant/tool.js +1 -1
  2. package/dist/core/pointCloud/annotation.js +1 -1
  3. package/dist/core/pointCloud/index.js +4 -4
  4. package/dist/core/pointCloud/matrix.js +1 -1
  5. package/dist/core/scheduler.js +1 -1
  6. package/dist/core/toolOperation/basicToolOperation.js +1 -1
  7. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -1
  8. package/dist/core/toolOperation/pointOperation.js +1 -1
  9. package/dist/core/toolOperation/polygonOperation.js +1 -1
  10. package/dist/core/toolOperation/rectOperation.js +2 -2
  11. package/dist/index.js +1 -1
  12. package/dist/types/constant/tool.d.ts +7 -0
  13. package/dist/types/core/pointCloud/annotation.d.ts +4 -3
  14. package/dist/types/core/pointCloud/index.d.ts +9 -5
  15. package/dist/types/core/scheduler.d.ts +1 -1
  16. package/dist/types/core/toolOperation/ScribbleTool.d.ts +1 -9
  17. package/dist/types/core/toolOperation/basicToolOperation.d.ts +8 -1
  18. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +19 -0
  19. package/dist/types/core/toolOperation/pointOperation.d.ts +1 -0
  20. package/dist/types/core/toolOperation/polygonOperation.d.ts +17 -13
  21. package/dist/types/core/toolOperation/rectOperation.d.ts +14 -4
  22. package/dist/types/utils/tool/AxisUtils.d.ts +3 -27
  23. package/dist/utils/tool/AxisUtils.js +1 -1
  24. package/dist/utils/tool/DrawUtils.js +1 -1
  25. package/dist/utils/tool/PolygonUtils.js +1 -1
  26. package/dist/utils/tool/polygonTool.js +1 -1
  27. package/es/constant/tool.js +1 -1
  28. package/es/core/pointCloud/annotation.js +1 -1
  29. package/es/core/pointCloud/index.js +4 -4
  30. package/es/core/pointCloud/matrix.js +1 -1
  31. package/es/core/scheduler.js +1 -1
  32. package/es/core/toolOperation/basicToolOperation.js +1 -1
  33. package/es/core/toolOperation/pointCloud2dOperation.js +1 -1
  34. package/es/core/toolOperation/pointOperation.js +1 -1
  35. package/es/core/toolOperation/polygonOperation.js +1 -1
  36. package/es/core/toolOperation/rectOperation.js +2 -2
  37. package/es/index.js +1 -1
  38. package/es/utils/tool/AxisUtils.js +1 -1
  39. package/es/utils/tool/DrawUtils.js +3 -3
  40. package/es/utils/tool/PolygonUtils.js +1 -1
  41. package/es/utils/tool/polygonTool.js +1 -1
  42. package/package.json +3 -3
@@ -14,10 +14,13 @@ declare class PointCloud2dOperation extends PolygonOperation {
14
14
  pointCloudConfig: IPointCloudConfig;
15
15
  private checkMode;
16
16
  private highlightAttributeList;
17
+ private rectToolMode?;
17
18
  constructor(props: IPolygonOperationProps & IPointCloud2dOperationProps);
18
19
  get getSelectedIDs(): string[];
19
20
  get enableDrag(): boolean;
20
21
  get visiblePolygonList(): IPolygonData[];
22
+ get lastStepByThreePointsMode(): boolean;
23
+ get lastStepByTwoPointsMode(): boolean;
21
24
  setHiddenAttributes(hideAttributes: string[]): void;
22
25
  setConfig(config: string): void;
23
26
  dragMouseDown(e: MouseEvent): void;
@@ -106,6 +109,22 @@ declare class PointCloud2dOperation extends PolygonOperation {
106
109
  setResultAndSelectedID(polygonList: IPolygonData[], selectedID: string): void;
107
110
  emitUpdatePolygonByDrag: () => void;
108
111
  setHighlightAttribute(attribute: string): void;
112
+ /**
113
+ * used in isTwoPointsMode;
114
+ * Effect:Determine the order of the four points, because the orientation is drawn along the line between the starting point and the first point;
115
+ * Orientation Logic: to the first point, adjacent to the two sides take one for orientation, such as side 1, Side 2, if side 1 clockwise rotation 90 degrees can get side 2, then take side 1 for orientation;
116
+ */
117
+ private createRectByTwoPointsMode;
118
+ protected addPointInDrawingHook(coordinateWithOrigin: ICoordinate): {
119
+ continue: boolean;
120
+ };
121
+ protected renderPolygonHook(polygon: IPolygonPoint[]): {
122
+ continue: boolean;
123
+ };
124
+ protected getPointListByRectDrawing(coordinate: ICoordinate, drawingPointList: IPolygonPoint[]): {
125
+ continue: boolean;
126
+ value: ICoordinate[] | undefined;
127
+ };
109
128
  }
110
129
  export default PointCloud2dOperation;
111
130
  export { IPointCloud2dOperationProps };
@@ -78,6 +78,7 @@ declare class PointOperation extends BasicToolOperation {
78
78
  onMouseDown(e: MouseEvent): true | undefined;
79
79
  onMouseMove(e: MouseEvent): undefined;
80
80
  onMouseUp(e: MouseEvent): true | undefined;
81
+ setPointValidAndRender(id?: string): void;
81
82
  onDragMove(e: MouseEvent): void;
82
83
  onKeyDown(e: KeyboardEvent): void;
83
84
  isMinDistance: (coord: ICoordinate) => boolean;
@@ -4,6 +4,10 @@ import { IPolygonConfig, IPolygonData, IPolygonPoint } from '../../types/tool/po
4
4
  import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
5
5
  import TextAttributeClass from './textAttributeClass';
6
6
  import Selection from './Selection';
7
+ interface IHookResult<T> {
8
+ continue: boolean;
9
+ value?: T;
10
+ }
7
11
  export interface IPolygonOperationProps extends IBasicToolOperationProps {
8
12
  }
9
13
  declare class PolygonOperation extends BasicToolOperation {
@@ -32,6 +36,7 @@ declare class PolygonOperation extends BasicToolOperation {
32
36
  _textAttributeInstance?: TextAttributeClass;
33
37
  forbidAddNewPolygonFuc?: (e: MouseEvent) => boolean;
34
38
  selection: Selection;
39
+ private attrChangeTrigger;
35
40
  constructor(props: IPolygonOperationProps);
36
41
  get selectedIDs(): string[];
37
42
  get selectedID(): string | undefined;
@@ -45,15 +50,7 @@ declare class PolygonOperation extends BasicToolOperation {
45
50
  get enableDrag(): boolean;
46
51
  get visiblePolygonList(): IPolygonData[];
47
52
  get polygonListUnderZoom(): {
48
- pointList: ({
49
- x: number;
50
- y: number;
51
- specialPoint?: boolean | undefined;
52
- specialEdge?: boolean | undefined;
53
- } | {
54
- x: number;
55
- y: number;
56
- })[];
53
+ pointList: IPoint[];
57
54
  sourceID: string;
58
55
  id: string;
59
56
  valid: boolean;
@@ -83,7 +80,7 @@ declare class PolygonOperation extends BasicToolOperation {
83
80
  * @param polygonList
84
81
  */
85
82
  setResultAndSelectedID(polygonList: IPolygonData[], selectedID: string): void;
86
- setResult(polygonList: IPolygonData[]): void;
83
+ setResult(polygonList: IPolygonData[], isDeleteSelectedID?: boolean): void;
87
84
  /**
88
85
  * 外层 sidabr 调用
89
86
  * @param v
@@ -108,10 +105,11 @@ declare class PolygonOperation extends BasicToolOperation {
108
105
  /**
109
106
  * 清楚所有的中间状态
110
107
  */
111
- clearActiveStatus(): void;
108
+ clearActiveStatus(isDeleteSelectedID?: boolean): void;
112
109
  clearDrawingStatus(): void;
113
110
  setPolygonList(polygonList: IPolygonData[]): void;
114
111
  setSelectedID(newID?: string, isAppend?: boolean): void;
112
+ setAttrChangeTrigger(attrChangeTrigger?: number): void;
115
113
  setDefaultAttribute(defaultAttribute?: string): void;
116
114
  setStyle(toolStyle: any): void;
117
115
  /**
@@ -178,6 +176,9 @@ declare class PolygonOperation extends BasicToolOperation {
178
176
  y: number;
179
177
  };
180
178
  dragPolygon(e: MouseEvent, selectedPolygon: IPolygonData): IPolygonPoint[] | undefined;
179
+ private lastMouseMoveTime;
180
+ private mouseMoveThrottle;
181
+ private determineTrigger;
181
182
  onMouseMove(e: MouseEvent): void;
182
183
  /**
183
184
  * Emit updateList for views update
@@ -207,13 +208,16 @@ declare class PolygonOperation extends BasicToolOperation {
207
208
  renderSelectedPolygons(): void;
208
209
  renderSelectedPolygon(polygon: IPolygonData): void;
209
210
  renderHoverPolygon(): void;
210
- renderPolygon(): void;
211
- render(): void;
211
+ renderPolygon(trigger?: string): void;
212
+ render(trigger?: string): void;
212
213
  renderCursorLine(lineColor: string): void;
213
214
  /** 撤销 */
214
215
  undo(): void;
215
216
  /** 重做 */
216
217
  redo(): void;
217
218
  deleteSelectedID(): void;
219
+ protected addPointInDrawingHook(..._args: unknown[]): IHookResult<unknown>;
220
+ protected renderPolygonHook(..._args: unknown[]): IHookResult<unknown>;
221
+ protected getPointListByRectDrawing(..._args: unknown[]): IHookResult<unknown>;
218
222
  }
219
223
  export default PolygonOperation;
@@ -137,13 +137,22 @@ declare class RectOperation extends BasicToolOperation {
137
137
  */
138
138
  onDragMoveAll(offset: ICoordinate): void;
139
139
  onDragMove(coordinate: ICoordinate): void;
140
- onMouseMove(e: MouseEvent): undefined;
140
+ private lastMouseMoveTime;
141
+ private mouseMoveThrottle;
142
+ onMouseMove(e: MouseEvent): void;
141
143
  setHighlightVisible(highlightVisible: boolean): void;
142
144
  setAttributeLockList(attributeLockList: string[]): void;
143
145
  setBasicResult(basicResult: any): void;
144
- setRectValidAndRender(id: string): void;
146
+ setRectValidAndRender(id?: string): void;
145
147
  setDefaultSubAttribute: () => void;
146
148
  createNewDrawingRect(e: MouseEvent, basicSourceID: string): void;
149
+ checkSize({ width, height, minWidth, minHeight, isAttributeConfig, }: {
150
+ width: number;
151
+ height: number;
152
+ minWidth: number;
153
+ minHeight: number;
154
+ isAttributeConfig?: boolean;
155
+ }): boolean;
147
156
  /**
148
157
  * 将绘制中的框体添加进 rectList 中
149
158
  * @returns
@@ -204,8 +213,9 @@ declare class RectOperation extends BasicToolOperation {
204
213
  /**
205
214
  * 渲染矩形框体
206
215
  */
207
- renderRect(): void;
208
- render(): void;
216
+ renderRect(trigger?: string): void;
217
+ render(trigger?: string): void;
218
+ renderCursorLine(lineColor: string): void;
209
219
  setDefaultAttribute(defaultAttribute?: string): void;
210
220
  setValid(valid: boolean): void;
211
221
  private clearDrawingStatus;
@@ -47,15 +47,7 @@ export default class AxisUtils {
47
47
  * @param currentPos
48
48
  * @returns
49
49
  */
50
- static changePointByZoom(point: IPoint | IPolygonPoint, zoom: number, currentPos?: ICoordinate): {
51
- x: number;
52
- y: number;
53
- specialPoint?: boolean | undefined;
54
- specialEdge?: boolean | undefined;
55
- } | {
56
- x: number;
57
- y: number;
58
- };
50
+ static changePointByZoom(point: IPoint | IPolygonPoint, zoom: number, currentPos?: ICoordinate): IPoint;
59
51
  /**
60
52
  * 计算点集在 zoom 和 currentPos 的转换
61
53
  * @param pointList
@@ -63,15 +55,7 @@ export default class AxisUtils {
63
55
  * @param currentPos
64
56
  * @returns
65
57
  */
66
- static changePointListByZoom(pointList: IPoint[] | IPolygonPoint[], zoom: number, currentPos?: ICoordinate): ({
67
- x: number;
68
- y: number;
69
- specialPoint?: boolean | undefined;
70
- specialEdge?: boolean | undefined;
71
- } | {
72
- x: number;
73
- y: number;
74
- })[];
58
+ static changePointListByZoom(pointList: IPoint[] | IPolygonPoint[], zoom: number, currentPos?: ICoordinate): IPoint[];
75
59
  static changePlanePointByZoom(planePoints: IPlanePoints, zoom: number, currentPos?: ICoordinate): IPlanePoints;
76
60
  static changeCuboidByZoom(cuboid: ICuboid | IDrawingCuboid, zoom: number, currentPos?: ICoordinate): ICuboid | IDrawingCuboid;
77
61
  static transformPlain2PointList({ tl, tr, br, bl }: IPlanePoints): any[];
@@ -140,15 +124,7 @@ export default class AxisUtils {
140
124
  zoom: number;
141
125
  }>): {
142
126
  type: string;
143
- points: ({
144
- x: number;
145
- y: number;
146
- specialPoint?: boolean | undefined;
147
- specialEdge?: boolean | undefined;
148
- } | {
149
- x: number;
150
- y: number;
151
- })[];
127
+ points: IPoint[];
152
128
  originCuboid: ICuboid;
153
129
  positions: import("@/types/tool/cuboid").ICuboidPosition[];
154
130
  }[] | undefined;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return e===1&&i.x===0&&i.y===0?t:__spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
@@ -1,3 +1,3 @@
1
1
  "use strict";var rgba=require("color-rgba"),lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),PolygonUtils=require("./PolygonUtils.js"),UnitUtils=require("./UnitUtils.js"),AxisUtils=require("./AxisUtils.js"),CuboidUtils=require("./CuboidUtils.js"),AttributeUtils=require("./AttributeUtils.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var rgba__default=_interopDefaultLegacy(rgba),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,i)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,__spreadValues=(r,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(r,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(r,i,t[i]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));const DEFAULT_ZOOM=1,DEFAULT_CURRENT_POS={x:0,y:0},DEFAULT_ROTATE=0,DEFAULT_COLOR="",HIGHLIGHT_ICON_SVG_PATHS=[{d:"M0.423514 10.1595C-0.362666 7.22543 1.37854 4.20957 4.3126 3.42339C7.24666 2.63721 10.2625 4.37842 11.0487 7.31248L49.8716 152.201C50.6577 155.135 48.9165 158.151 45.9825 158.937C43.0484 159.724 40.0325 157.982 39.2464 155.048L0.423514 10.1595Z"},{d:"M14.0774 9.47294C28.5 -16.5001 91.5 25.5001 113.138 0.529419L131.773 70.076C112 96.9999 50.5 54 32.7124 79.0196L14.0774 9.47294Z"}],_DrawUtils=class{static drawLine(r,t,i,e={}){const o=r.getContext("2d"),{color:s=DEFAULT_COLOR,thickness:l=1,lineCap:c="round",lineDash:n}=e;o.save(),o.strokeStyle=s,o.lineWidth=l,o.lineCap=c,n&&o.setLineDash(n),o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(i.x+1,i.y+1),o.stroke(),o.restore()}static drawRect(r,t,i={}){const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",hiddenText:c=!1,lineDash:n}=i;if(e.save(),e.strokeStyle=o,e.lineWidth=s,e.lineCap=l,Array.isArray(n)&&e.setLineDash(n),e.fillStyle=o,e.strokeRect(t.x,t.y,t.width,t.height),c===!1){let a="";if(t.attribute&&(a=`${a} ${t.attribute}`),this.drawText(r,{x:t.x,y:t.y-5},a),t.textAttribute){const h=`${~~t.width} * ${~~t.height}`.length*7,u=0,y=Math.max(20,t.width-h);this.drawText(r,{x:t.x,y:t.y+t.height+20+u},t.textAttribute,{textMaxWidth:y})}}e.restore()}static drawRectWithFill(r,t,i={}){const e=r.getContext("2d"),{color:o=DEFAULT_COLOR}=i;e.save(),e.fillStyle=o,e.fillRect(t.x,t.y,t.width,t.height),e.restore()}static drawTagByDom(r,t,i){const e=r;if(!((t==null?void 0:t.length)>0))return;const o=document.createElement("div");return o.innerHTML=t,o.setAttribute("id",i),e==null||e.appendChild(o),o}static drawTag(r,t){var i;const e=r==null?void 0:r.parentNode,o=window.self.document.getElementById("tagToolTag");if(o&&e&&e.contains(o)&&(e==null||e.removeChild(o)),!((t==null?void 0:t.length)>0))return;const s=document.createElement("div");return s.innerHTML=(i=t.reduce((l,c)=>`${l}${c.keyName}: ${c.value.join(" \u3001 ")}
2
- `,""))!=null?i:"",s.setAttribute("id","tagToolTag"),e==null||e.appendChild(s),s}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",lineType:c=tool.ELineTypes.Line,lineDash:n,hoverEdgeIndex:a}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=s,e.lineCap=l,Array.isArray(n)?e.setLineDash(n):e.setLineDash([])})(),c===tool.ELineTypes.Curve?(a!==void 0&&a>-1&&t.push(t[0]),t=PolygonUtils.createSmoothCurvePointsFromPointList([...t],tool.SEGMENT_NUMBER),a!==void 0&&a>-1&&(t=t.slice((tool.SEGMENT_NUMBER+1)*a,(tool.SEGMENT_NUMBER+1)*(a+1)))):a!==void 0&&a>-1&&(t=[...t,t[0]],t=t.slice(a,a+2));const h=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let f=0;f<t.length-1;f++)t[f].specialEdge&&h.push({i1:f,i2:f+1}),e.lineTo(t[f+1].x,t[f+1].y);e.stroke(),e.save(),e.lineWidth=s*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),h.forEach(f=>{const g=t[f.i1],w=t[f.i2];e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(w.x,w.y),e.stroke()}),e.restore();const u=4,y=2;return t.forEach(f=>{f.specialPoint&&(this.drawSpecialPoint(r,f,u+y,o),this.drawSpecialPoint(r,f,u,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:s=0,endAngleDeg:l=360,thickness:c=1,color:n=DEFAULT_COLOR,fill:a=DEFAULT_COLOR}=e,d=UnitUtils.deg2rad(s),h=UnitUtils.deg2rad(l);o.save(),o.beginPath(),o.strokeStyle=n,o.fillStyle=a,o.lineWidth=c,o.arc(t.x,t.y,i,d,h,!1),o.stroke(),a&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:s=DEFAULT_COLOR}=e;o.save();const l=UnitUtils.deg2rad(0),c=UnitUtils.deg2rad(360);o.fillStyle=s,o.beginPath(),o.arc(t.x,t.y,i,l,c,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:s,y:l}=t;o.save(),o.beginPath(),o.fillStyle=e;const c=i*1.5,n=c*Math.sqrt(3)/2,a=c/2;o.moveTo(s,l-c),o.lineTo(s-n,l+a),o.lineTo(s+n,l+a),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=tool.ELineTypes.Line}=i;return e===!0&&(t=[...t,t[0]]),o===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,__spreadProps(__spreadValues({},i),{lineType:tool.ELineTypes.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,lineType:s=tool.ELineTypes.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),s===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t,t[0]]));const[l,...c]=t;return e.moveTo(l.x,l.y),c.forEach(n=>{e.lineTo(n.x,n.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:s,lineCap:l,isClose:c,lineType:n}=i,a=this.drawPolygon(r,t,{color:e,thickness:s,lineCap:l,isClose:c,lineType:n});return this.drawPolygonWithFill(r,t,{color:o,lineType:n}),a}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygon(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygonWithFillAndLine(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:s=DEFAULT_COLOR,font:l=tool.DEFAULT_FONT,shadowColor:c="",shadowBlur:n=0,shadowOffsetX:a=0,shadowOffsetY:d=0,textMaxWidth:h=164,offsetX:u=0,offsetY:y=0,textAlign:f="start",lineHeight:g}=e;o.save(),o.textAlign=f,o.fillStyle=s!=null?s:"white",o.font=l,o.shadowColor=c,o.shadowOffsetX=a,o.shadowOffsetY=d,o.shadowBlur=n,this.wrapText(r,`${i}`,t.x+u,t.y+y,h,g),o.restore()}static wrapText(r,t,i,e,o,s){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const l=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof s=="undefined"&&(s=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const c=t.split(`
2
+ `,""))!=null?i:"",s.setAttribute("id","tagToolTag"),e==null||e.appendChild(s),s}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",lineType:c=tool.ELineTypes.Line,lineDash:n,hoverEdgeIndex:a}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=s,e.lineCap=l,Array.isArray(n)?e.setLineDash(n):e.setLineDash([])})(),c===tool.ELineTypes.Curve?(a!==void 0&&a>-1&&t.push(t[0]),t=PolygonUtils.createSmoothCurvePointsFromPointList([...t],tool.SEGMENT_NUMBER),a!==void 0&&a>-1&&(t=t.slice((tool.SEGMENT_NUMBER+1)*a,(tool.SEGMENT_NUMBER+1)*(a+1)))):a!==void 0&&a>-1&&(t=[...t,t[0]],t=t.slice(a,a+2));const h=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let f=0;f<t.length-1;f++)t[f].specialEdge&&h.push({i1:f,i2:f+1}),e.lineTo(t[f+1].x,t[f+1].y);e.stroke(),e.save(),e.lineWidth=s*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),h.forEach(f=>{const g=t[f.i1],w=t[f.i2];e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(w.x,w.y),e.stroke()}),e.restore();const u=4,y=2;return t.forEach(f=>{f.specialPoint&&(this.drawSpecialPoint(r,f,u+y,o),this.drawSpecialPoint(r,f,u,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:s=0,endAngleDeg:l=360,thickness:c=1,color:n=DEFAULT_COLOR,fill:a=DEFAULT_COLOR}=e,d=UnitUtils.deg2rad(s),h=UnitUtils.deg2rad(l);o.save(),o.beginPath(),o.strokeStyle=n,o.fillStyle=a,o.lineWidth=c,o.arc(t.x,t.y,i,d,h,!1),o.stroke(),a&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:s=DEFAULT_COLOR}=e;o.save();const l=UnitUtils.deg2rad(0),c=UnitUtils.deg2rad(360);o.fillStyle=s,o.beginPath(),o.arc(t.x,t.y,i,l,c,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:s,y:l}=t;o.save(),o.beginPath(),o.fillStyle=e;const c=i*1.5,n=c*Math.sqrt(3)/2,a=c/2;o.moveTo(s,l-c),o.lineTo(s-n,l+a),o.lineTo(s+n,l+a),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=tool.ELineTypes.Line}=i;return e===!0&&(t=[...t,t[0]]),o===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,__spreadProps(__spreadValues({},i),{lineType:tool.ELineTypes.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,lineType:s=tool.ELineTypes.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),s===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t,t[0]]));const[l,...c]=t;return e.moveTo(l.x,l.y),c.forEach(n=>{e.lineTo(n.x,n.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:s,lineCap:l,isClose:c,lineType:n}=i,a=this.drawPolygon(r,t,{color:e,thickness:s,lineCap:l,isClose:c,lineType:n});return this.drawPolygonWithFill(r,t,{color:o,lineType:n}),a}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygon(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,s=this.drawPolygonWithFillAndLine(r,t,i);return s.forEach(l=>{this.drawCircleWithFill(r,l,4,{color:o}),this.drawCircleWithFill(r,l,3,{color:e})}),s}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:s=DEFAULT_COLOR,font:l=tool.DEFAULT_FONT,shadowColor:c="",shadowBlur:n=0,shadowOffsetX:a=0,shadowOffsetY:d=0,textMaxWidth:h=164,offsetX:u=0,offsetY:y=0,textAlign:f="start",lineHeight:g}=e;!o||(o.save(),Object.assign(o,{textAlign:f,fillStyle:s!=null?s:"white",font:l,shadowColor:c,shadowOffsetX:a,shadowOffsetY:d,shadowBlur:n}),this.wrapText(r,i,t.x+u,t.y+y,h,g),o.restore())}static wrapText(r,t,i,e,o,s){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const l=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof s=="undefined"&&(s=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const c=t.split(`
3
3
  `);for(let n=0;n<c.length;n++){const a=c[n].split("");let d="";for(let h=0;h<a.length;h++){const u=d+a[h],f=l.measureText(u).width;o||(o=300),f>o&&h>0?(l.fillText(d,i,e),d=a[h],e+=s):d=u}l.fillText(d,i,e),e+=s}}static drawArrow(r,t,i,e={}){const{color:o=DEFAULT_COLOR,thickness:s=1,lineCap:l="round",theta:c=30,headLen:n=10}=e,a=Math.atan2(t.y-i.y,t.x-i.x)*180/Math.PI,d=(a+c)*Math.PI/180,h=(a-c)*Math.PI/180,u=n*Math.cos(d),y=n*Math.sin(d),f=n*Math.cos(h),g=n*Math.sin(h);r.save(),r.strokeStyle=o,r.lineWidth=s,r.lineCap=l,r.beginPath(),r.moveTo(i.x+u,i.y+y),r.lineTo(i.x,i.y),r.lineTo(i.x+f,i.y+g),r.stroke(),r.restore()}static drawArrowByCanvas(r,t,i,e={}){const o=r.getContext("2d");this.drawArrow(o,t,i,e)}static drawCuboid(r,t,i={}){const{backPoints:e,direction:o,frontPoints:s}=t,{strokeColor:l,thickness:c,fillColor:n}=i,a={color:l,thickness:c};if(e){const h=AxisUtils.default.transformPlain2PointList(e);_DrawUtils.drawPolygon(r,h,__spreadProps(__spreadValues({},a),{isClose:!0}));const u=CuboidUtils.getCuboidAllSideLine(t);u==null||u.forEach(y=>{_DrawUtils.drawLine(r,y.p1,y.p2,__spreadValues({},a))})}const d=AxisUtils.default.transformPlain2PointList(s);if(o&&e&&s){const h=CuboidUtils.getPointListsByDirection({direction:o,frontPoints:s,backPoints:e});h&&_DrawUtils.drawPolygonWithFill(r,h,{color:n})}_DrawUtils.drawPolygon(r,d,__spreadProps(__spreadValues({},a),{isClose:!0}))}static drawCuboidWithText(r,t,i,e){const{strokeColor:o}=i,s=o,{config:l,hiddenText:c,selectedID:n,headerText:a,bottomText:d}=e,{backPoints:h,frontPoints:u,textAttribute:y}=t,f=u.br.x-u.bl.x;_DrawUtils.drawCuboid(r,t,i);let g="";(l==null?void 0:l.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(g=`${t.order}`),t.attribute&&(g=`${g} ${AttributeUtils.default.getAttributeShowText(t.attribute,l==null?void 0:l.attributeList)}`),!c&&h&&g&&_DrawUtils.drawText(r,{x:h.tl.x,y:h.tl.y-5},a!=null?a:g,{color:o,textMaxWidth:300});const w=CuboidUtils.getCuboidTextAttributeOffset({cuboid:t,currentPos:{x:0,y:0},zoom:1,topOffset:16,leftOffset:0});if(!c&&y&&t.id!==n){const x=Math.max(20,f*.8);_DrawUtils.drawText(r,{x:w.left,y:w.top},d!=null?d:y,{color:s,textMaxWidth:x})}}static drawPixel({canvas:r,points:t,size:i,defaultRGBA:e,pixelSize:o=13}){const s=r.getContext("2d"),{width:l,height:c}=i,n=s.getImageData(0,0,l,c),[a,d,h,u]=rgba__default.default(e!=null?e:lbUtils.NULL_COLOR),y=g=>{n.data[g]=a,n.data[g+1]=d,n.data[g+2]=h,n.data[g+3]=Math.floor(255*u)},f=lbUtils.MathUtils.generateCoordinates(o);return t.forEach(g=>{for(const[w,x]of f){const C=(g.y+x)*(n.width*4)+(g.x+w)*4;y(C)}}),s.putImageData(n,0,0),{canvas:r}}static drawHighlightFlag(r){const{canvas:t,position:i,color:e,scale:o=.1}=r,s=t.getContext("2d");if(!!s)for(const l of HIGHLIGHT_ICON_SVG_PATHS){s.beginPath();const c=l.d.split(/(?=[CLMZclmz])/);for(const n of c){const d=n.slice(1).split(" ").map(Number).map((h,u)=>u%2==0?h*o+i.x:h*o+i.y);switch(n[0]){case"M":s.moveTo(d[0],d[1]);break;case"C":s.bezierCurveTo(d[0],d[1],d[2],d[3],d[4],d[5]);break;case"L":s.lineTo(d[0],d[1]);break;case"Z":s.closePath();break}}s.fillStyle=e,s.fill()}}};let DrawUtils=_DrawUtils;DrawUtils.drawImg=(r,t,i={})=>{const e=r.getContext("2d"),{zoom:o=DEFAULT_ZOOM,currentPos:s=DEFAULT_CURRENT_POS,rotate:l=DEFAULT_ROTATE,imgAttribute:c}=i;switch(e.save(),l){case 0:e.translate(s.x,s.y);break;case 90:e.translate(s.x+t.height*o,s.y),e.rotate(90*Math.PI/180);break;case 180:e.translate(s.x+t.width*o,s.y+t.height*o),e.rotate(Math.PI);break;case 270:e.translate(s.x,s.y+t.width*o),e.rotate(270*Math.PI/180);break;default:e.translate(s.x,s.y);break}if(c){const{contrast:n,saturation:a,brightness:d}=c;e.filter=`saturate(${a+100}%) contrast(${n+100}%) brightness(${d+100}%)`}e.drawImage(t,0,0,t.width*o,t.height*o),e.restore()},module.exports=DrawUtils;
@@ -1 +1 @@
1
- "use strict";var turf=require("@turf/turf"),annotation=require("../../constant/annotation.js"),CommonToolUtils=require("./CommonToolUtils.js"),tool=require("../../constant/tool.js"),AxisUtils=require("./AxisUtils.js"),MathUtils=require("../MathUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(p,e,t)=>e in p?__defProp(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,__spreadValues=(p,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(p,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(p,t,e[t]);return p};class PolygonUtils{static getHoverPolygonID(e,t,n=3,i=tool.ELineTypes.Line){let o="",r=Infinity;const l=AxisUtils.default.axisArea(e,n);return t.forEach(s=>{s.pointList&&l.forEach(c=>{const u=this.calcPolygonSize(s.pointList);this.isInPolygon(c,s.pointList,i)&&u<r&&(o=s.id,r=u)})}),o}static calcPolygonSize(e=[]){if((e==null?void 0:e.length)<=2)return 0;const t=e.length,n=e.reduce((i,o,r,l)=>{const s=l[(r+1)%t];return i+o.x*s.y-s.x*o.y},0);return Math.abs(n)/2}static isInPolygon(e,t,n=tool.ELineTypes.Line){return t=[...t],n===tool.ELineTypes.Curve&&(t=this.createSmoothCurvePoints(t.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!0,20)),this.isPointInOrOnPolygon(e,t)}static isPointInOrOnPolygon(e,t,n=1e-9){const{x:i,y:o}=e;let r=!1;for(let l=0,s=t.length-1;l<t.length;s=l++){const{x:c,y:u}=t[l],{x:h,y:d}=t[s],y=i<=Math.max(c,h)&&i>=Math.min(c,h)&&o<=Math.max(u,d)&&o>=Math.min(u,d),P=(o-u)*(h-c)-(i-c)*(d-u);if(y&&Math.abs(P)<n)return!0;u>o!=d>o&&i<(h-c)*(o-u)/(d-u)+c&&(r=!r)}return r}static createSmoothCurvePointsFromPointList(e,t=tool.SEGMENT_NUMBER){return this.createSmoothCurvePoints(e.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!1,t).map((i,o)=>{var r;const l=o/(tool.SEGMENT_NUMBER+1),s=Math.floor(l),c=(r=e[s])!=null?r:{};return __spreadValues(s===l?__spreadValues({},c):{specialEdge:c.specialEdge},i)})}static createSmoothCurvePoints(e,t=.5,n=!1,i=tool.SEGMENT_NUMBER){if(e.length<4)return e;const o=[],r=e.slice(0);let l,s,c,u,h,d,y,P,x,m,a,g,f;for(n?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(c=(r[f+2]-r[f-2])*t,u=(r[f+4]-r[f-0])*t,h=(r[f+3]-r[f-1])*t,d=(r[f+5]-r[f+1])*t,g=0;g<=i;g++)a=g/i,y=2*Math.pow(a,3)-3*Math.pow(a,2)+1,P=-(2*Math.pow(a,3))+3*Math.pow(a,2),x=Math.pow(a,3)-2*Math.pow(a,2)+a,m=Math.pow(a,3)-Math.pow(a,2),l=y*r[f]+P*r[f+2]+x*c+m*u,s=y*r[f+1]+P*r[f+3]+x*h+m*d,o.push(l),o.push(s);const v=[];for(let E=0;E<o.length-1;E+=2)v.push({x:o[E],y:o[E+1]});if(n)for(let E=0;E<i+1;E++){const L=v.shift();v.push(L)}return v}static getPolygonByID(e,t){return e.find(n=>n.id===t)}static getPolygonByIDs(e,t){return t&&(t==null?void 0:t.length)>0?e.filter(n=>t.includes(n.id)):[]}static getHoverEdgeIndex(e,t,n=tool.ELineTypes.Line,i=5){let o=[...t];n===tool.ELineTypes.Curve?o=this.createSmoothCurvePoints(t.reduce((s,c)=>[...s,c.x,c.y],[]),.5,!0,tool.SEGMENT_NUMBER):n===tool.ELineTypes.Line&&o.push(o[0]);let r=-1,l=i;for(let s=0;s<o.length-1;s++){const{length:c}=MathUtils.default.getFootOfPerpendicular(e,o[s],o[s+1],!0);c<l&&(r=s,l=c)}return r===-1?-1:n===tool.ELineTypes.Curve?Math.floor(r/tool.SEGMENT_NUMBER):r}static getClosestPoint(e,t,n=tool.ELineTypes.Line,i=3,o){var r;let l=!1;const s=(r=o==null?void 0:o.isClose)!=null?r:!0;let c="",u=-1,h=Infinity,d=e;const y=20;let P=!1;return t.forEach(x=>{if(!P&&!!x.pointList)switch(n){case tool.ELineTypes.Line:CommonToolUtils.findAllLine(x.pointList,s).forEach((a,g)=>{if(P)return;let{length:f,footPoint:v}=MathUtils.default.getFootOfPerpendicular(e,a.point1,a.point2);const E=MathUtils.default.getLineLength(a.point1,e),L=MathUtils.default.getLineLength(a.point2,e);E<i*2&&(v=a.point1,f=E,P=!0),L<i*2&&(v=a.point2,f=L,P=!0),f<h&&f<i&&(c=x.id,u=g,h=f,d=v,l=!0)});break;case tool.ELineTypes.Curve:{const m=this.createSmoothCurvePoints(x.pointList.reduce((a,g)=>[...a,g.x,g.y],[]),.5,s,y);for(let a=0;a<m.length-1;a++){const{length:g,footPoint:f}=MathUtils.default.getFootOfPerpendicular(e,m[a],m[a+1]);g<h&&g<i&&(c=x.id,u=Math.floor(a/(y+1)),h=g,d=f,l=!0)}}break}}),{dropFoot:d,closestEdgeIndex:u,closestPolygonID:c,hasClosed:l}}static isPointListInPolygon(e,t,n=tool.ELineTypes.Line){return e.every(i=>this.isInPolygon(i,t,n))}static isPointListOutSidePolygon(e,t,n=tool.ELineTypes.Line){return e.some(i=>!this.isInPolygon(i,t,n))}static getPolygonArea(e){let t=0;for(let n=0,i=e.length;n<i;n++){const o=e[n].x,r=e[n===e.length-1?0:n+1].y,l=e[n===e.length-1?0:n+1].x,s=e[n].y;t+=o*r*.5,t-=l*s*.5}return Math.abs(t)}static updatePolygonByRotate(e,t=1,n){let i=1;return e===annotation.ERotateDirection.Anticlockwise&&(i=-1),i*=t,MathUtils.default.rotateRectPointList(i,n)}static deletePolygonLastPoint(e,t,n,i){return n===i.length-1?e:[...e,{x:t[0],y:t[1]}]}static concatBeginAndEnd(e){return e.length<1?e:[...e,e[0]]}static segmentPolygonByPolygon(e,t){var n,i;try{let o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.map(l=>[l.x,l.y]))]]);return t.forEach(l=>{const s=turf.polygon([[...PolygonUtils.concatBeginAndEnd(l.pointList.map(u=>[u.x,u.y]))]]),c=turf.difference(o,s);c&&(o=c)}),((i=(n=o==null?void 0:o.geometry)==null?void 0:n.coordinates.map(l=>{var s;return((s=o==null?void 0:o.geometry)==null?void 0:s.type)==="MultiPolygon"?l[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):l.reduce(PolygonUtils.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((l,s)=>{const c=s.length,u=s.filter((h,d)=>{const y=(d+1)%c;return!AxisUtils.default.getIsInScope(h,s[y],1)});return u.length<3?l:[...l,u]},[])}catch(o){console.error(o)}}static getPolygonPointList(e,t){const n=t.find(i=>i.id===e);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(e,t){return t.findIndex(n=>PolygonUtils.isPointListInPolygon(e,n.pointList))}static clipPolygonFromWrapPolygon(e,t){const n=PolygonUtils.isPolygonClosewise(t),i=PolygonUtils.isPolygonClosewise(e),o=PolygonUtils.getClosePointDistanceFromPolygon(e[0],t),r=t[o];let l=[...t.slice(0,o),r,...e,e[0],...t.slice(o,t.length)];return n===i&&(l=[...t.slice(0,o),r,e[0],...e.reverse(),...t.slice(o,t.length)]),l}static isPolygonClosewise(e){const t=e.length;let n,i,o,r=0,l;if(t<3)return 0;for(n=0;n<t;n++)i=(n+1)%t,o=(n+2)%t,l=(e[i].x-e[n].x)*(e[o].y-e[i].y),l-=(e[i].y-e[n].y)*(e[o].x-e[i].x),l<0?r--:l>0&&r++;return r>0?1:r<0?-1:0}static getClosePointDistanceFromPolygon(e,t){let n=Number.MAX_SAFE_INTEGER,i=-1;return t.forEach((o,r)=>{const l=LineToolUtils.default.calcDistance(e,o);l<n&&(n=l,i=r)}),i}static combinePolygonWithPolygon(e,t){var n,i;try{const o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.pointList.map(u=>[u.x,u.y]))]]),r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(t.pointList.map(u=>[u.x,u.y]))]]),l=turf.union(o,r),s=[],c=e;if(((i=(n=l==null?void 0:l.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(t.id);const u=l==null?void 0:l.geometry.coordinates.map(h=>{var d;return((d=l==null?void 0:l.geometry)==null?void 0:d.type)==="MultiPolygon"?h[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):h.reduce(PolygonUtils.deletePolygonLastPoint,[])})[0];c.pointList=u}return{newPolygon:c,unionList:s}}catch(o){console.error(o)}}static composePointList(e,t){let n=0,i=0,o=Number.MAX_VALUE;return e.forEach((r,l)=>{t.forEach((s,c)=>{const u=LineToolUtils.default.calcDistance(r,s);u<o&&(n=l+1,i=c+1,o=u)})}),[...e.slice(0,n),...t.slice(i,t.length),...t.slice(0,i),...e.slice(n,e.length)]}static composeSegmentPolygonList(e){var t,n;const i=[];for(let o=0;o<e.length;o++)for(let r=0;r<e.length;r++){const l=(t=e[o])==null?void 0:t.pointList,s=(n=e[r])==null?void 0:n.pointList;o!==r&&l&&s&&PolygonUtils.isPointListInPolygon(s,l)&&(e[o].pointList=PolygonUtils.composePointList(l,s),i.unshift(r))}return i.forEach(o=>{e.splice(o,1)}),e}static computeConvexHull(e){e.sort((o,r)=>o.x!==r.x?o.x-r.x:o.y-r.y);const t=(o,r,l)=>(r.x-o.x)*(l.y-o.y)-(r.y-o.y)*(l.x-o.x),n=[];for(const o of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],o)<=0;)n.pop();n.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;i.length>=2&&t(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return i.pop(),n.pop(),n.concat(i)}static createConvexHullGroup(e){const t={};return e.forEach(n=>{n.type==="line"&&(t[n.annotation.id]||(t[n.annotation.id]={points:[],convexHull:[]}),t[n.annotation.id].points.push(...n.annotation.pointList))}),Object.keys(t).forEach(n=>{t[n].convexHull=this.computeConvexHull(t[n].points)}),t}}module.exports=PolygonUtils;
1
+ "use strict";var turf=require("@turf/turf"),annotation=require("../../constant/annotation.js"),CommonToolUtils=require("./CommonToolUtils.js"),tool=require("../../constant/tool.js"),AxisUtils=require("./AxisUtils.js"),MathUtils=require("../MathUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(p,e,t)=>e in p?__defProp(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,__spreadValues=(p,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(p,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(p,t,e[t]);return p};class PolygonUtils{static getHoverPolygonID(e,t,n=3,i=tool.ELineTypes.Line){let o="",r=Infinity;const l=AxisUtils.default.axisArea(e,n);return t.forEach(s=>{s.pointList&&l.forEach(c=>{if(this.isInPolygon(c,s.pointList,i)){const u=this.calcPolygonSize(s.pointList);u<r&&(o=s.id,r=u)}})}),o}static calcPolygonSize(e=[]){if((e==null?void 0:e.length)<=2)return 0;const t=e.length,n=e.reduce((i,o,r,l)=>{const s=l[(r+1)%t];return i+o.x*s.y-s.x*o.y},0);return Math.abs(n)/2}static isInPolygon(e,t,n=tool.ELineTypes.Line){return t=[...t],n===tool.ELineTypes.Curve&&(t=this.createSmoothCurvePoints(t.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!0,20)),this.isPointInOrOnPolygon(e,t)}static isPointInOrOnPolygon(e,t,n=1e-9){const{x:i,y:o}=e;let r=!1;for(let l=0,s=t.length-1;l<t.length;s=l++){const{x:c,y:u}=t[l],{x:h,y:d}=t[s],y=i<=Math.max(c,h)&&i>=Math.min(c,h)&&o<=Math.max(u,d)&&o>=Math.min(u,d),P=(o-u)*(h-c)-(i-c)*(d-u);if(y&&Math.abs(P)<n)return!0;u>o!=d>o&&i<(h-c)*(o-u)/(d-u)+c&&(r=!r)}return r}static createSmoothCurvePointsFromPointList(e,t=tool.SEGMENT_NUMBER){return this.createSmoothCurvePoints(e.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!1,t).map((i,o)=>{var r;const l=o/(tool.SEGMENT_NUMBER+1),s=Math.floor(l),c=(r=e[s])!=null?r:{};return __spreadValues(s===l?__spreadValues({},c):{specialEdge:c.specialEdge},i)})}static createSmoothCurvePoints(e,t=.5,n=!1,i=tool.SEGMENT_NUMBER){if(e.length<4)return e;const o=[],r=e.slice(0);let l,s,c,u,h,d,y,P,x,m,a,g,f;for(n?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(c=(r[f+2]-r[f-2])*t,u=(r[f+4]-r[f-0])*t,h=(r[f+3]-r[f-1])*t,d=(r[f+5]-r[f+1])*t,g=0;g<=i;g++)a=g/i,y=2*Math.pow(a,3)-3*Math.pow(a,2)+1,P=-(2*Math.pow(a,3))+3*Math.pow(a,2),x=Math.pow(a,3)-2*Math.pow(a,2)+a,m=Math.pow(a,3)-Math.pow(a,2),l=y*r[f]+P*r[f+2]+x*c+m*u,s=y*r[f+1]+P*r[f+3]+x*h+m*d,o.push(l),o.push(s);const v=[];for(let E=0;E<o.length-1;E+=2)v.push({x:o[E],y:o[E+1]});if(n)for(let E=0;E<i+1;E++){const L=v.shift();v.push(L)}return v}static getPolygonByID(e,t){return e.find(n=>n.id===t)}static getPolygonByIDs(e,t){return t&&(t==null?void 0:t.length)>0?e.filter(n=>t.includes(n.id)):[]}static getHoverEdgeIndex(e,t,n=tool.ELineTypes.Line,i=5){let o=[...t];n===tool.ELineTypes.Curve?o=this.createSmoothCurvePoints(t.reduce((s,c)=>[...s,c.x,c.y],[]),.5,!0,tool.SEGMENT_NUMBER):n===tool.ELineTypes.Line&&o.push(o[0]);let r=-1,l=i;for(let s=0;s<o.length-1;s++){const{length:c}=MathUtils.default.getFootOfPerpendicular(e,o[s],o[s+1],!0);c<l&&(r=s,l=c)}return r===-1?-1:n===tool.ELineTypes.Curve?Math.floor(r/tool.SEGMENT_NUMBER):r}static getClosestPoint(e,t,n=tool.ELineTypes.Line,i=3,o){var r;let l=!1;const s=(r=o==null?void 0:o.isClose)!=null?r:!0;let c="",u=-1,h=Infinity,d=e;const y=20;let P=!1;return t.forEach(x=>{if(!P&&!!x.pointList)switch(n){case tool.ELineTypes.Line:CommonToolUtils.findAllLine(x.pointList,s).forEach((a,g)=>{if(P)return;let{length:f,footPoint:v}=MathUtils.default.getFootOfPerpendicular(e,a.point1,a.point2);const E=MathUtils.default.getLineLength(a.point1,e),L=MathUtils.default.getLineLength(a.point2,e);E<i*2&&(v=a.point1,f=E,P=!0),L<i*2&&(v=a.point2,f=L,P=!0),f<h&&f<i&&(c=x.id,u=g,h=f,d=v,l=!0)});break;case tool.ELineTypes.Curve:{const m=this.createSmoothCurvePoints(x.pointList.reduce((a,g)=>[...a,g.x,g.y],[]),.5,s,y);for(let a=0;a<m.length-1;a++){const{length:g,footPoint:f}=MathUtils.default.getFootOfPerpendicular(e,m[a],m[a+1]);g<h&&g<i&&(c=x.id,u=Math.floor(a/(y+1)),h=g,d=f,l=!0)}}break}}),{dropFoot:d,closestEdgeIndex:u,closestPolygonID:c,hasClosed:l}}static isPointListInPolygon(e,t,n=tool.ELineTypes.Line){return e.every(i=>this.isInPolygon(i,t,n))}static isPointListOutSidePolygon(e,t,n=tool.ELineTypes.Line){return e.some(i=>!this.isInPolygon(i,t,n))}static getPolygonArea(e){let t=0;for(let n=0,i=e.length;n<i;n++){const o=e[n].x,r=e[n===e.length-1?0:n+1].y,l=e[n===e.length-1?0:n+1].x,s=e[n].y;t+=o*r*.5,t-=l*s*.5}return Math.abs(t)}static updatePolygonByRotate(e,t=1,n){let i=1;return e===annotation.ERotateDirection.Anticlockwise&&(i=-1),i*=t,MathUtils.default.rotateRectPointList(i,n)}static deletePolygonLastPoint(e,t,n,i){return n===i.length-1?e:[...e,{x:t[0],y:t[1]}]}static concatBeginAndEnd(e){return e.length<1?e:[...e,e[0]]}static segmentPolygonByPolygon(e,t){var n,i;try{let o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.map(l=>[l.x,l.y]))]]);return t.forEach(l=>{const s=turf.polygon([[...PolygonUtils.concatBeginAndEnd(l.pointList.map(u=>[u.x,u.y]))]]),c=turf.difference(o,s);c&&(o=c)}),((i=(n=o==null?void 0:o.geometry)==null?void 0:n.coordinates.map(l=>{var s;return((s=o==null?void 0:o.geometry)==null?void 0:s.type)==="MultiPolygon"?l[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):l.reduce(PolygonUtils.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((l,s)=>{const c=s.length,u=s.filter((h,d)=>{const y=(d+1)%c;return!AxisUtils.default.getIsInScope(h,s[y],1)});return u.length<3?l:[...l,u]},[])}catch(o){console.error(o)}}static getPolygonPointList(e,t){const n=t.find(i=>i.id===e);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(e,t){return t.findIndex(n=>PolygonUtils.isPointListInPolygon(e,n.pointList))}static clipPolygonFromWrapPolygon(e,t){const n=PolygonUtils.isPolygonClosewise(t),i=PolygonUtils.isPolygonClosewise(e),o=PolygonUtils.getClosePointDistanceFromPolygon(e[0],t),r=t[o];let l=[...t.slice(0,o),r,...e,e[0],...t.slice(o,t.length)];return n===i&&(l=[...t.slice(0,o),r,e[0],...e.reverse(),...t.slice(o,t.length)]),l}static isPolygonClosewise(e){const t=e.length;let n,i,o,r=0,l;if(t<3)return 0;for(n=0;n<t;n++)i=(n+1)%t,o=(n+2)%t,l=(e[i].x-e[n].x)*(e[o].y-e[i].y),l-=(e[i].y-e[n].y)*(e[o].x-e[i].x),l<0?r--:l>0&&r++;return r>0?1:r<0?-1:0}static getClosePointDistanceFromPolygon(e,t){let n=Number.MAX_SAFE_INTEGER,i=-1;return t.forEach((o,r)=>{const l=LineToolUtils.default.calcDistance(e,o);l<n&&(n=l,i=r)}),i}static combinePolygonWithPolygon(e,t){var n,i;try{const o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.pointList.map(u=>[u.x,u.y]))]]),r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(t.pointList.map(u=>[u.x,u.y]))]]),l=turf.union(o,r),s=[],c=e;if(((i=(n=l==null?void 0:l.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(t.id);const u=l==null?void 0:l.geometry.coordinates.map(h=>{var d;return((d=l==null?void 0:l.geometry)==null?void 0:d.type)==="MultiPolygon"?h[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):h.reduce(PolygonUtils.deletePolygonLastPoint,[])})[0];c.pointList=u}return{newPolygon:c,unionList:s}}catch(o){console.error(o)}}static composePointList(e,t){let n=0,i=0,o=Number.MAX_VALUE;return e.forEach((r,l)=>{t.forEach((s,c)=>{const u=LineToolUtils.default.calcDistance(r,s);u<o&&(n=l+1,i=c+1,o=u)})}),[...e.slice(0,n),...t.slice(i,t.length),...t.slice(0,i),...e.slice(n,e.length)]}static composeSegmentPolygonList(e){var t,n;const i=[];for(let o=0;o<e.length;o++)for(let r=0;r<e.length;r++){const l=(t=e[o])==null?void 0:t.pointList,s=(n=e[r])==null?void 0:n.pointList;o!==r&&l&&s&&PolygonUtils.isPointListInPolygon(s,l)&&(e[o].pointList=PolygonUtils.composePointList(l,s),i.unshift(r))}return i.forEach(o=>{e.splice(o,1)}),e}static computeConvexHull(e){e.sort((o,r)=>o.x!==r.x?o.x-r.x:o.y-r.y);const t=(o,r,l)=>(r.x-o.x)*(l.y-o.y)-(r.y-o.y)*(l.x-o.x),n=[];for(const o of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],o)<=0;)n.pop();n.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;i.length>=2&&t(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return i.pop(),n.pop(),n.concat(i)}static createConvexHullGroup(e){const t={};return e.forEach(n=>{n.type==="line"&&(t[n.annotation.id]||(t[n.annotation.id]={points:[],convexHull:[]}),t[n.annotation.id].points.push(...n.annotation.pointList))}),Object.keys(t).forEach(n=>{t[n].convexHull=this.computeConvexHull(t[n].points)}),t}}module.exports=PolygonUtils;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function createSmoothCurvePoints(e,t=.5,l=!1,s=16){if(e.length<4)return e;const f=[],r=e.slice(0);let a,o,x,y,p,m,_,v,w,P,h,c,u;for(l?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),u=2;u<r.length-4;u+=2)for(x=(r[u+2]-r[u-2])*t,y=(r[u+4]-r[u-0])*t,p=(r[u+3]-r[u-1])*t,m=(r[u+5]-r[u+1])*t,c=0;c<=s;c++)h=c/s,_=2*Math.pow(h,3)-3*Math.pow(h,2)+1,v=-(2*Math.pow(h,3))+3*Math.pow(h,2),w=Math.pow(h,3)-2*Math.pow(h,2)+h,P=Math.pow(h,3)-Math.pow(h,2),a=_*r[u]+v*r[u+2]+w*x+P*y,o=_*r[u+1]+v*r[u+3]+w*p+P*m,f.push(a),f.push(o);const i=[];for(let n=0;n<f.length-1;n+=2)i.push({x:f[n],y:f[n+1]});if(l)for(let n=0;n<s+1;n++){const M=i.shift();i.push(M)}return i}const createSmoothCurvePointsFromPointList=(e,t=16)=>createSmoothCurvePoints(e.reduce((l,s)=>[...l,s.x,s.y],[]),.5,!1,t);function isInPolygon(e,t,l=tool.ELineTypes.Line){let s=0,f,r,a,o;t=[...t],l===tool.ELineTypes.Curve&&(t=createSmoothCurvePoints(t.reduce((y,p)=>[...y,p.x,p.y],[]),.5,!0,tool.SEGMENT_NUMBER)),[a]=t;const x=t.length;for(f=1;f<=x;f++)o=t[f%x],e.x>Math.min(a.x,o.x)&&e.x<=Math.max(a.x,o.x)&&e.y<=Math.max(a.y,o.y)&&a.x!==o.x&&(r=(e.x-a.x)*(o.y-a.y)/(o.x-a.x)+a.y,(a.y===o.y||e.y<=r)&&s++),a=o;return s%2!=0}function getPolygonPointUnderZoom(e,t=1){return e.map(l=>__spreadProps(__spreadValues({},l),{x:l.x*t,y:l.y*t}))}exports.createSmoothCurvePoints=createSmoothCurvePoints,exports.createSmoothCurvePointsFromPointList=createSmoothCurvePointsFromPointList,exports.getPolygonPointUnderZoom=getPolygonPointUnderZoom,exports.isInPolygon=isInPolygon;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function createSmoothCurvePoints(e,t=.5,a=!1,h=16){if(e.length<4)return e;const l=[],r=e.slice(0);let m,_,M,c,u,o,i,p,y,x,n,v,f;for(a?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(M=(r[f+2]-r[f-2])*t,c=(r[f+4]-r[f-0])*t,u=(r[f+3]-r[f-1])*t,o=(r[f+5]-r[f+1])*t,v=0;v<=h;v++)n=v/h,i=2*Math.pow(n,3)-3*Math.pow(n,2)+1,p=-(2*Math.pow(n,3))+3*Math.pow(n,2),y=Math.pow(n,3)-2*Math.pow(n,2)+n,x=Math.pow(n,3)-Math.pow(n,2),m=i*r[f]+p*r[f+2]+y*M+x*c,_=i*r[f+1]+p*r[f+3]+y*u+x*o,l.push(m),l.push(_);const w=[];for(let s=0;s<l.length-1;s+=2)w.push({x:l[s],y:l[s+1]});if(a)for(let s=0;s<h+1;s++){const g=w.shift();w.push(g)}return w}const createSmoothCurvePointsFromPointList=(e,t=16)=>createSmoothCurvePoints(e.reduce((a,h)=>[...a,h.x,h.y],[]),.5,!1,t);function isInPolygon(e,t,a=tool.ELineTypes.Line){let h=0,l,r;a===tool.ELineTypes.Curve&&(t=createSmoothCurvePoints(t.flatMap(u=>[u.x,u.y]),.5,!0,tool.SEGMENT_NUMBER));const[m,_,M,c]=t.reduce(([u,o,i,p],{x:y,y:x})=>[Math.min(u,y),Math.max(o,y),Math.min(i,x),Math.max(p,x)],[Infinity,-Infinity,Infinity,-Infinity]);if(e.x<m||e.x>_||e.y<M||e.y>c)return!1;l=t[t.length-1];for(let u=0;u<t.length;u++){if(r=t[u],e.y>Math.min(l.y,r.y)&&e.y<=Math.max(l.y,r.y)&&e.x<=Math.max(l.x,r.x)){const o=l.y!==r.y?(e.y-l.y)*(r.x-l.x)/(r.y-l.y)+l.x:l.x;e.x<=o&&h++}if(l=r,h%2!=0&&u>t.length/2)break}return h%2!=0}function getPolygonPointUnderZoom(e,t=1){return e.map(a=>__spreadProps(__spreadValues({},a),{x:a.x*t,y:a.y*t}))}exports.createSmoothCurvePoints=createSmoothCurvePoints,exports.createSmoothCurvePointsFromPointList=createSmoothCurvePointsFromPointList,exports.getPolygonPointUnderZoom=getPolygonPointUnderZoom,exports.isInPolygon=isInPolygon;
@@ -1 +1 @@
1
- const v=320;var n;(function(u){u.PointCloud="pointCloudTool"})(n||(n={}));var i;(function(u){u.VideoTextTool="videoTextTool",u.VideoTagTool="videoTagTool",u.VideoClipTool="videoClipTool"})(i||(i={}));var l;(function(u){u.AudioTextTool="audioTextTool"})(l||(l={}));var e;(function(u){u[u.Rect=0]="Rect",u[u.Tag=1]="Tag"})(e||(e={}));var o;(function(u){u.Rect="rectTool",u.Tag="tagTool",u.Point="pointTool",u.PointMarker="pointMarkerTool",u.Segmentation="segmentationTool",u.Filter="filterTool",u.Text="textTool",u.Polygon="polygonTool",u.Line="lineTool",u.LineMarker="lineMarkerTool",u.Empty="emptyTool",u.FolderTag="folderTagTool",u.RectTrack="rectTrackTool",u.ScribbleTool="scribbleTool",u.Face="faceTool",u.ClientAttribute="clientAttributeTool",u.OCRRelation="OCRRelationTool",u.SegmentByRect="segmentByRectTool",u.Cuboid="cuboidTool",u.PointCloudPolygon="pointCloudPolygon",u.LLM="LLMTool",u.NLP="NLPTool",u.LLMMultiWheel="LLMMultiWheelTool"})(o||(o={}));var c;(function(u){u.Check="check"})(c||(c={}));var t;(function(u){u[u.nothing=0]="nothing",u[u.RectBG=1]="RectBG",u[u.showOrder=2]="showOrder"})(t||(t={}));const h={[o.Rect]:"\u62C9\u6846",[o.Tag]:"\u6807\u7B7E",[o.Point]:"\u6807\u70B9",[o.PointMarker]:"\u5217\u8868\u6807\u70B9",[o.Segmentation]:"\u524D\u666F\u5206\u5272",[o.Filter]:"\u7B5B\u9009",[o.Text]:"\u6587\u672C",[o.Polygon]:"\u591A\u8FB9\u5F62",[o.Line]:"\u7EBF\u6761",[o.LineMarker]:"\u5217\u8868\u7EBF\u6761",[o.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[o.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[o.Face]:"\u4EBA\u8138106\u5DE5\u5177",[o.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[o.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[o.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[i.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[i.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[i.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[n.PointCloud]:"\u70B9\u4E91",[o.Cuboid]:"\u7ACB\u4F53\u6846",[o.LLM]:"\u5927\u6A21\u578B",[o.NLP]:"NLP\u6807\u6CE8",[o.LLMMultiWheel]:"\u5927\u6A21\u578B\uFF08\u591A\u8F6E\u5BF9\u8BDD\uFF09"},_={[o.Rect]:"Rect",[o.Tag]:"Tag",[o.Point]:"Point",[o.PointMarker]:"PointMarker",[o.Segmentation]:"Segmentation",[o.Filter]:"Filter",[o.Text]:"Text",[o.Polygon]:"Polygon",[o.Line]:"Line",[o.LineMarker]:"LineMarker",[o.FolderTag]:"FolderTag",[o.RectTrack]:"RectTrack",[o.Face]:"Face",[o.ClientAttribute]:"ClientAttribute",[o.OCRRelation]:"OCRRelation",[o.SegmentByRect]:"SegmentByRect",[i.VideoTextTool]:"VideoTextTool",[i.VideoTagTool]:"VideoTagTool",[i.VideoClipTool]:"VideoClipTool",[n.PointCloud]:"PointCloud",[o.Cuboid]:"Cuboid",[o.LLM]:"LLM",[o.NLP]:"NLP",[o.LLMMultiWheel]:"LLMMultiWheelTool"};var r;(function(u){u[u.noDepend=1]="noDepend",u[u.dependOrigin=2]="dependOrigin",u[u.dependShape=3]="dependShape",u[u.dependLine=4]="dependLine",u[u.dependPolygon=5]="dependPolygon",u[u.dependPreShape=101]="dependPreShape",u[u.dependPreLine=102]="dependPreLine",u[u.dependPrePolygon=103]="dependPrePolygon"})(r||(r={}));var C;(function(u){u.lc="leftClick",u.rc="rightClick",u.clc="ctrlLeftClick",u.crc="ctrlRightClick"})(C||(C={}));const b={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var d;(function(u){u[u.Normal=1]="Normal",u[u.Modify=2]="Modify"})(d||(d={}));var L;(function(u){u[u.Line=0]="Line",u[u.Curve=1]="Curve"})(L||(L={}));var F;(function(u){u[u.SingleColor=0]="SingleColor",u[u.MultiColor=1]="MultiColor"})(F||(F={}));var T;(function(u){u[u.Form=1]="Form",u[u.Json=2]="Json"})(T||(T={}));var g;(function(u){u[u.Point=0]="Point",u[u.Line=1]="Line",u[u.Plane=2]="Plane"})(g||(g={}));var B;(function(u){u[u.None=0]="None",u[u.Drawing=1]="Drawing",u[u.Edit=2]="Edit"})(B||(B={}));var R;(function(u){u[u.Backward=0]="Backward",u[u.Forward=1]="Forward",u[u.JumpSkip=2]="JumpSkip",u[u.None=3]="None"})(R||(R={}));var M;(function(u){u[u.Wait=0]="Wait",u[u.Pass=1]="Pass",u[u.Fail=2]="Fail",u[u.Loading=3]="Loading"})(M||(M={}));var s;(function(u){u[u.AnyString=0]="AnyString",u[u.Order=1]="Order",u[u.EnglishOnly=2]="EnglishOnly",u[u.NumberOnly=3]="NumberOnly",u[u.CustomFormat=4]="CustomFormat"})(s||(s={}));const O={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},S=1e3,I=16,P=300,V="normal normal 500 14px Arial";var A;(function(u){u[u.ImgList=1e3]="ImgList",u[u.TrackPrediction=1001]="TrackPrediction",u[u.ImgSearch=1002]="ImgSearch"})(A||(A={}));const y={[n.PointCloud]:"sensebeepc",[o.ClientAttribute]:"sensebeepc-EnumAttributeTool",[o.Face]:"sensebeepc-FacePointsLabellingTool",[o.OCRRelation]:"sensebeepc-OCRRelationTool"},m={[n.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[o.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[o.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[o.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},W=16,N=10;var k;(function(u){u[u.Normal=0]="Normal",u[u.Rect=1]="Rect"})(k||(k={}));var f;(function(u){u[u.Scribble=1]="Scribble",u[u.Erase=2]="Erase"})(f||(f={}));var a;(function(u){u[u.General=1]="General",u[u.MultiMove=2]="MultiMove"})(a||(a={}));export{y as CLIENT_TOOL_HEAD_TYPE,m as CLIENT_TOOL_NAME,V as DEFAULT_FONT,P as DEFAULT_TEXT_MAX_WIDTH,d as EAnnotationMode,l as EAudioToolName,M as EAuditStatus,c as ECheckModel,r as EDependPattern,g as EDragTarget,B as EDrawPointPattern,C as EFilterToolOperation,F as ELineColor,L as ELineTypes,a as EOperationMode,R as EPageOperator,n as EPointCloudName,k as EPolygonPattern,t as ERectPattern,f as EScribblePattern,T as ESelectedType,s as ETextType,A as EThumbnailOption,o as EToolName,e as EToolType,i as EVideoToolName,b as OPERATION_LIST,W as SEGMENT_NUMBER,I as TEXT_ATTRIBUTE_LINE_HEIGHT,S as TEXT_ATTRIBUTE_MAX_LENGTH,O as TEXT_TYPE,h as TOOL_NAME,_ as TOOL_NAME_EN,N as edgeAdsorptionScope,v as editStepWidth};
1
+ const _=320;var n;(function(o){o.PointCloud="pointCloudTool"})(n||(n={}));var i;(function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"})(i||(i={}));var l;(function(o){o.AudioTextTool="audioTextTool"})(l||(l={}));var e;(function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"})(e||(e={}));var u;(function(o){o.Rect="rectTool",o.Tag="tagTool",o.Point="pointTool",o.PointMarker="pointMarkerTool",o.Segmentation="segmentationTool",o.Filter="filterTool",o.Text="textTool",o.Polygon="polygonTool",o.Line="lineTool",o.LineMarker="lineMarkerTool",o.Empty="emptyTool",o.FolderTag="folderTagTool",o.RectTrack="rectTrackTool",o.ScribbleTool="scribbleTool",o.Face="faceTool",o.ClientAttribute="clientAttributeTool",o.OCRRelation="OCRRelationTool",o.SegmentByRect="segmentByRectTool",o.Cuboid="cuboidTool",o.PointCloudPolygon="pointCloudPolygon",o.LLM="LLMTool",o.NLP="NLPTool",o.LLMMultiWheel="LLMMultiWheelTool"})(u||(u={}));var c;(function(o){o.Check="check"})(c||(c={}));var t;(function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"})(t||(t={}));const h={[u.Rect]:"\u62C9\u6846",[u.Tag]:"\u6807\u7B7E",[u.Point]:"\u6807\u70B9",[u.PointMarker]:"\u5217\u8868\u6807\u70B9",[u.Segmentation]:"\u524D\u666F\u5206\u5272",[u.Filter]:"\u7B5B\u9009",[u.Text]:"\u6587\u672C",[u.Polygon]:"\u591A\u8FB9\u5F62",[u.Line]:"\u7EBF\u6761",[u.LineMarker]:"\u5217\u8868\u7EBF\u6761",[u.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[u.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[u.Face]:"\u4EBA\u8138106\u5DE5\u5177",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[u.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[i.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[i.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[i.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[n.PointCloud]:"\u70B9\u4E91",[u.Cuboid]:"\u7ACB\u4F53\u6846",[u.LLM]:"\u5927\u6A21\u578B",[u.NLP]:"NLP\u6807\u6CE8",[u.LLMMultiWheel]:"\u5927\u6A21\u578B\uFF08\u591A\u8F6E\u5BF9\u8BDD\uFF09"},b={[u.Rect]:"Rect",[u.Tag]:"Tag",[u.Point]:"Point",[u.PointMarker]:"PointMarker",[u.Segmentation]:"Segmentation",[u.Filter]:"Filter",[u.Text]:"Text",[u.Polygon]:"Polygon",[u.Line]:"Line",[u.LineMarker]:"LineMarker",[u.FolderTag]:"FolderTag",[u.RectTrack]:"RectTrack",[u.Face]:"Face",[u.ClientAttribute]:"ClientAttribute",[u.OCRRelation]:"OCRRelation",[u.SegmentByRect]:"SegmentByRect",[i.VideoTextTool]:"VideoTextTool",[i.VideoTagTool]:"VideoTagTool",[i.VideoClipTool]:"VideoClipTool",[n.PointCloud]:"PointCloud",[u.Cuboid]:"Cuboid",[u.LLM]:"LLM",[u.NLP]:"NLP",[u.LLMMultiWheel]:"LLMMultiWheelTool"};var r;(function(o){o[o.noDepend=1]="noDepend",o[o.dependOrigin=2]="dependOrigin",o[o.dependShape=3]="dependShape",o[o.dependLine=4]="dependLine",o[o.dependPolygon=5]="dependPolygon",o[o.dependPreShape=101]="dependPreShape",o[o.dependPreLine=102]="dependPreLine",o[o.dependPrePolygon=103]="dependPrePolygon"})(r||(r={}));var C;(function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"})(C||(C={}));const O={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var d;(function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"})(d||(d={}));var T;(function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"})(T||(T={}));var L;(function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"})(L||(L={}));var F;(function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"})(F||(F={}));var g;(function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"})(g||(g={}));var B;(function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"})(B||(B={}));var R;(function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"})(R||(R={}));var s;(function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"})(s||(s={}));var M;(function(o){o[o.AnyString=0]="AnyString",o[o.Order=1]="Order",o[o.EnglishOnly=2]="EnglishOnly",o[o.NumberOnly=3]="NumberOnly",o[o.CustomFormat=4]="CustomFormat"})(M||(M={}));const S={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},P=1e3,I=16,V=300,m="normal normal 500 14px Arial";var A;(function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"})(A||(A={}));const y={[n.PointCloud]:"sensebeepc",[u.ClientAttribute]:"sensebeepc-EnumAttributeTool",[u.Face]:"sensebeepc-FacePointsLabellingTool",[u.OCRRelation]:"sensebeepc-OCRRelationTool"},N={[n.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},W=16,G=10;var f;(function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"})(f||(f={}));var k;(function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"})(k||(k={}));var a;(function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"})(a||(a={}));const w="rect_tool_mode";var v;(function(o){o.ThreePoints="three_points",o.TwoPoints="two_points"})(v||(v={}));export{y as CLIENT_TOOL_HEAD_TYPE,N as CLIENT_TOOL_NAME,m as DEFAULT_FONT,V as DEFAULT_TEXT_MAX_WIDTH,d as EAnnotationMode,l as EAudioToolName,s as EAuditStatus,c as ECheckModel,r as EDependPattern,g as EDragTarget,B as EDrawPointPattern,C as EFilterToolOperation,L as ELineColor,T as ELineTypes,a as EOperationMode,R as EPageOperator,n as EPointCloudName,f as EPolygonPattern,t as ERectPattern,v as ERectToolModeType,k as EScribblePattern,F as ESelectedType,M as ETextType,A as EThumbnailOption,u as EToolName,e as EToolType,i as EVideoToolName,O as OPERATION_LIST,w as RECT_TOOL_MODE_NAME,W as SEGMENT_NUMBER,I as TEXT_ATTRIBUTE_LINE_HEIGHT,P as TEXT_ATTRIBUTE_MAX_LENGTH,S as TEXT_TYPE,h as TOOL_NAME,b as TOOL_NAME_EN,G as edgeAdsorptionScope,_ as editStepWidth};
@@ -1 +1 @@
1
- import{PointCloudUtils as d}from"@labelbee/lb-utils";import{EToolName as C,EPolygonPattern as R}from"../../constant/tool.js";import{CanvasScheduler as A}from"../../newCore/CanvasScheduler.js";import{PointCloud as j}from"./index.js";import{ToolScheduler as B,HybridToolUtils as E}from"../scheduler.js";var V=Object.defineProperty,x=Object.defineProperties,F=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,w=(n,t,o)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,c=(n,t)=>{for(var o in t||(t={}))N.call(t,o)&&w(n,o,t[o]);if(y)for(var o of y(t))U.call(t,o)&&w(n,o,t[o]);return n},p=(n,t)=>x(n,F(t));const S=n=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,n.width,n.height),t.toDataURL()):""};class J{constructor({size:t,container:o,pcdPath:s,extraProps:L,config:O,checkMode:_,toolName:h,proxyMode:b}){this.updateLineList=a=>{const l=(a!=null?a:[]).map(i=>{var e;const r=(e=i.pointList)==null?void 0:e.map(u=>c({i:u},d.transferWorld2Canvas(u,this.toolInstance.size)));return p(c({},i),{pointList:r})});this.toolScheduler.updateDataByToolName(C.Line,l)},this.updatePolygonList=(a,l)=>{let i=a.map(e=>{var r;const{polygon2d:u}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(e);return{id:e.id,sourceID:"",pointList:u,isRect:!0,valid:(r=e.valid)!=null?r:!0,attribute:e.attribute,trackID:e==null?void 0:e.trackID}});l&&(i=i.concat(l.map(e=>{var r;return p(c({},e),{pointList:(r=e==null?void 0:e.pointList)==null?void 0:r.map(u=>d.transferWorld2Canvas(u,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(C.PointCloudPolygon,i)},this.updatePointList=a=>{const l=a==null?void 0:a.map(i=>{var e;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(i);return p(c({},r),{id:i.id,sourceID:"",valid:(e=i.valid)!=null?e:!0,attribute:i.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(C.Point,l)};const D=d.getDefaultOrthographicParams(t),T=S(t),g=new Image;g.src=T;const f=new B({container:o,size:t,toolName:h,proxyMode:b}),v=new A({container:o}),P=new j({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:D});s&&P.loadPCDFile(s),v.createCanvas(P.renderer.domElement);const I={size:t,config:JSON.stringify(p(c({},O),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:g,checkMode:_};L&&Object.assign(I,L);let m=[];E.isSingleTool(h)?m=[h]:m=h,m.forEach((a,l)=>{let i;if(a===C.PointCloudPolygon){const e=f.createOperation(a,g,I);e.eventBinding(),e.setPattern(R.Rect),this.toolInstance=e,this.toolInstance.eventBinding(),this.pointCloud2dOperation=e}else i=f.createOperation(a,g,p(c({},I),{textConfigurable:!1}));l===m.length-1&&(this.toolInstance||(this.toolInstance=i,this.toolInstance.eventBinding()))}),this.pointCloudInstance=P,this.canvasScheduler=v,this.toolScheduler=f,this.config=O}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}updateAttributeList(t){this.config=p(c({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(t)}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.toolScheduler.setSize(t),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(d.getDefaultOrthographicParams(t)),this.pointCloudInstance.render();const o=S(t),s=new Image;s.src=o,s.onload=()=>{this.toolInstance.setImgNode(s),this.toolInstance.initImgPos()}}addPolygonListOnTopView(t){const o=d.getBoxParamsFromResultList(t),s=d.getPolygonListFromResultList(t);this.updatePolygonList(o,s)}addLineListOnTopView(t){const o=d.getLineListFromResultList(t);this.updateLineList(o)}addPointListOnTopView(t){const o=d.getSphereParamsFromResultList(t);this.updatePointList(o)}updateData(t,o,s){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,s==null?void 0:s.radius),this.addPolygonListOnTopView(o),this.addLineListOnTopView(o),this.addPointListOnTopView(o))}switchToCanvas(t){const o=this.toolScheduler.switchToCanvas(t);return o?(this.toolInstance.eventUnbinding(),o.eventBinding(),this.toolInstance=o,o):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}export{J as PointCloudAnnotation};
1
+ import{PointCloudUtils as c}from"@labelbee/lb-utils";import{EToolName as C,EPolygonPattern as j}from"../../constant/tool.js";import{CanvasScheduler as B}from"../../newCore/CanvasScheduler.js";import{PointCloud as E}from"./index.js";import{ToolScheduler as V,HybridToolUtils as x}from"../scheduler.js";var F=Object.defineProperty,N=Object.defineProperties,U=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,S=(n,t,o)=>t in n?F(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,u=(n,t)=>{for(var o in t||(t={}))J.call(t,o)&&S(n,o,t[o]);if(w)for(var o of w(t))W.call(t,o)&&S(n,o,t[o]);return n},p=(n,t)=>N(n,U(t));const _=n=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,n.width,n.height),t.toDataURL()):""};class k{constructor({size:t,container:o,pcdPath:s,extraProps:O,config:v,checkMode:b,toolName:h,proxyMode:D,view:T}){this.updateLineList=a=>{const d=(a!=null?a:[]).map(l=>{var e;const i=(e=l.pointList)==null?void 0:e.map(r=>u({i:r},c.transferWorld2Canvas(r,this.toolInstance.size)));return p(u({},l),{pointList:i})});this.toolScheduler.updateDataByToolName(C.Line,d)},this.updatePolygonList=(a,d,l=!0)=>{let e=a.map(i=>{var r;const{polygon2d:L}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(i);return{id:i.id,sourceID:"",pointList:L,isRect:!0,valid:(r=i.valid)!=null?r:!0,attribute:i.attribute,trackID:i==null?void 0:i.trackID}});d&&(e=e.concat(d.map(i=>{var r;return p(u({},i),{pointList:(r=i==null?void 0:i.pointList)==null?void 0:r.map(L=>c.transferWorld2Canvas(L,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(C.PointCloudPolygon,e,l)},this.updatePointList=(a,d=!0)=>{const l=a==null?void 0:a.map(e=>{var i;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(e);return p(u({},r),{id:e.id,sourceID:"",valid:(i=e.valid)!=null?i:!0,attribute:e.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(C.Point,l,d)};const R=c.getDefaultOrthographicParams(t),A=_(t),g=new Image;g.src=A;const f=new V({container:o,size:t,toolName:h,proxyMode:D}),y=new B({container:o}),P=new E({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:R,view:T});s&&P.loadPCDFile(s),y.createCanvas(P.renderer.domElement);const I={size:t,config:JSON.stringify(p(u({},v),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:g,checkMode:b};O&&Object.assign(I,O);let m=[];x.isSingleTool(h)?m=[h]:m=h,m.forEach((a,d)=>{let l;if(a===C.PointCloudPolygon){const e=f.createOperation(a,g,I);e.eventBinding(),e.setPattern(j.Rect),this.toolInstance=e,this.toolInstance.eventBinding(),this.pointCloud2dOperation=e}else l=f.createOperation(a,g,p(u({},I),{textConfigurable:!1}));d===m.length-1&&(this.toolInstance||(this.toolInstance=l,this.toolInstance.eventBinding()))}),this.pointCloudInstance=P,this.canvasScheduler=y,this.toolScheduler=f,this.config=v}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}updateAttributeList(t){this.config=p(u({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(t)}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.toolScheduler.setSize(t),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(c.getDefaultOrthographicParams(t)),this.pointCloudInstance.render();const o=_(t),s=new Image;s.src=o,s.onload=()=>{this.toolInstance.setImgNode(s),this.toolInstance.initImgPos()}}addPolygonListOnTopView(t){const o=c.getBoxParamsFromResultList(t),s=c.getPolygonListFromResultList(t);this.updatePolygonList(o,s)}addLineListOnTopView(t){const o=c.getLineListFromResultList(t);this.updateLineList(o)}addPointListOnTopView(t){const o=c.getSphereParamsFromResultList(t);this.updatePointList(o)}updateData(t,o,s){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,s==null?void 0:s.radius),this.addPolygonListOnTopView(o),this.addLineListOnTopView(o),this.addPointListOnTopView(o))}switchToCanvas(t){const o=this.toolScheduler.switchToCanvas(t);return o?(this.toolInstance.eventUnbinding(),o.eventBinding(),this.toolInstance=o,o):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}export{k as PointCloudAnnotation};