Skip to content

Commit 4c1e83c

Browse files
author
Robert D. Vincent
committed
More improvements to zooming - sensible cursor drawing at high zoom levels, better zoom speeds at high zoom.
1 parent 401af5e commit 4c1e83c

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

examples/volume-viewer-demo.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ $(function() {
285285
});
286286
});
287287

288+
$(document).keypress(function(e) {
289+
if (e.keyCode === 114) {
290+
// Reset displays if user presses 'r' key.
291+
viewer.resetDisplays();
292+
viewer.redrawVolumes();
293+
}
294+
});
288295
//////////////////////////////////
289296
// Per volume UI hooks go in here.
290297
//////////////////////////////////

src/brainbrowser/volume-viewer/lib/panel.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@
295295
* ```
296296
*/
297297
reset: function() {
298-
panel.zoom = 1;
298+
panel.zoom = panel.default_zoom;
299299
panel.image_center.x = panel.canvas.width / 2;
300300
panel.image_center.y = panel.canvas.height / 2;
301+
panel.updated = true;
301302
},
302303

303304
/**
@@ -496,8 +497,10 @@
496497
}
497498

498499
if (panel.volume) {
499-
setSlice(panel, panel.volume.slice(panel.axis));
500-
panel.zoom = panel.volume.getPreferredZoom(panel.canvas.width, panel.canvas.height);
500+
var volume = panel.volume;
501+
setSlice(panel, volume.slice(panel.axis));
502+
panel.default_zoom = volume.getPreferredZoom(panel.canvas.width, panel.canvas.height);
503+
panel.zoom = panel.default_zoom;
501504
}
502505

503506
return panel;
@@ -518,7 +521,7 @@
518521
var context = panel.context;
519522
var cursor = panel.getCursorPosition();
520523
var zoom = panel.zoom;
521-
var length = 8 * zoom;
524+
var length = 8 * (zoom / panel.default_zoom);
522525
var x, y, space;
523526
var distance;
524527
var dx, dy;
@@ -529,7 +532,7 @@
529532
context.strokeStyle = color;
530533
context.fillStyle = color;
531534

532-
space = zoom;
535+
space = 1;
533536
x = cursor.x;
534537
y = cursor.y;
535538

src/brainbrowser/volume-viewer/modules/loading.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ BrainBrowser.VolumeViewer.modules.loading = function(viewer) {
646646

647647
last_touch_distance = null;
648648
}
649-
649+
650650
canvas.addEventListener("mousedown", function(event) {
651651
event.preventDefault();
652652

@@ -696,7 +696,8 @@ BrainBrowser.VolumeViewer.modules.loading = function(viewer) {
696696
}
697697

698698
function zoom(delta) {
699-
panel.zoom = Math.max(panel.zoom + delta * 0.05, 0.05);
699+
panel.zoom *= (delta < 0) ? 1/1.05 : 1.05;
700+
panel.zoom = Math.max(panel.zoom, 0.25);
700701
panel.updateVolumePosition();
701702
panel.updateSlice();
702703

0 commit comments

Comments
 (0)