From 77c7463c5380f34472b61711154b11d0d74c3830 Mon Sep 17 00:00:00 2001 From: igoroctaviano Date: Tue, 19 Jan 2021 17:56:41 -0300 Subject: [PATCH] RTSTRUCT does not apply to the specific image series, the button and the panel should not be shown --- extensions/dicom-rt/src/index.js | 41 ++++++++++++------- .../src/connectedComponents/ToolbarRow.js | 17 +++++--- .../viewer/src/connectedComponents/Viewer.js | 19 +++++---- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/extensions/dicom-rt/src/index.js b/extensions/dicom-rt/src/index.js index 44001d61b..f6a278007 100644 --- a/extensions/dicom-rt/src/index.js +++ b/extensions/dicom-rt/src/index.js @@ -5,6 +5,9 @@ import id from './id.js'; import RTPanel from './components/RTPanel/RTPanel'; import { version } from '../package.json'; +import { utils } from '@ohif/core'; +const { studyMetadataManager } = utils; + export default { /** * Only required property. Should be a unique value across all extensions. @@ -45,24 +48,34 @@ export default { icon: 'list', label: 'RTSTRUCT', target: 'rt-panel', - isDisabled: studies => { + isDisabled: (studies, activeViewport) => { if (!studies) { return true; } - for (let i = 0; i < studies.length; i++) { - const study = studies[i]; - - if (study && study.series) { - for (let j = 0; j < study.series.length; j++) { - const series = study.series[j]; - if ( - /* Could be expanded to contain RTPLAN and RTDOSE information in the future */ - ['RTSTRUCT'].includes(series.Modality) - ) { - return false; - } - } + if (activeViewport) { + const study = studies.find( + s => s.StudyInstanceUID === activeViewport.StudyInstanceUID + ); + const ds = study.displaySets.find( + ds => + ds.displaySetInstanceUID === + activeViewport.displaySetInstanceUID + ); + const studyMetadata = studyMetadataManager.get( + activeViewport.StudyInstanceUID + ); + const referencedDisplaySets = studyMetadata.getDerivedDatasets({ + referencedSeriesInstanceUID: activeViewport.SeriesInstanceUID, + Modality: 'RTSTRUCT', + }); + if ( + referencedDisplaySets && + referencedDisplaySets.some(ds => + ['RTSTRUCT'].includes(ds.Modality) + ) + ) { + return false; } } diff --git a/platform/viewer/src/connectedComponents/ToolbarRow.js b/platform/viewer/src/connectedComponents/ToolbarRow.js index b03f778bc..d2022e3f5 100644 --- a/platform/viewer/src/connectedComponents/ToolbarRow.js +++ b/platform/viewer/src/connectedComponents/ToolbarRow.js @@ -86,7 +86,7 @@ class ToolbarRow extends Component { // Note: This does not cleanly handle `studies` prop updating with panel open const isDisabled = typeof menuOption.isDisabled === 'function' && - menuOption.isDisabled(this.props.studies); + menuOption.isDisabled(this.props.studies, this.props.activeViewport); if (hasActiveContext && !isDisabled) { const menuOptionEntry = { @@ -114,25 +114,30 @@ class ToolbarRow extends Component { prevProps.activeContexts !== this.props.activeContexts; const prevStudies = prevProps.studies; + const prevActiveViewport = prevProps.activeViewport; + const activeViewport = this.props.activeViewport; const studies = this.props.studies; const seriesPerStudyCount = this.seriesPerStudyCount; - let studiesUpdated = false; + let shouldUpdate = false; - if (prevStudies.length !== studies.length) { - studiesUpdated = true; + if ( + prevStudies.length !== studies.length || + prevActiveViewport !== activeViewport + ) { + shouldUpdate = true; } else { for (let i = 0; i < studies.length; i++) { if (studies[i].series.length !== seriesPerStudyCount[i]) { seriesPerStudyCount[i] = studies[i].series.length; - studiesUpdated = true; + shouldUpdate = true; break; } } } - if (studiesUpdated) { + if (shouldUpdate) { this.updateButtonGroups(); } diff --git a/platform/viewer/src/connectedComponents/Viewer.js b/platform/viewer/src/connectedComponents/Viewer.js index 4cf756737..9e349f3ca 100644 --- a/platform/viewer/src/connectedComponents/Viewer.js +++ b/platform/viewer/src/connectedComponents/Viewer.js @@ -268,6 +268,9 @@ class Viewer extends Component { {/* TOOLBAR */} ) : ( - - )} + + )} @@ -347,7 +350,9 @@ class Viewer extends Component { viewports={this.props.viewports} studies={this.props.studies} activeIndex={this.props.activeViewportIndex} - activeViewport={this.props.viewports[this.props.activeViewportIndex]} + activeViewport={ + this.props.viewports[this.props.activeViewportIndex] + } getActiveViewport={this._getActiveViewport} /> )} @@ -371,7 +376,7 @@ export default withDialog(Viewer); * @param {Study[]} studies * @param {DisplaySet[]} studies[].displaySets */ -const _mapStudiesToThumbnails = function (studies) { +const _mapStudiesToThumbnails = function(studies) { return studies.map(study => { const { StudyInstanceUID } = study;