Skip to content

Instantly share code, notes, and snippets.

@ivmartel
Last active April 19, 2024 01:47
Show Gist options
  • Save ivmartel/8bae193e47c0d1e7a29e1dbc43edb4f5 to your computer and use it in GitHub Desktop.
Save ivmartel/8bae193e47c0d1e7a29e1dbc43edb4f5 to your computer and use it in GitHub Desktop.
Add external tool example
<!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/dwv@0.33.0-beta.38"></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>
@arhitiron
Copy link

Thanks for giving access to dwv.toolList

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment