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:
commit
f3582e514e
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -268,6 +268,9 @@ class Viewer extends Component {
|
||||
{/* TOOLBAR */}
|
||||
<ErrorBoundaryDialog context="ToolbarRow">
|
||||
<ToolbarRow
|
||||
activeViewport={
|
||||
this.props.viewports[this.props.activeViewportIndex]
|
||||
}
|
||||
isLeftSidePanelOpen={this.state.isLeftSidePanelOpen}
|
||||
isRightSidePanelOpen={this.state.isRightSidePanelOpen}
|
||||
selectedLeftSidePanel={
|
||||
@ -320,11 +323,11 @@ class Viewer extends Component {
|
||||
activeIndex={this.props.activeViewportIndex}
|
||||
/>
|
||||
) : (
|
||||
<ConnectedStudyBrowser
|
||||
studies={this.state.thumbnails}
|
||||
studyMetadata={this.props.studies}
|
||||
/>
|
||||
)}
|
||||
<ConnectedStudyBrowser
|
||||
studies={this.state.thumbnails}
|
||||
studyMetadata={this.props.studies}
|
||||
/>
|
||||
)}
|
||||
</SidePanel>
|
||||
</ErrorBoundaryDialog>
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user