Start switch to cornerstone
This commit is contained in:
@@ -35,57 +35,22 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
|
||||
if($(".dwv-container").length) {
|
||||
$(".dwv-container").append($('<!-- DWV --> <div id="dwv"> <!-- Toolbar --> <div class="toolbar"></div> <input type="range" id="sliceRange" value="0"><!-- Layer Container --> <div class="layerContainer"> <div class="dropBox"></div> <canvas class="imageLayer">Only for HTML5 compatible browsers...</canvas> <div class="infoLayer"> <div class="infotl"></div> <div class="infotc"></div> <div class="infotr"></div> <div class="infocl"></div> <div class="infocr"></div> <div class="infobl"></div> <div class="infobc"></div> <div class="infobr" style="bottom: 64px;"></div></div></div><!-- /layerContainer --> <!-- /dwv -->'));
|
||||
if($("#dicom-element").length) {
|
||||
const element = document.getElementById('dicom-element');
|
||||
const imageId = element.dataset.url;
|
||||
|
||||
var app = new dwv.App();
|
||||
dwvapp = app;
|
||||
//DEBUG
|
||||
var listenerWL = function (event) {
|
||||
console.log("event: " + event.type);
|
||||
console.log(event);
|
||||
$(".infotc").text(event.wc);
|
||||
};
|
||||
app.addEventListener("wl-width-change", listenerWL);
|
||||
//app.addEventListener("wl-center-change", listener);
|
||||
app.init({
|
||||
cornerstone.enable(element);
|
||||
cornerstone.loadAndCacheImage(imageId).then(function(image) {
|
||||
cornerstone.displayImage(element, image);
|
||||
|
||||
"containerDivId": "dwv",
|
||||
"fitToWindow": true,
|
||||
"isMobile": true,
|
||||
"gui": ["tool"],
|
||||
"filters": ["Threshold", "Sharpen", "Sobel"],
|
||||
"tools": ["Scroll", "WindowLevel", "ZoomAndPan"], // or try "ZoomAndPan"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var range = document.getElementById("sliceRange");
|
||||
range.min = 0;
|
||||
app.addEventListener("load-end", function () {
|
||||
range.max = app.getImage().getGeometry().getSize().getNumberOfSlices() - 1;
|
||||
|
||||
if(range.max == 0) {
|
||||
$(range).hide();
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
try {
|
||||
app.loadURLs([$(".dwv-container").data("url")]);
|
||||
} catch(error) {
|
||||
toastr.error(error.message);
|
||||
|
||||
}
|
||||
dwv.gui.appendResetHtml(app);
|
||||
// Enable our tools
|
||||
cornerstoneTools.mouseInput.enable(element);
|
||||
cornerstoneTools.mouseWheelInput.enable(element);
|
||||
cornerstoneTools.wwwc.activate(element, 1); // Left Click
|
||||
cornerstoneTools.pan.activate(element, 2); // Middle Click
|
||||
cornerstoneTools.zoom.activate(element, 4); // Right Click
|
||||
cornerstoneTools.zoomWheel.activate(element); // Mouse Wheel
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user