2015-12-09 15:48:24 +01:00
|
|
|
|
OHIF = window.OHIF || {};
|
|
|
|
|
|
|
|
|
|
|
|
Meteor.startup(function() {
|
|
|
|
|
|
|
|
|
|
|
|
if (!OHIF.viewer) {
|
|
|
|
|
|
OHIF.viewer = {};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OHIF.viewer.defaultHotkeys = {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
defaultTool: 'ESC',
|
|
|
|
|
|
angle: 'A',
|
|
|
|
|
|
stackScroll: 'S',
|
|
|
|
|
|
pan: 'P',
|
|
|
|
|
|
magnify: 'M',
|
|
|
|
|
|
scrollDown: ['DOWN', 'PAGEDOWN'],
|
|
|
|
|
|
scrollUp: ['UP', 'PAGEUP'],
|
|
|
|
|
|
nextPanel: 'RIGHT',
|
|
|
|
|
|
previousPanel: 'LEFT',
|
|
|
|
|
|
invert: 'I',
|
|
|
|
|
|
flipV: 'V',
|
|
|
|
|
|
flipH: 'H',
|
|
|
|
|
|
wwwc: 'W',
|
|
|
|
|
|
zoom: 'Z',
|
|
|
|
|
|
cinePlay: 'SPACE',
|
|
|
|
|
|
rotateR: 'R',
|
|
|
|
|
|
rotateL: 'L',
|
2015-12-09 15:48:24 +01:00
|
|
|
|
toggleOverlayTags: 'SHIFT',
|
2016-01-13 16:17:32 +01:00
|
|
|
|
WLPresetSoftTissue: ['NUMPAD1', '1'],
|
|
|
|
|
|
WLPresetLung: ['NUMPAD2', '2'],
|
|
|
|
|
|
WLPresetLiver: ['NUMPAD3', '3'],
|
|
|
|
|
|
WLPresetBone: ['NUMPAD4', '4'],
|
|
|
|
|
|
WLPresetBrain: ['NUMPAD5', '5']
|
2015-12-09 15:48:24 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// For now
|
|
|
|
|
|
OHIF.viewer.hotkeys = OHIF.viewer.defaultHotkeys;
|
|
|
|
|
|
|
|
|
|
|
|
OHIF.viewer.defaultWLPresets = {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
SoftTissue: {
|
|
|
|
|
|
wc: 40,
|
|
|
|
|
|
ww: 400
|
|
|
|
|
|
},
|
|
|
|
|
|
Lung: {
|
|
|
|
|
|
wc: -600,
|
|
|
|
|
|
ww: 1500
|
|
|
|
|
|
},
|
|
|
|
|
|
Liver: {
|
|
|
|
|
|
wc: 90,
|
|
|
|
|
|
ww: 150
|
|
|
|
|
|
},
|
|
|
|
|
|
Bone: {
|
|
|
|
|
|
wc: 480,
|
|
|
|
|
|
ww: 2500
|
|
|
|
|
|
},
|
|
|
|
|
|
Brain: {
|
|
|
|
|
|
wc: 40,
|
|
|
|
|
|
ww: 80
|
|
|
|
|
|
}
|
2015-12-09 15:48:24 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// For now
|
|
|
|
|
|
OHIF.viewer.wlPresets = OHIF.viewer.defaultWLPresets;
|
|
|
|
|
|
|
|
|
|
|
|
OHIF.viewer.hotkeyFunctions = {
|
|
|
|
|
|
wwwc: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('wwwc');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
2015-12-14 14:31:25 +01:00
|
|
|
|
zoom: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('zoom');
|
2015-12-14 14:31:25 +01:00
|
|
|
|
},
|
2015-12-09 15:48:24 +01:00
|
|
|
|
angle: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('angle');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
dragProbe: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('dragProbe');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
ellipticalRoi: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('ellipticalRoi');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
magnify: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('magnify');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
annotate: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('annotate');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
stackScroll: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('stackScroll');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
pan: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('pan');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
length: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('length');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
spine: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('spine');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
|
|
|
|
|
wwwcRegion: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
toolManager.setActiveTool('wwwcRegion');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
},
|
2016-01-13 16:17:32 +01:00
|
|
|
|
zoomIn: function() {
|
|
|
|
|
|
var button = document.getElementById('zoomIn');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
zoomIn();
|
|
|
|
|
|
},
|
2016-01-13 16:17:32 +01:00
|
|
|
|
zoomOut: function() {
|
|
|
|
|
|
var button = document.getElementById('zoomOut');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
zoomOut();
|
|
|
|
|
|
},
|
2016-01-13 16:17:32 +01:00
|
|
|
|
zoomToFit: function() {
|
|
|
|
|
|
var button = document.getElementById('zoomToFit');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
zoomToFit();
|
|
|
|
|
|
},
|
|
|
|
|
|
scrollDown: function() {
|
|
|
|
|
|
var container = $('.viewportContainer.active');
|
|
|
|
|
|
var button = container.find('#nextImage').get(0);
|
|
|
|
|
|
|
|
|
|
|
|
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
|
|
|
|
|
flashButton(button);
|
|
|
|
|
|
switchToImageRelative(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
scrollFirstImage: function() {
|
|
|
|
|
|
var container = $('.viewportContainer.active');
|
|
|
|
|
|
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
|
|
|
|
|
switchToImageByIndex(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
scrollLastImage: function() {
|
|
|
|
|
|
var container = $('.viewportContainer.active');
|
|
|
|
|
|
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
|
|
|
|
|
switchToImageByIndex(-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
scrollUp: function() {
|
|
|
|
|
|
var container = $('.viewportContainer.active');
|
|
|
|
|
|
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
|
|
|
|
|
var button = container.find('#prevImage').get(0);
|
|
|
|
|
|
flashButton(button);
|
|
|
|
|
|
switchToImageRelative(-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
nextPanel: function() {
|
|
|
|
|
|
nextActivePanel();
|
|
|
|
|
|
},
|
|
|
|
|
|
previousPanel: function() {
|
|
|
|
|
|
previousActivePanel();
|
|
|
|
|
|
},
|
|
|
|
|
|
invert: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
var button = document.getElementById('invert');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
invert();
|
|
|
|
|
|
},
|
|
|
|
|
|
flipV: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
var button = document.getElementById('flipV');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
flipV();
|
|
|
|
|
|
},
|
|
|
|
|
|
flipH: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
var button = document.getElementById('flipH');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
flipH();
|
|
|
|
|
|
},
|
|
|
|
|
|
rotateR: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
var button = document.getElementById('rotateR');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
rotateR();
|
|
|
|
|
|
},
|
|
|
|
|
|
rotateL: function() {
|
2016-01-13 16:17:32 +01:00
|
|
|
|
var button = document.getElementById('rotateL');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
flashButton(button);
|
|
|
|
|
|
rotateL();
|
|
|
|
|
|
},
|
|
|
|
|
|
cinePlay: function() {
|
|
|
|
|
|
toggleCinePlay();
|
|
|
|
|
|
},
|
|
|
|
|
|
defaultTool: function() {
|
|
|
|
|
|
var tool = toolManager.getDefaultTool();
|
|
|
|
|
|
toolManager.setActiveTool(tool);
|
|
|
|
|
|
},
|
|
|
|
|
|
toggleOverlayTags: function() {
|
|
|
|
|
|
var dicomTags = $('.imageViewerViewportOverlay .dicomTag');
|
|
|
|
|
|
if (dicomTags.eq(0).css('display') === 'none') {
|
|
|
|
|
|
dicomTags.show();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
dicomTags.hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2016-01-13 16:17:32 +01:00
|
|
|
|
|
|
|
|
|
|
OHIF.viewer.loadedSeriesData = {};
|
2015-12-09 15:48:24 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Define a jQuery reverse function
|
|
|
|
|
|
$.fn.reverse = [].reverse;
|
|
|
|
|
|
|
|
|
|
|
|
function previousActivePanel() {
|
|
|
|
|
|
log.info('nextActivePanel');
|
|
|
|
|
|
var currentIndex = Session.get('activeViewport');
|
|
|
|
|
|
currentIndex--;
|
|
|
|
|
|
|
|
|
|
|
|
var viewports = $('.imageViewerViewport');
|
|
|
|
|
|
var numViewports = viewports.length;
|
|
|
|
|
|
if (currentIndex < 0) {
|
|
|
|
|
|
currentIndex = numViewports - 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var element = viewports.get(currentIndex);
|
|
|
|
|
|
if (!element) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setActiveViewport(element);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function nextActivePanel() {
|
|
|
|
|
|
log.info('nextActivePanel');
|
|
|
|
|
|
var currentIndex = Session.get('activeViewport');
|
|
|
|
|
|
currentIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
var viewports = $('.imageViewerViewport');
|
|
|
|
|
|
var numViewports = viewports.length;
|
|
|
|
|
|
if (currentIndex >= numViewports) {
|
|
|
|
|
|
currentIndex = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var element = viewports.get(currentIndex);
|
|
|
|
|
|
if (!element) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setActiveViewport(element);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function flashButton(button) {
|
|
|
|
|
|
if (!button) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
button.classList.add('active');
|
2016-01-13 16:17:32 +01:00
|
|
|
|
setTimeout(function() {
|
2015-12-09 15:48:24 +01:00
|
|
|
|
button.classList.remove('active');
|
|
|
|
|
|
}, 100);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function bindHotkey(hotkey, task) {
|
|
|
|
|
|
var hotkeyFunctions = OHIF.viewer.hotkeyFunctions;
|
|
|
|
|
|
|
|
|
|
|
|
// Only bind defined, non-empty HotKeys
|
2016-01-13 16:17:32 +01:00
|
|
|
|
if (!hotkey || hotkey === '') {
|
2015-12-09 15:48:24 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var fn;
|
2016-01-13 16:17:32 +01:00
|
|
|
|
if (task.indexOf('WLPreset') > -1) {
|
|
|
|
|
|
var presetName = task.replace('WLPreset', '');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
fn = function() {
|
|
|
|
|
|
applyWLPresetToActiveElement(presetName);
|
|
|
|
|
|
};
|
|
|
|
|
|
} else {
|
|
|
|
|
|
fn = hotkeyFunctions[task];
|
2015-12-11 17:55:19 +01:00
|
|
|
|
|
|
|
|
|
|
// If the function doesn't exist in the
|
|
|
|
|
|
// hotkey function list, try the viewer-specific function list
|
|
|
|
|
|
if (!fn && OHIF.viewer && OHIF.viewer.functionList) {
|
|
|
|
|
|
fn = OHIF.viewer.functionList[task];
|
|
|
|
|
|
}
|
2015-12-09 15:48:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!fn) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var hotKeyForBinding = hotkey.toLowerCase();
|
|
|
|
|
|
|
|
|
|
|
|
$(document).bind('keydown', hotKeyForBinding, fn);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enableHotkeys = function() {
|
|
|
|
|
|
var viewerHotkeys = OHIF.viewer.hotkeys;
|
|
|
|
|
|
|
|
|
|
|
|
$(document).unbind('keydown');
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(viewerHotkeys).forEach(function(task) {
|
|
|
|
|
|
var taskHotkeys = viewerHotkeys[task];
|
|
|
|
|
|
if (!taskHotkeys || !taskHotkeys.length) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (taskHotkeys.constructor === Array) {
|
|
|
|
|
|
taskHotkeys.forEach(function(hotkey) {
|
|
|
|
|
|
bindHotkey(hotkey, task);
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// taskHotkeys represents a single key
|
|
|
|
|
|
bindHotkey(taskHotkeys, task);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2016-01-13 16:17:32 +01:00
|
|
|
|
};
|