feat(PDF):Add PDF viewer (#2730)

Display DICOM encapsulated PDF documents in a PDF viewer.
Addressed the remaining PR comments, and am merging this.
This commit is contained in:
Bill Wallace authored and GitHub committed 2022-04-04 09:48:14 -04:00
1 parent f3822f98a3
commit 82df3eac03
23 files changed
+376 -71

No files matched your search

@@ -1,7 +1,5 @@
import { SOPClassHandlerName, SOPClassHandlerId } from './id';
import { utils, classes } from '@ohif/core';
const { ImageSet } = classes;
import { Name, SOPClassHandlerId } from './id';
import { utils, } from '@ohif/core';
const SOP_CLASS_UIDS = {
VIDEO_MICROSCOPIC_IMAGE_STORAGE: '1.2.840.10008.5.1.4.1.1.77.1.2.1',
@@ -36,8 +34,7 @@ const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager)
return supportedTransferSyntaxUIDs.includes(tsuid);
})
.map(instance => {
const { Modality, FrameOfReferenceUID, SOPInstanceUID } = instance;
const { SeriesDescription, ContentDate, ContentTime } = instance;
const { Modality, SOPInstanceUID, SeriesDescription = "VIDEO" } = instance;
const { SeriesNumber, SeriesDate, SeriesInstanceUID, StudyInstanceUID, NumberOfFrames } = instance;
const displaySet = {
//plugin: id,
@@ -52,7 +49,7 @@ const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager)
SOPClassHandlerId,
referencedImages: null,
measurements: null,
videoUrl: dataSource.retrieve.directURL({ instance }),
videoUrl: dataSource.retrieve.directURL({ instance, singlepart: "video", tag: "PixelData", }),
others: [instance],
thumbnailSrc: dataSource.retrieve.directURL({ instance, defaultPath: "/thumbnail", defaultType: "image/jpeg", tag: "Absent" }),
isDerivedDisplaySet: true,
@@ -76,7 +73,7 @@ export default function getSopClassHandlerModule({ servicesManager, extensionMan
return [
{
name: SOPClassHandlerName,
name: Name,
sopClassUids,
getDisplaySetsFromSeries,
},
+5 -4
View File
@@ -1,7 +1,8 @@
const id = 'org.ohif.dicom-video';
const Name = 'dicom-video';
const id = `org.ohif.${Name}`;
export default id;
const SOPClassHandlerName = 'dicom-video';
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${SOPClassHandlerName}`;
export { SOPClassHandlerName, SOPClassHandlerId };
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${Name}`;
export { Name, SOPClassHandlerId, };
@@ -1,51 +1,36 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import cornerstoneTools from 'cornerstone-tools';
import cornerstone from 'cornerstone-core';
import CornerstoneViewport from 'react-cornerstone-viewport';
import OHIF, { DicomMetadataStore, utils } from '@ohif/core';
import {
Notification,
ViewportActionBar,
useViewportGrid,
useViewportDialog,
} from '@ohif/ui';
import { adapters } from 'dcmjs';
import id from '../id';
function OHIFCornerstoneVideoViewport({
children,
dataSource,
displaySet,
viewportIndex,
servicesManager,
extensionManager,
}) {
const {
DisplaySetService,
MeasurementService,
ToolBarService,
} = servicesManager.services;
const { videoUrl } = displaySet;
const mimeType = "video/mp4";
const [url, setUrl] = useState(null);
useEffect(async () => {
setUrl(await videoUrl);
});
// Need to copies of the source to fix a firefox bug
return (
<div className="bg-primary-black w-full h-full">
<video
src={videoUrl}
src={url}
controls
controlsList="nodownload"
preload="auto"
className="w-full h-full"
>
<source src={videoUrl} type={mimeType} />
<source src={videoUrl} type={mimeType} />
Video src/type not supported: <a href={videoUrl}>{videoUrl} of type {mimeType}</a>
<source src={url} type={mimeType} />
<source src={url} type={mimeType} />
Video src/type not supported: <a href={url}>{url} of type {mimeType}</a>
</video>
</div>
)
}
OHIFCornerstoneVideoViewport.propTypes = {
displaySet: PropTypes.object.isRequired,
};
export default OHIFCornerstoneVideoViewport;