-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display DICOM encapsulated PDF documents in a PDF viewer. Addressed the remaining PR comments, and am merging this.
- Loading branch information
1 parent
f3822f9
commit 82df3ea
Showing
23 changed files
with
376 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Open Health Imaging Foundation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# DICOM Encapsulated PDF | ||
This extension adds support for displaying DICOM encapsulated PDF documents. | ||
|
||
The extension is a "standard" extension in that it is installed and available | ||
by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@ohif/extension-dicom-pdf", | ||
"version": "3.0.1", | ||
"description": "OHIF extension for PDF display", | ||
"author": "OHIF", | ||
"license": "MIT", | ||
"repository": "OHIF/Viewers", | ||
"main": "dist/index.umd.js", | ||
"module": "src/index.js", | ||
"engines": { | ||
"node": ">=10", | ||
"npm": ">=6", | ||
"yarn": ">=1.16.0" | ||
}, | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo", | ||
"dev:cornerstone": "yarn run dev", | ||
"build": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js", | ||
"build:package": "yarn run build", | ||
"start": "yarn run dev", | ||
"test:unit": "jest --watchAll", | ||
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests" | ||
}, | ||
"peerDependencies": { | ||
"@ohif/core": "^0.50.0", | ||
"@ohif/ui": "^0.50.0", | ||
"cornerstone-core": "^2.6.0", | ||
"cornerstone-math": "^0.1.9", | ||
"cornerstone-tools": "6.0.2", | ||
"cornerstone-wado-image-loader": "4.0.4", | ||
"dcmjs": "0.16.1", | ||
"dicom-parser": "^1.8.9", | ||
"hammerjs": "^2.0.8", | ||
"prop-types": "^15.6.2", | ||
"react": "^17.0.2", | ||
"react-cornerstone-viewport": "4.1.2" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "7.7.6", | ||
"classnames": "^2.2.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Name, SOPClassHandlerId } from './id'; | ||
import { utils, classes } from '@ohif/core'; | ||
|
||
const { ImageSet } = classes; | ||
|
||
const SOP_CLASS_UIDS = { | ||
ENCAPSULATED_PDF: '1.2.840.10008.5.1.4.1.1.104.1', | ||
}; | ||
|
||
const sopClassUids = Object.values(SOP_CLASS_UIDS); | ||
|
||
|
||
const _getDisplaySetsFromSeries = (instances, servicesManager, extensionManager) => { | ||
const dataSource = extensionManager.getActiveDataSource()[0]; | ||
return instances | ||
.map(instance => { | ||
const { Modality, SOPInstanceUID, EncapsulatedDocument } = instance; | ||
const { SeriesDescription = "PDF", MIMETypeOfEncapsulatedDocument, } = instance; | ||
const { SeriesNumber, SeriesDate, SeriesInstanceUID, StudyInstanceUID, } = instance; | ||
const pdfUrl = dataSource.retrieve.directURL({ | ||
instance, | ||
tag: 'EncapsulatedDocument', | ||
defaultType: MIMETypeOfEncapsulatedDocument || "application/pdf", | ||
singlepart: "pdf", | ||
}); | ||
|
||
const displaySet = { | ||
//plugin: id, | ||
Modality, | ||
displaySetInstanceUID: utils.guid(), | ||
SeriesDescription, | ||
SeriesNumber, | ||
SeriesDate, | ||
SOPInstanceUID, | ||
SeriesInstanceUID, | ||
StudyInstanceUID, | ||
SOPClassHandlerId, | ||
referencedImages: null, | ||
measurements: null, | ||
pdfUrl, | ||
others: [instance], | ||
thumbnailSrc: dataSource.retrieve.directURL({ instance, defaultPath: "/thumbnail", defaultType: "image/jpeg", tag: "Absent" }), | ||
isDerivedDisplaySet: true, | ||
isLoaded: false, | ||
sopClassUids, | ||
numImageFrames: 0, | ||
numInstances: 1, | ||
instance, | ||
}; | ||
return displaySet; | ||
}); | ||
}; | ||
|
||
export default function getSopClassHandlerModule({ servicesManager, extensionManager }) { | ||
const getDisplaySetsFromSeries = instances => { | ||
return _getDisplaySetsFromSeries( | ||
instances, | ||
servicesManager, | ||
extensionManager | ||
); | ||
}; | ||
|
||
return [ | ||
{ | ||
name: Name, | ||
sopClassUids, | ||
getDisplaySetsFromSeries, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Name = 'dicom-pdf'; | ||
const id = `org.ohif.${Name}`; | ||
|
||
export default id; | ||
|
||
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${Name}`; | ||
|
||
export { Name, SOPClassHandlerId, }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import getSopClassHandlerModule from './getSopClassHandlerModule'; | ||
import id from './id.js'; | ||
|
||
const Component = React.lazy(() => { | ||
return import( | ||
/* webpackPrefetch: true */ './viewports/OHIFCornerstonePdfViewport' | ||
); | ||
}); | ||
|
||
const OHIFCornerstonePdfViewport = props => { | ||
return ( | ||
<React.Suspense fallback={<div>Loading...</div>}> | ||
<Component {...props} /> | ||
</React.Suspense> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
*/ | ||
export default { | ||
/** | ||
* Only required property. Should be a unique value across all extensions. | ||
*/ | ||
id, | ||
dependencies: [ | ||
// TODO -> This isn't used anywhere yet, but we do have a hard dependency, and need to check for these in the future. | ||
// OHIF-229 | ||
{ | ||
id: 'org.ohif.cornerstone', | ||
version: '3.0.0', | ||
}, | ||
{ | ||
id: 'org.ohif.measurement-tracking', | ||
version: '^0.0.1', | ||
}, | ||
], | ||
|
||
preRegistration({ servicesManager, configuration = {} }) { | ||
// No-op for now | ||
}, | ||
|
||
/** | ||
* | ||
* | ||
* @param {object} [configuration={}] | ||
* @param {object|array} [configuration.csToolsConfig] - Passed directly to `initCornerstoneTools` | ||
*/ | ||
getViewportModule({ servicesManager, extensionManager }) { | ||
const ExtendedOHIFCornerstonePdfViewport = props => { | ||
return ( | ||
<OHIFCornerstonePdfViewport | ||
servicesManager={servicesManager} | ||
extensionManager={extensionManager} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
return [{ name: 'dicom-pdf', component: ExtendedOHIFCornerstonePdfViewport }]; | ||
}, | ||
getCommandsModule({ servicesManager }) { | ||
return { | ||
definitions: { | ||
setToolActive: { | ||
commandFn: () => null, | ||
storeContexts: [], | ||
options: {}, | ||
}, | ||
}, | ||
defaultContext: 'ACTIVE_VIEWPORT::PDF', | ||
}; | ||
}, | ||
getSopClassHandlerModule, | ||
}; |
26 changes: 26 additions & 0 deletions
26
extensions/dicom-pdf/src/viewports/OHIFCornerstonePdfViewport.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
function OHIFCornerstonePdfViewport({ | ||
displaySet, | ||
}) { | ||
const [url, setUrl] = useState(null); | ||
const { pdfUrl } = displaySet; | ||
useEffect(async () => { | ||
setUrl(await pdfUrl); | ||
}); | ||
|
||
return ( | ||
<div className="bg-primary-black w-full h-full"> | ||
<object data={url} type="application/pdf" className="w-full h-full"> | ||
<div>No online PDF viewer installed</div> | ||
</object> | ||
</div> | ||
) | ||
} | ||
|
||
OHIFCornerstonePdfViewport.propTypes = { | ||
displaySet: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default OHIFCornerstonePdfViewport; |
Oops, something went wrong.