cornerstone-tools-cacalc
Version:
Medical imaging tools for the Cornerstone library with added functionality for computing Agatston calcium scores
141 lines (105 loc) • 4.82 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>timeSeriesTools/timeSeriesPlayer.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#applyWWWCRegion">applyWWWCRegion</a></li><li><a href="global.html#calculateMinMaxMean">calculateMinMaxMean</a></li><li><a href="global.html#createMagnificationCanvas">createMagnificationCanvas</a></li><li><a href="global.html#dragCallback">dragCallback</a></li><li><a href="global.html#drawMagnificationTool">drawMagnificationTool</a></li><li><a href="global.html#getPlayClipTimeouts">getPlayClipTimeouts</a></li><li><a href="global.html#mouseDownCallback">mouseDownCallback</a></li><li><a href="global.html#mouseUpCallback">mouseUpCallback</a></li><li><a href="global.html#onImageRendered">onImageRendered</a></li><li><a href="global.html#performThresholding">performThresholding</a></li><li><a href="global.html#playClip">playClip</a></li><li><a href="global.html#recordStartPoint">recordStartPoint</a></li><li><a href="global.html#removeMagnificationCanvas">removeMagnificationCanvas</a></li><li><a href="global.html#stopClip">stopClip</a></li><li><a href="global.html#stopClipWithData">stopClipWithData</a></li><li><a href="global.html#triggerStopEvent">triggerStopEvent</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">timeSeriesTools/timeSeriesPlayer.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import { addToolState, getToolState } from '../stateManagement/toolState.js';
import incrementTimePoint from './incrementTimePoint.js';
const toolType = 'timeSeriesPlayer';
/**
* Starts playing a clip of different time series of the same image or adjusts the frame rate of an
* already playing clip. framesPerSecond is optional and defaults to 30 if not specified. A negative
* framesPerSecond will play the clip in reverse.
* The element must have time series
* @param element
* @param framesPerSecond
*/
function playClip (element, framesPerSecond) {
if (element === undefined) {
throw new Error('playClip: element must not be undefined');
}
if (framesPerSecond === undefined) {
framesPerSecond = 30;
}
const timeSeriesToolData = getToolState(element, 'timeSeries');
if (timeSeriesToolData === undefined || timeSeriesToolData.data === undefined || timeSeriesToolData.data.length === 0) {
return;
}
const playClipToolData = getToolState(element, toolType);
let playClipData;
if (playClipToolData === undefined || playClipToolData.data.length === 0) {
playClipData = {
intervalId: undefined,
framesPerSecond,
lastFrameTimeStamp: undefined,
frameRate: 0
};
addToolState(element, toolType, playClipData);
} else {
playClipData = playClipToolData.data[0];
playClipData.framesPerSecond = framesPerSecond;
}
// If already playing, do not set a new interval
if (playClipData.intervalId !== undefined) {
return;
}
playClipData.intervalId = setInterval(function () {
if (playClipData.framesPerSecond > 0) {
incrementTimePoint(element, 1, true);
} else {
incrementTimePoint(element, -1, true);
}
}, 1000 / Math.abs(playClipData.framesPerSecond));
}
/**
* Stops an already playing clip.
* * @param element
*/
function stopClip (element) {
const playClipToolData = getToolState(element, toolType);
if (!playClipToolData || !playClipToolData.data || !playClipToolData.data.length) {
return;
}
const playClipData = playClipToolData.data[0];
clearInterval(playClipData.intervalId);
playClipData.intervalId = undefined;
}
// Module/private exports
const timeSeriesPlayer = {
start: playClip,
stop: stopClip
};
export default timeSeriesPlayer;
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>