Spaces:
Running
Running
Merge pull request #6 from andreped/restructuring
Browse filesMoved JS and CSS stuff to separate files; refactored index.html
- css/styles.css +75 -0
- index.html +34 -185
- js/viewer.js +124 -0
css/styles.css
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
padding: 0 0em;
|
| 3 |
+
height: 100%;
|
| 4 |
+
background: #303030;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
.sidebar-left {
|
| 8 |
+
float: left;
|
| 9 |
+
width: 10%;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.sidebar-left h1 {
|
| 13 |
+
color: white;
|
| 14 |
+
font-size: 16px;
|
| 15 |
+
padding: 0 1.5em;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.sidebar-left hr {
|
| 19 |
+
border: 2px solid white;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
#annotations-container h2 {
|
| 23 |
+
color: white;
|
| 24 |
+
padding: 0 0.5em;
|
| 25 |
+
font-size: 14px;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
#annotations-container hr {
|
| 29 |
+
border: 0.25px solid white;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
#wsi-canvas {
|
| 33 |
+
float: left;
|
| 34 |
+
width: 80%;
|
| 35 |
+
height: 100%;
|
| 36 |
+
background: white;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.sidebar-right {
|
| 40 |
+
float: right;
|
| 41 |
+
width: 10%;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.sidebar-right h2 {
|
| 45 |
+
color: white;
|
| 46 |
+
padding: 0 0.5em;
|
| 47 |
+
font-size: 14px;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.sidebar-right hr {
|
| 51 |
+
border: 0.25px solid white;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.sidebar-right .position,
|
| 55 |
+
.sidebar-right .zoom {
|
| 56 |
+
color: white;
|
| 57 |
+
padding: 0 0.5em;
|
| 58 |
+
font-size: 14px;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.annotation-item {
|
| 62 |
+
color: white;
|
| 63 |
+
padding: 10px;
|
| 64 |
+
border: 1px solid white;
|
| 65 |
+
margin-top: 10px;
|
| 66 |
+
cursor: pointer;
|
| 67 |
+
font-size: 12px;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
svg.a9s-annotationlayer .a9s-selection .a9s-inner,
|
| 71 |
+
svg.a9s-annotationlayer .a9s-annotation .a9s-inner {
|
| 72 |
+
stroke-width: 4;
|
| 73 |
+
stroke: blue;
|
| 74 |
+
fill: rgba(0, 0, 255, 0.4);
|
| 75 |
+
}
|
index.html
CHANGED
|
@@ -1,189 +1,38 @@
|
|
| 1 |
<html>
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
<
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
}
|
| 24 |
-
</style>
|
| 25 |
-
</head>
|
| 26 |
-
<body>
|
| 27 |
-
<div style="padding: 0 0em; height: 100%; background: #303030">
|
| 28 |
-
<div class="sidebar-left" style="float: left; width: 10%;">
|
| 29 |
-
<h1 style="color: white; font-size: 16px; padding: 0 1.5em;">Whole Slide Image Annotation Demo</h1>
|
| 30 |
-
|
| 31 |
-
<hr style="border: 2px solid white;">
|
| 32 |
-
|
| 33 |
-
<div id="annotations-container">
|
| 34 |
-
<h2 style="color: white; padding: 0 0.5em; font-size: 14px;">Annotations</h2>
|
| 35 |
-
<hr style="border: 0.25px solid white;">
|
| 36 |
-
<div id="annotations-list"></div>
|
| 37 |
-
</div>
|
| 38 |
</div>
|
| 39 |
-
<div id="wsi-canvas" style="float: left; width: 80%; height: 100%; background: white;"></div>
|
| 40 |
-
<div id="annotation-toolbar"></div>
|
| 41 |
-
|
| 42 |
-
<div class="sidebar-right" style="float: right; width: 10%;">
|
| 43 |
-
<h2 style="color: white; padding: 0 0.5em; font-size: 14px;">View tracking information</h2>
|
| 44 |
-
<hr style="border: 0.25px solid white;">
|
| 45 |
-
|
| 46 |
-
<div class="position" style="color: white; padding: 0 0.5em; font-size: 14px;"></div>
|
| 47 |
-
<hr style="border: 0.25px solid white;">
|
| 48 |
-
<div class="zoom" style="color: white; padding: 0 0.5em; font-size: 14px;"></div>
|
| 49 |
-
</div>
|
| 50 |
-
|
| 51 |
-
<div id="annotation_list" style="display: none;"></div>
|
| 52 |
</div>
|
| 53 |
-
<
|
| 54 |
-
<
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
tileSources: {
|
| 67 |
-
Image: {
|
| 68 |
-
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
|
| 69 |
-
Url: "A05_files/",
|
| 70 |
-
Format: "jpeg",
|
| 71 |
-
Overlap: "0",
|
| 72 |
-
TileSize: "256",
|
| 73 |
-
Size: {
|
| 74 |
-
Height: 42625,
|
| 75 |
-
Width: 51553
|
| 76 |
-
}
|
| 77 |
-
},
|
| 78 |
-
overlays: [],
|
| 79 |
-
},
|
| 80 |
-
});
|
| 81 |
-
viewer.innerTracker.keyHandler = null;
|
| 82 |
-
|
| 83 |
-
var anno = OpenSeadragon.Annotorious(viewer);
|
| 84 |
-
Annotorious.SelectorPack(anno);
|
| 85 |
-
|
| 86 |
-
const toolbar = new Annotorious.Toolbar(anno, document.getElementById('annotation-toolbar'));
|
| 87 |
-
viewer.addControl(document.getElementById("annotation-toolbar"), {anchor: OpenSeadragon.ControlAnchor.TOP_LEFT});
|
| 88 |
-
|
| 89 |
-
document.getElementById('annotation-toolbar').addEventListener('click', function(event) {
|
| 90 |
-
event.preventDefault();
|
| 91 |
-
});
|
| 92 |
-
|
| 93 |
-
// Listen for annotation creation event
|
| 94 |
-
anno.on('createAnnotation', function(annotation) {
|
| 95 |
-
// Create a new div element for the annotation
|
| 96 |
-
var annotationItem = document.createElement('div');
|
| 97 |
-
annotationItem.className = 'annotation-item';
|
| 98 |
-
annotationItem.style.color = 'white';
|
| 99 |
-
annotationItem.style.padding = '10px';
|
| 100 |
-
annotationItem.style.border = '1px solid white';
|
| 101 |
-
annotationItem.style.marginTop = '10px';
|
| 102 |
-
annotationItem.style.cursor = 'pointer';
|
| 103 |
-
annotationItem.style.fontSize = '12px'; // Set font size in pixels
|
| 104 |
-
annotationItem.dataset.annotationId = annotation.id;
|
| 105 |
-
|
| 106 |
-
// Add annotation details to the item
|
| 107 |
-
annotationItem.innerHTML = `
|
| 108 |
-
${annotation.body[0].value}
|
| 109 |
-
`;
|
| 110 |
-
|
| 111 |
-
// Add click event to make the annotation active
|
| 112 |
-
annotationItem.addEventListener('click', function() {
|
| 113 |
-
anno.selectAnnotation(annotation.id);
|
| 114 |
-
});
|
| 115 |
-
|
| 116 |
-
// Append the annotation item to the annotations list in the sidebar
|
| 117 |
-
document.getElementById('annotations-list').appendChild(annotationItem);
|
| 118 |
-
});
|
| 119 |
-
|
| 120 |
-
// Listen for annotation deletion event
|
| 121 |
-
anno.on('deleteAnnotation', function(annotation) {
|
| 122 |
-
// Find the corresponding annotation item in the sidebar
|
| 123 |
-
var annotationItems = document.querySelectorAll('.annotation-item');
|
| 124 |
-
annotationItems.forEach(function(item) {
|
| 125 |
-
if (item.dataset.annotationId === annotation.id) {
|
| 126 |
-
item.remove();
|
| 127 |
-
}
|
| 128 |
-
});
|
| 129 |
-
});
|
| 130 |
-
|
| 131 |
-
// Disable panning when polygon tool is active
|
| 132 |
-
anno.on('startSelection', function(event) {
|
| 133 |
-
if (event.tool === 'polygon') {
|
| 134 |
-
viewer.setMouseNavEnabled(false);
|
| 135 |
-
}
|
| 136 |
-
});
|
| 137 |
-
|
| 138 |
-
// Re-enable panning when polygon tool is deactivated
|
| 139 |
-
anno.on('cancelSelection', function(event) {
|
| 140 |
-
if (event.tool === 'polygon') {
|
| 141 |
-
viewer.setMouseNavEnabled(true);
|
| 142 |
-
}
|
| 143 |
-
});
|
| 144 |
-
|
| 145 |
-
anno.on('createAnnotation', function(event) {
|
| 146 |
-
if (event.tool === 'polygon') {
|
| 147 |
-
viewer.setMouseNavEnabled(true);
|
| 148 |
-
}
|
| 149 |
-
});
|
| 150 |
-
|
| 151 |
-
// Add a listener to the viewer to update the position and zoom info
|
| 152 |
-
var positionEl = document.querySelectorAll('.sidebar-right .position')[0];
|
| 153 |
-
var zoomEl = document.querySelectorAll('.sidebar-right .zoom')[0];
|
| 154 |
-
|
| 155 |
-
// Default values
|
| 156 |
-
positionEl.innerHTML = 'Web:<br> (NA) <br><br>Viewport:<br> (NA) <br><br>Image:<br> (NA)';
|
| 157 |
-
zoomEl.innerHTML = 'Zoom:<br> NA <br><br>Image Zoom:<br> NA';
|
| 158 |
-
|
| 159 |
-
var updateZoom = function() {
|
| 160 |
-
var zoom = viewer.viewport.getZoom(true);
|
| 161 |
-
var imageZoom = viewer.viewport.viewportToImageZoom(zoom);
|
| 162 |
-
|
| 163 |
-
zoomEl.innerHTML = 'Zoom:<br>' + (Math.round(zoom * 100) / 100) +
|
| 164 |
-
'<br><br>Image Zoom:<br>' + (Math.round(imageZoom * 100) / 100);
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
viewer.addHandler('open', function() {
|
| 168 |
-
var tracker = new OpenSeadragon.MouseTracker({
|
| 169 |
-
element: viewer.container,
|
| 170 |
-
moveHandler: function(event) {
|
| 171 |
-
var webPoint = event.position;
|
| 172 |
-
var viewportPoint = viewer.viewport.pointFromPixel(webPoint);
|
| 173 |
-
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint);
|
| 174 |
-
var zoom = viewer.viewport.getZoom(true);
|
| 175 |
-
var imageZoom = viewer.viewport.viewportToImageZoom(zoom);
|
| 176 |
-
|
| 177 |
-
positionEl.innerHTML = 'Web:<br>' + webPoint.toString() +
|
| 178 |
-
'<br><br>Viewport:<br>' + viewportPoint.toString() +
|
| 179 |
-
'<br><br>Image:<br>' + imagePoint.toString();
|
| 180 |
-
|
| 181 |
-
updateZoom();
|
| 182 |
-
}
|
| 183 |
-
});
|
| 184 |
-
tracker.setTracking(true);
|
| 185 |
-
viewer.addHandler('animation', updateZoom);
|
| 186 |
-
});
|
| 187 |
-
</script>
|
| 188 |
-
</body>
|
| 189 |
</html>
|
|
|
|
| 1 |
<html>
|
| 2 |
+
<head>
|
| 3 |
+
<title>Whole Slide Image Annotation</title>
|
| 4 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 5 |
+
<link rel="stylesheet" href="node_modules/@recogito/annotorious/dist/annotorious.min.css">
|
| 6 |
+
<link rel="stylesheet" href="node_modules/@recogito/annotorious-selector-pack/dist/annotorious-selector-pack.min.css">
|
| 7 |
+
<link rel="stylesheet" href="css/styles.css">
|
| 8 |
+
<!-- Dependencies -->
|
| 9 |
+
<script src="node_modules/openseadragon/build/openseadragon/openseadragon.min.js"></script>
|
| 10 |
+
<script src="node_modules/@recogito/annotorious-openseadragon/dist/openseadragon-annotorious.min.js"></script>
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/annotorious-toolbar.min.js"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/@recogito/annotorious-[email protected]/dist/annotorious-selector-pack.min.js"></script>
|
| 13 |
+
</head>
|
| 14 |
+
<body>
|
| 15 |
+
<div>
|
| 16 |
+
<div class="sidebar-left">
|
| 17 |
+
<h1>Whole Slide Image Annotation Demo</h1>
|
| 18 |
+
<hr>
|
| 19 |
+
<div id="annotations-container">
|
| 20 |
+
<h2>Annotations</h2>
|
| 21 |
+
<hr>
|
| 22 |
+
<div id="annotations-list"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
</div>
|
| 25 |
+
<div id="wsi-canvas"></div>
|
| 26 |
+
<div id="annotation-toolbar"></div>
|
| 27 |
+
<div class="sidebar-right">
|
| 28 |
+
<h2>View tracking information</h2>
|
| 29 |
+
<hr>
|
| 30 |
+
<div class="position"></div>
|
| 31 |
+
<hr>
|
| 32 |
+
<div class="zoom"></div>
|
| 33 |
+
</div>
|
| 34 |
+
<div id="annotation_list" style="display: none;"></div>
|
| 35 |
+
</div>
|
| 36 |
+
<script type="text/javascript" src="js/viewer.js"></script>
|
| 37 |
+
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
</html>
|
js/viewer.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var viewer = OpenSeadragon({
|
| 2 |
+
id: "wsi-canvas",
|
| 3 |
+
prefixUrl: "../node_modules/openseadragon/build/openseadragon/images/",
|
| 4 |
+
zoomPerScroll: 2,
|
| 5 |
+
zoomPerClick: 1,
|
| 6 |
+
showNavigator: true,
|
| 7 |
+
showHomeControl: false,
|
| 8 |
+
showFullPageControl: false,
|
| 9 |
+
showZoomControl: false,
|
| 10 |
+
minZoomLevel: 0.25,
|
| 11 |
+
maxZoomLevel: 40,
|
| 12 |
+
tileSources: {
|
| 13 |
+
Image: {
|
| 14 |
+
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
|
| 15 |
+
Url: "./A05_files/",
|
| 16 |
+
Format: "jpeg",
|
| 17 |
+
Overlap: "0",
|
| 18 |
+
TileSize: "256",
|
| 19 |
+
Size: {
|
| 20 |
+
Height: 42625,
|
| 21 |
+
Width: 51553
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
overlays: [],
|
| 25 |
+
},
|
| 26 |
+
});
|
| 27 |
+
viewer.innerTracker.keyHandler = null;
|
| 28 |
+
|
| 29 |
+
var anno = OpenSeadragon.Annotorious(viewer);
|
| 30 |
+
Annotorious.SelectorPack(anno);
|
| 31 |
+
|
| 32 |
+
const toolbar = new Annotorious.Toolbar(anno, document.getElementById('annotation-toolbar'));
|
| 33 |
+
viewer.addControl(document.getElementById("annotation-toolbar"), { anchor: OpenSeadragon.ControlAnchor.TOP_LEFT });
|
| 34 |
+
|
| 35 |
+
document.getElementById('annotation-toolbar').addEventListener('click', function (event) {
|
| 36 |
+
event.preventDefault();
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
// Listen for annotation creation event
|
| 40 |
+
anno.on('createAnnotation', function (annotation) {
|
| 41 |
+
// Create a new div element for the annotation
|
| 42 |
+
var annotationItem = document.createElement('div');
|
| 43 |
+
annotationItem.className = 'annotation-item';
|
| 44 |
+
annotationItem.dataset.annotationId = annotation.id;
|
| 45 |
+
|
| 46 |
+
// Add annotation details to the item
|
| 47 |
+
annotationItem.innerHTML = `${annotation.body[0].value}`;
|
| 48 |
+
|
| 49 |
+
// Add click event to make the annotation active
|
| 50 |
+
annotationItem.addEventListener('click', function () {
|
| 51 |
+
anno.selectAnnotation(annotation.id);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
// Append the annotation item to the annotations list in the sidebar
|
| 55 |
+
document.getElementById('annotations-list').appendChild(annotationItem);
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
// Listen for annotation deletion event
|
| 59 |
+
anno.on('deleteAnnotation', function (annotation) {
|
| 60 |
+
// Find the corresponding annotation item in the sidebar
|
| 61 |
+
var annotationItems = document.querySelectorAll('.annotation-item');
|
| 62 |
+
annotationItems.forEach(function (item) {
|
| 63 |
+
if (item.dataset.annotationId === annotation.id) {
|
| 64 |
+
item.remove();
|
| 65 |
+
}
|
| 66 |
+
});
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
// Disable panning when polygon tool is active
|
| 70 |
+
anno.on('startSelection', function (event) {
|
| 71 |
+
if (event.tool === 'polygon') {
|
| 72 |
+
viewer.setMouseNavEnabled(false);
|
| 73 |
+
}
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
// Re-enable panning when polygon tool is deactivated
|
| 77 |
+
anno.on('cancelSelection', function (event) {
|
| 78 |
+
if (event.tool === 'polygon') {
|
| 79 |
+
viewer.setMouseNavEnabled(true);
|
| 80 |
+
}
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
anno.on('createAnnotation', function (event) {
|
| 84 |
+
if (event.tool === 'polygon') {
|
| 85 |
+
viewer.setMouseNavEnabled(true);
|
| 86 |
+
}
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
// Add a listener to the viewer to update the position and zoom info
|
| 90 |
+
var positionEl = document.querySelectorAll('.sidebar-right .position')[0];
|
| 91 |
+
var zoomEl = document.querySelectorAll('.sidebar-right .zoom')[0];
|
| 92 |
+
|
| 93 |
+
// Default values
|
| 94 |
+
positionEl.innerHTML = 'Web:<br> (NA) <br><br>Viewport:<br> (NA) <br><br>Image:<br> (NA)';
|
| 95 |
+
zoomEl.innerHTML = 'Zoom:<br> NA <br><br>Image Zoom:<br> NA';
|
| 96 |
+
|
| 97 |
+
var updateZoom = function () {
|
| 98 |
+
var zoom = viewer.viewport.getZoom(true);
|
| 99 |
+
var imageZoom = viewer.viewport.viewportToImageZoom(zoom);
|
| 100 |
+
|
| 101 |
+
zoomEl.innerHTML = 'Zoom:<br>' + (Math.round(zoom * 100) / 100) +
|
| 102 |
+
'<br><br>Image Zoom:<br>' + (Math.round(imageZoom * 100) / 100);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
viewer.addHandler('open', function () {
|
| 106 |
+
var tracker = new OpenSeadragon.MouseTracker({
|
| 107 |
+
element: viewer.container,
|
| 108 |
+
moveHandler: function (event) {
|
| 109 |
+
var webPoint = event.position;
|
| 110 |
+
var viewportPoint = viewer.viewport.pointFromPixel(webPoint);
|
| 111 |
+
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint);
|
| 112 |
+
var zoom = viewer.viewport.getZoom(true);
|
| 113 |
+
var imageZoom = viewer.viewport.viewportToImageZoom(zoom);
|
| 114 |
+
|
| 115 |
+
positionEl.innerHTML = 'Web:<br>' + webPoint.toString() +
|
| 116 |
+
'<br><br>Viewport:<br>' + viewportPoint.toString() +
|
| 117 |
+
'<br><br>Image:<br>' + imagePoint.toString();
|
| 118 |
+
|
| 119 |
+
updateZoom();
|
| 120 |
+
}
|
| 121 |
+
});
|
| 122 |
+
tracker.setTracking(true);
|
| 123 |
+
viewer.addHandler('animation', updateZoom);
|
| 124 |
+
});
|