Skip to content

Commit

Permalink
fix(pointcloud): Fix the feature of COPY_BACKWARD_RESULT
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Mar 27, 2023
1 parent 8a28ad8 commit 26b3062
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ICoordinate } from '@labelbee/lb-utils/dist/types/types/common';
import { useConfig } from './hooks/useConfig';
import { usePolygon } from './hooks/usePolygon';
import { useTranslation } from 'react-i18next';
import { IFileItem } from '@/types/data';

const { EPolygonPattern } = cTool;

Expand Down Expand Up @@ -329,6 +330,13 @@ const PointCloudListener: React.FC<IProps> = ({
toolInstanceRef.current.setShowDefaultCursor = (showDefaultCursor: boolean) => {
ptCtx.topViewInstance?.pointCloud2dOperation?.setShowDefaultCursor(showDefaultCursor);
};

toolInstanceRef.current.asyncData = (newData: IFileItem) => {
// Next Tick to update.
setTimeout(() => {
updatePointCloudData?.(newData);
});
};
}, [
ptCtx.pointCloudBoxList,
ptCtx.selectedID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,13 @@ export const usePointCloudViews = () => {
* Update the data of pointCloudView when the page change.
* @returns
*/
const updatePointCloudData = async () => {
if (!currentData?.url || !mainViewInstance) {
const updatePointCloudData = async (newData = currentData) => {
if (!newData?.url || !mainViewInstance) {
return;
}

SetPointCloudLoading(dispatch, true);
await mainViewInstance.loadPCDFile(currentData.url, config?.radius ?? DEFAULT_RADIUS);
await mainViewInstance.loadPCDFile(newData.url, config?.radius ?? DEFAULT_RADIUS);

// Clear All Data
pointCloudBoxList.forEach((v) => {
Expand All @@ -693,9 +693,9 @@ export const usePointCloudViews = () => {

let boxParamsList: any[] = [];
let polygonList = [];
if (currentData.result) {
boxParamsList = PointCloudUtils.getBoxParamsFromResultList(currentData.result);
polygonList = PointCloudUtils.getPolygonListFromResultList(currentData.result);
if (newData.result) {
boxParamsList = PointCloudUtils.getBoxParamsFromResultList(newData.result);
polygonList = PointCloudUtils.getPolygonListFromResultList(newData.result);

// Add Init Box
boxParamsList.forEach((v: IPointCloudBox) => {
Expand All @@ -713,7 +713,7 @@ export const usePointCloudViews = () => {

mainViewInstance.updateTopCamera();

const valid = jsonParser(currentData.result)?.valid ?? true;
const valid = jsonParser(newData.result)?.valid ?? true;
ptCtx.setPointCloudValid(valid);

// Clear other view data during initialization
Expand All @@ -727,7 +727,7 @@ export const usePointCloudViews = () => {
* 2. Reload PointCloud
* 3. Clear Polygon
*/
topViewInstance.updateData(currentData.url, currentData.result, {
topViewInstance.updateData(newData.url, newData.result, {
radius: config?.radius ?? DEFAULT_RADIUS,
});
SetPointCloudLoading(dispatch, false);
Expand Down
5 changes: 5 additions & 0 deletions packages/lb-components/src/store/annotation/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,11 @@ export const annotationReducer = (
toolInstance?.setResult(result);
toolInstance?.history.pushHistory(result);

/**
* Async PointCloud Data.
*/
// @ts-ignore
toolInstance?.asyncData(imgList[imgIndex]);
return {
...state,
imgList: [...imgList],
Expand Down

0 comments on commit 26b3062

Please sign in to comment.