feat: Add new annotate tool using new dialog service (#1211)

* Testing dialog

* Refactor modal and add dialog component to simple dialog

* Use existent dialog

* Expect event from getText callback (annotation)

* Bump cornerstone-tools version

* Use simple dialog

* bump cornersotne version

* CR Update: Update dialgo method names and default values

* CR Update: Bump overlay and show only if theres at least one overlay prop set to true

* CR Update: Use percentage over view height in draggable area

* Fix broken test vtk checks WWWC tool

* Comment test (non-deterministic)
This commit is contained in:
Igor Octaviano authored and Danny Brown committed 2019-11-25 17:13:42 -05:00
1 parent 1334ba8eb0
commit 8fd3af1e13
18 files changed
+372 -254

No files matched your search

@@ -8,6 +8,7 @@ import {
getResetLabellingAndContextMenu,
} from './labelingFlowCallbacks.js';
import throttle from 'lodash.throttle';
import { SimpleDialog } from '@ohif/ui';
// TODO: This only works because we have a hard dependency on this extension
// We need to decouple and make stuff like this possible w/o bundling this at
@@ -35,6 +36,28 @@ const MEASUREMENT_ACTION_MAP = {
* @param {*} configuration
*/
export default function init({ servicesManager, configuration = {} }) {
const { UIDialogService } = servicesManager.services;
const callInputDialog = (data, event, callback) => {
let dialogId = UIDialogService.create({
content: SimpleDialog.InputDialog,
defaultPosition: {
x: (event && event.currentPoints.canvas.x) || 0,
y: (event && event.currentPoints.canvas.y) || 0,
},
showOverlay: true,
contentProps: {
title: 'Enter your annotation',
label: 'New label',
defaultValue: data ? data.text : '',
onClose: () => UIDialogService.dismiss({ id: dialogId }),
onSubmit: value => {
callback(value);
UIDialogService.dismiss({ id: dialogId });
},
},
});
};
// If these tools were already added by a different extension, we want to replace
// them with the same tools that have an alternative configuration. By passing in
// our custom `getMeasurementLocationCallback`, we can...
@@ -90,6 +113,10 @@ export default function init({ servicesManager, configuration = {} }) {
csTools.addTool(csTools.ArrowAnnotateTool, {
configuration: {
getMeasurementLocationCallback: toolLabellingFlowCallback,
getTextCallback: (callback, eventDetails) =>
callInputDialog(null, eventDetails, callback),
changeTextCallback: (data, eventDetails, callback) =>
callInputDialog(data, eventDetails, callback),
},
});
@@ -36,18 +36,14 @@ class Header extends Component {
}
loadOptions() {
const {
t,
user,
userManager,
modal: { show },
} = this.props;
const { t, user, userManager, modal } = this.props;
this.options = [
{
title: t('About'),
icon: { name: 'info' },
onClick: () =>
show(AboutContent, {
modal.show({
content: AboutContent,
title: t('OHIF Viewer - About'),
}),
},
@@ -57,7 +53,8 @@ class Header extends Component {
name: 'user',
},
onClick: () =>
show(ConnectedUserPreferencesForm, {
modal.show({
content: ConnectedUserPreferencesForm,
title: t('User Preferences'),
}),
},
@@ -308,7 +308,8 @@ function _handleBuiltIn(button) {
}
if (options.behavior === 'DOWNLOAD_SCREEN_SHOT') {
modal.show(ConnectedViewportDownloadForm, {
modal.show({
content: ConnectedViewportDownloadForm,
title: t('Download High Quality Image'),
});
}
@@ -1,20 +1,20 @@
.dicom-uploader .button {
float: left;
margin: 5px;
float: left;
margin: 5px;
}
.invisible-input {
position: absolute;
display: none;
z-index: -1000;
max-width: 0 !important;
max-height: 0 !important;
position: absolute;
display: none;
z-index: -1000;
max-width: 0 !important;
max-height: 0 !important;
}
.dicom-uploader .table-header {
color: #ffffff;
font-size: 16px;
font-weight: 28px;
text-align: left;
margin: 20px auto;
color: #ffffff;
font-size: 16px;
font-weight: 28px;
text-align: left;
margin: 20px auto;
}