-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expand various types of polygonOperation
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
packages/lb-annotation/src/core/toolOperation/pointCloud2dOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* It can expand various types of operations | ||
* | ||
* @file PointCloud 2D Operation | ||
* @createdate 2022-07-11 | ||
* @author Ron <ron.f.luo@gmail.com> | ||
*/ | ||
|
||
import AxisUtils from '@/utils/tool/AxisUtils'; | ||
import DrawUtils from '@/utils/tool/DrawUtils'; | ||
import StyleUtils from '@/utils/tool/StyleUtils'; | ||
import PolygonOperation from './polygonOperation'; | ||
|
||
class PointCloud2dOperation extends PolygonOperation { | ||
public renderStaticPolygon() { | ||
if (this.isHidden === false) { | ||
this.polygonList?.forEach((polygon) => { | ||
if ([this.selectedID, this.editPolygonID].includes(polygon.id)) { | ||
return; | ||
} | ||
const { attribute } = polygon; | ||
const toolColor = this.getColor(attribute); | ||
const toolData = StyleUtils.getStrokeAndFill(toolColor, polygon.valid); | ||
const transformPointList = AxisUtils.changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos); | ||
|
||
DrawUtils.drawPolygonWithFillAndLine(this.canvas, transformPointList, { | ||
fillColor: 'transparent', | ||
strokeColor: toolData.stroke, | ||
pointColor: 'white', | ||
thickness: this.style?.width ?? 2, | ||
lineCap: 'round', | ||
isClose: true, | ||
lineType: this.config?.lineType, | ||
}); | ||
|
||
DrawUtils.drawLine(this.canvas, transformPointList[0], transformPointList[1], { | ||
color: 'red', | ||
thickness: 3, | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
public renderSelectedPolygon() { | ||
if (this.selectedID) { | ||
const selectdPolygon = this.selectedPolygon; | ||
|
||
if (selectdPolygon) { | ||
const toolColor = this.getColor(selectdPolygon.attribute); | ||
const toolData = StyleUtils.getStrokeAndFill(toolColor, selectdPolygon.valid, { isSelected: true }); | ||
|
||
const polygon = AxisUtils.changePointListByZoom(selectdPolygon.pointList, this.zoom, this.currentPos); | ||
|
||
DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas, polygon, { | ||
fillColor: 'transparent', | ||
strokeColor: toolData.stroke, | ||
pointColor: 'white', | ||
thickness: 2, | ||
lineCap: 'round', | ||
isClose: true, | ||
lineType: this.config?.lineType, | ||
}); | ||
|
||
DrawUtils.drawLine(this.canvas, polygon[0], polygon[1], { | ||
color: 'red', | ||
thickness: 3, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default PointCloud2dOperation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters