Skip to content

Commit

Permalink
feat(config): Add activateViewportBeforeInteraction parameter for vie…
Browse files Browse the repository at this point in the history
…wport interaction customization (OHIF#3847)
  • Loading branch information
Sofien-Sellami authored and thanh-nguyen-dang committed Apr 30, 2024
1 parent f1f6ab6 commit 91d5591
Show file tree
Hide file tree
Showing 11 changed files with 2,890 additions and 3,614 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"prettier.endOfLine": "lf",
"workbench.colorCustomizations": {},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
3 changes: 2 additions & 1 deletion modes/basic-dev-mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@ohif/extension-dicom-video": "3.8.0-beta.28"
},
"dependencies": {
"@babel/runtime": "^7.20.13"
"@babel/runtime": "^7.20.13",
"i18next": "^17.0.3"
},
"devDependencies": {
"webpack": "^5.50.0",
Expand Down
3 changes: 2 additions & 1 deletion modes/basic-test-mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"@ohif/extension-test": "3.8.0-beta.28"
},
"dependencies": {
"@babel/runtime": "^7.20.13"
"@babel/runtime": "^7.20.13",
"i18next": "^17.0.3"
},
"devDependencies": {
"webpack": "^5.50.0",
Expand Down
3 changes: 2 additions & 1 deletion modes/longitudinal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"@ohif/extension-measurement-tracking": "3.8.0-beta.28"
},
"dependencies": {
"@babel/runtime": "^7.20.13"
"@babel/runtime": "^7.20.13",
"i18next": "^17.0.3"
},
"devDependencies": {
"webpack": "^5.50.0",
Expand Down
3 changes: 2 additions & 1 deletion modes/microscopy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@ohif/extension-dicom-microscopy": "3.8.0-beta.28"
},
"dependencies": {
"@babel/runtime": "^7.20.13"
"@babel/runtime": "^7.20.13",
"i18next": "^17.0.3"
}
}
3 changes: 2 additions & 1 deletion modes/segmentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"@ohif/core": "3.8.0-beta.28"
},
"dependencies": {
"@babel/runtime": "^7.20.13"
"@babel/runtime": "^7.20.13",
"i18next": "^17.0.3"
},
"devDependencies": {
"@babel/core": "^7.23.2",
Expand Down
3 changes: 1 addition & 2 deletions modes/segmentation/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { hotkeys } from '@ohif/core';
import { id } from './id';
import toolbarButtons from './toolbarButtons';
import initToolGroups from './initToolGroups';
import i18n from 'i18next';

const ohif = {
layout: '@ohif/extension-default.layoutTemplateModule.viewerLayout',
Expand Down Expand Up @@ -45,7 +44,7 @@ function modeFactory({ modeConfiguration }) {
* Mode name, which is displayed in the viewer's UI in the workList, for the
* user to select the mode.
*/
displayName: i18n.t('Modes:Segmentation'),
displayName: 'Segmentation',
/**
* Runs when the Mode Route is mounted to the DOM. Usually used to initialize
* Services and other resources.
Expand Down
3 changes: 2 additions & 1 deletion modes/tmtv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"@ohif/extension-measurement-tracking": "3.8.0-beta.28"
},
"dependencies": {
"@babel/runtime": "^7.20.13"
"@babel/runtime": "^7.20.13",
"i18next": "^17.0.3"
},
"devDependencies": {
"webpack": "^5.50.0",
Expand Down
17 changes: 15 additions & 2 deletions platform/app/src/components/ViewportGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { useEffect, useCallback } from 'react';
import React, {useEffect, useCallback, useMemo} from 'react';
import PropTypes from 'prop-types';
import { ServicesManager, Types, MeasurementService } from '@ohif/core';
import { ViewportGrid, ViewportPane, useViewportGrid } from '@ohif/ui';
import EmptyViewport from './EmptyViewport';
import classNames from 'classnames';
import { useAppConfig } from '@state';

function ViewerViewportGrid(props) {
const { servicesManager, viewportComponents, dataSource } = props;
Expand All @@ -17,6 +18,18 @@ function ViewerViewportGrid(props) {
servicesManager as ServicesManager
).services;

/**
* Determine whether users need to use the tools directly, or whether they need to click once to activate the viewport before using tools.
* If 'activateViewportBeforeInteraction' is available in the 'window.config' object, use its value;
* otherwise, default to true.
* If true, users need to click once to activate the viewport before using the tools.
* if false, tools can be used directly.
*/
const activateViewportBeforeInteraction = useMemo(() => {
const [appConfig] = useAppConfig();
return appConfig?.activateViewportBeforeInteraction ?? true;
}, []);

/**
* This callback runs after the viewports structure has changed in any way.
* On initial display, that means if it has changed by applying a HangingProtocol,
Expand Down Expand Up @@ -311,7 +324,7 @@ function ViewerViewportGrid(props) {
<div
data-cy="viewport-pane"
className={classNames('flex h-full w-full flex-col', {
'pointer-events-none': !isActive,
'pointer-events-none': !isActive && activateViewportBeforeInteraction,
})}
>
<ViewportComponent
Expand Down
1 change: 1 addition & 0 deletions platform/docs/docs/configuration/configurationFiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ if auth headers are used, a preflight request is required.
load the volume progressively as the data arrives (each webworker has the shared buffer and can write to it). However, there might be certain environments that do not support sharedArrayBuffer. In that case, you can set this flag to false and the viewer will use the regular arrayBuffer which might be slower for large volume loading.
- `supportsWildcard`: (default to false), if set to true, the datasource will support wildcard matching for patient name and patient id.
- `allowMultiSelectExport`: (default to false), if set to true, the user will be able to select the datasource to export the report to.
- `activateViewportBeforeInteraction`: (default to true), if set to false, tools can be used directly without the need to click and activate the viewport.
- `autoPlayCine`: (default to false), if set to true, data sets with the DICOM frame time tag (i.e. (0018,1063)) will auto play when displayed
- `dangerouslyUseDynamicConfig`: Dynamic config allows user to pass `configUrl` query string. This allows to load config without recompiling application. If the `configUrl` query string is passed, the worklist and modes will load from the referenced json rather than the default .env config. If there is no `configUrl` path provided, the default behaviour is used and there should not be any deviation from current user experience.<br/>
Points to consider while using `dangerouslyUseDynamicConfig`:<br/>
Expand Down
Loading

0 comments on commit 91d5591

Please sign in to comment.