@ohif/extension-default 3.14.0-beta.10 → 3.14.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohif-extension-default.css +1 -1
- package/dist/ohif-extension-default.umd.js +1 -1
- package/package.json +14 -10
- package/src/Actions/createReportAsync.tsx +45 -0
- package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
- package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
- package/src/Components/ItemListComponent.tsx +95 -0
- package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
- package/src/Components/LineChartViewport/index.ts +1 -0
- package/src/Components/MoreDropdownMenu.tsx +112 -0
- package/src/Components/ProgressDropdownWithService.tsx +101 -0
- package/src/Components/SidePanelWithServices.tsx +122 -0
- package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
- package/src/CustomizableContextMenu/index.ts +5 -0
- package/src/CustomizableContextMenu/types.ts +126 -0
- package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
- package/src/DicomJSONDataSource/index.js +326 -0
- package/src/DicomLocalDataSource/index.js +273 -0
- package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
- package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
- package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
- package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
- package/src/DicomWebDataSource/exampleInstances.js +280 -0
- package/src/DicomWebDataSource/index.ts +808 -0
- package/src/DicomWebDataSource/qido.js +215 -0
- package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
- package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
- package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
- package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
- package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
- package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
- package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
- package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
- package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
- package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
- package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
- package/src/DicomWebDataSource/utils/getImageId.js +54 -0
- package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
- package/src/DicomWebDataSource/utils/index.ts +9 -0
- package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
- package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
- package/src/DicomWebProxyDataSource/index.ts +90 -0
- package/src/MergeDataSource/index.test.ts +212 -0
- package/src/MergeDataSource/index.ts +319 -0
- package/src/MergeDataSource/types.ts +46 -0
- package/src/Panels/DataSourceSelector.tsx +55 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
- package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
- package/src/Panels/StudyBrowser/constants/index.ts +4 -0
- package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
- package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
- package/src/Panels/StudyBrowser/types/index.ts +4 -0
- package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
- package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
- package/src/Panels/createReportDialogPrompt.tsx +128 -0
- package/src/Panels/debounce.js +25 -0
- package/src/Panels/getImageSrcFromImageId.js +16 -0
- package/src/Panels/getStudiesForPatientByMRN.js +19 -0
- package/src/Panels/index.js +5 -0
- package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
- package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
- package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
- package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
- package/src/Toolbar/ToolRowWrapper.tsx +41 -0
- package/src/Toolbar/Toolbar.tsx +98 -0
- package/src/Toolbar/ToolbarDivider.tsx +5 -0
- package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
- package/src/Toolbar/index.ts +7 -0
- package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
- package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
- package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
- package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
- package/src/ViewerLayout/ViewerHeader.tsx +124 -0
- package/src/ViewerLayout/constants/panels.ts +42 -0
- package/src/ViewerLayout/index.tsx +227 -0
- package/src/ViewerLayout/useUndoRedoState.ts +75 -0
- package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
- package/src/commandsModule.ts +970 -0
- package/src/customizations/aboutModalCustomization.tsx +42 -0
- package/src/customizations/appearanceModalCustomization.tsx +143 -0
- package/src/customizations/contextMenuCustomization.ts +25 -0
- package/src/customizations/contextMenuUICustomization.ts +5 -0
- package/src/customizations/customRoutesCustomization.ts +6 -0
- package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
- package/src/customizations/datasourcesCustomization.tsx +14 -0
- package/src/customizations/defaultContextMenuCustomization.ts +22 -0
- package/src/customizations/hangingProtocolsCustomization.ts +15 -0
- package/src/customizations/headerRightSideCustomization.ts +19 -0
- package/src/customizations/helloPageCustomization.tsx +14 -0
- package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
- package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
- package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
- package/src/customizations/labellingFlowCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
- package/src/customizations/menuContentCustomization.tsx +67 -0
- package/src/customizations/metadataContextCustomization.test.ts +22 -0
- package/src/customizations/metadataContextCustomization.ts +28 -0
- package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
- package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
- package/src/customizations/multimonitorCustomization.ts +63 -0
- package/src/customizations/notificationCustomization.ts +29 -0
- package/src/customizations/onDropHandlerCustomization.ts +5 -0
- package/src/customizations/onboardingCustomization.ts +200 -0
- package/src/customizations/overlayItemCustomization.tsx +33 -0
- package/src/customizations/progressDropdownCustomization.ts +5 -0
- package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
- package/src/customizations/reportDialogCustomization.test.ts +701 -0
- package/src/customizations/reportDialogCustomization.tsx +661 -0
- package/src/customizations/sortingCriteriaCustomization.ts +14 -0
- package/src/customizations/studyBrowserCustomization.test.ts +69 -0
- package/src/customizations/studyBrowserCustomization.ts +95 -0
- package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
- package/src/customizations/userPreferencesCustomization.tsx +342 -0
- package/src/customizations/workListCustomization.ts +107 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
- package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
- package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
- package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
- package/src/findViewportsByPosition.ts +102 -0
- package/src/getCustomizationModule.tsx +109 -0
- package/src/getDataSourcesModule.js +44 -0
- package/src/getDisplaySetMessages.ts +54 -0
- package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
- package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
- package/src/getHangingProtocolModule.js +155 -0
- package/src/getLayoutTemplateModule.js +28 -0
- package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
- package/src/getPTImageIdInstanceMetadata.ts +124 -0
- package/src/getPanelModule.tsx +29 -0
- package/src/getSopClassHandlerModule.js +152 -0
- package/src/getSopClassHandlerModule.test.js +78 -0
- package/src/getToolbarModule.tsx +63 -0
- package/src/getViewportModule.tsx +12 -0
- package/src/hangingprotocols/hpCompare.ts +189 -0
- package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
- package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
- package/src/hangingprotocols/hpMNGrid.ts +419 -0
- package/src/hangingprotocols/hpMammo.ts +202 -0
- package/src/hangingprotocols/hpScale.ts +132 -0
- package/src/hangingprotocols/index.ts +16 -0
- package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
- package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
- package/src/hangingprotocols/utils/laterality.ts +9 -0
- package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
- package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
- package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
- package/src/hangingprotocols/utils/studySelectors.ts +14 -0
- package/src/hangingprotocols/utils/viewCode.test.js +25 -0
- package/src/hangingprotocols/utils/viewCode.ts +17 -0
- package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
- package/src/hooks/usePatientInfo.tsx +63 -0
- package/src/id.js +5 -0
- package/src/index.ts +113 -0
- package/src/init.ts +169 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/useDisplaySetSelectorStore.ts +83 -0
- package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
- package/src/stores/useToggleHangingProtocolStore.ts +76 -0
- package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
- package/src/stores/useUIStateStore.ts +87 -0
- package/src/stores/useViewportGridStore.ts +89 -0
- package/src/stores/useViewportsByPositionStore.ts +100 -0
- package/src/types/AppTypes.ts +20 -0
- package/src/types/commandModuleTypes.tsx +6 -0
- package/src/utils/Toolbox.tsx +123 -0
- package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
- package/src/utils/addIcon.ts +6 -0
- package/src/utils/appendFrameQueryToImageId.js +9 -0
- package/src/utils/callInputDialog.tsx +126 -0
- package/src/utils/colorPickerDialog.css +4 -0
- package/src/utils/colorPickerDialog.tsx +45 -0
- package/src/utils/createRenderedRetrieve.js +32 -0
- package/src/utils/createRenderedRetrieve.test.js +46 -0
- package/src/utils/dicomWriter.test.ts +228 -0
- package/src/utils/dicomWriter.ts +110 -0
- package/src/utils/getBulkdataValue.js +45 -0
- package/src/utils/getBulkdataValue.test.js +105 -0
- package/src/utils/getDirectURL.test.ts +207 -0
- package/src/utils/getDirectURL.ts +65 -0
- package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/layerConfigurationUtils.ts +202 -0
- package/src/utils/promptLabelAnnotation.js +47 -0
- package/src/utils/promptSaveReport.test.ts +106 -0
- package/src/utils/promptSaveReport.tsx +117 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
- package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
- package/src/utils/registerStoredInstanceImageId.ts +66 -0
- package/src/utils/reuseCachedLayouts.ts +92 -0
- package/src/utils/secureConfigFetch.js +115 -0
- package/src/utils/secureConfigFetch.test.js +163 -0
- package/src/utils/seriesDescriptionHistory.ts +83 -0
- package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
- package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
- package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
- package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
- package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
- package/src/utils/validations/checkMultiframe.ts +25 -0
- package/src/utils/validations/checkSingleFrames.ts +36 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { devtools } from 'zustand/middleware';
|
|
3
|
+
import { Types } from '@ohif/core';
|
|
4
|
+
|
|
5
|
+
const PRESENTATION_TYPE_ID = 'toggleHangingProtocolId';
|
|
6
|
+
const DEBUG_STORE = false;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the state and actions for managing toggle hanging protocols.
|
|
10
|
+
*/
|
|
11
|
+
type ToggleHangingProtocolState = {
|
|
12
|
+
/**
|
|
13
|
+
* Stores a mapping from key to `HPInfo`.
|
|
14
|
+
*/
|
|
15
|
+
toggleHangingProtocol: Record<string, Types.HangingProtocol.HPInfo>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sets the toggle hanging protocol for a given key.
|
|
19
|
+
*
|
|
20
|
+
* @param key - The key .
|
|
21
|
+
* @param value - The `HPInfo` to associate with the key.
|
|
22
|
+
*/
|
|
23
|
+
setToggleHangingProtocol: (key: string, value: Types.HangingProtocol.HPInfo) => void;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Clears all toggle hanging protocols.
|
|
27
|
+
*/
|
|
28
|
+
clearToggleHangingProtocol: () => void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Type identifier for the store.
|
|
32
|
+
*/
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates the Toggle Hanging Protocol store.
|
|
38
|
+
*
|
|
39
|
+
* @param set - The zustand set function.
|
|
40
|
+
* @returns The toggle hanging protocol store state and actions.
|
|
41
|
+
*/
|
|
42
|
+
const createToggleHangingProtocolStore = (set): ToggleHangingProtocolState => ({
|
|
43
|
+
toggleHangingProtocol: {},
|
|
44
|
+
type: PRESENTATION_TYPE_ID,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sets the toggle hanging protocol for a given key.
|
|
48
|
+
*/
|
|
49
|
+
setToggleHangingProtocol: (key, value) =>
|
|
50
|
+
set(
|
|
51
|
+
state => ({
|
|
52
|
+
toggleHangingProtocol: {
|
|
53
|
+
...state.toggleHangingProtocol,
|
|
54
|
+
[key]: value,
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
false,
|
|
58
|
+
'setToggleHangingProtocol'
|
|
59
|
+
),
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Clears all toggle hanging protocols.
|
|
63
|
+
*/
|
|
64
|
+
clearToggleHangingProtocol: () =>
|
|
65
|
+
set({ toggleHangingProtocol: {} }, false, 'clearToggleHangingProtocol'),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Zustand store for managing toggle hanging protocols.
|
|
70
|
+
* Applies devtools middleware when DEBUG_STORE is enabled.
|
|
71
|
+
*/
|
|
72
|
+
export const useToggleHangingProtocolStore = create<ToggleHangingProtocolState>()(
|
|
73
|
+
DEBUG_STORE
|
|
74
|
+
? devtools(createToggleHangingProtocolStore, { name: 'ToggleHangingProtocolStore' })
|
|
75
|
+
: createToggleHangingProtocolStore
|
|
76
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
|
|
3
|
+
const PRESENTATION_TYPE_ID = 'toggleOneUpViewportGridId';
|
|
4
|
+
|
|
5
|
+
type ToggleOneUpViewportGridState = {
|
|
6
|
+
toggleOneUpViewportGridStore: any | null;
|
|
7
|
+
setToggleOneUpViewportGridStore: (state: any) => void;
|
|
8
|
+
clearToggleOneUpViewportGridStore: () => void;
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// Stores the entire ViewportGridService getState when toggling to one up
|
|
13
|
+
// (e.g. via a double click) so that it can be restored when toggling back.
|
|
14
|
+
export const useToggleOneUpViewportGridStore = create<ToggleOneUpViewportGridState>(set => ({
|
|
15
|
+
toggleOneUpViewportGridStore: null,
|
|
16
|
+
type: PRESENTATION_TYPE_ID,
|
|
17
|
+
setToggleOneUpViewportGridStore: state => set({ toggleOneUpViewportGridStore: state }),
|
|
18
|
+
clearToggleOneUpViewportGridStore: () => set({ toggleOneUpViewportGridStore: null }),
|
|
19
|
+
}));
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { devtools } from 'zustand/middleware';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Identifier for the UI State store type.
|
|
6
|
+
*/
|
|
7
|
+
const PRESENTATION_TYPE_ID = 'uiStateId';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Flag to enable or disable debug mode for the store.
|
|
11
|
+
* Set to `true` to enable zustand devtools.
|
|
12
|
+
*/
|
|
13
|
+
const DEBUG_STORE = false;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the UI state.
|
|
17
|
+
*/
|
|
18
|
+
type UIState = {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* State shape for the UI State store.
|
|
24
|
+
*/
|
|
25
|
+
type UIStateStore = {
|
|
26
|
+
/**
|
|
27
|
+
* Type identifier for the store.
|
|
28
|
+
*/
|
|
29
|
+
type: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Stores the UI state as a key-value mapping.
|
|
33
|
+
*/
|
|
34
|
+
uiState: UIState;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sets the UI state for a given key.
|
|
38
|
+
*
|
|
39
|
+
* @param key - The key to set in the UI state.
|
|
40
|
+
* @param value - The value to associate with the key.
|
|
41
|
+
*/
|
|
42
|
+
setUIState: (key: string, value: unknown) => void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Clears all UI state.
|
|
46
|
+
*/
|
|
47
|
+
clearUIState: () => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates the UI State store.
|
|
52
|
+
*
|
|
53
|
+
* @param set - The zustand set function.
|
|
54
|
+
* @returns The UI State store state and actions.
|
|
55
|
+
*/
|
|
56
|
+
const createUIStateStore = (set): UIStateStore => ({
|
|
57
|
+
type: PRESENTATION_TYPE_ID,
|
|
58
|
+
uiState: {},
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sets the UI state for a given key.
|
|
62
|
+
*/
|
|
63
|
+
setUIState: (key, value) =>
|
|
64
|
+
set(
|
|
65
|
+
state => ({
|
|
66
|
+
uiState: {
|
|
67
|
+
...state.uiState,
|
|
68
|
+
[key]: value,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
false,
|
|
72
|
+
'setUIState'
|
|
73
|
+
),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Clears all UI state.
|
|
77
|
+
*/
|
|
78
|
+
clearUIState: () => set({ uiState: {} }, false, 'clearUIState'),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Zustand store for managing UI state.
|
|
83
|
+
* Applies devtools middleware when DEBUG_STORE is enabled.
|
|
84
|
+
*/
|
|
85
|
+
export const useUIStateStore = create<UIStateStore>()(
|
|
86
|
+
DEBUG_STORE ? devtools(createUIStateStore, { name: 'UIStateStore' }) : createUIStateStore
|
|
87
|
+
);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { devtools } from 'zustand/middleware';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Identifier for the viewport grid store type.
|
|
6
|
+
*/
|
|
7
|
+
const PRESENTATION_TYPE_ID = 'viewportGridId';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Flag to enable or disable debug mode for the store.
|
|
11
|
+
* Set to `true` to enable zustand devtools.
|
|
12
|
+
*/
|
|
13
|
+
const DEBUG_STORE = false;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the state of the viewport grid.
|
|
17
|
+
*/
|
|
18
|
+
type ViewportGridState = {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* State shape for the Viewport Grid store.
|
|
24
|
+
*/
|
|
25
|
+
type ViewportGridStore = {
|
|
26
|
+
/**
|
|
27
|
+
* Type identifier for the store.
|
|
28
|
+
*/
|
|
29
|
+
type: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Stores the viewport grid state as a key-value mapping.
|
|
33
|
+
*/
|
|
34
|
+
viewportGridState: ViewportGridState;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sets the viewport grid state for a given key.
|
|
38
|
+
*
|
|
39
|
+
* @param key - The key to set in the viewport grid state.
|
|
40
|
+
* @param value - The value to associate with the key.
|
|
41
|
+
*/
|
|
42
|
+
setViewportGridState: (key: string, value: unknown) => void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Clears the entire viewport grid state.
|
|
46
|
+
*/
|
|
47
|
+
clearViewportGridState: () => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates the Viewport Grid store.
|
|
52
|
+
*
|
|
53
|
+
* @param set - The zustand set function.
|
|
54
|
+
* @returns The Viewport Grid store state and actions.
|
|
55
|
+
*/
|
|
56
|
+
const createViewportGridStore = (set): ViewportGridStore => ({
|
|
57
|
+
type: PRESENTATION_TYPE_ID,
|
|
58
|
+
viewportGridState: {},
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sets the viewport grid state for a given key.
|
|
62
|
+
*/
|
|
63
|
+
setViewportGridState: (key, value) =>
|
|
64
|
+
set(
|
|
65
|
+
state => ({
|
|
66
|
+
viewportGridState: {
|
|
67
|
+
...state.viewportGridState,
|
|
68
|
+
[key]: value,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
false,
|
|
72
|
+
'setViewportGridState'
|
|
73
|
+
),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Clears the entire viewport grid state.
|
|
77
|
+
*/
|
|
78
|
+
clearViewportGridState: () => set({ viewportGridState: {} }, false, 'clearViewportGridState'),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Zustand store for managing viewport grid state.
|
|
83
|
+
* Applies devtools middleware when DEBUG_STORE is enabled.
|
|
84
|
+
*/
|
|
85
|
+
export const useViewportGridStore = create<ViewportGridStore>()(
|
|
86
|
+
DEBUG_STORE
|
|
87
|
+
? devtools(createViewportGridStore, { name: 'ViewportGridStore' })
|
|
88
|
+
: createViewportGridStore
|
|
89
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { devtools } from 'zustand/middleware';
|
|
3
|
+
|
|
4
|
+
const PRESENTATION_TYPE_ID = 'viewportsByPositionId';
|
|
5
|
+
const DEBUG_STORE = false;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents the state and actions for managing viewports by position.
|
|
9
|
+
*/
|
|
10
|
+
type ViewportsByPositionState = {
|
|
11
|
+
/**
|
|
12
|
+
* Type identifier for the store.
|
|
13
|
+
*/
|
|
14
|
+
type: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Stores viewports indexed by their position.
|
|
18
|
+
*/
|
|
19
|
+
viewportsByPosition: Record<string, unknown>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Stores initial display viewports as an array of strings.
|
|
23
|
+
*/
|
|
24
|
+
initialInDisplay: string[];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sets the viewport for a given key.
|
|
28
|
+
*
|
|
29
|
+
* @param key - The key identifying the viewport position.
|
|
30
|
+
* @param value - The viewport data to associate with the key.
|
|
31
|
+
*/
|
|
32
|
+
setViewportsByPosition: (key: string, value: unknown) => void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Clears all viewports by position.
|
|
36
|
+
*/
|
|
37
|
+
clearViewportsByPosition: () => void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Adds an initial display viewport.
|
|
41
|
+
*
|
|
42
|
+
* @param value - The viewport identifier to add.
|
|
43
|
+
*/
|
|
44
|
+
addInitialInDisplay: (value: string) => void;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates the Viewports By Position store.
|
|
49
|
+
*
|
|
50
|
+
* @param set - The zustand set function.
|
|
51
|
+
* @returns The Viewports By Position store state and actions.
|
|
52
|
+
*/
|
|
53
|
+
const createViewportsByPositionStore = (set): ViewportsByPositionState => ({
|
|
54
|
+
type: PRESENTATION_TYPE_ID,
|
|
55
|
+
viewportsByPosition: {},
|
|
56
|
+
initialInDisplay: [],
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sets the viewport for a given key.
|
|
60
|
+
*/
|
|
61
|
+
setViewportsByPosition: (key, value) =>
|
|
62
|
+
set(
|
|
63
|
+
state => ({
|
|
64
|
+
viewportsByPosition: {
|
|
65
|
+
...state.viewportsByPosition,
|
|
66
|
+
[key]: value,
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
false,
|
|
70
|
+
'setViewportsByPosition'
|
|
71
|
+
),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Clears all viewports by position.
|
|
75
|
+
*/
|
|
76
|
+
clearViewportsByPosition: () =>
|
|
77
|
+
set({ viewportsByPosition: {} }, false, 'clearViewportsByPosition'),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Adds an initial display viewport.
|
|
81
|
+
*/
|
|
82
|
+
addInitialInDisplay: value =>
|
|
83
|
+
set(
|
|
84
|
+
state => ({
|
|
85
|
+
initialInDisplay: [...state.initialInDisplay, value],
|
|
86
|
+
}),
|
|
87
|
+
false,
|
|
88
|
+
'addInitialInDisplay'
|
|
89
|
+
),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Zustand store for managing viewports by position.
|
|
94
|
+
* Applies devtools middleware when DEBUG_STORE is enabled.
|
|
95
|
+
*/
|
|
96
|
+
export const useViewportsByPositionStore = create<ViewportsByPositionState>()(
|
|
97
|
+
DEBUG_STORE
|
|
98
|
+
? devtools(createViewportsByPositionStore, { name: 'ViewportsByPositionStore' })
|
|
99
|
+
: createViewportsByPositionStore
|
|
100
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
import type { ComponentType } from 'react';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
namespace AppTypes {
|
|
6
|
+
interface Customizations {
|
|
7
|
+
/**
|
|
8
|
+
* The right side of the viewer header's menu bar, ahead of the settings
|
|
9
|
+
* menu. `items` is an ordered list of components — undo/redo and patient
|
|
10
|
+
* info by default — each rendered by `ViewerHeader` in its own separated
|
|
11
|
+
* slot, so reordering the array reorders the header and dropping an entry
|
|
12
|
+
* removes it (the
|
|
13
|
+
* `@ohif/extension-default.customizationModule.hideHeaderUndoRedo` module
|
|
14
|
+
* does exactly that). Items take no props and may use hooks; one that
|
|
15
|
+
* renders `null` collapses its slot.
|
|
16
|
+
*/
|
|
17
|
+
'ohif.headerRightSide': { items: ComponentType[] };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Icons, PanelSection, ToolSettings } from '@ohif/ui-next';
|
|
3
|
+
import { useSystem, useToolbar, useActiveToolOptions } from '@ohif/core';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for the Toolbox component that renders a collection of toolbar button sections.
|
|
8
|
+
*/
|
|
9
|
+
interface ToolboxProps {
|
|
10
|
+
/**
|
|
11
|
+
* The unique identifier of the button section this toolbox represents.
|
|
12
|
+
*/
|
|
13
|
+
buttonSectionId: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The display title for the toolbox.
|
|
17
|
+
*/
|
|
18
|
+
title: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A toolbox is a collection of buttons and commands that they invoke, used to provide
|
|
23
|
+
* custom control panels to users. This component is a generic UI component that
|
|
24
|
+
* interacts with services and commands in a generic fashion. While it might
|
|
25
|
+
* seem unconventional to import it from the UI and integrate it into the JSX,
|
|
26
|
+
* it belongs in the UI components as there isn't anything in this component that
|
|
27
|
+
* couldn't be used for a completely different type of app. It plays a crucial
|
|
28
|
+
* role in enhancing the app with a toolbox by providing a way to integrate
|
|
29
|
+
* and display various tools and their corresponding options
|
|
30
|
+
*/
|
|
31
|
+
export function Toolbox({ buttonSectionId, title }: ToolboxProps) {
|
|
32
|
+
const { servicesManager } = useSystem();
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
|
|
35
|
+
const { toolbarService, customizationService } = servicesManager.services;
|
|
36
|
+
const [showConfig, setShowConfig] = useState(false);
|
|
37
|
+
|
|
38
|
+
const { toolbarButtons: toolboxSections, onInteraction } = useToolbar({
|
|
39
|
+
buttonSection: buttonSectionId,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const { activeToolOptions } = useActiveToolOptions({ buttonSectionId });
|
|
43
|
+
|
|
44
|
+
if (!toolboxSections.length) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Ensure we have proper button sections at the top level.
|
|
49
|
+
if (!toolboxSections.every(section => section.componentProps.buttonSection)) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
'Toolbox accepts only button sections at the top level, not buttons. Create at least one button section.'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Define the interaction handler once.
|
|
56
|
+
const handleInteraction = ({ itemId }: { itemId: string }) => {
|
|
57
|
+
onInteraction?.({ itemId });
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const CustomConfigComponent = customizationService.getCustomization(`${buttonSectionId}.config`);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<PanelSection>
|
|
64
|
+
<PanelSection.Header className="flex items-center justify-between">
|
|
65
|
+
<span>{t(title)}</span>
|
|
66
|
+
{CustomConfigComponent && (
|
|
67
|
+
<div className="ml-auto mr-2">
|
|
68
|
+
<Icons.Settings
|
|
69
|
+
className="text-primary h-4 w-4"
|
|
70
|
+
onClick={e => {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
setShowConfig(!showConfig);
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
</PanelSection.Header>
|
|
78
|
+
|
|
79
|
+
<PanelSection.Content className="bg-muted flex-shrink-0 border-none">
|
|
80
|
+
{showConfig && <CustomConfigComponent />}
|
|
81
|
+
{toolboxSections.map(section => {
|
|
82
|
+
const sectionId = section.componentProps.buttonSection;
|
|
83
|
+
const buttons = toolbarService.getButtonSection(sectionId) as any[];
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div
|
|
87
|
+
key={sectionId}
|
|
88
|
+
className="bg-muted flex flex-wrap gap-2 py-2 px-1"
|
|
89
|
+
>
|
|
90
|
+
{buttons.map(tool => {
|
|
91
|
+
// Skip over tools that are not visible. The visible flag is typically set to
|
|
92
|
+
// false as a result of the evaluator function. The evaluator might explicitly
|
|
93
|
+
// set visible to false. Alternatively, the ToolbarService will set the visible flag to
|
|
94
|
+
// false when the evaluator sets disabled to true and the tool has the hideWhenDisabled flag set to true.
|
|
95
|
+
if (!tool || !tool.componentProps.visible) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const { id, Component, componentProps } = tool;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div key={id}>
|
|
102
|
+
<Component
|
|
103
|
+
{...componentProps}
|
|
104
|
+
id={id}
|
|
105
|
+
onInteraction={handleInteraction}
|
|
106
|
+
size="toolbox"
|
|
107
|
+
servicesManager={servicesManager}
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
})}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
{activeToolOptions && (
|
|
116
|
+
<div className="bg-muted mt-1 h-auto px-2">
|
|
117
|
+
<ToolSettings options={activeToolOptions} />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</PanelSection.Content>
|
|
121
|
+
</PanelSection>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Appends ?frame= or &frame= to a local/wadouri imageId.
|
|
3
|
+
*/
|
|
4
|
+
export function appendFrameQueryToImageId(baseImageId, frame) {
|
|
5
|
+
const withoutFrame = baseImageId.split('&frame=')[0].split('?frame=')[0];
|
|
6
|
+
const separator = withoutFrame.includes('?') ? '&' : '?';
|
|
7
|
+
|
|
8
|
+
return `${withoutFrame}${separator}frame=${frame}`;
|
|
9
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { setAnnotationLabel } from '@cornerstonejs/tools/utilities';
|
|
3
|
+
import { annotation } from '@cornerstonejs/tools';
|
|
4
|
+
import { LabellingFlow } from '@ohif/ui-next';
|
|
5
|
+
import { InputDialog } from '@ohif/ui-next';
|
|
6
|
+
|
|
7
|
+
interface InputDialogDefaultProps {
|
|
8
|
+
hide: () => void;
|
|
9
|
+
onSave: (value: string) => void;
|
|
10
|
+
placeholder: string;
|
|
11
|
+
defaultValue: string;
|
|
12
|
+
submitOnEnter: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function InputDialogDefault({
|
|
16
|
+
hide,
|
|
17
|
+
onSave,
|
|
18
|
+
placeholder = 'Enter value',
|
|
19
|
+
defaultValue = '',
|
|
20
|
+
submitOnEnter,
|
|
21
|
+
}: InputDialogDefaultProps) {
|
|
22
|
+
return (
|
|
23
|
+
<InputDialog
|
|
24
|
+
submitOnEnter={submitOnEnter}
|
|
25
|
+
defaultValue={defaultValue}
|
|
26
|
+
>
|
|
27
|
+
<InputDialog.Field>
|
|
28
|
+
<InputDialog.Input placeholder={placeholder} />
|
|
29
|
+
</InputDialog.Field>
|
|
30
|
+
<InputDialog.Actions>
|
|
31
|
+
<InputDialog.ActionsSecondary onClick={hide}>Cancel</InputDialog.ActionsSecondary>
|
|
32
|
+
<InputDialog.ActionsPrimary
|
|
33
|
+
onClick={value => {
|
|
34
|
+
onSave(value);
|
|
35
|
+
hide();
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
Save
|
|
39
|
+
</InputDialog.ActionsPrimary>
|
|
40
|
+
</InputDialog.Actions>
|
|
41
|
+
</InputDialog>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Shows an input dialog for entering text with customizable options
|
|
47
|
+
* @param uiDialogService - Service for showing UI dialogs
|
|
48
|
+
* @param onSave - Callback function called when save button is clicked with entered value
|
|
49
|
+
* @param defaultValue - Initial value to show in input field
|
|
50
|
+
* @param title - Title text to show in dialog header
|
|
51
|
+
* @param placeholder - Placeholder text for input field
|
|
52
|
+
* @param submitOnEnter - Whether to submit dialog when Enter key is pressed
|
|
53
|
+
*/
|
|
54
|
+
export async function callInputDialog({
|
|
55
|
+
uiDialogService,
|
|
56
|
+
defaultValue = '',
|
|
57
|
+
title = 'Annotation',
|
|
58
|
+
placeholder = '',
|
|
59
|
+
submitOnEnter = true,
|
|
60
|
+
}: {
|
|
61
|
+
uiDialogService: AppTypes.UIDialogService;
|
|
62
|
+
defaultValue?: string;
|
|
63
|
+
title?: string;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
submitOnEnter?: boolean;
|
|
66
|
+
}) {
|
|
67
|
+
const dialogId = 'dialog-enter-annotation';
|
|
68
|
+
|
|
69
|
+
const value = await new Promise<string>(resolve => {
|
|
70
|
+
uiDialogService.show({
|
|
71
|
+
id: dialogId,
|
|
72
|
+
content: InputDialogDefault,
|
|
73
|
+
title: title,
|
|
74
|
+
shouldCloseOnEsc: true,
|
|
75
|
+
contentProps: {
|
|
76
|
+
onSave: value => {
|
|
77
|
+
resolve(value);
|
|
78
|
+
},
|
|
79
|
+
placeholder,
|
|
80
|
+
defaultValue,
|
|
81
|
+
submitOnEnter,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function callInputDialogAutoComplete({
|
|
90
|
+
measurement,
|
|
91
|
+
uiDialogService,
|
|
92
|
+
labelConfig,
|
|
93
|
+
renderContent = LabellingFlow,
|
|
94
|
+
element,
|
|
95
|
+
}) {
|
|
96
|
+
const exclusive = labelConfig ? labelConfig.exclusive : false;
|
|
97
|
+
const dropDownItems = labelConfig ? labelConfig.items : [];
|
|
98
|
+
|
|
99
|
+
const value = await new Promise<Map<string, string>>((resolve, reject) => {
|
|
100
|
+
const labellingDoneCallback = newValue => {
|
|
101
|
+
uiDialogService.hide('select-annotation');
|
|
102
|
+
if (measurement && typeof newValue === 'string') {
|
|
103
|
+
const sourceAnnotation = annotation.state.getAnnotation(measurement.uid);
|
|
104
|
+
setAnnotationLabel(sourceAnnotation, element, newValue);
|
|
105
|
+
}
|
|
106
|
+
resolve(newValue);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
uiDialogService.show({
|
|
110
|
+
id: 'select-annotation',
|
|
111
|
+
title: 'Annotation',
|
|
112
|
+
content: renderContent,
|
|
113
|
+
contentProps: {
|
|
114
|
+
labellingDoneCallback: labellingDoneCallback,
|
|
115
|
+
measurementData: measurement,
|
|
116
|
+
componentClassName: {},
|
|
117
|
+
labelData: dropDownItems,
|
|
118
|
+
exclusive: exclusive,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default callInputDialog;
|