Skip to content

Commit

Permalink
fix: 修复获取order时候sourceID的diff问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjunbao committed Sep 17, 2021
1 parent 60d7c1a commit 00b8c2c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
25 changes: 14 additions & 11 deletions packages/lb-annotation/src/core/toolOperation/pointOperation.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import MathUtils from '@/utils/MathUtils';
import { DEFAULT_TEXT_OFFSET, EDragStatus, ESortDirection } from '../../constant/annotation';
import EKeyCode from '../../constant/keyCode';
import uuid from '../../utils/uuid';
import AttributeUtils from '../../utils/tool/AttributeUtils';
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
import TextAttributeClass from './textAttributeClass';
import DrawUtils from '../../utils/tool/DrawUtils';
import StyleUtils from '../../utils/tool/StyleUtils';
import AxisUtils from '../../utils/tool/AxisUtils';
import locale from '../../locales';
import { EMessage } from '../../locales/constants';
import CommonToolUtils from '../../utils/tool/CommonToolUtils';
import { IPolygonData } from '../../types/tool/polygon';
import MathUtils from '@/utils/MathUtils';
import AttributeUtils from '../../utils/tool/AttributeUtils';
import AxisUtils from '../../utils/tool/AxisUtils';
import CommonToolUtils from '../../utils/tool/CommonToolUtils';
import DrawUtils from '../../utils/tool/DrawUtils';
import StyleUtils from '../../utils/tool/StyleUtils';
import uuid from '../../utils/uuid';
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
import TextAttributeClass from './textAttributeClass';

const TEXTAREA_WIDTH = 200;

Expand Down Expand Up @@ -375,13 +375,16 @@ class PointOperation extends BasicToolOperation {
id: uuid(8, 62),
sourceID: basicSourceID,
textAttribute: '',
order: CommonToolUtils.getMaxOrder(this.pointList.filter((v) => v.sourceID === basicSourceID)) + 1,
order:
CommonToolUtils.getMaxOrder(
this.pointList.filter((v) => CommonToolUtils.isSameSourceID(v.sourceID, basicSourceID)),
) + 1,
} as IPointUnit;

if (this.config.textConfigurable) {
let textAttribute = '';
textAttribute = AttributeUtils.getTextAttribute(
this.pointList.filter((point) => point.sourceID === basicSourceID),
this.pointList.filter((point) => CommonToolUtils.isSameSourceID(point.sourceID, basicSourceID)),
this.config.textCheckType,
);
// const { x, y } = AxisUtils.changePointByZoom(newDrawingPoint, 1 / this.zoom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import locale from '../../locales';
import { EMessage } from '../../locales/constants';
import { IPolygonConfig, IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
import ActionsHistory from '../../utils/ActionsHistory';
import uuid from '../../utils/uuid';
import AttributeUtils from '../../utils/tool/AttributeUtils';
import AxisUtils from '../../utils/tool/AxisUtils';
import CanvasUtils from '../../utils/tool/CanvasUtils';
import CommonToolUtils from '../../utils/tool/CommonToolUtils';
import DrawUtils from '../../utils/tool/DrawUtils';
import PolygonUtils from '../../utils/tool/PolygonUtils';
import StyleUtils from '../../utils/tool/StyleUtils';
import uuid from '../../utils/uuid';
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
import TextAttributeClass from './textAttributeClass';

Expand Down Expand Up @@ -397,13 +397,16 @@ class PolygonOperation extends BasicToolOperation {
textAttribute: '',
pointList: this.drawingPointList,
attribute: this.defaultAttribute,
order: CommonToolUtils.getMaxOrder(polygonList.filter((v) => v.sourceID === basicSourceID)) + 1,
order:
CommonToolUtils.getMaxOrder(
polygonList.filter((v) => CommonToolUtils.isSameSourceID(v.sourceID, basicSourceID)),
) + 1,
};

if (this.config.textConfigurable) {
let textAttribute = '';
textAttribute = AttributeUtils.getTextAttribute(
this.polygonList.filter((polygon) => polygon.sourceID === basicSourceID),
this.polygonList.filter((polygon) => CommonToolUtils.isSameSourceID(polygon.sourceID, basicSourceID)),
this.config.textCheckType,
);
newPolygon = {
Expand Down
12 changes: 6 additions & 6 deletions packages/lb-annotation/src/core/toolOperation/rectOperation.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { AxisUtils, RectUtils } from '@/';
import MathUtils from '@/utils/MathUtils';
import { DEFAULT_TEXT_SHADOW, EDragStatus, ESortDirection } from '../../constant/annotation';
import EKeyCode from '../../constant/keyCode';
import { EDragTarget } from '../../constant/tool';
import locale from '../../locales';
import { EMessage } from '../../locales/constants';
import uuid from '../../utils/uuid';
import AttributeUtils from '../../utils/tool/AttributeUtils';
import CanvasUtils from '../../utils/tool/CanvasUtils';
import CommonToolUtils from '../../utils/tool/CommonToolUtils';
import DrawUtils from '../../utils/tool/DrawUtils';
import MarkerUtils from '../../utils/tool/MarkerUtils';
import { getPolygonPointUnderZoom } from '../../utils/tool/polygonTool';
import uuid from '../../utils/uuid';
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
import TextAttributeClass from './textAttributeClass';
import DrawUtils from '../../utils/tool/DrawUtils';
import { AxisUtils, RectUtils } from '@/';
import MathUtils from '@/utils/MathUtils';

interface IRectOperationProps extends IBasicToolOperationProps {
drawOutSideTarget: boolean; // 是否可以在边界外进行标注
Expand Down Expand Up @@ -905,7 +905,7 @@ class RectOperation extends BasicToolOperation {
if (this.config.textConfigurable) {
let textAttribute = '';
textAttribute = AttributeUtils.getTextAttribute(
this.rectList.filter((rect) => rect.sourceID === basicSourceID),
this.rectList.filter((rect) => CommonToolUtils.isSameSourceID(rect.sourceID,basicSourceID) ),
this.config.textCheckType,
);
if (this.drawingRect) {
Expand All @@ -918,7 +918,7 @@ class RectOperation extends BasicToolOperation {

// 标注序号添加
Object.assign(this.drawingRect, {
order: CommonToolUtils.getMaxOrder(this.rectList.filter((v) => v.sourceID === basicSourceID)) + 1,
order: CommonToolUtils.getMaxOrder(this.rectList.filter((v) => CommonToolUtils.isSameSourceID(v.sourceID,basicSourceID))) + 1,
});

this.firstClickCoord = {
Expand Down

0 comments on commit 00b8c2c

Please sign in to comment.