fix(jump): Jump to measurement wasn't jumping when presentation already existed (#3318)
* fix: Jump to measurement after presentation store * Fix initial load of DICOM SR * Fix measurement highlight issues * Clear measurements changed to array * Fix merge issues * PR comments * Removed unused formatting. Change to single event * Fix the unit test * PR review comments * refactor(viewport): simplify imports, align destructuring Simplify import statements by removing unused imports, organize existing imports, and align destructured imports consistently across the component. ---------
This commit is contained in:
1 parent
66f6e3eade
commit
b5b936b53e
21 files changed
+640
-298
No files matched your search
@@ -7,8 +7,8 @@ import React, {
|
||||
} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import isEqual from 'lodash.isequal';
|
||||
import { ViewportGridService } from '@ohif/core';
|
||||
import viewportLabels from '../utils/viewportLabels';
|
||||
import getPresentationIds from './getPresentationIds';
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
activeViewportIndex: 0,
|
||||
@@ -173,7 +173,7 @@ export function ViewportGridProvider({ children, service }) {
|
||||
displaySetOptions,
|
||||
viewportLabel: viewportLabels[viewportIndex],
|
||||
};
|
||||
viewportOptions.presentationIds = getPresentationIds(
|
||||
viewportOptions.presentationIds = ViewportGridService.getPresentationIds(
|
||||
newViewport,
|
||||
viewports
|
||||
);
|
||||
@@ -265,7 +265,7 @@ export function ViewportGridProvider({ children, service }) {
|
||||
state.viewports
|
||||
);
|
||||
if (!viewport.viewportOptions.presentationIds) {
|
||||
viewport.viewportOptions.presentationIds = getPresentationIds(
|
||||
viewport.viewportOptions.presentationIds = ViewportGridService.getPresentationIds(
|
||||
viewport,
|
||||
viewports
|
||||
);
|
||||
@@ -403,12 +403,16 @@ export function ViewportGridProvider({ children, service }) {
|
||||
getNumViewportPanes,
|
||||
]);
|
||||
|
||||
// run many of the calls through the service itself since we want to publish events
|
||||
const api = {
|
||||
getState,
|
||||
setActiveViewportIndex: index => service.setActiveViewportIndex(index), // run it through the service itself since we want to publish events
|
||||
setDisplaySetsForViewports,
|
||||
setLayout: layout => service.setLayout(layout), // run it through the service itself since we want to publish events
|
||||
reset,
|
||||
setActiveViewportIndex: index => service.setActiveViewportIndex(index),
|
||||
setDisplaySetsForViewport: props =>
|
||||
service.setDisplaySetsForViewports([props]),
|
||||
setDisplaySetsForViewports: props =>
|
||||
service.setDisplaySetsForViewports(props),
|
||||
setLayout: layout => service.setLayout(layout),
|
||||
reset: () => service.reset(),
|
||||
set: gridLayoutState => service.setState(gridLayoutState), // run it through the service itself since we want to publish events
|
||||
getNumViewportPanes,
|
||||
};
|
||||
@@ -422,9 +426,7 @@ export function ViewportGridProvider({ children, service }) {
|
||||
|
||||
ViewportGridProvider.propTypes = {
|
||||
children: PropTypes.any,
|
||||
service: PropTypes.shape({
|
||||
setServiceImplementation: PropTypes.func,
|
||||
}).isRequired,
|
||||
service: PropTypes.instanceOf(ViewportGridService).isRequired,
|
||||
};
|
||||
|
||||
export const useViewportGrid = () => useContext(ViewportGridContext);
|
||||
@@ -1,120 +0,0 @@
|
||||
const JOIN_STR = '&';
|
||||
|
||||
// The default lut presentation id if none defined
|
||||
const DEFAULT = 'default';
|
||||
|
||||
// This code finds the first unique index to add to the presentation id so that
|
||||
// two viewports containing the same display set in the same type of viewport
|
||||
// can have different presentation information. This allows comparison of
|
||||
// a single display set in two or more viewports, when the user has simply
|
||||
// dragged and dropped the view in twice. For example, it allows displaying
|
||||
// bone, brain and soft tissue views of a single display set, and to still
|
||||
// remember the specific changes to each viewport.
|
||||
const addUniqueIndex = (arr, key, viewports) => {
|
||||
arr.push(0);
|
||||
// The 128 is just a value that is larger than how many viewports we
|
||||
// display at once, used as an upper bound on how many unique presentation
|
||||
// ID's might exist for a single display set at once.
|
||||
for (let displayInstance = 0; displayInstance < 128; displayInstance++) {
|
||||
arr[arr.length - 1] = displayInstance;
|
||||
const testId = arr.join(JOIN_STR);
|
||||
if (
|
||||
!viewports.find(
|
||||
viewport => viewport.viewportOptions?.presentationIds?.[key] === testId
|
||||
)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getLutId = (ds): string => {
|
||||
if (!ds || !ds.options) return DEFAULT;
|
||||
if (ds.options.id) return ds.options.id;
|
||||
const arr = Object.entries(ds.options).map(([key, val]) => `${key}=${val}`);
|
||||
if (!arr.length) return DEFAULT;
|
||||
return arr.join(JOIN_STR);
|
||||
};
|
||||
|
||||
export type PresentationIds = {
|
||||
positionPresentationId?: string;
|
||||
lutPresentationId?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a set of presentation IDs for a viewport. The presentation IDs are
|
||||
* used to remember the presentation state of the viewport when it is navigated
|
||||
* to different layouts.
|
||||
*
|
||||
* The design of this is setup to allow preserving the view information in the
|
||||
* following cases:
|
||||
*
|
||||
*
|
||||
* * If a set of display sets was previously displayed in the same initial
|
||||
* position as it is currently being asked to be displayed,
|
||||
* then remember the camera position as previously displayed
|
||||
*
|
||||
* * If a set of display sets was previously displayed with the same initial
|
||||
* LUT conditions, then remember the last LUT displayed for that display set
|
||||
* and re-apply it.
|
||||
*
|
||||
* * Otherwise, apply the initial hanging protocol specified LUT and camera
|
||||
* position to new display sets.
|
||||
*
|
||||
* This means generating two presentationId keys:
|
||||
*
|
||||
* `positionPresentationId`
|
||||
*
|
||||
* Used for getting the camera/initial position state sync values.
|
||||
* This is a combination of:
|
||||
* * `viewportOptions.id`
|
||||
* * `viewportOptions.orientation`
|
||||
* * display set UID's - as displayed for this viewport, excluding seg
|
||||
* * a unique index number if the previous key is already displayed
|
||||
*
|
||||
* `lutPresentationId`
|
||||
*
|
||||
* Used for getting the voi LUT information. Generated from:
|
||||
*
|
||||
* * `displaySetOption[0].options` - including the id if present
|
||||
* * displaySetUID's
|
||||
* * a unique index number if the previously generated key is already
|
||||
* displayed.
|
||||
*
|
||||
* @param viewport requiring a presentation Id
|
||||
* @param viewports is the list of viewports being shown. Any presentation ID's
|
||||
* among them must not be re-used in order to have each viewport have it's own presentation ID.
|
||||
* @returns PresentationIds
|
||||
*/
|
||||
const getPresentationIds = (viewport, viewports): PresentationIds => {
|
||||
if (!viewport) return;
|
||||
const {
|
||||
viewportOptions,
|
||||
displaySetInstanceUIDs,
|
||||
displaySetOptions,
|
||||
} = viewport;
|
||||
if (!viewportOptions || !displaySetInstanceUIDs?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { id, orientation } = viewportOptions;
|
||||
const lutId = getLutId(displaySetOptions[0]);
|
||||
const lutPresentationArr = [lutId];
|
||||
|
||||
const positionPresentationArr = [orientation || 'acquisition'];
|
||||
if (id) positionPresentationArr.push(id);
|
||||
|
||||
for (const uid of displaySetInstanceUIDs) {
|
||||
positionPresentationArr.push(uid);
|
||||
lutPresentationArr.push(uid);
|
||||
}
|
||||
|
||||
addUniqueIndex(positionPresentationArr, 'positionPresentationId', viewports);
|
||||
addUniqueIndex(lutPresentationArr, 'lutPresentationId', viewports);
|
||||
|
||||
const lutPresentationId = lutPresentationArr.join(JOIN_STR);
|
||||
const positionPresentationId = positionPresentationArr.join(JOIN_STR);
|
||||
return { lutPresentationId, positionPresentationId };
|
||||
};
|
||||
|
||||
export default getPresentationIds;
|
||||
@@ -18,4 +18,4 @@ const StringNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||
*/
|
||||
const StringArray = PropTypes.oneOfType([PropTypes.string, PropTypes.array]);
|
||||
|
||||
export { StringNumber, StringArray, ThumbnailType, PresentationIds };
|
||||
export { StringNumber, StringArray, ThumbnailType };
|
||||
Reference in new issue
Block a user