Update example extension

This commit is contained in:
dannyrb 2020-06-14 21:48:56 -04:00
parent 83e191b850
commit 38203c9b31

View File

@ -1,112 +1,138 @@
import ImageSet from '@ohif/core/src/classes/ImageSet';
import { IWebApiDataSource } from '@ohif/core';
/** /**
* *
*/ */
export default { export default {
/** id: 'org.ohif.*',
* Only required property. Should be a unique value across all extensions.
*/
id: 'example-extension',
/** /**
* LIFECYCLE HOOKS * LIFECYCLE HOOKS
*/ */
preRegistration() {},
preRegistration({ beforeExtInit() {},
servicesManager = {}, beforeExtDestroy() {},
commandsManager = {},
appConfig = {},
configuration = {},
}) {},
/** /**
* MODULE GETTERS * MODULES
*/ */
getViewportModule() { getCommandsModule,
return '... react component ...'; getContextModule,
}, getDataSourcesModule,
getSopClassHandlerModule() { getLayoutTemplateModule,
return sopClassHandlerModule; getPanelModule,
}, getSopClassHandlerModule,
getPanelModule() { getToolbarModule() {},
return panelModule; getViewportModule,
},
getToolbarModule() {
return panelModule;
},
getCommandsModule(/* store */) {
return commandsModule;
},
}; };
// appConfig,
// extensionConfig,
// dataSources,
// servicesManager,
// extensionManager,
// commandsManager,
/** /**
* *
*/ */
const commandsModule = { const getCommandsModule = () => ({
actions: {
// Store Contexts + Options
exampleAction: ({ viewports, param1 }) => {
console.log(`There are ${viewports.length} viewports`);
console.log(`param1's value is: ${param1}`);
},
},
definitions: { definitions: {
exampleActionDef: { exampleActionDef: {
commandFn: this.actions.exampleAction, commandFn: ({ param1 }) => {
storeContexts: ['viewports'], console.log(`param1's value is: ${param1}`);
},
// storeContexts: ['viewports'],
options: { param1: 'hello world' }, options: { param1: 'hello world' },
context: 'VIEWER', // optional
}, },
}, },
}; defaultContext: 'ACTIVE_VIEWPORT::DICOMSR',
});
/** const ExampleContext = React.createContext();
*
*/
const sopClassHandlerModule = {
id: 'OHIFDicomHtmlSopClassHandler',
sopClassUIDs: Object.values({
BASIC_TEXT_SR: '1.2.840.10008.5.1.4.1.1.88.11',
ENHANCED_SR: '1.2.840.10008.5.1.4.1.1.88.22',
COMPREHENSIVE_SR: '1.2.840.10008.5.1.4.1.1.88.33',
PROCEDURE_LOG_STORAGE: '1.2.840.10008.5.1.4.1.1.88.40',
MAMMOGRAPHY_CAD_SR: '1.2.840.10008.5.1.4.1.1.88.50',
CHEST_CAD_SR: '1.2.840.10008.5.1.4.1.1.88.65',
X_RAY_RADIATION_DOSE_SR: '1.2.840.10008.5.1.4.1.1.88.67',
}),
getDisplaySetFromSeries(series, study, dicomWebClient, authorizationHeaders) {
const instance = series.getFirstInstance();
return { function ExampleContextProvider({ children }) {
plugin: 'html', return (
displaySetInstanceUID: 0, //utils.guid(), <ExampleContext.Provider value={{ example: 'value' }}>
wadoRoot: study.getData().wadoRoot, {children}
wadoUri: instance.getData().wadouri, </TrackedMeasurementsContext.Provider>
SOPInstanceUID: instance.getSOPInstanceUID(), );
SeriesInstanceUID: series.getSeriesInstanceUID(), }
StudyInstanceUID: study.getStudyInstanceUID(),
authorizationHeaders, const getContextModule = () => [
}; {
name: 'ExampleContext',
context: ExampleContext,
provider: ExampleContextProvider,
}, },
];
const getDataSourcesModule = () => [
{
name: 'exampleDataSource',
type: 'webApi', // 'webApi' | 'local' | 'other'
createDataSource: dataSourceConfig => {
return IWebApiDataSource.create(/* */);
},
},
];
const getLayoutTemplateModule = (/* ... */) => [
{
id: 'exampleLayout',
name: 'exampleLayout',
component: ExampleLayoutComponent,
},
];
const getPanelModule = () => {
return [
{
name: 'exampleSidePanel',
iconName: 'info-circle-o',
iconLabel: 'Example',
label: 'Hello World',
isDisabled: studies => {}, // optional
component: ExamplePanelContentComponent,
},
];
}; };
/** const getSopClassHandlerModule = (/* ... */) => {
* const BASIC_TEXT_SR = '1.2.840.10008.5.1.4.1.1.88.11';
*/
const panelModule = { return [
menuOptions: [
{ {
icon: 'th-list', name: 'ExampleSopClassHandle',
label: 'Segments', sopClassUids: [BASIC_TEXT_SR],
target: 'segment-panel', getDisplaySetsFromSeries: instances => {
isDisabled: studies => { const imageSet = new ImageSet(instances);
return false;
imageSet.setAttributes(/** */);
imageSet.sortBy((a, b) => 0);
return imageSet;
}, },
}, },
], ];
components: [ };
{
id: 'segment-panel', const getToolbarModule = () => {};
component: '... react component ...',
}, // displaySet, viewportIndex, dataSource
], const getViewportModule = () => {
defaultContext: ['VIEWER'], const wrappedViewport = props => {
return (
<ExampleViewport
{...props}
onEvent={data => {
commandsManager.runCommand('commandName', data);
}}
/>
);
};
return [{ name: 'example', component: wrappedViewport }];
}; };