Skip to content

Instantly share code, notes, and snippets.

@marlocorridor
Created May 17, 2017 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marlocorridor/07e72e994e59cf3e342134365070689a to your computer and use it in GitHub Desktop.
Save marlocorridor/07e72e994e59cf3e342134365070689a to your computer and use it in GitHub Desktop.
(function () {
// Image decoders (for web workers)
dwv.image.decoderScripts = dicom_extenstions;
// base function to get elements
dwv.gui.getElement = dwv.gui.base.getElement;
dwv.gui.displayProgress = function (percent) {};
// create the dwv app
var app = new dwv.App();
// prepare options
var options = {
"containerDivId": "dwv",
"tools": []
};
// will determine if we will bind to scrolling
is_scrollable = dicom_urls.length > 1;
// use appropriate tool
if ( is_scrollable ) {
options.tools.push("Scroll");
}
// initialise with the id of the container div
app.init( options );
// load dicom data
app.loadURLs(
// set from template
dicom_urls
);
// setup scroll on range input
var range = document.getElementById("sliceRange");
if ( !is_scrollable ) {
// hide
range.style.display = "none";
// do not attach events
return;
}
range.min = 0;
app.addEventListener("load-end", function () {
range.max = app.getImage().getGeometry().getSize().getNumberOfSlices() - 1;
});
app.addEventListener("slice-change", function () {
range.value = app.getViewController().getCurrentPosition().k;
});
range.oninput = function () {
var pos = app.getViewController().getCurrentPosition();
pos.k = this.value;
app.getViewController().setCurrentPosition(pos);
};
})();
// end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment