Last active
April 19, 2024 01:47
-
-
Save ivmartel/8bae193e47c0d1e7a29e1dbc43edb4f5 to your computer and use it in GitHub Desktop.
Add external tool example
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
<!DOCTYPE html> | |
<head> | |
<style type="text/css"> | |
body { | |
font-family: Arial, Helvetica, sans-serif; | |
} | |
html, body { | |
height: 99%; | |
} | |
</style> | |
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | |
<script type="text/javascript"> | |
function onDOMContentLoaded() { | |
// create the dwv app | |
const app = new dwv.App(); | |
// initialise | |
const viewConfig0 = new dwv.ViewConfig('layerGroup0'); | |
const viewConfigs = {'*': [viewConfig0]}; | |
const options = new dwv.AppOptions(viewConfigs); | |
// simple demo tool | |
class AlertTool { | |
mousedown() { | |
alert('bouh'); | |
}; | |
init() {}; | |
activate() {} | |
}; | |
// add to tools constructor list | |
dwv.toolList['Alert'] = AlertTool; | |
// add to app options | |
options.tools = {'Alert': {}}; | |
// activate tool on data load | |
app.addEventListener('load', function () { | |
app.setTool('Alert'); | |
}); | |
// init app | |
app.init(options); | |
// load dicom data | |
app.loadURLs([ | |
'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm' | |
]); | |
}; | |
document.addEventListener('DOMContentLoaded', onDOMContentLoaded); | |
</script> | |
</head> | |
<body> | |
<div id='dwv'><div id='layerGroup0'></div></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for giving access to dwv.toolList