Skip to content

Commit

Permalink
fix: AttributeDisplayIssue
Browse files Browse the repository at this point in the history
  • Loading branch information
Original-Recipe committed Oct 15, 2024
1 parent e2987f8 commit f7dc099
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions packages/lb-annotation/src/core/toolOperation/ViewOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import RectUtils from '@/utils/tool/RectUtils';
import PolygonUtils, { IConvexHullGroupType } from '@/utils/tool/PolygonUtils';
import MathUtils from '@/utils/MathUtils';
import RenderDomClass from '@/utils/tool/RenderDomClass';
import { DEFAULT_FONT, ELineTypes, SEGMENT_NUMBER } from '@/constant/tool';
import { DEFAULT_FONT, ELineTypes, EToolName, SEGMENT_NUMBER } from '@/constant/tool';
import { DEFAULT_TEXT_SHADOW, DEFAULT_TEXT_OFFSET, TEXT_ATTRIBUTE_OFFSET } from '@/constant/annotation';
import ImgUtils, { cropAndEnlarge } from '@/utils/ImgUtils';
import CanvasUtils from '@/utils/tool/CanvasUtils';
Expand All @@ -39,6 +39,7 @@ interface IViewOperationProps extends IBasicToolOperationProps {
style: IBasicStyle;
staticMode?: boolean;
annotations: TAnnotationViewData[];
toolName?: EToolName;
}

export interface ISpecificStyle {
Expand Down Expand Up @@ -83,6 +84,8 @@ export default class ViewOperation extends BasicToolOperation {

private hiddenText?: boolean = false;

private toolName?: EToolName = EToolName.Empty;

constructor(props: IViewOperationProps) {
super({ ...props, showDefaultCursor: true });
this.style = props.style ?? { stroke: DEFAULT_STROKE_COLOR, thickness: 3 };
Expand All @@ -93,6 +96,7 @@ export default class ViewOperation extends BasicToolOperation {
container: this.container,
height: this.canvas.height,
});
this.toolName = props.toolName || EToolName.Empty;
}

public clearConnectionPoints() {
Expand Down Expand Up @@ -450,6 +454,7 @@ export default class ViewOperation extends BasicToolOperation {
/**
* Separate rendering of sub attribute content
* The principle is the same as other tools for rendering sub attribute content
* Currently, only secondary attributes are being rendered in point cloud rendering
*/
public renderAttribute() {
const annotationChunks = _.chunk(this.annotations, 6);
Expand All @@ -460,6 +465,8 @@ export default class ViewOperation extends BasicToolOperation {
const { fontStyle } = this.getRenderStyle(annotation);
const polygon = annotation.annotation as IBasicPolygon;
const curPointCloudBox = this.pointCloudBoxList?.find((item: IPointCloudBox) => item.id === polygon.id);
// Without this rendered graphic, return in advance to avoid errors in the future
if (!curPointCloudBox) return;
const headerText = this.hiddenText ? '' : `${curPointCloudBox?.trackID} ${curPointCloudBox?.attribute}`;
const renderPolygon = AxisUtils.changePointListByZoom(polygon?.pointList ?? [], this.zoom, this.currentPos);

Expand Down Expand Up @@ -975,7 +982,9 @@ export default class ViewOperation extends BasicToolOperation {
});

this.renderConnectionPoints();
this.renderAttribute();
if (this.toolName && this.toolName === EToolName.Rect) {
this.renderAttribute();
}
} catch (e) {
console.error('ViewOperation Render Error', e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const AnnotationView = (props: IProps, ref: any) => {
const annotationListCacheRef = useRef<TAnnotationViewData[][]>([]);
const canUpdateRef = useRef(true); // Judge if rending is Possible.

const { setSelectedIDs } = useContext(PointCloudContext);
const { setSelectedIDs, pointCloudPattern } = useContext(PointCloudContext);

useImperativeHandle(
ref,
Expand Down Expand Up @@ -139,6 +139,7 @@ const AnnotationView = (props: IProps, ref: any) => {
config: '{}', // TODO,暂时不需要
zoomInfo: props.zoomInfo,
staticMode: props.staticMode,
toolName: pointCloudPattern,
});

viewOperation.current.init();
Expand Down

0 comments on commit f7dc099

Please sign in to comment.