fix capture not maintaining flip/rotate state (#5843)

* fix capture not maintaining flip/rotate state

* fix capture not maintaining flip/rotate state

---------

Co-authored-by: silasshellenbarger <sdshe@Silas-Computer.localdomain>
This commit is contained in:
Silas Shellenbarger 2026-02-28 04:50:35 -05:00 committed by GitHub
parent 2b486f16ed
commit 6a3caa1ac9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,33 +118,50 @@ const CornerstoneViewportDownloadForm = ({
const downloadViewport = renderingEngine.getViewport(VIEWPORT_ID);
try {
// Capture current viewport state
// - properties: VOI, colormap, interpolation, etc.
// - viewPresentation: flip/rotate/zoom presentation state added for
// saving flip and rotation for capture
// - viewReference: image/volume reference
const properties = viewport.getProperties();
const viewPresentation = viewport.getViewPresentation?.();
const viewRef = viewport.getViewReference?.();
if (downloadViewport instanceof StackViewport) {
const imageId = viewport.getCurrentImageId();
await downloadViewport.setStack([imageId]);
downloadViewport.setProperties(properties);
} else if (downloadViewport instanceof BaseVolumeViewport) {
const volumeIds = viewport.getAllVolumeIds();
await downloadViewport.setVolumes([{ volumeId: volumeIds[0] }]);
}
// Apply presentation state so captured image preserves flip/rotate
if (viewPresentation && downloadViewport.setViewPresentation) {
downloadViewport.setViewPresentation(viewPresentation);
}
// Apply viewport display properties
downloadViewport.setProperties(properties);
const viewRef = viewport.getViewReference();
downloadViewport.setViewReference(viewRef);
// Ensure correct image/volume reference
if (viewRef && downloadViewport.setViewReference) {
downloadViewport.setViewReference(viewRef);
}
downloadViewport.render();
// Re-apply segmentation overlays to the download viewport
if (segmentationRepresentations?.length) {
segmentationRepresentations.forEach(segRepresentation => {
const { segmentationId, colorLUTIndex, type } = segRepresentation;
if (type === Enums.SegmentationRepresentations.Labelmap) {
segmentation.addLabelmapRepresentationToViewportMap({
[downloadViewport.id]: [
{
segmentationId,
type: Enums.SegmentationRepresentations.Labelmap,
config: {
colorLUTOrIndex: colorLUTIndex,
},
config: { colorLUTOrIndex: colorLUTIndex },
},
],
});
@ -156,9 +173,7 @@ const CornerstoneViewportDownloadForm = ({
{
segmentationId,
type: Enums.SegmentationRepresentations.Contour,
config: {
colorLUTOrIndex: colorLUTIndex,
},
config: { colorLUTOrIndex: colorLUTIndex },
},
],
});