custom-cornerstone-tools
Version:
Medical imaging tools for the Cornerstone library - customized for DrNuvem
159 lines (132 loc) • 5.81 kB
HTML
<html>
<head>
<!-- support for mobile touch devices -->
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- twitter bootstrap CSS stylesheet - not required by cornerstoneTools -->
<link href="../bootstrap.min.css" rel="stylesheet">
<link href="../cornerstone.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>
Crosshairs Example
</h1>
<p>
This page contains an example of the crosshairs tool.
</p>
</div>
<div class="row">
<div class="col-xs-2">
<ul class="list-group">
<a href="#" id="enable" class="list-group-item active">Enable</a>
<a href="#" id="disable" class="list-group-item">Disable</a>
</ul>
</div>
<div class="col-xs-10">
<div style="width:256px;height:256px;position:relative;display:inline-block;color:white;"
oncontextmenu="return false"
class='cornerstone-enabled-image'
unselectable='on'
onselectstart='return false;'
onmousedown='return false;'>
<div id="axial"
style="width:256px;height:256px;top:0px;left:0px; position:absolute;">
</div>
</div>
<div style="width:256px;height:256px;position:relative;display:inline-block;color:white;"
oncontextmenu="return false"
class='cornerstone-enabled-image'
unselectable='on'
onselectstart='return false;'
onmousedown='return false;'>
<div id="coronal"
style="width:256px;height:256px;top:0px;left:0px; position:absolute;">
</div>
</div>
</div>
</div>
</div>
</body>
<!-- jquery - included to make things easier to demo, not needed or used by the cornerstone library but
is used by our example image loader-->
<script src="../jquery.min.js"></script>
<!-- include the hammer.js library for touch gestures-->
<script src="../hammer.min.js"></script>
<!-- include the cornerstone library -->
<script src="../cornerstone.min.js"></script>
<script src="../cornerstoneMath.min.js"></script>
<!-- include the cornerstone tools library -->
<script src="../../dist/cornerstoneTools.js"></script>
<!-- include special code for these examples which provides images -->
<script src="../exampleImageLoader.js"></script>
<script src="../exampleMetaDataProvider.js"></script>
<script>
var axialElement = $('#axial').get(0);
var coronalElement = $('#coronal').get(0);
var axialImageIds = [
'example://1',
'example://2'
];
var axialStack = {
currentImageIdIndex : 0,
imageIds: axialImageIds
};
var synchronizer = new cornerstoneTools.Synchronizer("CornerstoneNewImage", cornerstoneTools.updateImageSynchronizer);
// image enable the dicomImage element
cornerstone.enable(axialElement);
cornerstone.enable(coronalElement);
// Enable mouse inputs
cornerstoneTools.mouseInput.enable(axialElement);
cornerstoneTools.touchInput.enable(axialElement);
cornerstoneTools.mouseWheelInput.enable(axialElement);
cornerstoneTools.mouseInput.enable(coronalElement);
cornerstoneTools.touchInput.enable(coronalElement);
var axialDeferred = cornerstone.loadImage(axialImageIds[0]).then(function(image) {
// display this image
cornerstone.displayImage(axialElement, image);
// set the stack as tool state
cornerstoneTools.addStackStateManager(axialElement, ['stack', 'crosshairs']);
cornerstoneTools.addToolState(axialElement, 'stack', axialStack);
// Enable all tools we want to use with this element
cornerstoneTools.stackScroll.activate(axialElement, 1);
cornerstoneTools.stackScrollWheel.activate(axialElement);
});
var coronalDeferred = cornerstone.loadImage('example://3').then(function(image) {
// display this image
cornerstone.displayImage(coronalElement, image);
});
$.when(axialDeferred, coronalDeferred).then(function() {
// Add the enabled elements to the synchronization context
synchronizer.add(axialElement);
synchronizer.add(coronalElement);
cornerstoneTools.crosshairs.enable(axialElement, 1, synchronizer);
cornerstoneTools.crosshairs.enable(coronalElement, 1, synchronizer);
cornerstoneTools.crosshairsTouch.enable(axialElement, synchronizer);
cornerstoneTools.crosshairsTouch.enable(coronalElement, synchronizer);
function activate(id)
{
$('a').removeClass('active');
$(id).addClass('active');
}
$('#enable').click(function() {
activate("#enable");
cornerstoneTools.crosshairs.enable(coronalElement, 1, synchronizer);
cornerstoneTools.crosshairs.enable(axialElement, 1, synchronizer);
cornerstoneTools.crosshairsTouch.enable(axialElement, synchronizer);
cornerstoneTools.crosshairsTouch.enable(coronalElement, synchronizer);
return false;
});
$('#disable').click(function() {
activate("#disable");
cornerstoneTools.crosshairs.disable(coronalElement);
cornerstoneTools.crosshairs.disable(axialElement);
cornerstoneTools.crosshairsTouch.disable(coronalElement);
cornerstoneTools.crosshairsTouch.disable(axialElement);
return false;
});
});
</script>
</html>