Expose ViewportGridService API methods to extensions

This commit is contained in:
dannyrb committed 2020-06-25 17:00:42 -04:00
1 parent 1a065855f2
commit 6e873cc92a
7 files changed
+199 -60

No files matched your search

+2 -48
View File
@@ -54,60 +54,14 @@ function App({ config, defaultExtensions }) {
UIModalService,
UINotificationService,
UIViewportDialogService,
ViewportGridService, // TODO: Should this be a "UI" Service?
} = servicesManager.services;
// A UI Service may need to use the ViewportGrid context
const viewportGridReducer = (state, action) => {
console.log(state, action);
switch (action.type) {
case 'SET_ACTIVE_VIEWPORT_INDEX':
return { ...state, ...{ activeViewportIndex: action.payload } };
case 'SET_DISPLAYSET_FOR_VIEWPORT': {
const { viewportIndex, displaySetInstanceUID } = action.payload;
const viewports = state.viewports.slice();
viewports[viewportIndex] = { displaySetInstanceUID };
return { ...state, ...{ viewports } };
}
case 'SET_LAYOUT': {
const { numCols, numRows } = action.payload;
const numPanes = numCols * numRows;
const viewports = state.viewports.slice();
const activeViewportIndex =
state.activeViewportIndex >= numPanes ? 0 : state.activeViewportIndex;
while (viewports.length < numPanes) {
viewports.push({});
}
while (viewports.length > numPanes) {
viewports.pop();
}
return {
...state,
...{ activeViewportIndex, numCols, numRows, viewports },
};
}
default:
return action.payload;
}
};
return (
<AppConfigProvider value={appConfigState}>
<Router basename={routerBasename}>
<ThemeWrapper>
<ViewportGridProvider
initialState={{
numRows: 1,
numCols: 1,
viewports: [],
activeViewportIndex: 0,
}}
reducer={viewportGridReducer}
>
<ViewportGridProvider service={ViewportGridService}>
<ViewportDialogProvider service={UIViewportDialogService}>
<SnackbarProvider service={UINotificationService}>
<DialogProvider service={UIDialogService}>
+2
View File
@@ -10,6 +10,7 @@ import {
MeasurementService,
DisplaySetService,
ToolBarSerivce,
ViewportGridService,
// utils,
// redux as reduxOHIF,
} from '@ohif/core';
@@ -51,6 +52,7 @@ function appInit(appConfigOrFunc, defaultExtensions) {
MeasurementService,
DisplaySetService,
ToolBarSerivce,
ViewportGridService,
]);
/**