OHIF-223: Add "Clear" all measurements to annotation toolbar (#1861)
* Add clear button * Use james event * Create new commands module to default
This commit is contained in:
1 parent
61fc093fc5
commit
11fbe4cf01
13 files changed
+112
-7
No files matched your search
@@ -121,6 +121,7 @@ const commandsModule = ({ servicesManager }) => {
|
||||
lesionNamingNumber,
|
||||
measurementNumber,
|
||||
} = measurementData;
|
||||
|
||||
if (!_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ const _connectToolsToMeasurementService = measurementService => {
|
||||
const csToolsVer4MeasurementSource = _initMeasurementService(
|
||||
measurementService
|
||||
);
|
||||
_connectMeasurementServiceToTools(measurementService, csToolsVer4MeasurementSource);
|
||||
const { addOrUpdate, remove } = csToolsVer4MeasurementSource;
|
||||
const elementEnabledEvt = cornerstone.EVENTS.ELEMENT_ENABLED;
|
||||
|
||||
@@ -335,6 +336,30 @@ const _connectToolsToMeasurementService = measurementService => {
|
||||
});
|
||||
};
|
||||
|
||||
const _connectMeasurementServiceToTools = (measurementService, measurementSource) => {
|
||||
const { MEASUREMENTS_CLEARED, MEASUREMENT_REMOVED } = measurementService.EVENTS;
|
||||
const sourceId = measurementSource.id;
|
||||
|
||||
measurementService.subscribe(MEASUREMENTS_CLEARED, () => {
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(
|
||||
{}
|
||||
);
|
||||
cornerstone.getEnabledElements().forEach(enabledElement => {
|
||||
cornerstone.updateImage(enabledElement.element);
|
||||
});
|
||||
});
|
||||
|
||||
/* TODO: Remove per measurement
|
||||
measurementService.subscribe(MEASUREMENT_REMOVED,
|
||||
({ source, measurement }) => {
|
||||
if ([sourceId].includes(source.id)) {
|
||||
// const annotation = getAnnotation('Length', measurement.id);
|
||||
// iterate tool state
|
||||
}
|
||||
}
|
||||
); */
|
||||
};
|
||||
|
||||
// const {
|
||||
// MEASUREMENT_ADDED,
|
||||
// MEASUREMENT_UPDATED,
|
||||
|
||||
@@ -23,9 +23,10 @@ export default function PanelMeasurementTable({
|
||||
const added = MeasurementService.EVENTS.MEASUREMENT_ADDED;
|
||||
const updated = MeasurementService.EVENTS.MEASUREMENT_UPDATED;
|
||||
const removed = MeasurementService.EVENTS.MEASUREMENT_REMOVED;
|
||||
const cleared = MeasurementService.EVENTS.MEASUREMENTS_CLEARED;
|
||||
const subscriptions = [];
|
||||
|
||||
[added, updated, removed].forEach(evt => {
|
||||
[added, updated, removed, cleared].forEach(evt => {
|
||||
subscriptions.push(
|
||||
MeasurementService.subscribe(evt, () => {
|
||||
debouncedSetDisplayMeasurements(
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
const commandsModule = ({ servicesManager }) => {
|
||||
const { MeasurementService } = servicesManager.services;
|
||||
|
||||
const actions = {
|
||||
clearMeasurements: () => {
|
||||
MeasurementService.clear();
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
clearMeasurements: {
|
||||
commandFn: actions.clearMeasurements,
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
actions,
|
||||
definitions,
|
||||
defaultContext: 'DEFAULT',
|
||||
};
|
||||
};
|
||||
|
||||
export default commandsModule;
|
||||
@@ -3,7 +3,7 @@ import { ViewModelContext } from '@ohif/core';
|
||||
|
||||
const HelloWorldContext = React.createContext({
|
||||
message: 'HelloWorldContextTesting',
|
||||
setMessage: () => {},
|
||||
setMessage: () => { },
|
||||
});
|
||||
|
||||
HelloWorldContext.displayName = 'HelloWorldContext';
|
||||
|
||||
@@ -4,6 +4,7 @@ import getLayoutTemplateModule from './getLayoutTemplateModule.js';
|
||||
import getPanelModule from './getPanelModule.js';
|
||||
import getSopClassHandlerModule from './getSopClassHandlerModule.js';
|
||||
import getToolbarModule from './getToolbarModule.js';
|
||||
import commandsModule from './commandsModule';
|
||||
import id from './id';
|
||||
|
||||
export default {
|
||||
@@ -17,4 +18,7 @@ export default {
|
||||
getPanelModule,
|
||||
getSopClassHandlerModule,
|
||||
getToolbarModule,
|
||||
getCommandsModule({ servicesManager }) {
|
||||
return commandsModule({ servicesManager });
|
||||
},
|
||||
};
|
||||
@@ -101,9 +101,10 @@ function PanelMeasurementTableTracking({ servicesManager, extensionManager }) {
|
||||
const added = MeasurementService.EVENTS.MEASUREMENT_ADDED;
|
||||
const updated = MeasurementService.EVENTS.MEASUREMENT_UPDATED;
|
||||
const removed = MeasurementService.EVENTS.MEASUREMENT_REMOVED;
|
||||
const cleared = MeasurementService.EVENTS.MEASUREMENTS_CLEARED;
|
||||
const subscriptions = [];
|
||||
|
||||
[added, updated, removed].forEach(evt => {
|
||||
[added, updated, removed, cleared].forEach(evt => {
|
||||
subscriptions.push(
|
||||
MeasurementService.subscribe(evt, () => {
|
||||
setMeasurementsUpdated(Date.now().toString());
|
||||
|
||||
Reference in new issue
Block a user