Switch Random.id() to Math.random() for triggering reactive updates. Random.id() is taking 40ms on Chrome for some reason
This commit is contained in:
parent
05d9a41f45
commit
37fff25b50
@ -4,7 +4,6 @@
|
||||
// Pull request: https://github.com/chafey/cornerstoneTools/pull/230
|
||||
|
||||
import { cornerstone, cornerstoneTools, cornerstoneMath } from 'meteor/ohif:cornerstone';
|
||||
cornerstoneTools.copyPoints
|
||||
const { copyPoints, pauseEvent } = cornerstoneTools;
|
||||
|
||||
let isClickEvent = true;
|
||||
|
||||
@ -212,7 +212,7 @@ Template.stageSortable.events({
|
||||
}
|
||||
|
||||
// Update the Session variable to the UI re-renders
|
||||
Session.set('LayoutManagerUpdated', Random.id());
|
||||
Session.set('LayoutManagerUpdated', Math.random());
|
||||
}, options);
|
||||
},
|
||||
|
||||
@ -234,7 +234,7 @@ Template.stageSortable.events({
|
||||
ProtocolEngine.stage = newIndex;
|
||||
|
||||
// Update the Session variable to the UI re-renders
|
||||
Session.set('LayoutManagerUpdated', Random.id());
|
||||
Session.set('LayoutManagerUpdated', Math.random());
|
||||
},
|
||||
'click .moveStageDown': function() {
|
||||
// Get the old and new indices following a 'sort' event
|
||||
@ -254,6 +254,6 @@ Template.stageSortable.events({
|
||||
ProtocolEngine.stage = newIndex;
|
||||
|
||||
// Update the Session variable to the UI re-renders
|
||||
Session.set('LayoutManagerUpdated', Random.id());
|
||||
Session.set('LayoutManagerUpdated', Math.random());
|
||||
}
|
||||
});
|
||||
|
||||
@ -60,7 +60,7 @@ Template.cineDialog.onCreated(() => {
|
||||
playClipData.framesPerSecond = OHIF.viewer.cine.framesPerSecond;
|
||||
}
|
||||
|
||||
Session.set('UpdateCINE', Random.id());
|
||||
Session.set('UpdateCINE', Math.random());
|
||||
};
|
||||
|
||||
// Define the actions API
|
||||
@ -123,7 +123,7 @@ Template.cineDialog.onCreated(() => {
|
||||
}
|
||||
|
||||
// Update the session to refresh the framerate text
|
||||
Session.set('UpdateCINE', Random.id());
|
||||
Session.set('UpdateCINE', Math.random());
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// Sets the global variable
|
||||
OHIF.viewer.cine.framesPerSecond = parseFloat(stack.frameRate);
|
||||
// Update the cine dialog FPS
|
||||
Session.set('UpdateCINE', Random.id());
|
||||
Session.set('UpdateCINE', Math.random());
|
||||
}
|
||||
|
||||
// Shortcut for array with image IDs
|
||||
@ -284,7 +284,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
|
||||
// Use Session to trigger reactive updates in the viewportOverlay helper functions
|
||||
// This lets the viewport overlay always display correct window / zoom values
|
||||
Session.set('CornerstoneImageRendered' + viewportIndex, Random.id());
|
||||
Session.set('CornerstoneImageRendered' + viewportIndex, Math.random());
|
||||
|
||||
// Save the current viewport into the OHIF.viewer.data global variable
|
||||
const viewport = cornerstone.getViewport(element);
|
||||
@ -302,7 +302,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
$element.on('CornerstoneImageRendered', onImageRendered);
|
||||
|
||||
// Set a random value for the Session variable in order to trigger an overlay update
|
||||
Session.set('CornerstoneImageRendered' + viewportIndex, Random.id());
|
||||
Session.set('CornerstoneImageRendered' + viewportIndex, Math.random());
|
||||
|
||||
// Define a function to run whenever the Cornerstone viewport changes images
|
||||
// (e.g. during scrolling)
|
||||
@ -319,7 +319,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// Update the templateData with the new imageId
|
||||
// This allows the template helpers to update reactively
|
||||
templateData.imageId = eventData.enabledElement.image.imageId;
|
||||
Session.set('CornerstoneNewImage' + viewportIndex, Random.id());
|
||||
Session.set('CornerstoneNewImage' + viewportIndex, Math.random());
|
||||
layoutManager.viewportData[viewportIndex].imageId = eventData.enabledElement.image.imageId;
|
||||
|
||||
// Get the element and stack data
|
||||
@ -353,7 +353,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
$element.on('CornerstoneNewImage', onNewImage);
|
||||
|
||||
// Set a random value for the Session variable in order to trigger an overlay update
|
||||
Session.set('CornerstoneNewImage' + viewportIndex, Random.id());
|
||||
Session.set('CornerstoneNewImage' + viewportIndex, Math.random());
|
||||
|
||||
const onStackScroll = (e, eventData) => {
|
||||
// Attention: Adding OHIF.log.info in this function may decrease the performance
|
||||
@ -361,7 +361,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
||||
// enabled/disabled -> cornerstone[toolName].tool.enable)
|
||||
|
||||
// Update the imageSlider value
|
||||
Session.set('CornerstoneNewImage' + viewportIndex, Random.id());
|
||||
Session.set('CornerstoneNewImage' + viewportIndex, Math.random());
|
||||
};
|
||||
|
||||
$element.off('CornerstoneStackScroll', onStackScroll);
|
||||
|
||||
@ -46,7 +46,7 @@ Template.viewerMain.onRendered(() => {
|
||||
OHIF.viewerbase.layoutManager = new LayoutManager(parentElement, studies);
|
||||
studyPrefetcher.setStudies(studies);
|
||||
|
||||
Session.set('OHIFViewerMainRendered', Random.id());
|
||||
Session.set('OHIFViewerMainRendered', Math.random());
|
||||
});
|
||||
|
||||
Template.viewerMain.onDestroyed(() => {
|
||||
|
||||
@ -30,7 +30,7 @@ export class LayoutManager {
|
||||
|
||||
this.isZoomed = false;
|
||||
|
||||
const updateSessionFn = () => Tracker.afterFlush(() => Session.set('LayoutManagerUpdated', Random.id()));
|
||||
const updateSessionFn = () => Tracker.afterFlush(() => Session.set('LayoutManagerUpdated', Math.random()));
|
||||
this.updateSession = _.throttle(updateSessionFn, 300);
|
||||
}
|
||||
|
||||
|
||||
@ -188,7 +188,7 @@ const toggleDialog = element => {
|
||||
$element.toggleClass('dialog-open', !isClosed);
|
||||
}
|
||||
|
||||
Session.set('UpdateCINE', Random.id());
|
||||
Session.set('UpdateCINE', Math.random());
|
||||
};
|
||||
|
||||
// Toggle the play/stop state for the cornerstone clip tool
|
||||
@ -204,7 +204,7 @@ const toggleCinePlay = () => {
|
||||
}
|
||||
|
||||
// Update the UpdateCINE session property
|
||||
Session.set('UpdateCINE', Random.id());
|
||||
Session.set('UpdateCINE', Math.random());
|
||||
};
|
||||
|
||||
// Show/hide the CINE dialog
|
||||
@ -305,7 +305,7 @@ const isStackScrollLinkingDisabled = () => {
|
||||
};
|
||||
|
||||
// Create an event listener to update playing state when a clip stops playing
|
||||
$(window).on('CornerstoneToolsClipStopped', () => Session.set('UpdateCINE', Random.id()));
|
||||
$(window).on('CornerstoneToolsClipStopped', () => Session.set('UpdateCINE', Math.random()));
|
||||
|
||||
/**
|
||||
* Export functions inside viewportUtils namespace.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user