Replacing switchToTab with routes
This commit is contained in:
1 parent
0cf4dbf13f
commit
7718d31a77
46 files changed
+358
-753
No files matched your search
+12
-15
@@ -54,11 +54,11 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// This data will be saved so that the tab can be reloaded to the same state after tabs
|
||||
// are switched
|
||||
if (contentId) {
|
||||
if (!ViewerData[contentId]) {
|
||||
if (!OHIF.viewer.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
ViewerData[contentId].loadedSeriesData[viewportIndex] = {};
|
||||
OHIF.viewer.data.loadedSeriesData[viewportIndex] = {};
|
||||
}
|
||||
|
||||
// Create shortcut to displaySet
|
||||
@@ -154,7 +154,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// Additional tasks for metadata provider. If using your own
|
||||
// metadata provider, this may not be necessary.
|
||||
// updateMetadata is important, though, to update image metadata that
|
||||
// for any reason was missing some information such as rows, columns,
|
||||
// for any reason was missing some information such as rows, columns,
|
||||
// sliceThickness, etc (See MetadataProvider class from ohif-cornerstone package)
|
||||
const metadataProvider = OHIF.viewer.metadataProvider;
|
||||
const isUpdateMetadataDefined = metadataProvider && typeof metadataProvider.updateMetadata === 'function';
|
||||
@@ -173,7 +173,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
let enabledElement;
|
||||
try {
|
||||
enabledElement = cornerstone.getEnabledElement(element);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
OHIF.log.warn('Viewport destroyed before loaded image could be displayed');
|
||||
return;
|
||||
@@ -305,15 +305,13 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// This lets the viewport overlay always display correct window / zoom values
|
||||
Session.set('CornerstoneImageRendered' + viewportIndex, Random.id());
|
||||
|
||||
// Save the current viewport into the ViewerData global variable, as well as the
|
||||
// Meteor Session. This lets the viewport be saved/reloaded on a hot-code reload
|
||||
// Save the current viewport into the OHIF.viewer.data global variable
|
||||
const viewport = cornerstone.getViewport(element);
|
||||
layoutManager.viewportData[viewportIndex].viewport = viewport;
|
||||
ViewerData[contentId].loadedSeriesData[viewportIndex].viewport = viewport;
|
||||
Session.set('ViewerData', ViewerData);
|
||||
OHIF.viewer.data.loadedSeriesData[viewportIndex].viewport = viewport;
|
||||
|
||||
// Check if it has onImageRendered loadAndCacheImage callback
|
||||
if(typeof callbacks.onImageRendered === 'function') {
|
||||
if (typeof callbacks.onImageRendered === 'function') {
|
||||
callbacks.onImageRendered(event, eventData, viewportIndex, templateData);
|
||||
}
|
||||
};
|
||||
@@ -332,7 +330,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// since this callback function is called multiple times (eg: when a tool is
|
||||
// enabled/disabled -> cornerstone[toolName].tool.enable)
|
||||
|
||||
if(isUpdateMetadataDefined) {
|
||||
if (isUpdateMetadataDefined) {
|
||||
// Update the metaData for missing fields
|
||||
metadataProvider.updateMetadata(eventData.enabledElement.image);
|
||||
}
|
||||
@@ -355,17 +353,16 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
updateOrientationMarkers(element);
|
||||
|
||||
// If this viewport is displaying a stack of images, save the current image
|
||||
// index in the stack to the global ViewerData object, as well as the Meteor Session.
|
||||
// index in the stack to the global OHIF.viewer.data object.
|
||||
const stack = cornerstoneTools.getToolState(element, 'stack');
|
||||
if (stack && stack.data.length && stack.data[0].imageIds.length > 1) {
|
||||
const imageIdIndex = stack.data[0].imageIds.indexOf(templateData.imageId);
|
||||
layoutManager.viewportData[viewportIndex].currentImageIdIndex = imageIdIndex;
|
||||
ViewerData[contentId].loadedSeriesData[viewportIndex].currentImageIdIndex = imageIdIndex;
|
||||
Session.set('ViewerData', ViewerData);
|
||||
OHIF.viewer.data.loadedSeriesData[viewportIndex].currentImageIdIndex = imageIdIndex;
|
||||
}
|
||||
|
||||
// Check if it has onNewImage loadAndCacheImage callback
|
||||
if(typeof callbacks.onNewImage === 'function') {
|
||||
if (typeof callbacks.onNewImage === 'function') {
|
||||
callbacks.onNewImage(event, eventData, viewportIndex, templateData);
|
||||
}
|
||||
};
|
||||
@@ -429,7 +426,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
$element.off(allCornerstoneEvents, sendActivationTrigger);
|
||||
$element.on(allCornerstoneEvents, sendActivationTrigger);
|
||||
|
||||
ViewerData[contentId].loadedSeriesData = layoutManager.viewportData;
|
||||
OHIF.viewer.data.loadedSeriesData = layoutManager.viewportData;
|
||||
|
||||
// Check if image plane (orientation / location) data is present for the current image
|
||||
const imagePlane = cornerstoneTools.metaData.get('imagePlane', image.imageId);
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ Template.studyTimepointBrowser.onCreated(() => {
|
||||
return loadedStudy;
|
||||
}
|
||||
|
||||
const notYetLoaded = StudyListStudies.findOne(query);
|
||||
const notYetLoaded = OHIF.studylist.collections.Studies.findOne(query);
|
||||
if (!notYetLoaded) {
|
||||
throw new OHIFError(`No study data available for Study: ${studyInstanceUid}`);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
|
||||
import { $ } from 'meteor/jquery';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { toolManager } from './toolManager';
|
||||
import { setActiveViewport } from './setActiveViewport';
|
||||
import { switchToImageRelative } from './switchToImageRelative';
|
||||
import { switchToImageByIndex } from './switchToImageByIndex';
|
||||
import { viewportUtils } from './viewportUtils';
|
||||
@@ -11,10 +10,6 @@ import { WLPresets } from './WLPresets';
|
||||
|
||||
// TODO: add this to namespace definitions
|
||||
Meteor.startup(function() {
|
||||
if (!OHIF.viewer) {
|
||||
OHIF.viewer = {};
|
||||
}
|
||||
|
||||
OHIF.viewer.loadIndicatorDelay = 200;
|
||||
OHIF.viewer.defaultTool = 'wwwc';
|
||||
OHIF.viewer.refLinesEnabled = true;
|
||||
@@ -56,149 +51,134 @@ Meteor.startup(function() {
|
||||
OHIF.viewer.hotkeys = OHIF.viewer.defaultHotkeys;
|
||||
|
||||
OHIF.viewer.hotkeyFunctions = {
|
||||
wwwc() {
|
||||
toolManager.setActiveTool('wwwc');
|
||||
},
|
||||
zoom() {
|
||||
toolManager.setActiveTool('zoom');
|
||||
},
|
||||
angle() {
|
||||
toolManager.setActiveTool('angle');
|
||||
},
|
||||
dragProbe() {
|
||||
toolManager.setActiveTool('dragProbe');
|
||||
},
|
||||
ellipticalRoi() {
|
||||
toolManager.setActiveTool('ellipticalRoi');
|
||||
},
|
||||
magnify() {
|
||||
toolManager.setActiveTool('magnify');
|
||||
},
|
||||
annotate() {
|
||||
toolManager.setActiveTool('annotate');
|
||||
},
|
||||
stackScroll() {
|
||||
toolManager.setActiveTool('stackScroll');
|
||||
},
|
||||
pan() {
|
||||
toolManager.setActiveTool('pan');
|
||||
},
|
||||
length() {
|
||||
toolManager.setActiveTool('length');
|
||||
},
|
||||
spine() {
|
||||
toolManager.setActiveTool('spine');
|
||||
},
|
||||
wwwcRegion() {
|
||||
toolManager.setActiveTool('wwwcRegion');
|
||||
},
|
||||
wwwc: () => toolManager.setActiveTool('wwwc'),
|
||||
zoom: () => toolManager.setActiveTool('zoom'),
|
||||
angle: () => toolManager.setActiveTool('angle'),
|
||||
dragProbe: () => toolManager.setActiveTool('dragProbe'),
|
||||
ellipticalRoi: () => toolManager.setActiveTool('ellipticalRoi'),
|
||||
magnify: () => toolManager.setActiveTool('magnify'),
|
||||
annotate: () => toolManager.setActiveTool('annotate'),
|
||||
stackScroll: () => toolManager.setActiveTool('stackScroll'),
|
||||
pan: () => toolManager.setActiveTool('pan'),
|
||||
length: () => toolManager.setActiveTool('length'),
|
||||
spine: () => toolManager.setActiveTool('spine'),
|
||||
wwwcRegion: () => toolManager.setActiveTool('wwwcRegion'),
|
||||
|
||||
zoomIn() {
|
||||
const button = document.getElementById('zoomIn');
|
||||
flashButton(button);
|
||||
viewportUtils.zoomIn();
|
||||
},
|
||||
|
||||
zoomOut() {
|
||||
const button = document.getElementById('zoomOut');
|
||||
flashButton(button);
|
||||
viewportUtils.zoomOut();
|
||||
},
|
||||
|
||||
zoomToFit() {
|
||||
const button = document.getElementById('zoomToFit');
|
||||
flashButton(button);
|
||||
viewportUtils.zoomToFit();
|
||||
},
|
||||
scrollDown() {
|
||||
const container = $('.viewportContainer.active');
|
||||
const button = container.find('#nextImage').get(0);
|
||||
|
||||
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
scrollDown() {
|
||||
const $container = $('.viewportContainer.active');
|
||||
const button = $container.find('#nextImage').get(0);
|
||||
|
||||
if (!$container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
flashButton(button);
|
||||
switchToImageRelative(1);
|
||||
}
|
||||
},
|
||||
|
||||
scrollFirstImage() {
|
||||
const container = $('.viewportContainer.active');
|
||||
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
const $container = $('.viewportContainer.active');
|
||||
if (!$container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
switchToImageByIndex(0);
|
||||
}
|
||||
},
|
||||
|
||||
scrollLastImage() {
|
||||
const container = $('.viewportContainer.active');
|
||||
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
const $container = $('.viewportContainer.active');
|
||||
if (!$container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
switchToImageByIndex(-1);
|
||||
}
|
||||
},
|
||||
|
||||
scrollUp() {
|
||||
const container = $('.viewportContainer.active');
|
||||
if (!container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
const button = container.find('#prevImage').get(0);
|
||||
const $container = $('.viewportContainer.active');
|
||||
if (!$container.find('.imageViewerViewport').hasClass('empty')) {
|
||||
const button = $container.find('#prevImage').get(0);
|
||||
flashButton(button);
|
||||
switchToImageRelative(-1);
|
||||
}
|
||||
},
|
||||
previousDisplaySet() {
|
||||
OHIF.viewerbase.layoutManager.moveDisplaySets(false);
|
||||
},
|
||||
nextDisplaySet() {
|
||||
OHIF.viewerbase.layoutManager.moveDisplaySets(true);
|
||||
},
|
||||
nextPanel() {
|
||||
panelNavigation.loadNextActivePanel();
|
||||
},
|
||||
previousPanel() {
|
||||
panelNavigation.loadPreviousActivePanel();
|
||||
},
|
||||
|
||||
previousDisplaySet: () => OHIF.viewerbase.layoutManager.moveDisplaySets(false),
|
||||
nextDisplaySet: () => OHIF.viewerbase.layoutManager.moveDisplaySets(true),
|
||||
nextPanel: () => panelNavigation.loadNextActivePanel(),
|
||||
previousPanel: () => panelNavigation.loadPreviousActivePanel(),
|
||||
|
||||
invert() {
|
||||
const button = document.getElementById('invert');
|
||||
flashButton(button);
|
||||
viewportUtils.invert();
|
||||
},
|
||||
|
||||
flipV() {
|
||||
const button = document.getElementById('flipV');
|
||||
flashButton(button);
|
||||
viewportUtils.flipV();
|
||||
},
|
||||
|
||||
flipH() {
|
||||
const button = document.getElementById('flipH');
|
||||
flashButton(button);
|
||||
viewportUtils.flipH();
|
||||
},
|
||||
|
||||
rotateR() {
|
||||
const button = document.getElementById('rotateR');
|
||||
flashButton(button);
|
||||
viewportUtils.rotateR();
|
||||
},
|
||||
|
||||
rotateL() {
|
||||
const button = document.getElementById('rotateL');
|
||||
flashButton(button);
|
||||
viewportUtils.rotateL();
|
||||
},
|
||||
cinePlay() {
|
||||
viewportUtils.toggleCinePlay();
|
||||
},
|
||||
|
||||
cinePlay: () => viewportUtils.toggleCinePlay(),
|
||||
|
||||
defaultTool() {
|
||||
const tool = toolManager.getDefaultTool();
|
||||
toolManager.setActiveTool(tool);
|
||||
},
|
||||
|
||||
toggleOverlayTags() {
|
||||
const dicomTags = $('.imageViewerViewportOverlay .dicomTag');
|
||||
if (dicomTags.eq(0).css('display') === 'none') {
|
||||
dicomTags.show();
|
||||
const $dicomTags = $('.imageViewerViewportOverlay .dicomTag');
|
||||
if ($dicomTags.eq(0).css('display') === 'none') {
|
||||
$dicomTags.show();
|
||||
} else {
|
||||
dicomTags.hide();
|
||||
$dicomTags.hide();
|
||||
}
|
||||
},
|
||||
|
||||
resetStack() {
|
||||
const button = document.getElementById('resetStack');
|
||||
flashButton(button);
|
||||
resetStack();
|
||||
},
|
||||
|
||||
clearImageAnnotations() {
|
||||
const button = document.getElementById('clearImageAnnotations');
|
||||
flashButton(button);
|
||||
clearImageAnnotations();
|
||||
},
|
||||
cineDialog () {
|
||||
|
||||
cineDialog() {
|
||||
/**
|
||||
* TODO: This won't work in OHIF's, since this element
|
||||
* doesn't exist
|
||||
@@ -233,21 +213,18 @@ function setOHIFHotkeys(hotkeys) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Global function to merge different hotkeys configurations
|
||||
* Global function to merge different hotkeys configurations
|
||||
* but avoiding conflicts between different keys with same action
|
||||
* When this occurs, it will delete the action from OHIF's configuration
|
||||
* So if you want to keep all OHIF's actions, use an unused-ohif-key
|
||||
* Used for compatibility with others systems only
|
||||
*
|
||||
*
|
||||
* @param hotkeysActions {object} Object with actions map
|
||||
* @return {object}
|
||||
*/
|
||||
function mergeHotkeys(hotkeysActions) {
|
||||
// Merge hotkeys, overriding OHIF's settings
|
||||
let mergedHotkeys = {
|
||||
...OHIF.viewer.defaultHotkeys,
|
||||
...hotkeysActions
|
||||
};
|
||||
const mergedHotkeys = Object.assign({}, OHIF.viewer.defaultHotkeys, hotkeysActions);
|
||||
|
||||
const defaultHotkeys = OHIF.viewer.defaultHotkeys;
|
||||
const hotkeysKeys = Object.keys(hotkeysActions);
|
||||
@@ -258,7 +235,7 @@ function mergeHotkeys(hotkeysActions) {
|
||||
// Different action but same key:
|
||||
// Remove action from merge if is not in "hotkeysActions"
|
||||
// If it is, it's already merged so nothing to do
|
||||
if(ohifAction !== definedAction && hotkeysActions[definedAction] === defaultHotkeys[ohifAction] && !hotkeysActions[ohifAction]) {
|
||||
if (ohifAction !== definedAction && hotkeysActions[definedAction] === defaultHotkeys[ohifAction] && !hotkeysActions[ohifAction]) {
|
||||
delete mergedHotkeys[ohifAction];
|
||||
}
|
||||
});
|
||||
@@ -272,7 +249,7 @@ function mergeHotkeys(hotkeysActions) {
|
||||
* to give the impressiont the button was pressed.
|
||||
* This is for tools that don't keep the button "pressed"
|
||||
* all the time the tool is active.
|
||||
*
|
||||
*
|
||||
* @param button DOM Element for the button to be "flashed"
|
||||
*/
|
||||
function flashButton(button) {
|
||||
@@ -292,16 +269,16 @@ function flashButton(button) {
|
||||
* @param {String} task task function name
|
||||
*/
|
||||
function bindHotkey(hotkey, task) {
|
||||
var hotkeyFunctions = OHIF.viewer.hotkeyFunctions;
|
||||
const hotkeyFunctions = OHIF.viewer.hotkeyFunctions;
|
||||
|
||||
// Only bind defined, non-empty HotKeys
|
||||
if (!hotkey || hotkey === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
var fn;
|
||||
let fn;
|
||||
if (task.indexOf('WLPreset') > -1) {
|
||||
var presetName = task.replace('WLPreset', '');
|
||||
const presetName = task.replace('WLPreset', '');
|
||||
fn = function() {
|
||||
WLPresets.applyWLPresetToActiveElement(presetName);
|
||||
};
|
||||
@@ -319,7 +296,7 @@ function bindHotkey(hotkey, task) {
|
||||
return;
|
||||
}
|
||||
|
||||
var hotKeyForBinding = hotkey.toLowerCase();
|
||||
const hotKeyForBinding = hotkey.toLowerCase();
|
||||
|
||||
$(document).bind('keydown', hotKeyForBinding, fn);
|
||||
}
|
||||
@@ -341,9 +318,7 @@ function enableHotkeys(hotkeys) {
|
||||
}
|
||||
|
||||
if (taskHotkeys instanceof Array) {
|
||||
taskHotkeys.forEach(function(hotkey) {
|
||||
bindHotkey(hotkey, task);
|
||||
});
|
||||
taskHotkeys.forEach(hotkey => bindHotkey(hotkey, task));
|
||||
} else {
|
||||
// taskHotkeys represents a single key
|
||||
bindHotkey(taskHotkeys, task);
|
||||
|
||||
Reference in new issue
Block a user