OHIF-198 - Jump to thumbnail when a new displaySet is added (#1834)
* Viewport letter only in multi-viewport layout. * If SliceThickness not available print N/A * Create displaySet in local session on SR generation. * Jump to thumbnail when a new displaySet is added with the madeInClient property. * Check if scrollIntoView exists.
This commit is contained in:
parent
eb8f3a63f2
commit
2c11609c55
@ -28,6 +28,8 @@ function PanelStudyBrowser({
|
|||||||
const [displaySets, setDisplaySets] = useState([]);
|
const [displaySets, setDisplaySets] = useState([]);
|
||||||
const [thumbnailImageSrcMap, setThumbnailImageSrcMap] = useState({});
|
const [thumbnailImageSrcMap, setThumbnailImageSrcMap] = useState({});
|
||||||
|
|
||||||
|
console.log(DisplaySetService);
|
||||||
|
|
||||||
// ~~ studyDisplayList
|
// ~~ studyDisplayList
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Fetch all studies for the patient in each primary study
|
// Fetch all studies for the patient in each primary study
|
||||||
@ -98,8 +100,9 @@ function PanelStudyBrowser({
|
|||||||
// DISPLAY_SETS_ADDED returns an array of DisplaySets that were added
|
// DISPLAY_SETS_ADDED returns an array of DisplaySets that were added
|
||||||
const SubscriptionDisplaySetsAdded = DisplaySetService.subscribe(
|
const SubscriptionDisplaySetsAdded = DisplaySetService.subscribe(
|
||||||
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
||||||
newDisplaySets => {
|
data => {
|
||||||
newDisplaySets.forEach(async dSet => {
|
const { displaySetsAdded } = data;
|
||||||
|
displaySetsAdded.forEach(async dSet => {
|
||||||
const newImageSrcEntry = {};
|
const newImageSrcEntry = {};
|
||||||
const displaySet = DisplaySetService.getDisplaySetByUID(
|
const displaySet = DisplaySetService.getDisplaySetByUID(
|
||||||
dSet.displaySetInstanceUID
|
dSet.displaySetInstanceUID
|
||||||
|
|||||||
@ -103,10 +103,11 @@ function _getDisplaySetsFromSeries(
|
|||||||
// Subscribe to new displaySets as the source may come in after.
|
// Subscribe to new displaySets as the source may come in after.
|
||||||
DisplaySetService.subscribe(
|
DisplaySetService.subscribe(
|
||||||
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
||||||
newDisplaySets => {
|
data => {
|
||||||
|
const { displaySetsAdded } = data;
|
||||||
// If there are still some measurements that have not yet been loaded into cornerstone,
|
// If there are still some measurements that have not yet been loaded into cornerstone,
|
||||||
// See if we can load them onto any of the new displaySets.
|
// See if we can load them onto any of the new displaySets.
|
||||||
newDisplaySets.forEach(newDisplaySet => {
|
displaySetsAdded.forEach(newDisplaySet => {
|
||||||
_checkIfCanAddMeasurementsToDisplaySet(
|
_checkIfCanAddMeasurementsToDisplaySet(
|
||||||
displaySet,
|
displaySet,
|
||||||
newDisplaySet,
|
newDisplaySet,
|
||||||
|
|||||||
@ -117,7 +117,7 @@ function PanelMeasurementTableTracking({ servicesManager, extensionManager }) {
|
|||||||
DICOMSR.downloadReport(trackedMeasurements, dataSource);
|
DICOMSR.downloadReport(trackedMeasurements, dataSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
const createReport = () => {
|
const createReport = async () => {
|
||||||
const measurements = MeasurementService.getMeasurements();
|
const measurements = MeasurementService.getMeasurements();
|
||||||
const trackedMeasurements = measurements.filter(
|
const trackedMeasurements = measurements.filter(
|
||||||
m =>
|
m =>
|
||||||
@ -134,7 +134,9 @@ function PanelMeasurementTableTracking({ servicesManager, extensionManager }) {
|
|||||||
trackedMeasurements,
|
trackedMeasurements,
|
||||||
dataSource,
|
dataSource,
|
||||||
naturalizedReport => {
|
naturalizedReport => {
|
||||||
DisplaySetService.makeDisplaySets([naturalizedReport]);
|
DisplaySetService.makeDisplaySets([naturalizedReport], {
|
||||||
|
madeInClient: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,6 +34,7 @@ function PanelStudyBrowserTracking({
|
|||||||
const [studyDisplayList, setStudyDisplayList] = useState([]);
|
const [studyDisplayList, setStudyDisplayList] = useState([]);
|
||||||
const [displaySets, setDisplaySets] = useState([]);
|
const [displaySets, setDisplaySets] = useState([]);
|
||||||
const [thumbnailImageSrcMap, setThumbnailImageSrcMap] = useState({});
|
const [thumbnailImageSrcMap, setThumbnailImageSrcMap] = useState({});
|
||||||
|
const [jumpToDisplaySet, setJumpToDisplaySet] = useState(null);
|
||||||
|
|
||||||
// TODO: Should this be somewhere else? Feels more like a mode "lifecycle" setup/destroy?
|
// TODO: Should this be somewhere else? Feels more like a mode "lifecycle" setup/destroy?
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -136,18 +137,26 @@ function PanelStudyBrowserTracking({
|
|||||||
// DISPLAY_SETS_ADDED returns an array of DisplaySets that were added
|
// DISPLAY_SETS_ADDED returns an array of DisplaySets that were added
|
||||||
const SubscriptionDisplaySetsAdded = DisplaySetService.subscribe(
|
const SubscriptionDisplaySetsAdded = DisplaySetService.subscribe(
|
||||||
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
||||||
newDisplaySets => {
|
data => {
|
||||||
newDisplaySets.forEach(async dSet => {
|
const { displaySetsAdded, options } = data;
|
||||||
|
displaySetsAdded.forEach(async dSet => {
|
||||||
|
const displaySetInstanceUID = dSet.displaySetInstanceUID;
|
||||||
|
|
||||||
const newImageSrcEntry = {};
|
const newImageSrcEntry = {};
|
||||||
const displaySet = DisplaySetService.getDisplaySetByUID(
|
const displaySet = DisplaySetService.getDisplaySetByUID(
|
||||||
dSet.displaySetInstanceUID
|
displaySetInstanceUID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (options.madeInClient) {
|
||||||
|
setJumpToDisplaySet(displaySetInstanceUID);
|
||||||
|
}
|
||||||
|
|
||||||
const imageIds = dataSource.getImageIdsForDisplaySet(displaySet);
|
const imageIds = dataSource.getImageIdsForDisplaySet(displaySet);
|
||||||
const imageId = imageIds[Math.floor(imageIds.length / 2)];
|
const imageId = imageIds[Math.floor(imageIds.length / 2)];
|
||||||
// TODO: Is it okay that imageIds are not returned here for SR displaysets?
|
// TODO: Is it okay that imageIds are not returned here for SR displaysets?
|
||||||
if (imageId) {
|
if (imageId) {
|
||||||
// When the image arrives, render it and store the result in the thumbnailImgSrcMap
|
// When the image arrives, render it and store the result in the thumbnailImgSrcMap
|
||||||
newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc(
|
newImageSrcEntry[displaySetInstanceUID] = await getImageSrc(
|
||||||
imageId
|
imageId
|
||||||
);
|
);
|
||||||
setThumbnailImageSrcMap(prevState => {
|
setThumbnailImageSrcMap(prevState => {
|
||||||
@ -214,6 +223,51 @@ function PanelStudyBrowserTracking({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (jumpToDisplaySet) {
|
||||||
|
// Get element by displaySetInstanceUID
|
||||||
|
const displaySetInstanceUID = jumpToDisplaySet;
|
||||||
|
const element = document.getElementById(
|
||||||
|
`thumbnail-${displaySetInstanceUID}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (element && typeof element.scrollIntoView === 'function') {
|
||||||
|
// TODO: Any way to support IE here?
|
||||||
|
element.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
|
||||||
|
setJumpToDisplaySet(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [jumpToDisplaySet, expandedStudyInstanceUIDs, activeTabName]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!jumpToDisplaySet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const displaySetInstanceUID = jumpToDisplaySet;
|
||||||
|
// Set the activeTabName and expand the study
|
||||||
|
const thumbnailLocation = _findTabAndStudyOfDisplaySet(
|
||||||
|
displaySetInstanceUID,
|
||||||
|
tabs
|
||||||
|
);
|
||||||
|
if (!thumbnailLocation) {
|
||||||
|
console.warn('jumpToThumbnail: displaySet thumbnail not found.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { tabName, StudyInstanceUID } = thumbnailLocation;
|
||||||
|
setActiveTabName(tabName);
|
||||||
|
const studyExpanded = expandedStudyInstanceUIDs.includes(StudyInstanceUID);
|
||||||
|
if (!studyExpanded) {
|
||||||
|
const updatedExpandedStudyInstanceUIDs = [
|
||||||
|
...expandedStudyInstanceUIDs,
|
||||||
|
StudyInstanceUID,
|
||||||
|
];
|
||||||
|
setExpandedStudyInstanceUIDs(updatedExpandedStudyInstanceUIDs);
|
||||||
|
}
|
||||||
|
}, [jumpToDisplaySet]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StudyBrowser
|
<StudyBrowser
|
||||||
tabs={tabs}
|
tabs={tabs}
|
||||||
@ -401,3 +455,24 @@ function _createStudyBrowserTabs(
|
|||||||
|
|
||||||
return tabs;
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs) {
|
||||||
|
for (let t = 0; t < tabs.length; t++) {
|
||||||
|
const { studies } = tabs[t];
|
||||||
|
|
||||||
|
for (let s = 0; s < studies.length; s++) {
|
||||||
|
const { displaySets } = studies[s];
|
||||||
|
|
||||||
|
for (let d = 0; d < displaySets.length; d++) {
|
||||||
|
const displaySet = displaySets[d];
|
||||||
|
|
||||||
|
if (displaySet.displaySetInstanceUID === displaySetInstanceUID) {
|
||||||
|
return {
|
||||||
|
tabName: tabs[t].name,
|
||||||
|
StudyInstanceUID: studies[s].studyInstanceUid,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ export default class DisplaySetService {
|
|||||||
displaySet => displaySet.displaySetInstanceUID === displaySetInstanceUid
|
displaySet => displaySet.displaySetInstanceUID === displaySetInstanceUid
|
||||||
);
|
);
|
||||||
|
|
||||||
makeDisplaySets = (input, batch = false) => {
|
makeDisplaySets = (input, { batch = false, madeInClient = false } = {}) => {
|
||||||
if (!input || !input.length) {
|
if (!input || !input.length) {
|
||||||
throw new Error('No instances were provided.');
|
throw new Error('No instances were provided.');
|
||||||
}
|
}
|
||||||
@ -78,11 +78,20 @@ export default class DisplaySetService {
|
|||||||
displaySetsAdded = displaySets;
|
displaySetsAdded = displaySets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const options = {};
|
||||||
|
|
||||||
|
if (madeInClient) {
|
||||||
|
options.madeInClient = true;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: This is tricky. How do we know we're not resetting to the same/existing DSs?
|
// TODO: This is tricky. How do we know we're not resetting to the same/existing DSs?
|
||||||
// TODO: This is likely run anytime we touch DicomMetadataStore. How do we prevent uneccessary broadcasts?
|
// TODO: This is likely run anytime we touch DicomMetadataStore. How do we prevent uneccessary broadcasts?
|
||||||
if (displaySetsAdded && displaySetsAdded.length) {
|
if (displaySetsAdded && displaySetsAdded.length) {
|
||||||
this._broadcastEvent(EVENTS.DISPLAY_SETS_ADDED, displaySetsAdded);
|
|
||||||
this._broadcastEvent(EVENTS.DISPLAY_SETS_CHANGED, this.activeDisplaySets);
|
this._broadcastEvent(EVENTS.DISPLAY_SETS_CHANGED, this.activeDisplaySets);
|
||||||
|
this._broadcastEvent(EVENTS.DISPLAY_SETS_ADDED, {
|
||||||
|
displaySetsAdded,
|
||||||
|
options,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { Icon } from '@ohif/ui';
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const Thumbnail = ({
|
const Thumbnail = ({
|
||||||
|
displaySetInstanceUID,
|
||||||
className,
|
className,
|
||||||
imageSrc,
|
imageSrc,
|
||||||
imageAltText,
|
imageAltText,
|
||||||
@ -36,6 +37,7 @@ const Thumbnail = ({
|
|||||||
className,
|
className,
|
||||||
'flex flex-col flex-1 px-3 mb-8 cursor-pointer outline-none'
|
'flex flex-col flex-1 px-3 mb-8 cursor-pointer outline-none'
|
||||||
)}
|
)}
|
||||||
|
id={`thumbnail-${displaySetInstanceUID}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onKeyDown={onClick}
|
onKeyDown={onClick}
|
||||||
role="button"
|
role="button"
|
||||||
|
|||||||
@ -33,6 +33,7 @@ const ThumbnailList = ({
|
|||||||
return (
|
return (
|
||||||
<Thumbnail
|
<Thumbnail
|
||||||
key={displaySetInstanceUID}
|
key={displaySetInstanceUID}
|
||||||
|
displaySetInstanceUID={displaySetInstanceUID}
|
||||||
dragData={dragData}
|
dragData={dragData}
|
||||||
description={description}
|
description={description}
|
||||||
seriesNumber={seriesNumber}
|
seriesNumber={seriesNumber}
|
||||||
@ -48,6 +49,7 @@ const ThumbnailList = ({
|
|||||||
return (
|
return (
|
||||||
<ThumbnailTracked
|
<ThumbnailTracked
|
||||||
key={displaySetInstanceUID}
|
key={displaySetInstanceUID}
|
||||||
|
displaySetInstanceUID={displaySetInstanceUID}
|
||||||
dragData={dragData}
|
dragData={dragData}
|
||||||
description={description}
|
description={description}
|
||||||
seriesNumber={seriesNumber}
|
seriesNumber={seriesNumber}
|
||||||
@ -65,6 +67,7 @@ const ThumbnailList = ({
|
|||||||
return (
|
return (
|
||||||
<ThumbnailNoImage
|
<ThumbnailNoImage
|
||||||
key={displaySetInstanceUID}
|
key={displaySetInstanceUID}
|
||||||
|
displaySetInstanceUID={displaySetInstanceUID}
|
||||||
dragData={dragData}
|
dragData={dragData}
|
||||||
modality={modality}
|
modality={modality}
|
||||||
seriesDate={seriesDate}
|
seriesDate={seriesDate}
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import classnames from 'classnames';
|
||||||
import { useDrag } from 'react-dnd';
|
import { useDrag } from 'react-dnd';
|
||||||
|
|
||||||
import { Icon } from '@ohif/ui';
|
import { Icon } from '@ohif/ui';
|
||||||
|
|
||||||
const ThumbnailNoImage = ({
|
const ThumbnailNoImage = ({
|
||||||
|
displaySetInstanceUID,
|
||||||
description,
|
description,
|
||||||
seriesDate,
|
seriesDate,
|
||||||
modality,
|
modality,
|
||||||
@ -21,7 +23,8 @@ const ThumbnailNoImage = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={drag}
|
ref={drag}
|
||||||
className="flex flex-row flex-1 px-4 py-3 cursor-pointer"
|
className={'flex flex-row flex-1 px-4 py-3 cursor-pointer'}
|
||||||
|
id={`thumbnail-${displaySetInstanceUID}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onKeyDown={onClick}
|
onKeyDown={onClick}
|
||||||
role="button"
|
role="button"
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import classnames from 'classnames';
|
|||||||
import { Icon, Thumbnail, Tooltip } from '@ohif/ui';
|
import { Icon, Thumbnail, Tooltip } from '@ohif/ui';
|
||||||
|
|
||||||
const ThumbnailTracked = ({
|
const ThumbnailTracked = ({
|
||||||
|
displaySetInstanceUID,
|
||||||
className,
|
className,
|
||||||
imageSrc,
|
imageSrc,
|
||||||
imageAltText,
|
imageAltText,
|
||||||
@ -26,6 +27,7 @@ const ThumbnailTracked = ({
|
|||||||
'flex flex-row flex-1 px-3 py-2 cursor-pointer outline-none',
|
'flex flex-row flex-1 px-3 py-2 cursor-pointer outline-none',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
id={`thumbnail-${displaySetInstanceUID}`}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col items-center flex-2">
|
<div className="flex flex-col items-center flex-2">
|
||||||
<div
|
<div
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user