Merge pull request #2244 from OHIF/IDC-2123

feat(IDC-2123): When RTSTRUCT does not apply to the specific image series, the button and the panel should not be shown
This commit is contained in:
Igor Octaviano 2021-01-21 14:30:41 -03:00 committed by GitHub
commit f3582e514e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 27 deletions

View File

@ -5,6 +5,9 @@ import id from './id.js';
import RTPanel from './components/RTPanel/RTPanel'; import RTPanel from './components/RTPanel/RTPanel';
import { version } from '../package.json'; import { version } from '../package.json';
import { utils } from '@ohif/core';
const { studyMetadataManager } = utils;
export default { export default {
/** /**
* Only required property. Should be a unique value across all extensions. * Only required property. Should be a unique value across all extensions.
@ -45,26 +48,36 @@ export default {
icon: 'list', icon: 'list',
label: 'RTSTRUCT', label: 'RTSTRUCT',
target: 'rt-panel', target: 'rt-panel',
isDisabled: studies => { isDisabled: (studies, activeViewport) => {
if (!studies) { if (!studies) {
return true; return true;
} }
for (let i = 0; i < studies.length; i++) { if (activeViewport) {
const study = studies[i]; const study = studies.find(
s => s.StudyInstanceUID === activeViewport.StudyInstanceUID
if (study && study.series) { );
for (let j = 0; j < study.series.length; j++) { const ds = study.displaySets.find(
const series = study.series[j]; ds =>
ds.displaySetInstanceUID ===
activeViewport.displaySetInstanceUID
);
const studyMetadata = studyMetadataManager.get(
activeViewport.StudyInstanceUID
);
const referencedDisplaySets = studyMetadata.getDerivedDatasets({
referencedSeriesInstanceUID: activeViewport.SeriesInstanceUID,
Modality: 'RTSTRUCT',
});
if ( if (
/* Could be expanded to contain RTPLAN and RTDOSE information in the future */ referencedDisplaySets &&
['RTSTRUCT'].includes(series.Modality) referencedDisplaySets.some(ds =>
['RTSTRUCT'].includes(ds.Modality)
)
) { ) {
return false; return false;
} }
} }
}
}
return true; return true;
}, },

View File

@ -86,7 +86,7 @@ class ToolbarRow extends Component {
// Note: This does not cleanly handle `studies` prop updating with panel open // Note: This does not cleanly handle `studies` prop updating with panel open
const isDisabled = const isDisabled =
typeof menuOption.isDisabled === 'function' && typeof menuOption.isDisabled === 'function' &&
menuOption.isDisabled(this.props.studies); menuOption.isDisabled(this.props.studies, this.props.activeViewport);
if (hasActiveContext && !isDisabled) { if (hasActiveContext && !isDisabled) {
const menuOptionEntry = { const menuOptionEntry = {
@ -114,25 +114,30 @@ class ToolbarRow extends Component {
prevProps.activeContexts !== this.props.activeContexts; prevProps.activeContexts !== this.props.activeContexts;
const prevStudies = prevProps.studies; const prevStudies = prevProps.studies;
const prevActiveViewport = prevProps.activeViewport;
const activeViewport = this.props.activeViewport;
const studies = this.props.studies; const studies = this.props.studies;
const seriesPerStudyCount = this.seriesPerStudyCount; const seriesPerStudyCount = this.seriesPerStudyCount;
let studiesUpdated = false; let shouldUpdate = false;
if (prevStudies.length !== studies.length) { if (
studiesUpdated = true; prevStudies.length !== studies.length ||
prevActiveViewport !== activeViewport
) {
shouldUpdate = true;
} else { } else {
for (let i = 0; i < studies.length; i++) { for (let i = 0; i < studies.length; i++) {
if (studies[i].series.length !== seriesPerStudyCount[i]) { if (studies[i].series.length !== seriesPerStudyCount[i]) {
seriesPerStudyCount[i] = studies[i].series.length; seriesPerStudyCount[i] = studies[i].series.length;
studiesUpdated = true; shouldUpdate = true;
break; break;
} }
} }
} }
if (studiesUpdated) { if (shouldUpdate) {
this.updateButtonGroups(); this.updateButtonGroups();
} }

View File

@ -268,6 +268,9 @@ class Viewer extends Component {
{/* TOOLBAR */} {/* TOOLBAR */}
<ErrorBoundaryDialog context="ToolbarRow"> <ErrorBoundaryDialog context="ToolbarRow">
<ToolbarRow <ToolbarRow
activeViewport={
this.props.viewports[this.props.activeViewportIndex]
}
isLeftSidePanelOpen={this.state.isLeftSidePanelOpen} isLeftSidePanelOpen={this.state.isLeftSidePanelOpen}
isRightSidePanelOpen={this.state.isRightSidePanelOpen} isRightSidePanelOpen={this.state.isRightSidePanelOpen}
selectedLeftSidePanel={ selectedLeftSidePanel={
@ -347,7 +350,9 @@ class Viewer extends Component {
viewports={this.props.viewports} viewports={this.props.viewports}
studies={this.props.studies} studies={this.props.studies}
activeIndex={this.props.activeViewportIndex} activeIndex={this.props.activeViewportIndex}
activeViewport={this.props.viewports[this.props.activeViewportIndex]} activeViewport={
this.props.viewports[this.props.activeViewportIndex]
}
getActiveViewport={this._getActiveViewport} getActiveViewport={this._getActiveViewport}
/> />
)} )}
@ -371,7 +376,7 @@ export default withDialog(Viewer);
* @param {Study[]} studies * @param {Study[]} studies
* @param {DisplaySet[]} studies[].displaySets * @param {DisplaySet[]} studies[].displaySets
*/ */
const _mapStudiesToThumbnails = function (studies) { const _mapStudiesToThumbnails = function(studies) {
return studies.map(study => { return studies.map(study => {
const { StudyInstanceUID } = study; const { StudyInstanceUID } = study;