Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { useLutPresentationStore } from '../../stores/useLutPresentationStore';
import { usePositionPresentationStore } from '../../stores/usePositionPresentationStore';
import { useSynchronizersStore } from '../../stores/useSynchronizersStore';
import { useSegmentationPresentationStore } from '../../stores/useSegmentationPresentationStore';
import getClosestOrientationFromIOP from '../../utils/isReferenceViewable';

const EVENTS = {
VIEWPORT_DATA_CHANGED: 'event::cornerstoneViewportService:viewportDataChanged',
Expand Down Expand Up @@ -613,6 +614,9 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
* case where the user is in MPR and a viewport other than active should be
* the one to change to display the iamge.
*
* Third choice is to use a viewport whose orientation best matches the
* measurement when no other viewport qualifies.
*
* Final choice is to use the provide activeViewportId. This will cover
* changes to/from video and wsi viewports and other cases where no
* viewport is really even close to being able to display the measurement.
Expand Down Expand Up @@ -669,6 +673,30 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
}
}

// Use a viewport with matching orientation when no displaySet match is found.
const closestOrientation = getClosestOrientationFromIOP(
displaySetService,
displaySetInstanceUID
);

for (const id of this.viewportsById.keys()) {
const viewportOptions = this.getViewportOptions(id);

if (!viewportOptions) {
continue;
}

const { orientation } = viewportOptions;

if (closestOrientation === orientation) {
return {
viewportId: id,
displaySetInstanceUID,
viewportOptions: { orientation: closestOrientation, viewportType },
};
}
}

// Just display in the active viewport
return {
viewportId: activeViewportId,
Expand Down