import { EToolName, ELineTypes } from '@/constant/tool'; import type { ICuboid, IDrawingCuboid, IPlanePoints } from '@/types/tool/cuboid'; import { IPolygonPoint, IPolygonData, IPolygonConfig } from '../../types/tool/polygon'; export default class AxisUtils { /** * 获取原图坐标下,相对当前图片的偏移值 * @param coordinate * @param currentPos * @param zoom */ static getOffsetCoordinate(coordinate: ICoordinate, currentPos: ICoordinate, zoom: number): { x: number; y: number; }; static changeDrawOutsideTarget(coord: ICoordinate, currentPos: ICoordinate, imgInfo: ISize, drawOutsideTarget?: boolean, basicResult?: IRect, zoom?: number): ICoordinate; static changeCoordinateByRotate(coordinate: ICoordinate, rotate: number, imgSize: ISize): ICoordinate; /** * 计算点在 zoom 和 currentPos 的转换 * @param rect * @param zoom * @param currentPos * @returns */ static changeRectByZoom(rect: IRect, zoom: number, currentPos?: ICoordinate): { x: number; y: number; width: number; height: number; id: string; sourceID: string; valid: boolean; order?: number | undefined; attribute: string; textAttribute: string; disableDelete?: boolean | undefined; isHighlight?: boolean | undefined; label?: string | undefined; lineDash?: number[] | undefined; subAttribute?: { [key: string]: string; } | undefined; }; /** * 计算点在 zoom 和 currentPos 的转换 * @param point * @param zoom * @param currentPos * @returns */ static changePointByZoom(point: IPoint | IPolygonPoint, zoom: number, currentPos?: ICoordinate): { x: number; y: number; specialPoint?: boolean | undefined; specialEdge?: boolean | undefined; } | { x: number; y: number; }; /** * 计算点集在 zoom 和 currentPos 的转换 * @param pointList * @param zoom * @param currentPos * @returns */ static changePointListByZoom(pointList: IPoint[] | IPolygonPoint[], zoom: number, currentPos?: ICoordinate): ({ x: number; y: number; specialPoint?: boolean | undefined; specialEdge?: boolean | undefined; } | { x: number; y: number; })[]; static changePlanePointByZoom(planePoints: IPlanePoints, zoom: number, currentPos?: ICoordinate): IPlanePoints; static changeCuboidByZoom(cuboid: ICuboid | IDrawingCuboid, zoom: number, currentPos?: ICoordinate): ICuboid | IDrawingCuboid; static transformPlain2PointList({ tl, tr, br, bl }: IPlanePoints): any[]; /** * 扩大点的热区范围 * @param axis * @param radius * @returns */ static axisArea(axis: ICoordinate, radius?: number): { x: number; y: number; }[]; /** * 计算当前坐标相对于原图的坐标 * @param coord 在 canvas 内的相对坐标 */ static getOriginCoordinateWithOffsetCoordinate(coord: ICoordinate, zoom?: number, currentPos?: { x: number; y: number; }): { x: number; y: number; }; /** * 获取当前坐标是否在当前点 * 注意:checkPoint 为原图的坐标 * * @export * @param {IPolygonPoint} checkPoint * @param {IPolygonPoint[]} polygonPoints * @param {number} [scope=3] * @returns {number} */ static returnClosePointIndex(checkPoint: IPolygonPoint | ICoordinate, polygonPoints: IPolygonPoint[] | ICoordinate[], scope?: number): number; /** * Judge the mousePoint is in the hoverRange of cuboid. * @param checkPoint * @param cuboid * @param options * @returns */ static isCloseCuboid(checkPoint: ICoordinate, cuboid: ICuboid, options?: Partial<{ scope: number; zoom: number; }>): boolean; /** * Judge the mousePoint is in the hoverRange of cuboidList. * @param checkPoint * @param cuboid * @param options * @returns */ static isCloseCuboidList(checkPoint: ICoordinate, cuboidList: ICuboid[], options?: Partial<{ scope: number; zoom: number; }>): boolean; /** * Point > Line * @param checkPoint * @param cuboid * @param scope */ static returnClosePointOrLineInCuboid(checkPoint: ICoordinate, cuboid: ICuboid, options?: Partial<{ scope: number; zoom: number; }>): { type: string; points: ({ x: number; y: number; specialPoint?: boolean | undefined; specialEdge?: boolean | undefined; } | { x: number; y: number; })[]; originCuboid: ICuboid; positions: import("@/types/tool/cuboid").ICuboidPosition[]; }[] | undefined; /** * 对比两个点是否在一范围内 * * @export * @param {IPolygonPoint} currentCoord * @param {IPolygonPoint} targetCoord * @param {number} scope * @returns */ static getIsInScope(currentCoord: ICoordinate, targetCoord: ICoordinate, scope: number): boolean; } export declare class CoordinateUtils { private currentPos; private zoom; private basicImgInfo; private basicResult?; private dependToolConfig?; private dependToolName; constructor(props: any); get isDependPolygon(): boolean; get isDependRect(): boolean; get isDependOriginalImage(): boolean; /** * 渲染坐标 => 绝对坐标 * @param renderCoordinate */ getAbsCoord(renderCoord: ICoordinate): { x: number; y: number; }; /** * 绝对坐标 => 渲染坐标 * @param absoluteCoordinate */ getRenderCoord(absCoord: ICoordinate): { x: number; y: number; }; /** * 在矩形内的点 * @param absCoord * @param rect */ coordInsideRect(absCoord: ICoordinate, rect: { x: number; y: number; height: number; width: number; }): { x: number; y: number; }; getPolygonPointList(lineType: ELineTypes, pointList: IPoint[]): any[]; /** * 计算线段与线段的交点 * @param curCoord * @param preCoord * @param polygonPointListToLineList */ getIntersection(curCoord: ICoordinate, preCoord: ICoordinate, polygonPointListToLineList: IPoint[]): { point: ICoordinate; minDistance?: undefined; } | { point: IPoint; minDistance: number; } | undefined; /** * 在多边形内的点 * @param absCoord * @param rect */ coordInsidePolygon(curCoord: ICoordinate, preCoord: ICoordinate, polygon: IPolygonData, polygonToolConfig: IPolygonConfig): ICoordinate; coordInsideImage(coord: ICoordinate): { x: number; y: number; }; /** * 根据依赖工具计算下一个点的绝对坐标 * @param curAbsCoord * @param preAbsCoord */ getNextCoordByDependTool(curAbsCoord: ICoordinate, preAbsCoord: ICoordinate): ICoordinate | undefined; setDependInfo(dependToolName: EToolName | '', dependToolConfig?: IRectConfig | IPolygonConfig): void; setBasicImgInfo(basicImgInfo: any): void; setBasicResult(basicResult: any): void; setZoomAndCurrentPos(zoom: number, currentPos: ICoordinate): void; isCoordInsideTarget(coord: ICoordinate): boolean; isInBasicPolygon(coord: ICoordinate): boolean; }