Skip to content

Commit

Permalink
feat(pointcloud): Support more dataShowing in checkMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Feb 3, 2023
1 parent 9c35600 commit 4db92f6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ class PolygonOperation extends BasicToolOperation {

/**
* Judgment of drag information during mousedown
* @param e
* @returns
* @param e
* @returns
*/
public dragMouseDown(e: MouseEvent) {
const firstPolygon = this.selectedPolygon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @createdate 2022-07-13
*/

import { EPerspectiveView, PointCloudUtils } from '@labelbee/lb-utils';
import { EPerspectiveView, IPointCloudConfig, PointCloudUtils } from '@labelbee/lb-utils';
import React, { useEffect, useState } from 'react';
import { PointCloudContext } from './PointCloudContext';
import { UnitUtils } from '@labelbee/lb-annotation';
Expand Down Expand Up @@ -65,7 +65,13 @@ export const SizeInfoForView = ({ perspectiveView }: { perspectiveView: EPerspec
/**
* Display selected box's infos
*/
export const BoxInfos = () => {
export const BoxInfos = ({
checkMode,
config,
}: {
checkMode?: boolean;
config: IPointCloudConfig;
}) => {
const ptCtx = React.useContext(PointCloudContext);
const { selectedBox } = useSingleBox();
const [infos, setInfos] = useState<Array<{ label: string; value: string }>>([]);
Expand Down Expand Up @@ -111,6 +117,16 @@ export const BoxInfos = () => {
label: t('PointCount'),
value: `${data.num}`,
});

// SubAttribute is shown in checkMode
if (checkMode === true && selectedBox.info.subAttribute && config) {
const subAttributeNameList = PointCloudUtils.getSubAttributeName(
selectedBox.info.subAttribute,
config,
);
subAttributeNameList.forEach((data) => infos.push(data));
}

setInfos(infos);
});
}, [selectedBox, i18n.language]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ const TopViewToolbar = ({ currentData }: IAnnotationStateProps) => {
const ZAxisSlider = ({
setZAxisLimit,
zAxisLimit,
checkMode,
}: {
setZAxisLimit: (value: number) => void;
zAxisLimit: number;
checkMode?: boolean;
}) => {
if (checkMode) {
return null;
}

return (
<div style={{ position: 'absolute', top: 128, right: 8, height: '50%', zIndex: 20 }}>
<Slider
Expand All @@ -136,11 +142,17 @@ const ZAxisSlider = ({
};

interface IProps extends IA2MapStateProps {
drawLayerSlot?: TDrawLayerSlot
drawLayerSlot?: TDrawLayerSlot;
checkMode?: boolean;
}

const PointCloudTopView: React.FC<IProps> = ({ currentData, imgList, stepInfo, drawLayerSlot, checkMode }) => {
const PointCloudTopView: React.FC<IProps> = ({
currentData,
imgList,
stepInfo,
drawLayerSlot,
checkMode,
}) => {
const [annotationPos, setAnnotationPos] = useState({ zoom: 1, currentPos: { x: 0, y: 0 } });
const ref = useRef<HTMLDivElement>(null);
const ptCtx = React.useContext(PointCloudContext);
Expand Down Expand Up @@ -170,9 +182,9 @@ const PointCloudTopView: React.FC<IProps> = ({ currentData, imgList, stepInfo, d
size,
pcdPath: currentData.url,
config,
checkMode
checkMode,
});

ptCtx.setTopViewInstance(pointCloudAnnotation);
}
}, [currentData]);
Expand Down Expand Up @@ -294,8 +306,8 @@ const PointCloudTopView: React.FC<IProps> = ({ currentData, imgList, stepInfo, d
{drawLayerSlot?.(annotationPos)}
</div>

<BoxInfos />
<ZAxisSlider zAxisLimit={zAxisLimit} setZAxisLimit={setZAxisLimit} />
<BoxInfos checkMode={checkMode} config={config} />
<ZAxisSlider checkMode={checkMode} zAxisLimit={zAxisLimit} setZAxisLimit={setZAxisLimit} />
<PointCloudValidity />
</div>
</PointCloudContainer>
Expand Down
26 changes: 25 additions & 1 deletion packages/lb-utils/src/PointCloudUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Ron <ron.f.luo@gmail.com>
*/

import { IPointCloudBox } from './types/pointCloud';
import { IPointCloudBox, IPointCloudConfig } from './types/pointCloud';

class PointCloudUtils {
public static genColorByCoord(x: number, y: number, z: number) {
Expand Down Expand Up @@ -465,6 +465,30 @@ class PointCloudUtils {

return basicSize;
}

public static getSubAttributeName(
subAttribute: { [key: string]: string },
config: IPointCloudConfig,
) {
const subAttributeList = config.inputList;
return Object.entries(subAttribute).map(([label, value]) => {
const data = subAttributeList.find((v) => v.value === label);
if (data) {
const subValue = data?.subSelected?.find((v) => v.value === value);

if (subValue) {
return {
label: data.key,
value: subValue.key,
};
}
}
return {
label,
value,
};
});
}
}

export default PointCloudUtils;

0 comments on commit 4db92f6

Please sign in to comment.