Skip to content

Commit

Permalink
feat: Split the function of PolygonOpeartion
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Jul 18, 2022
1 parent e3dd7ac commit fb7631b
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions packages/lb-annotation/src/core/toolOperation/polygonOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class PolygonOperation extends BasicToolOperation {
return PolygonUtils.getPolygonByID(this.polygonList, this.selectedID);
}

public get hoverPolygon() {
return this.polygonList.find((v) => v.id === this.hoverID && v.id !== this.selectedID);
}

public get polygonListUnderZoom() {
return this.polygonList.map((polygon) => ({
...polygon,
Expand Down Expand Up @@ -140,9 +144,8 @@ class PolygonOperation extends BasicToolOperation {
return this.polygonList;
}

// 更改当前标注模式
public setPattern(pattern: EPolygonPattern) {
if (this.drawingPointList?.length > 0) {
public setPattern(pattern: EPolygonPattern, isForce = false) {
if (this.drawingPointList?.length > 0 && isForce === true) {
// 编辑中不允许直接跳出
return;
}
Expand Down Expand Up @@ -364,6 +367,10 @@ class PolygonOperation extends BasicToolOperation {
this.setSelectedID(undefined);
}

public clearDrawingStatus() {
this.drawingPointList = [];
}

// SET DATA
public setPolygonList(polygonList: IPolygonData[]) {
const oldLen = this.polygonList.length;
Expand Down Expand Up @@ -1531,13 +1538,9 @@ class PolygonOperation extends BasicToolOperation {
}
}

public renderPolygon() {
// 1. 静态多边形
this.renderStaticPolygon();

// 2. hover 多边形
public renderHoverPolygon() {
if (this.hoverID && this.hoverID !== this.editPolygonID) {
const hoverPolygon = this.polygonList.find((v) => v.id === this.hoverID && v.id !== this.selectedID);
const { hoverPolygon } = this;
if (hoverPolygon) {
let color = '';
const toolColor = this.getColor(hoverPolygon.attribute);
Expand All @@ -1557,6 +1560,14 @@ class PolygonOperation extends BasicToolOperation {
);
}
}
}

public renderPolygon() {
// 1. 静态多边形
this.renderStaticPolygon();

// 2. hover 多边形
this.renderHoverPolygon();

// 3. 选中多边形的渲染
this.renderSelectedPolygon();
Expand Down

0 comments on commit fb7631b

Please sign in to comment.