Skip to content

Commit

Permalink
feat(ViewportActionBar and CinePlayer): Add new design for action bar…
Browse files Browse the repository at this point in the history
… and cine player (#3204)

* feat(ViewportActionBar): OHIF issue #3123 (#3186)

* feat(ViewportActionBar): OHIF issue #3123

- Renamed previous viewport action bar to be LegacyViewportActionBar
- Components LegacyViewportActionBar depends on also renamed: LegacyCinePlayer and LegacyPatientInfo
- New Viewport coded to specs in issue
- added React hook useResizeObserver
- added some tailwind classes

* Updated tailwind to 3.2.7.
Put external imports like React at the top of the import list.

* feat(CinePlayer and ViewportActionBar) (#3198)

* feat(CinePlayer and ViewportActionBar)
- OHIF issue 3123

- new look cine control implemented
- new custom blue color in tailwind config for various hover backgrounds in the cine control
- new icons added for cine

- Tooltip component now can be placed top (center) on hover
- Tooltip component border colour now consistent with specs

- fixed NPE in ViewportActionBar

- upgraded tailwind to 3.2.7 in platform/ui
- fixed issues in various button components brought by tailwind 3.2.7 where classes now need important flag

- fixed issue with InputRange component so that the tracked value property can change externally
- InputRange component can now optionally show its label

- added new measurement tracking state service to hydrate SR without prompting
- segmentation can also now be hydrated without prompting

* PR feedback:
- cine centralized to OHIFCornerstoneViewport
- introduced a type for the CinePlayer properties

* Addressed PR comments and concerns...

The DOM ref for the root component of the ViewportActionBar is now added to state
so that the various callbacks and ResizeObserver are updated with it.
The CinePlayer FPS slider tooltip was moved up so that its arrow does not
intersect the FPS text.
The hover area for the CinePlayer slider tooltip is now the FPS < > buttons and text.
The tracked measurements are now filtered to only include those of the active
viewport series when the tracked measurement navigation arrows are used.

* Addressed PR comments...

The update to tailwind 3.2.7 caused several look-and-feel, UI regressions,
so we are rolling back to 3.2.4.
  • Loading branch information
jbocce authored Feb 28, 2023
1 parent c9125a0 commit 35d0787
Show file tree
Hide file tree
Showing 55 changed files with 1,204 additions and 512 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import OHIF, { utils } from '@ohif/core';
import {
Notification,
ViewportActionBar,
useViewportGrid,
useViewportDialog,
LoadingIndicatorProgress,
LoadingIndicatorProgress, Notification, useViewportDialog, useViewportGrid, ViewportActionBar
} from '@ohif/ui';

import { useTranslation } from 'react-i18next';

import createSEGToolGroupAndAddTools from '../utils/initSEGToolGroup';
import _hydrateSEGDisplaySet from '../utils/_hydrateSEG';
import promptHydrateSEG from '../utils/promptHydrateSEG';
import hydrateSEGDisplaySet from '../utils/_hydrateSEG';
import _getStatusComponent from './_getStatusComponent';

const { formatDate } = utils;
Expand Down Expand Up @@ -307,16 +301,15 @@ function OHIFCornerstoneSEGViewport(props) {
SeriesNumber,
} = referencedDisplaySetRef.current.metadata;

const onPillClick = () => {
promptHydrateSEG({
servicesManager,
viewportIndex,
const onStatusClick = async () => {
const isHydrated = await hydrateSEGDisplaySet({
segDisplaySet,
}).then(isHydrated => {
if (isHydrated) {
setIsHydrated(true);
}
viewportIndex,
toolGroupId,
servicesManager,
});

setIsHydrated(isHydrated);
};

return (
Expand All @@ -330,14 +323,13 @@ function OHIFCornerstoneSEGViewport(props) {
getStatusComponent={() => {
return _getStatusComponent({
isHydrated,
onPillClick,
onStatusClick,
});
}}
studyData={{
label: viewportLabel,
useAltStyling: true,
studyDate: formatDate(StudyDate),
currentSeries: SeriesNumber,
seriesDescription: `SEG Viewport ${SeriesDescription}`,
patientInformation: {
patientName: PatientName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,92 +1,56 @@
import React from 'react';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { Icon, Tooltip } from '@ohif/ui';

import _hydrateSEGDisplaySet from '../utils/_hydrateSEG';

export default function _getStatusComponent({ isHydrated, onPillClick }) {
export default function _getStatusComponent({ isHydrated, onStatusClick }) {
let ToolTipMessage = null;
let StatusIcon = null;

const {t} = useTranslation("Common");
const loadStr = t("LOAD");

switch (isHydrated) {
case true:
StatusIcon = () => (
<div
className="flex items-center justify-center -mr-1 rounded-full"
style={{
width: '18px',
height: '18px',
backgroundColor: '#98e5c1',
border: 'solid 1.5px #000000',
}}
>
<Icon
name="exclamation"
style={{ color: '#000', width: '12px', height: '12px' }}
/>
</div>
);
StatusIcon = () => <Icon name="status-alert" />;

ToolTipMessage = () => (
<div>This Segmentation is loaded in the segmentation panel</div>
);
break;
case false:
StatusIcon = () => (
<div
className="flex items-center justify-center -mr-1 bg-white rounded-full group-hover:bg-customblue-200"
style={{
width: '18px',
height: '18px',
border: 'solid 1.5px #000000',
}}
>
<Icon
name="arrow-left"
style={{ color: '#000', width: '14px', height: '14px' }}
/>
</div>
);
case false:
StatusIcon = () => <Icon name="status-untracked" />;

ToolTipMessage = () => <div>Click to load segmentation.</div>;
ToolTipMessage = () => <div>Click LOAD to load segmentation.</div>;
}

const StatusPill = () => (
<div
className={classNames(
'group relative flex items-center justify-center px-8 rounded-full cursor-default bg-customgreen-100',
{
'hover:bg-customblue-100': !isHydrated,
'cursor-pointer': !isHydrated,
}
)}
style={{
height: '24px',
width: '55px',
}}
onClick={() => {
if (!isHydrated) {
if (onPillClick) {
onPillClick();
}
}
}}
>
<div className="pr-1 text-base font-medium leading-none text-black">
SEG
const StatusArea = () => (
<div className="flex h-6 leading-6 cursor-default text-sm text-white">
<div className="min-w-[45px] flex items-center p-1 rounded-l-xl rounded-r bg-customgray-100">
<StatusIcon />
<span className="ml-1">SEG</span>
</div>
<StatusIcon />
{!isHydrated && (
<div
className="ml-1 px-1.5 rounded cursor-pointer hover:text-black bg-primary-main hover:bg-primary-light"
// Using onMouseUp here because onClick is not working when the viewport is not active and is styled with pointer-events:none
onMouseUp={onStatusClick}
>
{loadStr}
</div>
)}
</div>
);


return (
<>
{ToolTipMessage && (
<Tooltip content={<ToolTipMessage />} position="bottom-left">
<StatusPill />
<StatusArea />
</Tooltip>
)}
{!ToolTipMessage && <StatusPill />}
{!ToolTipMessage && <StatusArea />}
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import OHIF, { utils } from '@ohif/core';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import OHIF, { utils } from '@ohif/core';
import { setTrackingUniqueIdentifiersForElement } from '../tools/modules/dicomSRModule';

import {
Icon,
Notification,
ViewportActionBar,
useViewportGrid,
useViewportDialog,
Tooltip,
Icon,
useViewportDialog,
useViewportGrid,
ViewportActionBar,
} from '@ohif/ui';
import classNames from 'classnames';
import hydrateStructuredReport from '../utils/hydrateStructuredReport';

const { formatDate } = utils;
Expand All @@ -33,8 +32,6 @@ function OHIFCornerstoneSRViewport(props) {
extensionManager,
} = props;

const { t } = useTranslation('SRViewport');

const {
displaySetService,
cornerstoneViewportService,
Expand Down Expand Up @@ -379,7 +376,6 @@ function OHIFCornerstoneSRViewport(props) {
label: viewportLabel,
useAltStyling: true,
studyDate: formatDate(StudyDate),
currentSeries: SeriesNumber,
seriesDescription: SeriesDescription || '',
patientInformation: {
patientName: PatientName
Expand Down Expand Up @@ -468,13 +464,16 @@ function _getStatusComponent({
isLocked,
sendTrackedMeasurementsEvent,
}) {
const onPillClick = () => {
sendTrackedMeasurementsEvent('RESTORE_PROMPT_HYDRATE_SR', {
const handleMouseUp = () => {
sendTrackedMeasurementsEvent('HYDRATE_SR', {
displaySetInstanceUID: srDisplaySet.displaySetInstanceUID,
viewportIndex,
});
};

const { t } = useTranslation('Common');
const loadStr = t('LOAD');

// 1 - Incompatible
// 2 - Locked
// 3 - Rehydratable / Open
Expand All @@ -485,22 +484,7 @@ function _getStatusComponent({

switch (state) {
case 1:
StatusIcon = () => (
<div
className="flex items-center justify-center -mr-1 rounded-full"
style={{
width: '18px',
height: '18px',
backgroundColor: '#98e5c1',
border: 'solid 1.5px #000000',
}}
>
<Icon
name="exclamation"
style={{ color: '#000', width: '12px', height: '12px' }}
/>
</div>
);
StatusIcon = () => <Icon name="status-alert" />;

ToolTipMessage = () => (
<div>
Expand All @@ -511,20 +495,7 @@ function _getStatusComponent({
);
break;
case 2:
StatusIcon = () => (
<div
className="flex items-center justify-center -mr-1 bg-black rounded-full"
style={{
width: '18px',
height: '18px',
}}
>
<Icon
name="lock"
style={{ color: '#05D97C', width: '8px', height: '11px' }}
/>
</div>
);
StatusIcon = () => <Icon name="status-locked" />;

ToolTipMessage = () => (
<div>
Expand All @@ -537,71 +508,41 @@ function _getStatusComponent({
);
break;
case 3:
StatusIcon = () => (
<div
className="flex items-center justify-center -mr-1 bg-white rounded-full group-hover:bg-customblue-200"
style={{
width: '18px',
height: '18px',
border: 'solid 1.5px #000000',
}}
>
<Icon
name="arrow-left"
style={{ color: '#000', width: '14px', height: '14px' }}
/>
</div>
);
StatusIcon = () => <Icon name="status-untracked" />;

ToolTipMessage = () => <div>Click to restore measurements.</div>;
ToolTipMessage = () => (
<div>{`Click ${loadStr} to restore measurements.`}</div>
);
}

const StatusPill = () => (
<div
className={classNames(
'group relative flex items-center justify-center px-2 rounded-full cursor-default bg-customgreen-100',
{
'hover:bg-customblue-100': state === 3,
'cursor-pointer': state === 3,
}
const StatusArea = () => (
<div className="flex h-6 leading-6 cursor-default text-sm text-white">
<div className="min-w-[45px] flex items-center p-1 rounded-l-xl rounded-r bg-customgray-100">
<StatusIcon />
<span className="ml-1">SR</span>
</div>
{state === 3 && (
<div
className="ml-1 px-1.5 rounded cursor-pointer hover:text-black bg-primary-main hover:bg-primary-light"
// Using onMouseUp here because onClick is not working when the viewport is not active and is styled with pointer-events:none
onMouseUp={handleMouseUp}
>
{loadStr}
</div>
)}
style={{
height: '24px',
width: '55px',
}}
onClick={() => {
if (state === 3) {
if (onPillClick) {
onPillClick();
}
}
}}
>
<span className="pr-1 text-lg font-bold leading-none text-black">SR</span>
<StatusIcon />
</div>
);

return (
<>
{ToolTipMessage && (
<Tooltip content={<ToolTipMessage />} position="bottom-left">
<StatusPill />
<StatusArea />
</Tooltip>
)}
{!ToolTipMessage && <StatusPill />}
{!ToolTipMessage && <StatusArea />}
</>
);
}

// function _onDoubleClick() {
// const cancelActiveManipulatorsForElement = cornerstoneTools.getModule(
// 'manipulatorState'
// ).setters.cancelActiveManipulatorsForElement;
// const enabledElements = cornerstoneTools.store.state.enabledElements;
// enabledElements.forEach(element => {
// cancelActiveManipulatorsForElement(element);
// });
// }

export default OHIFCornerstoneSRViewport;
Loading

0 comments on commit 35d0787

Please sign in to comment.