Skip to content

Commit

Permalink
Merge pull request #609 from Original-Recipe/fix-unifiedParams
Browse files Browse the repository at this point in the history
fix: Color and label update issues fixed
  • Loading branch information
lihqi authored Nov 6, 2024
2 parents fcbd151 + 81e4cea commit 51033b2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
15 changes: 11 additions & 4 deletions packages/lb-annotation/src/core/pointCloud/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1502,14 +1502,21 @@ export class PointCloud extends EventListener {
if (!classInfo || !classInfo.subSelected) return; // If the type of the secondary attribute cannot be found, it will be returned directly

const { key: classKey, subSelected } = classInfo;
const subValues: string[] = [];
subSelected.forEach((item) => {
const subAttributeKey = boxParams.subAttribute?.[key];

if (subAttributeKey?.includes(item.value)) {
if (resultStr) resultStr += '、';
resultStr += `${classKey}:${item.key}`;
// If subAttributeKey is an array, use it directly; Otherwise, use split to convert it into an array
const subAttributeKeyList = Array.isArray(subAttributeKey) ? subAttributeKey : subAttributeKey?.split(';');
if (subAttributeKeyList?.includes(item.value)) {
subValues.push(item.key);
}
});

// If there are matching sub items in the current group, concatenate them into the result
if (subValues.length > 0) {
if (resultStr) resultStr += '、';
resultStr += `${classKey}:${subValues.join('、')}`;
}
});

return resultStr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ const PointCloud3D: React.FC<IA2MapStateProps> = ({
const [showDirection, setShowDirection] = useState(true);
const [isEnlarge, setIsEnlarge] = useState(false);
const ref = useRef<HTMLDivElement>(null);
const { initPointCloud3d } = usePointCloudViews();
const { initPointCloud3d, generateRects } = usePointCloudViews();
const size = useSize(ref);
const { t } = useTranslation();
const { value: toolStyle } = useToolStyleContext();
const { hiddenText } = toolStyle || {};
const { updatePointCloudAttribute } = usePointCloudAttribute(setResourceLoading, config);
const { updateSelectedBox } = useSingleBox({
generateRects,
});

useEffect(() => {
let pointCloud = ptCtx.mainViewInstance;
Expand Down Expand Up @@ -218,11 +221,18 @@ const PointCloud3D: React.FC<IA2MapStateProps> = ({
const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(currentData.result);
const currentSelectInfo = boxParamsList.find((item) => item.id === ptCtx.selectedID);
if (currentSelectInfo) {
// Update the border drawing position of the rectangle in the top view of the current page
ptCtx.topViewInstance?.updatePolygonList(boxParamsList, undefined);
updatePointCloudAttribute(currentSelectInfo.attribute);
// Update the size change of the currently selected rectangle
updateSelectedBox(currentSelectInfo);
// Because updatePolygonList will reset the selected state, it is necessary to reset the current rectangle selection
ptCtx.setSelectedIDs(currentSelectInfo.id);
}
ptCtx.setPointCloudValid(jsonParser(currentData.result)?.valid);
ptCtx.setPointCloudResult(boxParamsList);
ptCtx.setRectList(rectParamsList);
// Update the box of 3D view
pointCloud.generateBoxes(boxParamsList);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ const UnifyParamsModal = ({ id, visible, onCancel, config, imgList, imgIndex }:
config.inputList?.forEach((data) => {
const subData = values[data.value];
if (subData !== undefined) {
Object.assign(newSubAttribute, { [data.value]: subData });
// Compatible with multiple selections
const mapData = Array.isArray(subData) ? subData.join(';') : subData;
Object.assign(newSubAttribute, { [data.value]: mapData });
}
});

Expand Down Expand Up @@ -260,7 +262,7 @@ const UnifyParamsModal = ({ id, visible, onCancel, config, imgList, imgIndex }:
<div key={v.value} style={attributeStyle}>
<PrefixTag text={v.key} />
<Form.Item name={v.value} noStyle={true} required={false}>
<Select style={selectStyle}>
<Select style={selectStyle} mode={v.isMulti ? 'multiple' : undefined}>
{v.subSelected?.map((subData) => (
<Select.Option key={subData.value} value={subData.value}>
{subData.key}
Expand Down

0 comments on commit 51033b2

Please sign in to comment.