diff --git a/packages/lb-annotation/src/core/toolOperation/rectOperation.ts b/packages/lb-annotation/src/core/toolOperation/rectOperation.ts index a555a2237..befda5293 100644 --- a/packages/lb-annotation/src/core/toolOperation/rectOperation.ts +++ b/packages/lb-annotation/src/core/toolOperation/rectOperation.ts @@ -1167,6 +1167,27 @@ class RectOperation extends BasicToolOperation { } } + public checkSize({ + width, + height, + minWidth, + minHeight, + }: { + width: number; + height: number; + minWidth: number; + minHeight: number; + }) { + if (Math.round(width) < minWidth || Math.round(height) < minHeight) { + this.emit('messageInfo', locale.getMessagesByLocale(EMessage.RectErrorSizeNotice, this.lang)); + + this.clearDrawingStatus(); + this.render(); + return false; + } + return true; + } + /** * 将绘制中的框体添加进 rectList 中 * @returns @@ -1183,12 +1204,19 @@ class RectOperation extends BasicToolOperation { width /= this.zoom; height /= this.zoom; - // 小于最小尺寸设置为无效框 - if (Math.round(width) < this.config.minWidth || Math.round(height) < this.config.minHeight) { - this.emit('messageInfo', locale.getMessagesByLocale(EMessage.RectErrorSizeNotice, this.lang)); + const { attribute } = this.drawingRect; - this.clearDrawingStatus(); - this.render(); + let limit = { minWidth: this.config.minWidth, minHeight: this.config.minHeight }; + + if (attribute && this.config.attributeConfigurable) { + const attributeList = this.config?.attributeList ?? []; + const attributeLimit = attributeList.find((i: any) => i.value === attribute)?.limit; + if (attributeLimit) { + limit = attributeLimit; + } + } + + if (!this.checkSize({ width, height, ...limit })) { return; } diff --git a/packages/lb-annotation/src/types/tool/tagTool.d.ts b/packages/lb-annotation/src/types/tool/tagTool.d.ts index c693df010..a09f62f3c 100644 --- a/packages/lb-annotation/src/types/tool/tagTool.d.ts +++ b/packages/lb-annotation/src/types/tool/tagTool.d.ts @@ -17,6 +17,7 @@ declare interface IInputList { isMulti?: boolean; subSelected?: IInfoList[]; color?: string; // Custom Color for scribbleTool + limit?: ILimit; } /** v3.2.0 仅标点工具 列表标注 */ diff --git a/packages/lb-components/src/components/attributeList/components/limitPopover/index.tsx b/packages/lb-components/src/components/attributeList/components/limitPopover/index.tsx index f75d9a86a..21abd9297 100644 --- a/packages/lb-components/src/components/attributeList/components/limitPopover/index.tsx +++ b/packages/lb-components/src/components/attributeList/components/limitPopover/index.tsx @@ -1,14 +1,14 @@ import React from 'react'; import { Tooltip } from 'antd'; import defaultSizeSvg from '@/assets/toolStyle/icon_defaultSize.svg'; -import { ILimit, IDefaultSize } from '@labelbee/lb-utils'; +import { ILimit, IDefaultSize, IPointCloudLimit } from '@labelbee/lb-utils'; import { useTranslation } from 'react-i18next'; const LimitPopover = ({ limit, updateSize, }: { - limit: ILimit; + limit: IPointCloudLimit; updateSize?: (size: IDefaultSize) => void; }) => { const { t } = useTranslation(); diff --git a/packages/lb-utils/src/types/base.ts b/packages/lb-utils/src/types/base.ts index 76bbb87f2..69538dc06 100644 --- a/packages/lb-utils/src/types/base.ts +++ b/packages/lb-utils/src/types/base.ts @@ -32,7 +32,13 @@ interface IPositionLimit { ZMin?: string; ZMax?: string; } -export interface ILimit { + +export interface IRectLimit { + minWidth: number; + minHeight: number; +} + +export interface IPointCloudLimit { sizeLimit: { sizeRange: ISizeRange; defaultSize?: IDefaultSize; @@ -40,6 +46,7 @@ export interface ILimit { }; positionLimit: IPositionLimit; } +export type ILimit = IPointCloudLimit | IRectLimit; export interface IInfoList { key: string; value: string;