2020-05-07 16:55:42 +02:00
|
|
|
import {
|
|
|
|
|
CommandsManager,
|
|
|
|
|
ExtensionManager,
|
|
|
|
|
ServicesManager,
|
2020-06-29 16:53:46 +02:00
|
|
|
HotkeysManager,
|
2020-05-07 16:55:42 +02:00
|
|
|
UINotificationService,
|
|
|
|
|
UIModalService,
|
|
|
|
|
UIDialogService,
|
2020-06-05 21:19:09 +02:00
|
|
|
UIViewportDialogService,
|
2020-05-12 21:41:11 +02:00
|
|
|
MeasurementService,
|
2020-05-18 17:21:57 +02:00
|
|
|
DisplaySetService,
|
2020-05-19 11:01:44 +02:00
|
|
|
ToolBarSerivce,
|
2020-06-25 23:00:42 +02:00
|
|
|
ViewportGridService,
|
2020-05-07 16:55:42 +02:00
|
|
|
// utils,
|
|
|
|
|
// redux as reduxOHIF,
|
|
|
|
|
} from '@ohif/core';
|
|
|
|
|
|
2020-06-05 17:36:11 +02:00
|
|
|
// TODO -> this feels bad.
|
|
|
|
|
|
2020-05-07 16:55:42 +02:00
|
|
|
/**
|
|
|
|
|
* @param {object|func} appConfigOrFunc - application configuration, or a function that returns application configuration
|
|
|
|
|
* @param {object[]} defaultExtensions - array of extension objects
|
|
|
|
|
*/
|
|
|
|
|
function appInit(appConfigOrFunc, defaultExtensions) {
|
|
|
|
|
const appConfig = {
|
|
|
|
|
...(typeof appConfigOrFunc === 'function'
|
2020-05-07 20:05:03 +02:00
|
|
|
? appConfigOrFunc({ servicesManager })
|
2020-05-07 16:55:42 +02:00
|
|
|
: appConfigOrFunc),
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-07 20:05:03 +02:00
|
|
|
// TODO: Wire this up to Rodrigo's basic Context "ContextService"
|
2020-05-07 16:55:42 +02:00
|
|
|
const commandsManagerConfig = {
|
|
|
|
|
/** Used by commands to inject `viewports` from "redux" */
|
2020-06-29 16:53:46 +02:00
|
|
|
getAppState: () => { },
|
2020-05-07 16:55:42 +02:00
|
|
|
/** Used by commands to determine active context */
|
2020-05-07 20:05:03 +02:00
|
|
|
getActiveContexts: () => ['VIEWER', 'ACTIVE_VIEWPORT::CORNERSTONE'],
|
2020-05-07 16:55:42 +02:00
|
|
|
};
|
2020-06-29 16:53:46 +02:00
|
|
|
|
2020-05-07 16:55:42 +02:00
|
|
|
const servicesManager = new ServicesManager();
|
2020-06-29 16:53:46 +02:00
|
|
|
const commandsManager = new CommandsManager(commandsManagerConfig);
|
|
|
|
|
const hotkeysManager = new HotkeysManager(commandsManager, servicesManager);
|
2020-05-07 16:55:42 +02:00
|
|
|
const extensionManager = new ExtensionManager({
|
|
|
|
|
commandsManager,
|
|
|
|
|
servicesManager,
|
|
|
|
|
appConfig,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
servicesManager.registerServices([
|
|
|
|
|
UINotificationService,
|
|
|
|
|
UIModalService,
|
|
|
|
|
UIDialogService,
|
2020-06-05 21:19:09 +02:00
|
|
|
UIViewportDialogService,
|
2020-05-12 21:41:11 +02:00
|
|
|
MeasurementService,
|
2020-05-18 17:21:57 +02:00
|
|
|
DisplaySetService,
|
2020-05-19 11:01:44 +02:00
|
|
|
ToolBarSerivce,
|
2020-06-25 23:00:42 +02:00
|
|
|
ViewportGridService,
|
2020-05-07 16:55:42 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Example: [ext1, ext2, ext3]
|
|
|
|
|
* Example2: [[ext1, config], ext2, [ext3, config]]
|
|
|
|
|
*/
|
2020-05-11 18:56:46 +02:00
|
|
|
extensionManager.registerExtensions(
|
|
|
|
|
[...defaultExtensions, ...appConfig.extensions],
|
|
|
|
|
appConfig.dataSources
|
|
|
|
|
);
|
2020-05-07 16:55:42 +02:00
|
|
|
|
|
|
|
|
// TODO: We no longer use `utils.addServer`
|
|
|
|
|
// TODO: We no longer init webWorkers at app level
|
|
|
|
|
// TODO: We no longer init the user Manager
|
|
|
|
|
|
2020-05-18 04:18:25 +02:00
|
|
|
// TODO: Remove this
|
|
|
|
|
if (!appConfig.modes.length) {
|
2020-05-26 15:03:58 +02:00
|
|
|
appConfig.modes.push(window.longitudinalMode);
|
2020-06-30 21:48:42 +02:00
|
|
|
appConfig.modes.push(window.segmentationMode);
|
2020-05-18 04:18:25 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-07 16:55:42 +02:00
|
|
|
return {
|
|
|
|
|
appConfig,
|
|
|
|
|
commandsManager,
|
|
|
|
|
extensionManager,
|
|
|
|
|
servicesManager,
|
2020-06-30 21:48:42 +02:00
|
|
|
hotkeysManager,
|
2020-05-07 16:55:42 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default appInit;
|