feat(microscopy): add dicom microscopy extension and mode (#3247)
* skeleton for dicom-microscopy extension * skeleton for microscopy mode * [feat] ported @radicalimaging/microscopy-dicom to OHIF's default extension * [feat] ported microscopy mode from private repo * added new definitions to the package.json * webpack configuration update for microscopy extension * register new icons for microscopy tools * fixes to the microscopy extension and mode * trivial error fix - typescript type import error * link microscopy extension with default OHIF app plugin config * demo config fix * fix logs * remove unsed imports * [fix] loading of microscopy * [fix] webworker script loading, normalizing denaturalized dataset * found the latest version of dicom-microscopy-viewer that works with current OHIF extension : 0.35.2 * hide thumbnail pane by default, as we have issues with * comments * remove unused code * [feat] microscopy - annotation selection * [feat] microscopy - edit annotation label * wip * [bugfix] dicom-microscopy tool * [bugfix] dicom microscopy annotations * [fix] mixed-content blocking caused by BulkDataURI * [fix] microscopy measurements panel - center button * [fix] microscopy measurements panel - styling * [fix] microscopy - controls * fix local loading of microscopy * fix local loading of dicom microscopy * fix typo - indexof to indexOf * [fix] remove unused icons * remove commented out lines from webpack configuration * platform/viewer/public/config/default.js - revert accidental changes * [refactor] redirecting to microscopy mode on Local mode * attribution to DMV and SLIM viewer * [fix] code review feedbacks * fix thumbnails * [fix] microscopy - fix old publisher.publish() to PubSubService._broadcastEvent() * [fix] interactions, webpack config, roi selection * [feat] microscopy - remove select tool from UI * microscopy author * [fix] saving and loading SR * [bugfix] - missing publish() function in MicroscopyService, replace with _broadcastEvent * remove author section from readme * refactor SR saving feature * fix webpack config after merge * [bugfix] repeated import * fix e2e * webpack configuration * hide "Create report" button for microscopy
This commit is contained in:
76 files changed
+5868
-31
No files matched your search
@@ -0,0 +1,198 @@
|
||||
import { ServicesManager, CommandsManager, ExtensionManager } from '@ohif/core';
|
||||
import styles from './utils/styles';
|
||||
import callInputDialog from './utils/callInputDialog';
|
||||
|
||||
export default function getCommandsModule({
|
||||
servicesManager,
|
||||
commandsManager,
|
||||
extensionManager,
|
||||
}: {
|
||||
servicesManager: ServicesManager;
|
||||
commandsManager: CommandsManager;
|
||||
extensionManager: ExtensionManager;
|
||||
}) {
|
||||
const {
|
||||
viewportGridService,
|
||||
uiDialogService,
|
||||
microscopyService,
|
||||
} = servicesManager.services;
|
||||
|
||||
const actions = {
|
||||
// Measurement tool commands:
|
||||
deleteMeasurement: ({ uid }) => {
|
||||
if (uid) {
|
||||
const roiAnnotation = microscopyService.getAnnotation(uid);
|
||||
if (roiAnnotation) microscopyService.removeAnnotation(roiAnnotation);
|
||||
}
|
||||
},
|
||||
|
||||
setLabel: ({ uid }) => {
|
||||
const roiAnnotation = microscopyService.getAnnotation(uid);
|
||||
|
||||
callInputDialog({
|
||||
uiDialogService,
|
||||
title: 'Enter your annotation',
|
||||
defaultValue: '',
|
||||
callback: (value: string, action: string) => {
|
||||
switch (action) {
|
||||
case 'save': {
|
||||
roiAnnotation.setLabel(value);
|
||||
microscopyService.triggerRelabel(roiAnnotation);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
setToolActive: ({ toolName, toolGroupId = 'MICROSCOPY' }) => {
|
||||
const dragPanOnMiddle = [
|
||||
'dragPan',
|
||||
{
|
||||
bindings: {
|
||||
mouseButtons: ['middle'],
|
||||
},
|
||||
},
|
||||
];
|
||||
const dragZoomOnRight = [
|
||||
'dragZoom',
|
||||
{
|
||||
bindings: {
|
||||
mouseButtons: ['right'],
|
||||
},
|
||||
},
|
||||
];
|
||||
if (
|
||||
[
|
||||
'line',
|
||||
'box',
|
||||
'circle',
|
||||
'point',
|
||||
'polygon',
|
||||
'freehandpolygon',
|
||||
'freehandline',
|
||||
].indexOf(toolName) >= 0
|
||||
) {
|
||||
// TODO: read from configuration
|
||||
let options = {
|
||||
geometryType: toolName,
|
||||
vertexEnabled: true,
|
||||
styleOptions: styles.default,
|
||||
bindings: {
|
||||
mouseButtons: ['left'],
|
||||
},
|
||||
} as any;
|
||||
if ('line' === toolName) {
|
||||
options.minPoints = 2;
|
||||
options.maxPoints = 2;
|
||||
} else if ('point' === toolName) {
|
||||
delete options.styleOptions;
|
||||
delete options.vertexEnabled;
|
||||
}
|
||||
|
||||
microscopyService.activateInteractions([
|
||||
['draw', options],
|
||||
dragPanOnMiddle,
|
||||
dragZoomOnRight,
|
||||
]);
|
||||
} else if (toolName == 'dragPan') {
|
||||
microscopyService.activateInteractions([
|
||||
[
|
||||
'dragPan',
|
||||
{
|
||||
bindings: {
|
||||
mouseButtons: ['left', 'middle'],
|
||||
},
|
||||
},
|
||||
],
|
||||
dragZoomOnRight,
|
||||
]);
|
||||
} else {
|
||||
microscopyService.activateInteractions([
|
||||
[
|
||||
toolName,
|
||||
{
|
||||
bindings: {
|
||||
mouseButtons: ['left'],
|
||||
},
|
||||
},
|
||||
],
|
||||
dragPanOnMiddle,
|
||||
dragZoomOnRight,
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
incrementActiveViewport: () => {
|
||||
const { activeViewportIndex, viewports } = viewportGridService.getState();
|
||||
const nextViewportIndex = (activeViewportIndex + 1) % viewports.length;
|
||||
viewportGridService.setActiveViewportIndex(nextViewportIndex);
|
||||
},
|
||||
decrementActiveViewport: () => {
|
||||
const { activeViewportIndex, viewports } = viewportGridService.getState();
|
||||
const nextViewportIndex =
|
||||
(activeViewportIndex - 1 + viewports.length) % viewports.length;
|
||||
viewportGridService.setActiveViewportIndex(nextViewportIndex);
|
||||
},
|
||||
|
||||
toggleOverlays: () => {
|
||||
// overlay
|
||||
const overlays = document.getElementsByClassName(
|
||||
'microscopy-viewport-overlay'
|
||||
);
|
||||
let onoff = false; // true if this will toggle on
|
||||
for (let i = 0; i < overlays.length; i++) {
|
||||
if (i === 0) onoff = overlays.item(0).classList.contains('hidden');
|
||||
overlays.item(i).classList.toggle('hidden');
|
||||
}
|
||||
|
||||
// overview
|
||||
const { activeViewportIndex, viewports } = viewportGridService.getState();
|
||||
microscopyService.toggleOverviewMap(activeViewportIndex);
|
||||
},
|
||||
toggleAnnotations: () => {
|
||||
microscopyService.toggleROIsVisibility();
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
deleteMeasurement: {
|
||||
commandFn: actions.deleteMeasurement,
|
||||
storeContexts: [] as any[],
|
||||
options: {},
|
||||
},
|
||||
setLabel: {
|
||||
commandFn: actions.setLabel,
|
||||
storeContexts: [] as any[],
|
||||
options: {},
|
||||
},
|
||||
setToolActive: {
|
||||
commandFn: actions.setToolActive,
|
||||
storeContexts: [] as any[],
|
||||
options: {},
|
||||
},
|
||||
incrementActiveViewport: {
|
||||
commandFn: actions.incrementActiveViewport,
|
||||
storeContexts: [] as any[],
|
||||
},
|
||||
decrementActiveViewport: {
|
||||
commandFn: actions.decrementActiveViewport,
|
||||
storeContexts: [] as any[],
|
||||
},
|
||||
toggleOverlays: {
|
||||
commandFn: actions.toggleOverlays,
|
||||
storeContexts: [] as any[],
|
||||
options: {},
|
||||
},
|
||||
toggleAnnotations: {
|
||||
commandFn: actions.toggleAnnotations,
|
||||
storeContexts: [] as any[],
|
||||
options: {},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
actions,
|
||||
definitions,
|
||||
defaultContext: 'MICROSCOPY',
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user