2026-05-24-19-17-13 补齐位姿精度并隐藏自动拉伸成功提示

This commit is contained in:
2026-05-24 19:24:26 +08:00
parent b6e6ace233
commit e380a19acb
9 changed files with 174 additions and 14 deletions

View File

@@ -155,6 +155,12 @@ const defaultModelPose: ModelPoseValue = {
flipY: false,
flipZ: false,
};
const modelPoseValuePrecision: Partial<Record<keyof ModelPoseValue, number>> = {
translateX: 3,
translateY: 3,
translateZ: 3,
scale: 3,
};
interface DicomAttributes {
patientName: string;
@@ -442,9 +448,11 @@ function defaultModelPoses(): ModelPoseRecord[] {
function normalizeModelPoseValue(value: Partial<ModelPoseValue> | undefined): ModelPoseValue {
const read = (key: keyof ModelPoseValue, fallback: number, min: number, max: number) => {
const nextValue = value?.[key];
return typeof nextValue === 'number' && Number.isFinite(nextValue)
const clampedValue = typeof nextValue === 'number' && Number.isFinite(nextValue)
? clampNumber(nextValue, min, max)
: fallback;
const precision = modelPoseValuePrecision[key];
return typeof precision === 'number' ? Number(clampedValue.toFixed(precision)) : clampedValue;
};
const readBoolean = (key: keyof ModelPoseValue, fallback: boolean) => (
typeof value?.[key] === 'boolean' ? Boolean(value?.[key]) : fallback

View File

@@ -3027,15 +3027,10 @@ export default function ReverseWorkspace({
dicomSize.y / (Math.max(rotatedSize.y, 1e-6) * baseScale),
dicomSize.z / (Math.max(rotatedSize.z, 1e-6) * baseScale),
);
const limitedByVolume = axisFitScale > containmentScale + 1e-6;
const nextScale = clampPoseValue('scale', Math.min(axisFitScale, containmentScale));
const nextPose = { ...modelPose, scale: nextScale };
updateModelPose({ scale: nextScale }, { markCustom: !options.silentInitial, keepStatus: true });
setPoseImportStatus(
limitedByVolume
? `已按 ${axis.toUpperCase()} 方向拉伸,并限制在 DICOM 体范围内`
: `已按 ${axis.toUpperCase()} 方向进行三维等比例拉伸`,
);
setPoseImportStatus('');
if (options.silentInitial) {
savedWorkspaceSnapshotRef.current = createWorkspaceSnapshot({
modelPose: nextPose,