From 2df8e1d5cd7a203bdde1cac6230b60a0b87bfcdd Mon Sep 17 00:00:00 2001
From: Joe Boccanfuso <109477394+jbocce@users.noreply.github.com>
Date: Wed, 18 Dec 2024 15:06:06 -0500
Subject: [PATCH] fix(SR): Bring back the onModeEnter for the
cornerstone-dicom-sr extension that was accidentally removed by PR #4586
(#4616)
---
extensions/cornerstone-dicom-sr/src/index.tsx | 27 +------------
.../cornerstone-dicom-sr/src/onModeEnter.js | 15 -------
.../cornerstone-dicom-sr/src/onModeEnter.tsx | 39 +++++++++++++++++++
3 files changed, 41 insertions(+), 40 deletions(-)
delete mode 100644 extensions/cornerstone-dicom-sr/src/onModeEnter.js
create mode 100644 extensions/cornerstone-dicom-sr/src/onModeEnter.tsx
diff --git a/extensions/cornerstone-dicom-sr/src/index.tsx b/extensions/cornerstone-dicom-sr/src/index.tsx
index ff0c9e3cf9a..b6ca6efd2ee 100644
--- a/extensions/cornerstone-dicom-sr/src/index.tsx
+++ b/extensions/cornerstone-dicom-sr/src/index.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import getSopClassHandlerModule from './getSopClassHandlerModule';
import { srProtocol } from './getHangingProtocolModule';
+import onModeEnter from './onModeEnter';
import getCommandsModule from './commandsModule';
import preRegistration from './init';
import { id } from './id.js';
@@ -8,8 +9,6 @@ import toolNames from './tools/toolNames';
import hydrateStructuredReport from './utils/hydrateStructuredReport';
import createReferencedImageDisplaySet from './utils/createReferencedImageDisplaySet';
import Enums from './enums';
-import { ViewportActionButton } from '@ohif/ui';
-import i18n from '@ohif/i18n';
const Component = React.lazy(() => {
return import(/* webpackPrefetch: true */ './components/OHIFCornerstoneSRViewport');
@@ -32,29 +31,7 @@ const dicomSRExtension = {
*/
id,
- onModeEnter({ servicesManager }) {
- const { toolbarService } = servicesManager.services;
-
- toolbarService.addButtons([
- {
- // A base/default button for loading measurements. It is added to the toolbar below.
- // Customizations to this button can be made in the mode or by another extension.
- // For example, the button label can be changed and/or the command to clear
- // the measurements can be dropped.
- id: 'loadSRMeasurements',
- component: props => (
- {i18n.t('Common:LOAD')}
- ),
- props: {
- commands: ['clearMeasurements', 'loadSRMeasurements'],
- },
- },
- ]);
-
- // The toolbar used in the viewport's status bar. Modes and extensions can further customize
- // it to optionally add other buttons.
- toolbarService.createButtonSection('loadSRMeasurements', ['loadSRMeasurements']);
- },
+ onModeEnter,
preRegistration,
diff --git a/extensions/cornerstone-dicom-sr/src/onModeEnter.js b/extensions/cornerstone-dicom-sr/src/onModeEnter.js
deleted file mode 100644
index a2387720438..00000000000
--- a/extensions/cornerstone-dicom-sr/src/onModeEnter.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import { SOPClassHandlerId, SOPClassHandlerId3D } from './id';
-
-export default function onModeEnter({ servicesManager }) {
- const { displaySetService } = servicesManager.services;
- const displaySetCache = displaySetService.getDisplaySetCache();
-
- const srDisplaySets = [...displaySetCache.values()].filter(
- ds => ds.SOPClassHandlerId === SOPClassHandlerId || ds.SOPClassHandlerId === SOPClassHandlerId3D
- );
-
- srDisplaySets.forEach(ds => {
- // New mode route, allow SRs to be hydrated again
- ds.isHydrated = false;
- });
-}
diff --git a/extensions/cornerstone-dicom-sr/src/onModeEnter.tsx b/extensions/cornerstone-dicom-sr/src/onModeEnter.tsx
new file mode 100644
index 00000000000..603e46f9b27
--- /dev/null
+++ b/extensions/cornerstone-dicom-sr/src/onModeEnter.tsx
@@ -0,0 +1,39 @@
+import React from 'react';
+
+import { SOPClassHandlerId, SOPClassHandlerId3D } from './id';
+import { ViewportActionButton } from '@ohif/ui';
+import i18n from '@ohif/i18n';
+
+export default function onModeEnter({ servicesManager }) {
+ const { displaySetService, toolbarService } = servicesManager.services;
+ const displaySetCache = displaySetService.getDisplaySetCache();
+
+ const srDisplaySets = [...displaySetCache.values()].filter(
+ ds => ds.SOPClassHandlerId === SOPClassHandlerId || ds.SOPClassHandlerId === SOPClassHandlerId3D
+ );
+
+ srDisplaySets.forEach(ds => {
+ // New mode route, allow SRs to be hydrated again
+ ds.isHydrated = false;
+ });
+
+ toolbarService.addButtons([
+ {
+ // A base/default button for loading measurements. It is added to the toolbar below.
+ // Customizations to this button can be made in the mode or by another extension.
+ // For example, the button label can be changed and/or the command to clear
+ // the measurements can be dropped.
+ id: 'loadSRMeasurements',
+ component: props => (
+ {i18n.t('Common:LOAD')}
+ ),
+ props: {
+ commands: ['clearMeasurements', 'loadSRMeasurements'],
+ },
+ },
+ ]);
+
+ // The toolbar used in the viewport's status bar. Modes and extensions can further customize
+ // it to optionally add other buttons.
+ toolbarService.createButtonSection('loadSRMeasurements', ['loadSRMeasurements']);
+}