-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
308 additions
and
106 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @author Ron <[email protected]> | ||
*/ | ||
|
||
import { IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils'; | ||
import { IPointCloudBox, PointCloudUtils, IPointCloudConfig } from '@labelbee/lb-utils'; | ||
import { EPolygonPattern } from '@/constant/tool'; | ||
import { CanvasScheduler } from '@/newCore'; | ||
import { IPolygonData } from '@/types/tool/polygon'; | ||
|
@@ -21,6 +21,8 @@ interface IPointCloudAnnotationProps { | |
|
||
pcdPath?: string; | ||
polygonOperationProps?: IPointCloud2dOperationProps; | ||
|
||
config: IPointCloudConfig; | ||
} | ||
|
||
const createEmptyImage = (size: { width: number; height: number }) => { | ||
|
@@ -43,7 +45,9 @@ export class PointCloudAnnotation implements IPointCloudAnnotationOperation { | |
|
||
public canvasScheduler: CanvasScheduler; | ||
|
||
constructor({ size, container, pcdPath, polygonOperationProps }: IPointCloudAnnotationProps) { | ||
public config: IPointCloudConfig; | ||
|
||
constructor({ size, container, pcdPath, polygonOperationProps, config }: IPointCloudAnnotationProps) { | ||
const defaultOrthographic = this.getDefaultOrthographic(size); | ||
|
||
const imgSrc = createEmptyImage(size); | ||
|
@@ -69,7 +73,7 @@ export class PointCloudAnnotation implements IPointCloudAnnotationOperation { | |
const defaultPolygonProps = { | ||
container, | ||
size, | ||
config: '{ "textConfigurable": false }', | ||
config: JSON.stringify(config), | ||
imgNode: image, | ||
isAppend: false, | ||
}; | ||
|
@@ -82,12 +86,17 @@ export class PointCloudAnnotation implements IPointCloudAnnotationOperation { | |
polygonOperation.eventBinding(); | ||
polygonOperation.setPattern(EPolygonPattern.Rect); | ||
|
||
// Set the DefaultAttribute. | ||
polygonOperation.setDefaultAttribute(config?.attributeList?.[0]?.value); | ||
|
||
canvasScheduler.createCanvas(polygonOperation.canvas, { size }); | ||
|
||
// 3. Data record | ||
this.pointCloud2dOperation = polygonOperation; | ||
this.pointCloudInstance = pointCloud; | ||
this.canvasScheduler = canvasScheduler; | ||
|
||
this.config = config; | ||
} | ||
|
||
/** | ||
|
@@ -156,6 +165,7 @@ export class PointCloudAnnotation implements IPointCloudAnnotationOperation { | |
pointList, | ||
isRect: true, | ||
valid: v.valid ?? true, | ||
attribute: v.attribute, | ||
}; | ||
}) as IPolygonData[]; | ||
|
||
|
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
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 |
---|---|---|
|
@@ -6,15 +6,16 @@ | |
* @author Ron <[email protected]> | ||
*/ | ||
|
||
import { IPointCloudConfig, toolStyleConverter } from '@labelbee/lb-utils'; | ||
import { ESortDirection } from '@/constant/annotation'; | ||
import { EPolygonPattern } from '@/constant/tool'; | ||
import { IPolygonData, IPolygonPoint } from '@/types/tool/polygon'; | ||
import AxisUtils from '@/utils/tool/AxisUtils'; | ||
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 PolygonOperation, { IPolygonOperationProps } from './polygonOperation'; | ||
import { polygonConfig } from '@/constant/defaultConfig'; | ||
|
||
interface IPointCloud2dOperationProps { | ||
showDirectionLine?: boolean; | ||
|
@@ -26,13 +27,24 @@ class PointCloud2dOperation extends PolygonOperation { | |
|
||
public forbidAddNew: boolean; | ||
|
||
public pointCloudConfig: IPointCloudConfig; | ||
|
||
private selectedIDs: string[] = []; | ||
|
||
constructor(props: IPolygonOperationProps & IPointCloud2dOperationProps) { | ||
super(props); | ||
|
||
this.showDirectionLine = props.showDirectionLine ?? true; | ||
this.forbidAddNew = props.forbidAddNew ?? false; | ||
this.pointCloudConfig = CommonToolUtils.jsonParser(props.config) ?? {}; | ||
|
||
// Set the default | ||
this.config = { | ||
...polygonConfig, | ||
textConfigurable: false, | ||
attributeConfigurable: true, | ||
attributeList: this.pointCloudConfig?.attributeList ?? [], | ||
}; | ||
} | ||
|
||
get getSelectedIDs() { | ||
|
@@ -93,6 +105,15 @@ class PointCloud2dOperation extends PolygonOperation { | |
return 'rgba(0, 255, 255, 0.5)'; | ||
} | ||
|
||
/** 获取当前属性颜色 */ | ||
public getPointCloudLineColor(attribute = '') { | ||
return toolStyleConverter.getColorFromConfig( | ||
{ attribute }, | ||
{ ...this.pointCloudConfig, attributeConfigurable: true }, | ||
{}, | ||
).stroke; | ||
} | ||
|
||
/** | ||
* Add direction | ||
* @override | ||
|
@@ -104,13 +125,12 @@ class PointCloud2dOperation extends PolygonOperation { | |
return; | ||
} | ||
const { attribute } = polygon; | ||
const toolColor = this.getColor(attribute); | ||
const toolData = StyleUtils.getStrokeAndFill(toolColor, polygon.valid); | ||
const lineColor = this.getPointCloudLineColor(attribute); | ||
const transformPointList = AxisUtils.changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos); | ||
|
||
DrawUtils.drawPolygonWithFillAndLine(this.canvas, transformPointList, { | ||
fillColor: 'transparent', | ||
strokeColor: toolData.stroke, | ||
strokeColor: lineColor, | ||
pointColor: 'white', | ||
thickness: this.style?.width ?? 2, | ||
lineCap: 'round', | ||
|
@@ -138,14 +158,14 @@ class PointCloud2dOperation extends PolygonOperation { | |
|
||
public renderSingleSelectedPolygon = (selectedPolygon: IPolygonData) => { | ||
if (this.selectedPolygons) { | ||
const toolColor = this.getColor(selectedPolygon.attribute); | ||
const toolData = StyleUtils.getStrokeAndFill(toolColor, selectedPolygon.valid, { isSelected: true }); | ||
const color = this.getPointCloudLineColor(selectedPolygon.attribute); | ||
// const toolData = StyleUtils.getStrokeAndFill(toolColor, selectedPolygon.valid, { isSelected: true }); | ||
|
||
const polygon = AxisUtils.changePointListByZoom(selectedPolygon.pointList, this.zoom, this.currentPos); | ||
|
||
DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas, polygon, { | ||
fillColor: 'transparent', | ||
strokeColor: toolData.stroke, | ||
strokeColor: color, | ||
pointColor: 'white', | ||
thickness: 2, | ||
lineCap: 'round', | ||
|
@@ -166,8 +186,9 @@ class PointCloud2dOperation extends PolygonOperation { | |
} | ||
|
||
DrawUtils.drawLine(this.canvas, polygon[0], polygon[1], { | ||
color: 'red', | ||
color: 'white', | ||
thickness: 3, | ||
lineDash: [6], | ||
}); | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.