Compare commits

..

2 Commits

Author SHA1 Message Date
mozzie
9917b77077 fff 2024-09-18 13:00:28 +08:00
mozzie
5814637d7a chore: remove unuse var 2024-09-18 12:59:40 +08:00

View File

@ -68,6 +68,7 @@ export const Viewer = () => {
const [imageIds, setImageIds] = useState<string[]>(); const [imageIds, setImageIds] = useState<string[]>();
const renderingEngineId = "renderEngineNo1"; const renderingEngineId = "renderEngineNo1";
const renderingEngineRef = useRef<RenderingEngine>(); const renderingEngineRef = useRef<RenderingEngine>();
const volumeRef = useRef<Record<string, any>>();
useEffect(() => { useEffect(() => {
cornerstoneTools.addTool(StackScrollMouseWheelTool); cornerstoneTools.addTool(StackScrollMouseWheelTool);
@ -89,10 +90,10 @@ export const Viewer = () => {
wadoRsRoot, wadoRsRoot,
}); });
// 这一步会对imageIds进行排序如果不排序imageIds会错误乱,stackViewport顺序会错误 // 这一步会对imageIds进行排序如果不排序imageIds会错误乱,stackViewport顺序会错误
const volume = await volumeLoader.createAndCacheVolume(volumeId, { volumeRef.current = await volumeLoader.createAndCacheVolume(volumeId, {
imageIds, imageIds
}); });
volume.load(); volumeRef.current.load();
const volumeViewportInput: PublicViewportInput[] = [ const volumeViewportInput: PublicViewportInput[] = [
{ {
@ -141,8 +142,8 @@ export const Viewer = () => {
stackViewportId stackViewportId
) as IStackViewport; ) as IStackViewport;
stackViewport.setStack(volume.imageIds); stackViewport.setStack(volumeRef.current.imageIds);
setImageIds(volume.imageIds); setImageIds(volumeRef.current.imageIds);
await setVolumesForViewports( await setVolumesForViewports(
renderingEngineRef.current, renderingEngineRef.current,
@ -201,7 +202,8 @@ export const Viewer = () => {
} }
// 默认windowWidtth // 默认windowWidtth
const { windowCenter, windowWidth } = volume.cornerstoneImageMetaData; const { windowCenter, windowWidth } =
volumeRef.current.cornerstoneImageMetaData;
console.log("默认窗宽/位: ", windowCenter, windowWidth); console.log("默认窗宽/位: ", windowCenter, windowWidth);
}; };
@ -219,10 +221,14 @@ export const Viewer = () => {
ToolGroupManager.destroyToolGroup(toolGroupMprId); ToolGroupManager.destroyToolGroup(toolGroupMprId);
ToolGroupManager.destroyToolGroup(toolGroupStackId); ToolGroupManager.destroyToolGroup(toolGroupStackId);
cornerstoneTools.removeTool(StackScrollMouseWheelTool); cornerstoneTools.removeTool(StackScrollMouseWheelTool);1
cornerstoneTools.removeTool(CrosshairsTool); cornerstoneTools.removeTool(CrosshairsTool);
cornerstoneTools.removeTool(WindowLevelTool); cornerstoneTools.removeTool(WindowLevelTool);
cornerstoneTools.removeTool(ZoomTool); cornerstoneTools.removeTool(ZoomTool);
renderingEngineRef.current
?.getVolumeViewports()
.forEach((vp) => vp.setVolumes([]));
}; };
}, [SeriesInstanceUID, StudyInstanceUID]); }, [SeriesInstanceUID, StudyInstanceUID]);