-
Notifications
You must be signed in to change notification settings - Fork 2
/
react.js
68 lines (63 loc) · 2.3 KB
/
react.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React from "react"
import ReactDOM from 'react-dom'
import cornerstone from "cornerstone-core"
import cornerstoneTools from "cornerstone-tools"
import RotatedEllipticalRoiTool from "cornerstone-tools-rotated-elliptical-roi-tool"
import cornerstoneWebImageLoader from "cornerstone-web-image-loader"
import cornerstoneMath from "cornerstone-math"
import Hammer from "hammerjs"
export default class Viewer extends React.Component {
componentDidMount() {
cornerstoneTools.external.cornerstone = cornerstone
cornerstoneWebImageLoader.external.cornerstone = cornerstone
cornerstoneTools.external.Hammer = Hammer
cornerstoneTools.external.cornerstoneMath = cornerstoneMath
cornerstone.registerImageLoader("http", cornerstoneWebImageLoader.loadImage)
cornerstone.registerImageLoader(
"https",
cornerstoneWebImageLoader.loadImage,
)
cornerstoneTools.init({
showSVGCursors: true,
})
cornerstoneTools.toolColors.setToolColor("orange")
// Enable Element
const element = document.querySelector("#cornerstone-element")
cornerstone.enable(element)
// Load and Display Image
const exampleImageId =
"https://rawgit.com/dannyrb/cornerstone-vuejs-poc/master/static/simple-study/1.2.276.0.74.3.1167540280.200511.112514.1.1.10.jpg"
cornerstone.loadImage(exampleImageId).then(function(image) {
cornerstone.displayImage(element, image)
const WwwcTool = cornerstoneTools.WwwcTool
const PanTool = cornerstoneTools.PanTool
const EraserTool = cornerstoneTools.EraserTool
cornerstoneTools.addTool(WwwcTool)
cornerstoneTools.addTool(PanTool)
cornerstoneTools.addTool(EraserTool)
cornerstoneTools.setToolActive("Pan", { mouseButtonMask: 4 })
cornerstoneTools.setToolActive("Eraser", { mouseButtonMask: 2 })
cornerstoneTools.addTool(RotatedEllipticalRoiTool)
cornerstoneTools.setToolActive("RotatedEllipticalRoi", {
mouseButtonMask: 1,
})
})
}
render() {
return (
<div
id="cornerstone-element"
onContextMenu={() => {
return false
}}
style={{
width: 512,
height: 512,
margin: "0 auto",
background: "black",
}}
></div>
)
}
}
ReactDOM.render(<Viewer />, document.getElementById('root'))