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-08-19 21:24:07 +02:00
|
|
|
ToolBarService,
|
2020-06-25 23:00:42 +02:00
|
|
|
ViewportGridService,
|
2020-08-19 21:24:07 +02:00
|
|
|
HangingProtocolService,
|
2020-09-15 03:18:46 +02:00
|
|
|
CineService,
|
2021-06-23 20:41:27 +02:00
|
|
|
UserAuthenticationService,
|
2020-05-07 16:55:42 +02:00
|
|
|
// utils,
|
|
|
|
|
} from '@ohif/core';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const commandsManagerConfig = {
|
2020-09-15 03:18:46 +02:00
|
|
|
getAppState: () => {},
|
2020-05-07 16:55:42 +02:00
|
|
|
/** Used by commands to determine active context */
|
2020-09-15 03:18:46 +02:00
|
|
|
getActiveContexts: () => [
|
|
|
|
|
'VIEWER',
|
|
|
|
|
'DEFAULT',
|
|
|
|
|
'ACTIVE_VIEWPORT::CORNERSTONE',
|
|
|
|
|
],
|
2020-05-07 16:55:42 +02:00
|
|
|
};
|
2020-06-29 16:53:46 +02:00
|
|
|
|
|
|
|
|
const commandsManager = new CommandsManager(commandsManagerConfig);
|
2020-09-15 03:18:46 +02:00
|
|
|
const servicesManager = new ServicesManager(commandsManager);
|
2020-06-29 16:53:46 +02:00
|
|
|
const hotkeysManager = new HotkeysManager(commandsManager, servicesManager);
|
2020-05-07 16:55:42 +02:00
|
|
|
const extensionManager = new ExtensionManager({
|
|
|
|
|
commandsManager,
|
|
|
|
|
servicesManager,
|
2020-08-19 21:02:59 +02:00
|
|
|
hotkeysManager,
|
2020-05-07 16:55:42 +02:00
|
|
|
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-08-19 21:24:07 +02:00
|
|
|
ToolBarService,
|
2020-06-25 23:00:42 +02:00
|
|
|
ViewportGridService,
|
2020-08-19 21:24:07 +02:00
|
|
|
HangingProtocolService,
|
2020-09-15 03:18:46 +02:00
|
|
|
CineService,
|
2021-06-23 20:41:27 +02:00
|
|
|
UserAuthenticationService,
|
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
|
|
|
|
|
|
2021-06-23 20:41:27 +02:00
|
|
|
if (!appConfig.modes) {
|
|
|
|
|
throw new Error('No modes are defined! Check your app-config.js');
|
|
|
|
|
}
|
|
|
|
|
|
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-07-06 14:42:06 +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;
|