From 2795ad97c1b0d07380f71573e4f828a756f0d000 Mon Sep 17 00:00:00 2001 From: hyunchan-jung Date: Wed, 5 Oct 2022 15:27:47 +0900 Subject: [PATCH] Fixed shape color not changed --- .../annotation-page/canvas/canvas-wrapper.tsx | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cvat-ui/src/components/annotation-page/canvas/canvas-wrapper.tsx b/cvat-ui/src/components/annotation-page/canvas/canvas-wrapper.tsx index f49b8249b57..9b87bc8be76 100644 --- a/cvat-ui/src/components/annotation-page/canvas/canvas-wrapper.tsx +++ b/cvat-ui/src/components/annotation-page/canvas/canvas-wrapper.tsx @@ -681,9 +681,33 @@ export default class CanvasWrapperComponent extends React.PureComponent { private updateCanvas(): void { const { - curZLayer, annotations, frameData, canvasInstance, + curZLayer, annotations, frameData, canvasInstance, colorBy, } = this.props; + for (const state of annotations) { + let shapeColor = ''; + + if (colorBy === ColorBy.INSTANCE) { + shapeColor = state.color; + } else if (colorBy === ColorBy.GROUP) { + shapeColor = state.group.color; + } else if (colorBy === ColorBy.LABEL) { + shapeColor = state.label.color; + } + + const shapeView = window.document.getElementById(`cvat_canvas_shape_${state.clientID}`); + if (shapeView) { + const handler = (shapeView as any).instance.remember('_selectHandler'); + if (handler && handler.nested) { + handler.nested.fill({ color: shapeColor }); + } + + (shapeView as any).instance + .fill({ color: shapeColor }) + .stroke({ color: shapeColor }); + } + } + if (frameData !== null && canvasInstance) { canvasInstance.setup( frameData,