From 6c93e729dbb430a3c8fccca36b1a0483aea4e7e1 Mon Sep 17 00:00:00 2001 From: ivmartel Date: Tue, 19 Dec 2017 23:09:50 +0100 Subject: [PATCH] Update dist to v0.22.1 --- dist/dwv.js | 159 +++++++++++++++++++++++++++++++++++++++--------- dist/dwv.min.js | 4 +- 2 files changed, 131 insertions(+), 32 deletions(-) diff --git a/dist/dwv.js b/dist/dwv.js index 0b06efe60a..f8fed6ab8f 100644 --- a/dist/dwv.js +++ b/dist/dwv.js @@ -127,6 +127,9 @@ dwv.App = function () // Loadbox var loadbox = null; + // Current loader + var currentLoader = null; + // UndoStack var undoStack = null; @@ -554,6 +557,17 @@ dwv.App = function () } }; + /** + * Abort the current load. + */ + this.abortLoad = function () + { + if ( currentLoader ) { + currentLoader.abort(); + currentLoader = null; + } + }; + /** * Load a list of ArrayBuffers. * @param {Array} data The list of ArrayBuffers to load @@ -610,13 +624,16 @@ dwv.App = function () */ function loadImageData(data, loader, options) { + // store loader + currentLoader = loader; + // allow to cancel var previousOnKeyDown = window.onkeydown; window.onkeydown = function (event) { if (event.ctrlKey && event.keyCode === 88 ) // crtl-x { console.log("crtl-x pressed!"); - loader.abort(); + self.abortLoad(); } }; @@ -654,6 +671,8 @@ dwv.App = function () fireEvent({type: "load-progress", lengthComputable: true, loaded: 100, total: 100}); fireEvent({ 'type': 'load-end' }); + // reset member + currentLoader = null; }; loader.onprogress = onLoadProgress; // main load (asynchronous) @@ -2659,7 +2678,7 @@ dwv.dicom = dwv.dicom || {}; * Get the version of the library. * @return {String} The version of the library. */ -dwv.getVersion = function () { return "0.22.0"; }; +dwv.getVersion = function () { return "0.22.1"; }; /** * Clean string: trim and remove ending. @@ -15793,6 +15812,15 @@ dwv.image.View = function (image) this.setWindowPresets = function (presets) { windowPresets = presets; }; + + /** + * Set the default colour map. + * @param {Object} map The colour map. + */ + this.setDefaultColourMap = function (map) { + colourMap = map; + }; + /** * Add window presets to the existing ones. * @param {Object} presets The window presets. @@ -15829,10 +15857,6 @@ dwv.image.View = function (image) */ this.setColourMap = function(map) { colourMap = map; - // TODO Better handle this... - if( this.getImage().getPhotometricInterpretation() === "MONOCHROME1") { - colourMap = dwv.image.lut.invPlain; - } this.fireEvent({"type": "colour-change", "wc": this.getCurrentWindowLut().getWindowLevel().getCenter(), "ww": this.getCurrentWindowLut().getWindowLevel().getWidth() }); @@ -16293,6 +16317,11 @@ dwv.image.ViewFactory.prototype.create = function (dicomElements, image) // view var view = new dwv.image.View(image); + // default color map + if( image.getPhotometricInterpretation() === "MONOCHROME1") { + view.setDefaultColourMap(dwv.image.lut.invPlain); + } + // presets var windowPresets = {}; @@ -19790,6 +19819,18 @@ dwv.tool.ArrowFactory.prototype.create = function (points, style/*, image*/) strokeWidth: style.getScaledStrokeWidth(), name: "shape" }); + // larger hitfunc + var linePerp0 = dwv.math.getPerpendicularLine( line, points[0], 10 ); + var linePerp1 = dwv.math.getPerpendicularLine( line, points[1], 10 ); + kshape.hitFunc( function (context) { + context.beginPath(); + context.moveTo( linePerp0.getBegin().getX(), linePerp0.getBegin().getY() ); + context.lineTo( linePerp0.getEnd().getX(), linePerp0.getEnd().getY() ); + context.lineTo( linePerp1.getEnd().getX(), linePerp1.getEnd().getY() ); + context.lineTo( linePerp1.getBegin().getX(), linePerp1.getBegin().getY() ); + context.closePath(); + context.fillStrokeShape(this); + }); // triangle var beginTy = new dwv.math.Point2D(line.getBegin().getX(), line.getBegin().getY() - 10); var verticalLine = new dwv.math.Line(line.getBegin(), beginTy); @@ -19888,6 +19929,20 @@ dwv.tool.UpdateArrow = function (anchor/*, image*/) var p2d0 = new dwv.math.Point2D(begin.x(), begin.y()); var p2d1 = new dwv.math.Point2D(end.x(), end.y()); var line = new dwv.math.Line(p2d0, p2d1); + // larger hitfunc + var p2b = new dwv.math.Point2D(bx, by); + var p2e = new dwv.math.Point2D(ex, ey); + var linePerp0 = dwv.math.getPerpendicularLine( line, p2b, 10 ); + var linePerp1 = dwv.math.getPerpendicularLine( line, p2e, 10 ); + kline.hitFunc( function (context) { + context.beginPath(); + context.moveTo( linePerp0.getBegin().getX(), linePerp0.getBegin().getY() ); + context.lineTo( linePerp0.getEnd().getX(), linePerp0.getEnd().getY() ); + context.lineTo( linePerp1.getEnd().getX(), linePerp1.getEnd().getY() ); + context.lineTo( linePerp1.getBegin().getX(), linePerp1.getBegin().getY() ); + context.closePath(); + context.fillStrokeShape(this); + }); // udate triangle var beginTy = new dwv.math.Point2D(line.getBegin().getX(), line.getBegin().getY() - 10); var verticalLine = new dwv.math.Line(line.getBegin(), beginTy); @@ -20322,11 +20377,11 @@ dwv.tool.Draw = function (app, shapeFactoryList) // store original colour var colour = null; + // save start position + dragStartPos = {'x': shape.x(), 'y': shape.y()}; + // drag start event handling - shape.on('dragstart', function (event) { - // save start position - var offset = dwv.html.getEventOffset( event.evt )[0]; - dragStartPos = getRealPosition( offset ); + shape.on('dragstart', function (/*event*/) { // colour colour = shape.stroke(); // display trash @@ -20344,21 +20399,21 @@ dwv.tool.Draw = function (app, shapeFactoryList) }); // drag move event handling shape.on('dragmove', function (event) { - var offset = dwv.html.getEventOffset( event.evt )[0]; - var pos = getRealPosition( offset ); + var pos = {'x': this.x(), 'y': this.y()}; var translation; if ( dragLastPos ) { translation = {'x': pos.x - dragLastPos.x, 'y': pos.y - dragLastPos.y}; - } - else { + } else { translation = {'x': pos.x - dragStartPos.x, - 'y': pos.y - dragStartPos.y}; + 'y': pos.y - dragStartPos.y}; } dragLastPos = pos; // highlight trash when on it - if ( Math.abs( pos.x - trash.x() ) < 10 && - Math.abs( pos.y - trash.y() ) < 10 ) { + var offset = dwv.html.getEventOffset( event.evt )[0]; + var eventPos = getRealPosition( offset ); + if ( Math.abs( eventPos.x - trash.x() ) < 10 && + Math.abs( eventPos.y - trash.y() ) < 10 ) { trash.getChildren().each( function (tshape){ tshape.stroke('orange'); }); shape.stroke('red'); } @@ -20368,12 +20423,12 @@ dwv.tool.Draw = function (app, shapeFactoryList) } // update group but not 'this' shape var group = this.getParent(); - group.getChildren().each( function (shape) { - if ( shape == this ) { + group.getChildren().each( function (ashape) { + if ( ashape === shape ) { return; } - shape.x( shape.x() + translation.x ); - shape.y( shape.y() + translation.y ); + ashape.x( ashape.x() + translation.x ); + ashape.y( ashape.y() + translation.y ); }); // reset anchors shapeEditor.resetAnchors(); @@ -20381,21 +20436,23 @@ dwv.tool.Draw = function (app, shapeFactoryList) drawLayer.draw(); }); // drag end event handling - shape.on('dragend', function (/*event*/) { - var pos = dragLastPos; + shape.on('dragend', function (event) { + var pos = {'x': this.x(), 'y': this.y()}; dragLastPos = null; // remove trash trash.remove(); // delete case - if ( Math.abs( pos.x - trash.x() ) < 10 && - Math.abs( pos.y - trash.y() ) < 10 ) { + var offset = dwv.html.getEventOffset( event.evt )[0]; + var eventPos = getRealPosition( offset ); + if ( Math.abs( eventPos.x - trash.x() ) < 10 && + Math.abs( eventPos.y - trash.y() ) < 10 ) { // compensate for the drag translation - var delTranslation = {'x': pos.x - dragStartPos.x, - 'y': pos.y - dragStartPos.y}; + var delTranslation = {'x': eventPos.x - dragStartPos.x, + 'y': eventPos.y - dragStartPos.y}; var group = this.getParent(); - group.getChildren().each( function (shape) { - shape.x( shape.x() - delTranslation.x ); - shape.y( shape.y() - delTranslation.y ); + group.getChildren().each( function (ashape) { + ashape.x( ashape.x() - delTranslation.x ); + ashape.y( ashape.y() - delTranslation.y ); }); // disable editor shapeEditor.disable(); @@ -20422,6 +20479,9 @@ dwv.tool.Draw = function (app, shapeFactoryList) mvcmd.onExecute = fireEvent; mvcmd.onUndo = fireEvent; app.addToUndoStack(mvcmd); + + // reset start position + dragStartPos = {'x': this.x(), 'y': this.y()}; // the move is handled by Konva, trigger an event manually fireEvent({'type': 'draw-move'}); } @@ -22992,6 +23052,15 @@ dwv.tool.ProtractorFactory.prototype.create = function (points, style/*, image*/ // text and decoration if ( points.length === 3 ) { var line1 = new dwv.math.Line(points[1], points[2]); + // larger hitfunc + kshape.hitFunc( function (context) { + context.beginPath(); + context.moveTo( points[0].getX(), points[0].getY() ); + context.lineTo( points[1].getX(), points[1].getY() ); + context.lineTo( points[2].getX(), points[2].getY() ); + context.closePath(); + context.fillStrokeShape(this); + }); // quantification var angle = dwv.math.getAngle(line0, line1); var inclination = line0.getInclination(); @@ -23100,6 +23169,15 @@ dwv.tool.UpdateProtractor = function (anchor/*, image*/) var ex = end.x() - kline.x(); var ey = end.y() - kline.y(); kline.points( [bx,by,mx,my,ex,ey] ); + // larger hitfunc + kline.hitFunc( function (context) { + context.beginPath(); + context.moveTo( bx, by ); + context.lineTo( mx, my ); + context.lineTo( ex, ey ); + context.closePath(); + context.fillStrokeShape(this); + }); // update text var p2d0 = new dwv.math.Point2D(begin.x(), begin.y()); var p2d1 = new dwv.math.Point2D(mid.x(), mid.y()); @@ -23479,6 +23557,17 @@ dwv.tool.RulerFactory.prototype.create = function (points, style, image) name: "shape-tick1" }); + // larger hitfunc + kshape.hitFunc( function (context) { + context.beginPath(); + context.moveTo( linePerp0.getBegin().getX(), linePerp0.getBegin().getY() ); + context.lineTo( linePerp0.getEnd().getX(), linePerp0.getEnd().getY() ); + context.lineTo( linePerp1.getEnd().getX(), linePerp1.getEnd().getY() ); + context.lineTo( linePerp1.getBegin().getX(), linePerp1.getBegin().getY() ); + context.closePath(); + context.fillStrokeShape(this); + }); + // quantification var quant = image.quantifyLine( line ); var ktext = new Konva.Text({ @@ -23576,6 +23665,16 @@ dwv.tool.UpdateRuler = function (anchor, image) var linePerp1 = dwv.math.getPerpendicularLine( line, p2e, 10 ); ktick1.points( [linePerp1.getBegin().getX(), linePerp1.getBegin().getY(), linePerp1.getEnd().getX(), linePerp1.getEnd().getY()] ); + // larger hitfunc + kline.hitFunc( function (context) { + context.beginPath(); + context.moveTo( linePerp0.getBegin().getX(), linePerp0.getBegin().getY() ); + context.lineTo( linePerp0.getEnd().getX(), linePerp0.getEnd().getY() ); + context.lineTo( linePerp1.getEnd().getX(), linePerp1.getEnd().getY() ); + context.lineTo( linePerp1.getBegin().getX(), linePerp1.getBegin().getY() ); + context.closePath(); + context.fillStrokeShape(this); + }); // update text var quant = image.quantifyLine( line ); var ktext = klabel.getText(); diff --git a/dist/dwv.min.js b/dist/dwv.min.js index 5ab6d7c707..98c5fe65fb 100644 --- a/dist/dwv.min.js +++ b/dist/dwv.min.js @@ -1,3 +1,3 @@ -/*! dwv 0.22.0 29-11-2017 */ +/*! dwv 0.22.1 19-12-2017 */ -!function(e,t){"function"==typeof define&&define.amd?define(["modernizr","i18next","i18nextXHRBackend","i18nextBrowserLanguageDetector","jszip","konva",""],t):"object"==typeof module&&module.exports?module.exports=t(require("modernizr"),require("i18next"),require("i18next-xhr-backend"),require("i18next-browser-languagedetector"),require("jszip"),null,null):e.dwv=t(e.Modernizr,e.i18next,e.i18nextXHRBackend,e.i18nextBrowserLanguageDetector,e.JSZip,e.Konva,e.MagicWand)}(this,function(e,t,n,i,r,o,a){function s(e,t,n){var i=null;return null!==t&&null!==n&&(i=e*t*n),i}var l=void 0!==l?l:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};(u=u||{}).App=function(){function e(e,t){n([e],new u.io.UrlsLoader,{requestHeaders:t})}function t(e,t,n){var o=l.onkeydown;l.onkeydown=function(e){e.ctrlKey&&88===e.keyCode&&(console.log("crtl-x pressed!"),t.abort())},m.reset();var a="";a=void 0!==e[0].name?e[0].name:e[0],D=1===e.length&&"zip"!==a.split(".").pop().toLowerCase(),t.setDefaultCharacterSet(g),t.onload=function(e){h&&(A.append(e.view),q&&q.appendDrawLayer(h.getNumberOfFrames())),function(e){if(A)return;A=e.view,E=new u.ViewController(A),b&&b.update(e.info);p=A.getImage();var t=(h=p).getGeometry().getSize();C=t.getNumberOfColumns(),y=t.getNumberOfRows(),function(e,t){var n=m.getElement("imageLayer");(R=new u.html.Layer(n)).initialise(e,t),R.fillContext(),R.setStyleDisplay(!0);var i=m.getElement("drawDiv");i&&(q=new u.DrawController(i)).create(e,t),T?m.fitToSize(u.gui.getWindowSize()):m.fitToSize({width:m.getElement("layerContainer").offsetWidth,height:m.getElement("layerContainer").offsetHeight}),m.resetLayout()}(C,y),f=R.getContext().createImageData(C,y),A.addEventListener("wl-width-change",m.onWLChange),A.addEventListener("wl-center-change",m.onWLChange),A.addEventListener("colour-change",m.onColourChange),A.addEventListener("slice-change",m.onSliceChange),A.addEventListener("frame-change",m.onFrameChange),A.addEventListener("wl-width-change",i),A.addEventListener("wl-center-change",i),A.addEventListener("colour-change",i),A.addEventListener("position-change",i),A.addEventListener("slice-change",i),A.addEventListener("frame-change",i),q&&q.appendDrawLayer(h.getNumberOfFrames());M&&M.initAndDisplay(R);var n=m.getElement("dropBox");if(n){n.removeEventListener("dragover",s),n.removeEventListener("dragleave",c),n.removeEventListener("drop",S),u.html.removeNode(n);var o=m.getElement("layerContainer");o.addEventListener("dragover",s),o.addEventListener("dragleave",c),o.addEventListener("drop",S)}m.getElement("infoLayer")&&((O=new u.InfoController(v)).create(m),O.toggleListeners(m,A));m.initWLDisplay(),r()}(e)},t.onerror=function(e){d(e)},t.onabort=function(e){!function(e){e.message?console.warn(e.message):console.warn("Abort called.");u.gui.displayProgress(100)}(e)},t.onloadend=function(){l.onkeydown=o,q&&q.activateDrawLayer(E),i({type:"load-progress",lengthComputable:!0,loaded:100,total:100}),i({type:"load-end"})},t.onprogress=x,i({type:"load-start"}),t.load(e,n)}function n(e,t,n){t.onload=function(e){new u.State(m).fromJSON(e)},t.onerror=function(e){d(e)},t.load(e,n)}function i(e){if(void 0!==B[e.type])for(var t=0;t0)for(var a=0;a0)for(var a=0;a0},u.dicom.getUtfLabel=function(e){var t="utf-8";return"ISO_IR 100"===e?t="iso-8859-1":"ISO_IR 101"===e?t="iso-8859-2":"ISO_IR 109"===e?t="iso-8859-3":"ISO_IR 110"===e?t="iso-8859-4":"ISO_IR 144"===e?t="iso-8859-5":"ISO_IR 127"===e?t="iso-8859-6":"ISO_IR 126"===e?t="iso-8859-7":"ISO_IR 138"===e?t="iso-8859-8":"ISO_IR 148"===e?t="iso-8859-9":"ISO_IR 13"===e?t="shift-jis":"ISO_IR 166"===e?t="iso-8859-11":"ISO 2022 IR 87"===e?t="iso-2022-jp":"ISO 2022 IR 149"===e||"ISO 2022 IR 58"===e||("ISO_IR 192"===e?t="utf-8":"GB18030"===e?t="gb18030":"GB2312"===e?t="gb2312":"GBK"===e&&(t="chinese")),t},u.dicom.DataReader=function(e,t){void 0===t&&(t=!0);var n={};n.decode=function(e){for(var t="",n=0,i=e.length;ns;a--,s++)t=i[s],i[s]=i[a],i[a]=t},this.readUint16=function(e){return a.getUint16(e,t)},this.readUint32=function(e){return a.getUint32(e,t)},this.readInt32=function(e){return a.getInt32(e,t)},this.readUint8Array=function(t,n){return new Uint8Array(e,t,n)},this.readInt8Array=function(t,n){return new Int8Array(e,t,n)},this.readUint16Array=function(n,i){var r=i/Uint16Array.BYTES_PER_ELEMENT,s=null;if(n%Uint16Array.BYTES_PER_ELEMENT==0)s=new Uint16Array(e,n,r),o&&this.flipArrayEndianness(s);else{s=new Uint16Array(r);for(var l=0;l1&&p.length>S){for(var f=p.length/S,C=[],y=0,D=0;D=4?l.substr(2,2):"00")+":"+(l.length>=6?l.substr(4,2):"00")}else for(var c="O"===e.vr[0].toUpperCase(),S="FL"===e.vr||"FD"===e.vr||"DS"===e.vr,d="",x=0,g=e.value.length;x0)for(var c=0;c1&&(o=u.dicom.flattenArrayOfTypedArrays(i)),n=this.writeDataElementValue(e,n,o,r)}else{var a={};a.xFFFEE000={tag:{group:"0xFFFE",element:"0xE000",name:"xFFFEE000"},vr:"UN",vl:0,value:[]};for(var s=0;s255&&(o=200),[0,o,o]}}},u.dicom.generatePixelDataFromJSONTags=function(e,t,n){if(void 0===n&&(n="gradSquare"),void 0===e.TransferSyntaxUID)throw new Error("Missing transfer syntax for pixel generation.");if(void 0===e.Rows)throw new Error("Missing number of rows for pixel generation.");if(void 0===e.Columns)throw new Error("Missing number of columns for pixel generation.");if(void 0===e.BitsAllocated)throw new Error("Missing BitsAllocated for pixel generation.");if(void 0===e.PixelRepresentation)throw new Error("Missing PixelRepresentation for pixel generation.");if(void 0===e.SamplesPerPixel)throw new Error("Missing SamplesPerPixel for pixel generation.");if(void 0===e.PhotometricInterpretation)throw new Error("Missing PhotometricInterpretation for pixel generation.");var i=u.dicom.isImplicitTransferSyntax(e.TransferSyntaxUID),r=e.Rows,o=e.Columns,a=e.BitsAllocated,s=e.PixelRepresentation,l=e.SamplesPerPixel,c=e.PhotometricInterpretation,S=r*o*l;if(1!==l&&3!==l)throw new Error("Unsupported SamplesPerPixel for pixel generation: "+l);if(1===l&&"MONOCHROME1"!==c&&"MONOCHROME2"!==c||3===l&&"RGB"!==c)throw new Error("Unsupported PhotometricInterpretation for pixel generation: "+c+" with SamplesPerPixel: "+l);var d=1,x=1;if(3===l){if(void 0===e.PlanarConfiguration)throw new Error("Missing PlanarConfiguration for pixel generation.");var g=e.PlanarConfiguration;if(0!==g&&1!==g)throw new Error("Unsupported PlanarConfiguration for pixel generation: "+g);0===g?d=3:x=3}var m=u.dicom.getTypedArray(a,s,S);if(void 0===u.dicom.pixelGenerators[n])throw new Error("Unknown PixelData generator: "+n);var h=new u.dicom.pixelGenerators[n](o,r),p=h.getGrey;"RGB"===c&&(p=h.getRGB);for(var f=0,C=0;C";for(var x=1;x10&&((t=Array.prototype.slice.call(t,0,10))[10]="..."),i=Array.prototype.join.call(t,", ")),n.appendChild(document.createTextNode(i))},u.html.appendHCell=function(e,t){var n=document.createElement("th");n.appendChild(document.createTextNode(t)),e.appendChild(n)},u.html.appendRowForArray=function(e,t,n,i,r){for(var o=null,a=0;a=i?(o||(o=e.insertRow(-1)),u.html.appendCell(o,s)):u.html.appendRow(e,s,n+a,i,r)}},u.html.appendRowForObject=function(e,t,n,i,r){for(var o=Object.keys(t),a=null,s=0;s=i?(a||(a=e.insertRow(-1)),0===s&&r&&u.html.appendCell(a,r),u.html.appendCell(a,l)):u.html.appendRow(e,l,n+s,i,o[s])}if(2===n){var c=e.createTHead().insertRow(-1);r&&u.html.appendHCell(c,"");for(var S=0;S]+>/g,"").toLowerCase().indexOf(n[o])<0?i="none":n[o].length&&u.html.highlight(n[o],t.rows[r]),t.rows[r].style.display=i}},u.html.dehighlight=function(e){for(var t=0;t]+>/g,"")),n.parentNode);3!==n.nodeType&&u.html.dehighlight(n)}},u.html.highlight=function(e,t){for(var n=0;n=0){var a=document.createElement("span");i.parentNode.replaceChild(a,i);for(var s;-1!==(s=o.indexOf(e));)a.appendChild(document.createTextNode(r.substr(0,s))),a.appendChild(u.html.createHighlightNode(document.createTextNode(r.substr(s,e.length)))),r=r.substr(s+e.length),o=o.substr(s+e.length);a.appendChild(document.createTextNode(r))}}else u.html.highlight(e,i)}},u.html.createHighlightNode=function(e){var t=document.createElement("span");return t.setAttribute("class","highlighted"),t.attributes.class.value="highlighted",t.appendChild(e),t},u.html.cleanNode=function(e){if(e)for(;e.hasChildNodes();)e.removeChild(e.firstChild)},u.html.removeNode=function(e){if(e){u.html.cleanNode(e);e.parentNode.removeChild(e)}},u.html.removeNodes=function(e){for(var t=0;t=t){var l=s[t].firstChild.data;s[t].firstChild.data=u.i18n(r+l+o)}}},u.html.makeCellEditable=function(e,t,n){if(void 0!==e){var i=document.createElement("input");t?i.onchange=t:i.disabled=!0,i.value=e.firstChild.data,void 0===n||"color"===n&&!u.browser.hasInputColor()?i.type="text":i.type=n,u.html.cleanNode(e);var r=document.createElement("form");r.onsubmit=function(e){e.preventDefault()},r.appendChild(i),e.appendChild(r)}else console.warn("Cannot create input for non existing cell.")},u.html.setCursorToPointer=function(){document.body.style.cursor="pointer"},u.html.setCursorToDefault=function(){document.body.style.cursor="default"},u.html.createHtmlSelect=function(e,t,n,i){var r=document.createElement("select");r.className=e;var o,a=void 0===n?"":n+".",s=void 0!==i,l=function(e){var t=a+e+".name";return s?u.i18nExists(t)?u.i18n(t):e:u.i18n(t)};if(t instanceof Array)for(var c in t)t.hasOwnProperty(c)&&((o=document.createElement("option")).value=t[c],o.appendChild(document.createTextNode(l(t[c]))),r.appendChild(o));else{if("object"!=typeof t)throw new Error("Unsupported input list type.");for(var S in t)(o=document.createElement("option")).value=S,o.appendChild(document.createTextNode(l(S))),r.appendChild(o)}return r},u.html.displayElement=function(e,t){e.style.display=t?"":"none"},u.html.toggleDisplay=function(e){"none"===e.style.display?e.style.display="":e.style.display="none"},u.html.appendElement=function(e,t){e.appendChild(t),u.gui.refreshElement(e)},u.html.createHiddenElement=function(e,t){var n=document.createElement(e);return n.className=t,n.style.display="none",n};(u=u||{}).gui=u.gui||{},u.gui.base=u.gui.base||{},u.gui.info=u.gui.info||{},u.gui.base.plot=function(){},u.gui.info.MiniColourMap=function(e,t){this.create=function(){var t=e.getElementsByClassName("colour-map-info");0!==t.length&&u.html.removeNodes(t);var n=document.createElement("canvas");n.className="colour-map-info",n.width=98,n.height=10,e.appendChild(n)},this.update=function(n){for(var i,r=n.wc,o=n.ww,a=e.getElementsByClassName("colour-map-info")[0],s=a.getContext("2d"),l=t.getViewController().getColourMap(),u=s.getImageData(0,0,a.width,a.height),c=0,S=t.getImage().getRescaledDataRange().min,d=(t.getImage().getRescaledDataRange().max-S)/a.width,x=0,g=r-.5-(o-1)/2,m=r-.5+(o-1)/2,h=0;hm?x=255:(x=255*((c-(r-.5))/(o-1)+.5)+0,x=parseInt(x,10)),i=4*(p+h*a.width),u.data[i]=l.red[x],u.data[i+1]=l.green[x],u.data[i+2]=l.blue[x],u.data[i+3]=255,c+=d}s.putImageData(u,0,0)}},u.gui.info.Plot=function(e,t){this.create=function(){e&&u.html.cleanNode(e),u.gui.plot(e,t.getImage().getHistogram())},this.update=function(n){var i=n.wc,r=n.ww,o=parseInt((r-1)/2,10),a=parseInt(i-.5,10),s=a-o,l=a+o,c=[{color:"#faa",lineWidth:1,xaxis:{from:s,to:s}},{color:"#aaf",lineWidth:1,xaxis:{from:l,to:l}}];u.gui.plot(e,t.getImage().getHistogram(),{markings:c})}},u.gui.info.Overlay=function(e,t,n){var i=this;this.getOverlays=function(){var e=n.getImage();if(e){var i=e.getOverlays();if(i){var r=i[n.getViewController().getCurrentPosition().k];if(r)return r[t]}}},this.create=function(){u.html.cleanNode(e);var n=i.getOverlays();if(n)if("bc"===t||"tc"===t||"cr"===t||"cl"===t)e.textContent=n[0].value;else{for(var r=document.createElement("ul"),o=0;n[o];o++){var a;"window-center"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-window-center",r.appendChild(a)):"window-width"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-window-width",r.appendChild(a)):"zoom"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-zoom",r.appendChild(a)):"offset"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-offset",r.appendChild(a)):"value"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-value",r.appendChild(a)):"position"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-position",r.appendChild(a)):"frame"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-frame",r.appendChild(a)):((a=document.createElement("li")).className="info-"+t+"-"+o,a.appendChild(document.createTextNode(n[o].value)),r.appendChild(a))}e.appendChild(r)}},this.update=function(n){var r=i.getOverlays();if(r)if("bc"===t||"tc"===t||"cr"===t||"cl"===t)e.textContent=r[0].value;else{var o,a;for(a=0;r[a];a++)if("window-center"===r[a].value){if("wl-center-change"===n.type){o=e.getElementsByClassName("info-"+t+"-window-center")[0],u.html.cleanNode(o);var s=u.utils.replaceFlags2(r[a].format,[Math.round(n.wc)]);o&&o.appendChild(document.createTextNode(s))}}else if("window-width"===r[a].value){if("wl-width-change"===n.type){o=e.getElementsByClassName("info-"+t+"-window-width")[0],u.html.cleanNode(o);var l=u.utils.replaceFlags2(r[a].format,[Math.round(n.ww)]);o&&o.appendChild(document.createTextNode(l))}}else if("zoom"===r[a].value){if("zoom-change"===n.type){o=e.getElementsByClassName("info-"+t+"-zoom")[0],u.html.cleanNode(o);var c=Number(n.scale).toPrecision(3),S=u.utils.replaceFlags2(r[a].format,[c]);o&&o.appendChild(document.createTextNode(S))}}else if("offset"===r[a].value){if("zoom-change"===n.type){o=e.getElementsByClassName("info-"+t+"-offset")[0],u.html.cleanNode(o);var d=[Number(n.cx).toPrecision(3),Number(n.cy).toPrecision(3)],x=u.utils.replaceFlags2(r[a].format,d);o&&o.appendChild(document.createTextNode(x))}}else if("value"===r[a].value){if("position-change"===n.type){o=e.getElementsByClassName("info-"+t+"-value")[0],u.html.cleanNode(o);var g=u.utils.replaceFlags2(r[a].format,[n.value]);o&&o.appendChild(document.createTextNode(g))}}else if("position"===r[a].value){if("position-change"===n.type){o=e.getElementsByClassName("info-"+t+"-position")[0],u.html.cleanNode(o);var m=u.utils.replaceFlags2(r[a].format,[n.i,n.j,n.k]);o&&o.appendChild(document.createTextNode(m))}}else if("frame"===r[a].value){if("frame-change"===n.type){o=e.getElementsByClassName("info-"+t+"-frame")[0],u.html.cleanNode(o);var h=u.utils.replaceFlags2(r[a].format,[n.frame]);o&&o.appendChild(document.createTextNode(h))}}else"position-change"===n.type&&(o=e.getElementsByClassName("info-"+t+"-"+a)[0],u.html.cleanNode(o),o&&o.appendChild(document.createTextNode(r[a].value)))}}},u.gui.info.createOverlays=function(e){var t={},n=e.getFromKey("x00080060");if(!n)return t;var i=u.gui.info.overlayMaps;if(!i)return t;for(var r=i[n]||i["*"],o=0;r[o];o++){var a=r[o].value,s=r[o].tags,l=r[o].format,c=r[o].pos;if(void 0!==s&&0!==s.length){for(var S=[],d=0;d=0;--n)t.remove(n);u.gui.refreshElement(t)},this.addCommandToUndoHtml=function(t){var n=e.getElement("history_list"),i=n.length-(n.selectedIndex+1);if(i>0)for(var r=0;rn.getMax()?t:e})},u.image.filter.Sharpen=function(){this.getName=function(){return"Sharpen"};var e=null;this.setOriginalImage=function(t){e=t},this.getOriginalImage=function(){return e}},u.image.filter.Sharpen.prototype.update=function(){return this.getOriginalImage().convolute2D([0,-1,0,-1,5,-1,0,-1,0])},u.image.filter.Sobel=function(){this.getName=function(){return"Sobel"};var e=null;this.setOriginalImage=function(t){e=t},this.getOriginalImage=function(){return e}},u.image.filter.Sobel.prototype.update=function(){var e=this.getOriginalImage(),t=e.convolute2D([1,0,-1,2,0,-2,1,0,-1]),n=e.convolute2D([1,2,1,0,0,0,-1,-2,-1]);return t.compose(n,function(e,t){return Math.sqrt(e*e+t*t)})};(u=u||{}).image=u.image||{},u.image.Size=function(e,t,n){this.getNumberOfColumns=function(){return e},this.getNumberOfRows=function(){return t},this.getNumberOfSlices=function(){return n||1}},u.image.Size.prototype.getSliceSize=function(){return this.getNumberOfColumns()*this.getNumberOfRows()},u.image.Size.prototype.getTotalSize=function(){return this.getSliceSize()*this.getNumberOfSlices()},u.image.Size.prototype.equals=function(e){return null!==e&&this.getNumberOfColumns()===e.getNumberOfColumns()&&this.getNumberOfRows()===e.getNumberOfRows()&&this.getNumberOfSlices()===e.getNumberOfSlices()},u.image.Size.prototype.isInBounds=function(e,t,n){return!(e<0||e>this.getNumberOfColumns()-1||t<0||t>this.getNumberOfRows()-1||n<0||n>this.getNumberOfSlices()-1)},u.image.Size.prototype.toString=function(){return"("+this.getNumberOfColumns()+", "+this.getNumberOfRows()+", "+this.getNumberOfSlices()+")"},u.image.Spacing=function(e,t,n){this.getColumnSpacing=function(){return e},this.getRowSpacing=function(){return t},this.getSliceSpacing=function(){return n||1}},u.image.Spacing.prototype.equals=function(e){return null!==e&&this.getColumnSpacing()===e.getColumnSpacing()&&this.getRowSpacing()===e.getRowSpacing()&&this.getSliceSpacing()===e.getSliceSpacing()},u.image.Spacing.prototype.toString=function(){return"("+this.getColumnSpacing()+", "+this.getRowSpacing()+", "+this.getSliceSpacing()+")"},u.image.Geometry=function(e,t,n,i){void 0===e&&(e=new u.math.Point3D(0,0,0));var r=[e];void 0===i&&(i=new u.math.getIdentityMat33),this.getOrigin=function(){return e},this.getOrigins=function(){return r},this.getSize=function(){return t},this.getSpacing=function(){return n},this.getOrientation=function(){return i},this.getSliceIndex=function(e){for(var t=0,n=e.getDistance(r[0]),o=0,a=0;a0?t+1:t},this.appendOrigin=function(e,n){r.splice(n,0,e),t=new u.image.Size(t.getNumberOfColumns(),t.getNumberOfRows(),t.getNumberOfSlices()+1)}},u.image.Geometry.prototype.equals=function(e){return null!==e&&this.getOrigin()===e.getOrigin()&&this.getSize()===e.getSize()&&this.getSpacing()===e.getSpacing()},u.image.Geometry.prototype.indexToOffset=function(e){var t=this.getSize();return e.getI()+e.getJ()*t.getNumberOfColumns()+e.getK()*t.getSliceSize()},u.image.Geometry.prototype.indexToWorld=function(e){var t=this.getOrigin(),n=this.getSpacing();return new u.math.Point3D(t.getX()+e.getI()*n.getColumnSpacing(),t.getY()+e.getJ()*n.getRowSpacing(),t.getZ()+e.getK()*n.getSliceSpacing())},u.image.Geometry.prototype.worldToIndex=function(e){var t=this.getOrigin(),n=this.getSpacing();return new u.math.Point3D(e.getX()/n.getColumnSpacing()-t.getX(),e.getY()/n.getRowSpacing()-t.getY(),e.getZ()/n.getSliceSpacing()-t.getZ())};(u=u||{}).image=u.image||{},u.image.RescaleSlopeAndIntercept=function(e,t){this.getSlope=function(){return e},this.getIntercept=function(){return t},this.apply=function(n){return n*e+t}},u.image.RescaleSlopeAndIntercept.prototype.equals=function(e){return null!==e&&this.getSlope()===e.getSlope()&&this.getIntercept()===e.getIntercept()},u.image.RescaleSlopeAndIntercept.prototype.toString=function(){return this.getSlope()+", "+this.getIntercept()},u.image.RescaleSlopeAndIntercept.prototype.isID=function(){return 1===this.getSlope()&&0===this.getIntercept()},u.image.Image=function(e,t,n){void 0===n&&(n=t.length),this.getNumberOfFrames=function(){return n};for(var i=[],r=0,o=e.getSize().getNumberOfSlices();r0&&!i[n].equals(i[n-1])&&(s=!1)},this.isIdentityRSI=function(){return a},this.isConstantRSI=function(){return s},this.getPhotometricInterpretation=function(){return l},this.setPhotometricInterpretation=function(e){l=e},this.getPlanarConfiguration=function(){return c},this.setPlanarConfiguration=function(e){c=e},this.getNumberOfComponents=function(){return S},this.getMeta=function(){return d},this.setMeta=function(e){d=e},this.getValueAtOffset=function(e,n){return t[n][e]},this.clone=function(){for(var e=[],n=0,i=this.getNumberOfFrames();nn&&(n=i),in?t:n}}for(var i=this.getGeometry().getSize(),r=this.getRescaledValue(0,0,0),o=r,a=0,s=0;s<1;++s)for(var l=0,u=i.getNumberOfSlices();lo&&(o=a),ai&&(i=r),ra&&(a=s),s=t&&e<2*t?u.image.lut.range_max-1:0},u.image.lut.maxThirdThird=function(e){return e>=2*u.image.lut.range_max/3?u.image.lut.range_max-1:0},u.image.lut.toMaxFirstThird=function(e){var t=3*e;return t>u.image.lut.range_max-1?u.image.lut.range_max-1:t},u.image.lut.toMaxSecondThird=function(e){var t=u.image.lut.range_max/3,n=0;return e>=t&&(n=3*(e-t))>u.image.lut.range_max-1?u.image.lut.range_max-1:n},u.image.lut.toMaxThirdThird=function(e){var t=u.image.lut.range_max/3,n=0;return e>=2*t&&(n=3*(e-2*t))>u.image.lut.range_max-1?u.image.lut.range_max-1:n},u.image.lut.zero=function(){return 0},u.image.lut.id=function(e){return e},u.image.lut.invId=function(e){return u.image.lut.range_max-1-e},u.image.lut.plain={red:u.image.lut.buildLut(u.image.lut.id),green:u.image.lut.buildLut(u.image.lut.id),blue:u.image.lut.buildLut(u.image.lut.id)},u.image.lut.invPlain={red:u.image.lut.buildLut(u.image.lut.invId),green:u.image.lut.buildLut(u.image.lut.invId),blue:u.image.lut.buildLut(u.image.lut.invId)},u.image.lut.rainbow={blue:[0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,247,239,231,223,215,207,199,191,183,175,167,159,151,143,135,127,119,111,103,95,87,79,71,63,55,47,39,31,23,15,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,253,251,249,247,245,243,241,239,237,235,233,231,229,227,225,223,221,219,217,215,213,211,209,207,205,203,201,199,197,195,193,192,189,186,183,180,177,174,171,168,165,162,159,156,153,150,147,144,141,138,135,132,129,126,123,120,117,114,111,108,105,102,99,96,93,90,87,84,81,78,75,72,69,66,63,60,57,54,51,48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3],red:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,62,60,58,56,54,52,50,48,46,44,42,40,38,36,34,32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]},u.image.lut.hot={red:u.image.lut.buildLut(u.image.lut.toMaxFirstThird),green:u.image.lut.buildLut(u.image.lut.toMaxSecondThird),blue:u.image.lut.buildLut(u.image.lut.toMaxThirdThird)},u.image.lut.hot_iron={red:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],blue:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255]},u.image.lut.pet={red:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,128,126,124,122,120,118,116,114,112,110,108,106,104,102,100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,63,61,59,57,55,53,51,49,47,45,43,41,39,37,35,33,31,29,27,25,23,21,19,17,15,13,11,9,7,5,3,1,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],blue:[0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,252,248,244,240,236,232,228,224,220,216,212,208,204,200,196,192,188,184,180,176,172,168,164,160,156,152,148,144,140,136,132,128,124,120,116,112,108,104,100,96,92,88,84,80,76,72,68,64,60,56,52,48,44,40,36,32,28,24,20,16,12,8,4,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,170,174,178,182,186,190,194,198,202,206,210,214,218,222,226,230,234,238,242,246,250,255]},u.image.lut.hot_metal_blue={red:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,52,55,57,59,62,64,66,69,71,74,76,78,81,83,85,88,90,93,96,99,102,105,108,111,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,166,169,172,175,178,181,184,187,190,194,198,201,205,209,213,217,221,224,228,232,236,240,244,247,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,9,11,13,15,17,19,21,23,24,26,28,30,32,34,36,38,40,41,43,45,47,49,51,53,55,56,58,60,62,64,66,68,70,72,73,75,77,79,81,83,85,87,88,90,92,94,96,98,100,102,104,105,107,109,111,113,115,117,119,120,122,124,126,128,130,132,134,136,137,139,141,143,145,147,149,151,152,154,156,158,160,162,164,166,168,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,201,203,205,207,209,211,213,215,216,218,220,222,224,226,228,229,231,233,235,237,239,240,242,244,246,248,250,251,253,255],blue:[0,2,4,6,8,10,12,14,16,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,197,194,191,188,185,182,179,176,174,171,168,165,162,159,156,153,150,144,138,132,126,121,115,109,103,97,91,85,79,74,68,62,56,50,47,44,41,38,35,32,29,26,24,21,18,15,12,9,6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,176,179,182,185,188,191,194,197,200,203,206,210,213,216,219,223,226,229,232,236,239,242,245,249,252,255]},u.image.lut.pet_20step={red:[0,0,0,0,0,0,0,0,0,0,0,0,0,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192,192,192,192,192,176,176,176,176,176,176,176,176,176,176,176,176,176,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,96,96,96,96,96,96,96,96,96,96,96,96,96,144,144,144,144,144,144,144,144,144,144,144,144,144,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,176,176,176,176,176,176,176,176,176,176,176,176,176,144,144,144,144,144,144,144,144,144,144,144,144,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255],blue:[0,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,128,176,176,176,176,176,176,176,176,176,176,176,176,176,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,64,64,64,64,64,64,64,64,64,64,64,64,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255]},u.image.lut.test={red:u.image.lut.buildLut(u.image.lut.id),green:u.image.lut.buildLut(u.image.lut.zero),blue:u.image.lut.buildLut(u.image.lut.zero)};(u=u||{}).image=u.image||{},u.image.WindowLevel=function(e,t){function n(){var n=e+i;a=n-.5-(t-1)/2,s=n-.5+(t-1)/2,l=(o-r)/(t-1),u=(-(n-.5)/(t-1)+.5)*(o-r)+r}if(0===t)throw new Error("A window level with a width of zero is not possible.");var i=0,r=0,o=255,a=null,s=null,l=null,u=null;n(),this.getCenter=function(){return e},this.getWidth=function(){return t},this.setRange=function(e,t){r=parseInt(e,10),o=parseInt(t,10),n()},this.setSignedOffset=function(e){i=e,n()},this.apply=function(e){return e<=a?r:e>s?o:parseInt(e*l+u,10)}},u.image.WindowLevel.prototype.equals=function(e){return null!==e&&this.getCenter()===e.getCenter()&&this.getWidth()===e.getWidth()},u.image.WindowLevel.prototype.toString=function(){return this.getCenter()+", "+this.getWidth()},u.image.View=function(e){var t={},n={minmax:{name:"minmax"}},i=null,r=u.image.lut.plain,o={i:0,j:0,k:0},a=null;this.getImage=function(){return e},this.setImage=function(t){e=t},this.getCurrentWindowLut=function(r){var o=this.getCurrentPosition().k;void 0===r&&(r=e.getRescaleSlopeAndIntercept(o));var a=t[r.toString()];if(i&&void 0!==n[i]&&void 0!==n[i].perslice&&!0===n[i].perslice){var s=n[i].wl[o];if(!a.getWindowLevel().equals(s)){var l=a.getWindowLevel().getWidth(),u=a.getWindowLevel().getCenter();a.setWindowLevel(s),l!==s.getWidth()&&this.fireEvent({type:"wl-width-change",wc:s.getCenter(),ww:s.getWidth(),skipGenerate:!0}),u!==s.getCenter()&&this.fireEvent({type:"wl-center-change",wc:s.getCenter(),ww:s.getWidth(),skipGenerate:!0})}}return a.update(),a},this.addWindowLut=function(e){var n=e.getRescaleLut().getRSI();t[n.toString()]=e},this.getWindowPresets=function(){return n},this.getWindowPresetsNames=function(){return Object.keys(n)},this.setWindowPresets=function(e){n=e},this.addWindowPresets=function(e,t){for(var i=Object.keys(e),r=null,o=0;o=e.getNumberOfFrames())return!1;var n=a;return a=t,n!==a&&1!==e.getNumberOfFrames()&&(this.fireEvent({type:"frame-change",frame:a}),this.setCurrentPosition(this.getCurrentPosition(),!0)),!0},this.append=function(e){var t=this.getImage().appendSlice(e.getImage());t<=this.getCurrentPosition().k&&this.setCurrentPosition({i:this.getCurrentPosition().i,j:this.getCurrentPosition().j,k:this.getCurrentPosition().k+1},!0),this.addWindowPresets(e.getWindowPresets(),t)},this.appendFrameBuffer=function(e){this.getImage().appendFrameBuffer(e)},this.setWindowLevel=function(n,r,o){if(r>=1){var a=this.getCurrentPosition().k,s=null,l=e.getRescaleSlopeAndIntercept(a);if(l&&void 0!==l){var c=t[l.toString()];c&&void 0!==c&&(s=c.getWindowLevel())}void 0===o&&(o="manual"),i=o;var S=new u.image.WindowLevel(n,r);if(0===Object.keys(t).length){var d=new u.image.lut.Rescale(e.getRescaleSlopeAndIntercept(0),e.getMeta().BitsStored),x=new u.image.lut.Window(d,e.getMeta().IsSigned);this.addWindowLut(x)}for(var g in t)t[g].setWindowLevel(S);s&&void 0!==s?(s.getWidth()!==r&&this.fireEvent({type:"wl-width-change",wc:n,ww:r}),s.getCenter()!==n&&this.fireEvent({type:"wl-center-change",wc:n,ww:r})):(this.fireEvent({type:"wl-width-change",wc:n,ww:r}),this.fireEvent({type:"wl-center-change",wc:n,ww:r}))}},this.setWindowLevelPreset=function(e){var t=this.getWindowPresets()[e];if(void 0===t)throw new Error("Unknown window level preset: '"+e+"'");"minmax"===e&&void 0===t.wl&&(t.wl=this.getWindowLevelMinMax()),void 0!==t.perslice&&!0===t.perslice&&(t={wl:t.wl[this.getCurrentPosition().k]}),this.setWindowLevel(t.wl.getCenter(),t.wl.getWidth(),e)},this.setWindowLevelPresetById=function(e){var t=Object.keys(this.getWindowPresets());this.setWindowLevelPreset(t[e])},this.clone=function(){var e=new u.image.View(this.getImage());for(var n in t)e.addWindowLut(t[n]);return e.setListeners(this.getListeners()),e};var s={};this.getListeners=function(){return s},this.setListeners=function(e){s=e}},u.image.View.prototype.getWindowLevelMinMax=function(){var e=this.getImage().getRescaledDataRange(),t=e.min,n=e.max-t,i=t+n/2;return new u.image.WindowLevel(i,n)},u.image.View.prototype.setWindowLevelMinMax=function(){var e=this.getWindowLevelMinMax();this.setWindowLevel(e.getCenter(),e.getWidth(),"minmax")},u.image.View.prototype.generateImageData=function(e){var t=this.getCurrentWindowLut(),n=this.getImage(),i=n.getGeometry().getSize().getSliceSize(),r=i*this.getCurrentPosition().k,o=this.getCurrentFrame()?this.getCurrentFrame():0,a=0,s=0,l=0,u=n.getPhotometricInterpretation();switch(u){case"MONOCHROME1":case"MONOCHROME2":for(var c=this.getColourMap(),S=r+i,d=r;d.33?0:1;t[i][e[i].length-2]=1,t[i][e[i].length-1]=1}t[e.length-2]=[],t[e.length-1]=[];for(var o=1;on&&(n=l),r+=l,o+=l*l;return i=r/e.length,s=o/e.length-i*i,a=Math.sqrt(s),{min:t,max:n,mean:i,stdDev:a}},u.math.guid=function(){return Math.random().toString(36).substring(2,15)};(u=u||{}).math=u.math||{},u.math.Vector3D=function(e,t,n){this.getX=function(){return e},this.getY=function(){return t},this.getZ=function(){return n}},u.math.Vector3D.prototype.equals=function(e){return null!==e&&this.getX()===e.getX()&&this.getY()===e.getY()&&this.getZ()===e.getZ()},u.math.Vector3D.prototype.toString=function(){return"("+this.getX()+", "+this.getY()+", "+this.getZ()+")"},u.math.Vector3D.prototype.norm=function(){return Math.sqrt(this.getX()*this.getX()+this.getY()*this.getY()+this.getZ()*this.getZ())},u.math.Vector3D.prototype.crossProduct=function(e){return new u.math.Vector3D(this.getY()*e.getZ()-e.getY()*this.getZ(),this.getZ()*e.getX()-e.getZ()*this.getX(),this.getX()*e.getY()-e.getX()*this.getY())},u.math.Vector3D.prototype.dotProduct=function(e){return this.getX()*e.getX()+this.getY()*e.getY()+this.getZ()*e.getZ()};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.ArrowFactory=function(){this.getNPoints=function(){return 2},this.getTimeout=function(){return 0}},u.tool.ArrowFactory.prototype.create=function(e,t){var n=new u.math.Line(e[0],e[1]),i=new o.Line({points:[n.getBegin().getX(),n.getBegin().getY(),n.getEnd().getX(),n.getEnd().getY()],stroke:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),name:"shape"}),r=new u.math.Point2D(n.getBegin().getX(),n.getBegin().getY()-10),a=new u.math.Line(n.getBegin(),r),s=u.math.getAngle(n,a),l=s*Math.PI/180,c=new o.RegularPolygon({x:n.getBegin().getX()+5*Math.sin(l),y:n.getBegin().getY()+5*Math.cos(l),sides:3,radius:5,rotation:-s,fill:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),name:"shape-triangle"}),S=new o.Text({fontSize:t.getScaledFontSize(),fontFamily:t.getFontFamily(),fill:t.getLineColour(),name:"text"});S.textExpr="",S.longText="",S.quant=null,S.setText(S.textExpr);var d=n.getBegin().getX()>n.getEnd().getX()?0:-1,x=n.getBegin().getY()>n.getEnd().getY()?-1:.5,g=new o.Label({x:n.getEnd().getX()+25*d,y:n.getEnd().getY()+15*x,name:"label"});g.add(S),g.add(new o.Tag);var m=new o.Group;return m.name("line-group"),m.add(i),m.add(c),m.add(g),m.visible(!0),m},u.tool.UpdateArrow=function(e){var t=e.getParent(),n=t.getChildren(function(e){return"shape"===e.name()})[0],i=t.getChildren(function(e){return"shape-triangle"===e.name()})[0],r=t.getChildren(function(e){return"label"===e.name()})[0],o=t.getChildren(function(e){return"begin"===e.id()})[0],a=t.getChildren(function(e){return"end"===e.id()})[0];switch(e.id()){case"begin":o.x(e.x()),o.y(e.y());break;case"end":a.x(e.x()),a.y(e.y())}var s=o.x()-n.x(),l=o.y()-n.y(),c=a.x()-n.x(),S=a.y()-n.y();n.points([s,l,c,S]);var d=new u.math.Point2D(o.x(),o.y()),x=new u.math.Point2D(a.x(),a.y()),g=new u.math.Line(d,x),m=new u.math.Point2D(g.getBegin().getX(),g.getBegin().getY()-10),h=new u.math.Line(g.getBegin(),m),p=u.math.getAngle(g,h),f=p*Math.PI/180;i.x(g.getBegin().getX()+i.radius()*Math.sin(f)),i.y(g.getBegin().getY()+i.radius()*Math.cos(f)),i.rotation(-p);var C=r.getText();C.quant=null,C.setText(C.textExpr);var y=g.getBegin().getX()>g.getEnd().getX()?0:-1,D=g.getBegin().getY()>g.getEnd().getY()?-1:.5,v={x:g.getEnd().getX()+25*y,y:g.getEnd().getY()+15*D};r.position(v)};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.Draw=function(e,t){function n(){i(!1),y=e.getCurrentDrawLayer(),i(!0)}function i(t){y.listening(t),y.hitGraphEnabled(t);for(var n=y.getChildren(),i=[],r=function(e){return"shape"===e.name()},o=0;o0||Math.abs(t._y-g.getY())>0)){g=new u.math.Point2D(t._x,t._y),1!=x.length&&x.pop(),x.push(g);var n=new s.shapeFactoryList[s.shapeName];x.length1){d&&d.destroy();var t=(new s.shapeFactoryList[s.shapeName]).create(x,s.style,e.getImage());t.id(u.math.guid()),y.hitGraphEnabled(!0),(S=new u.tool.DrawGroupCommand(t,s.shapeName,y)).onExecute=a,S.onUndo=a,S.execute(),e.addToUndoStack(S);var n=t.getChildren(function(e){return"shape"===e.name()})[0];s.setShapeOn(n)}c=!1},this.mouseout=function(e){s.mouseup(e)},this.touchstart=function(e){s.mousedown(e)},this.touchmove=function(e){s.mousemove(e)},this.touchend=function(e){s.mouseup(e)},this.keydown=function(t){e.onKeydown(t)},this.setup=function(){(l=new u.gui.Draw(e)).setup(this.shapeFactoryList)},this.display=function(t){l&&l.display(t),m.disable(),m.setShape(null),m.setImage(null),document.body.style.cursor="default",e.getDrawStage().listening(t),y=e.getCurrentDrawLayer(),i(t),t?(e.addEventListener("slice-change",n),e.addEventListener("frame-change",n)):(e.removeEventListener("slice-change",n),e.removeEventListener("frame-change",n))},this.setShapeOn=function(t){t.on("mouseover",function(){document.body.style.cursor="pointer"}),t.on("mouseout",function(){document.body.style.cursor="default"}),t.draggable(!0);var n=null,i=null,o=u.tool.GetShapeDisplayName(t),s=null;t.on("dragstart",function(i){var o=u.html.getEventOffset(i.evt)[0];n=r(o),s=t.stroke();var a=e.getDrawStage(),l=a.scale(),c={x:1/l.x,y:1/l.y};h.x(a.offset().x+256/l.x),h.y(a.offset().y+20/l.y),h.scale(c),y.add(h),m.setAnchorsActive(!1),y.draw()}),t.on("dragmove",function(e){var o,a=r(u.html.getEventOffset(e.evt)[0]);o=i?{x:a.x-i.x,y:a.y-i.y}:{x:a.x-n.x,y:a.y-n.y},i=a,Math.abs(a.x-h.x())<10&&Math.abs(a.y-h.y())<10?(h.getChildren().each(function(e){e.stroke("orange")}),t.stroke("red")):(h.getChildren().each(function(e){e.stroke("red")}),t.stroke(s));this.getParent().getChildren().each(function(e){e!=this&&(e.x(e.x()+o.x),e.y(e.y()+o.y))}),m.resetAnchors(),y.draw()}),t.on("dragend",function(){var r=i;if(i=null,h.remove(),Math.abs(r.x-h.x())<10&&Math.abs(r.y-h.y())<10){var l=r.x-n.x,c=r.y-n.y;this.getParent().getChildren().each(function(e){e.x(e.x()-l),e.y(e.y()-c)}),m.disable(),m.setShape(null),m.setImage(null),t.stroke(s),document.body.style.cursor="default";var S=new u.tool.DeleteGroupCommand(this.getParent(),o,y);S.onExecute=a,S.onUndo=a,S.execute(),e.addToUndoStack(S)}else{var d={x:r.x-n.x,y:r.y-n.y};if(0!==d.x||0!==d.y){var x=new u.tool.MoveGroupCommand(this.getParent(),o,d,y);x.onExecute=a,x.onUndo=a,e.addToUndoStack(x),a({type:"draw-move"})}m.setAnchorsActive(!0),m.resetAnchors()}y.draw()}),t.on("dblclick",function(){var e=this.getParent().find("Label");if(1!==e.length)throw new Error("Could not find the shape label.");var t=e[0].getText(),n=u.gui.prompt("Shape label",t.textExpr);null!==n&&n!==t.textExpr&&(t.textExpr=n,t.setText(u.utils.replaceFlags(t.textExpr,t.quant)),a({type:"draw-change"}),y.draw())})},this.init=function(){var t=0;for(var n in this.shapeFactoryList){t=n;break}return this.setShapeName(t),l&&(this.style.setScale(e.getWindowScale()),this.setLineColour(this.style.getLineColour()),l.initialise()),!0},this.addEventListener=function(e,t){void 0===C[e]&&(C[e]=[]),C[e].push(t)},this.removeEventListener=function(e,t){if(void 0!==C[e])for(var n=0;n0&&s[0].points[0].x){if(r)return s[0].points;for(var l=0,c=s[0].points.length;lc&&C(s,o);u--)e.getViewController().decrementSliceNb();e.getViewController().setCurrentPosition(i)},this.modifyThreshold=function(e,t){if(t||!d)throw"No shape found";t=d.getChildren(function(e){return"shape"===e.name()})[0],clearTimeout(l),l=setTimeout(function(){if(!(x=f(s,e,!0)))return!1;for(var n=[],i=0,r=x.length;i180&&(S+=c=360-c);var d={angle:{value:c,unit:u.i18n("unit.degree")}},x=new o.Text({fontSize:t.getScaledFontSize(),fontFamily:t.getFontFamily(),fill:t.getLineColour(),name:"text"});x.textExpr="{angle}",x.longText="",x.quant=d,x.setText(u.utils.replaceFlags(x.textExpr,x.quant));var g=(n.getMidpoint().getX()+l.getMidpoint().getX())/2,m=(n.getMidpoint().getY()+l.getMidpoint().getY())/2,h=new o.Label({x:g,y:m-15,name:"label"});h.add(x),h.add(new o.Tag);var p=33*Math.min(n.getLength(),l.getLength())/100,f=new o.Arc({innerRadius:p,outerRadius:p,stroke:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),angle:c,rotation:-S,x:e[1].getX(),y:e[1].getY(),name:"shape-arc"});s.add(h),s.add(f)}return s},u.tool.UpdateProtractor=function(e){var t=e.getParent(),n=t.getChildren(function(e){return"shape"===e.name()})[0],i=t.getChildren(function(e){return"label"===e.name()})[0],r=t.getChildren(function(e){return"shape-arc"===e.name()})[0],o=t.getChildren(function(e){return"begin"===e.id()})[0],a=t.getChildren(function(e){return"mid"===e.id()})[0],s=t.getChildren(function(e){return"end"===e.id()})[0];switch(e.id()){case"begin":o.x(e.x()),o.y(e.y());break;case"mid":a.x(e.x()),a.y(e.y());break;case"end":s.x(e.x()),s.y(e.y())}var l=o.x()-n.x(),c=o.y()-n.y(),S=a.x()-n.x(),d=a.y()-n.y(),x=s.x()-n.x(),g=s.y()-n.y();n.points([l,c,S,d,x,g]);var m=new u.math.Point2D(o.x(),o.y()),h=new u.math.Point2D(a.x(),a.y()),p=new u.math.Point2D(s.x(),s.y()),f=new u.math.Line(m,h),C=new u.math.Line(h,p),y=u.math.getAngle(f,C),D=f.getInclination();y>180&&(D+=y=360-y);var v={angle:{value:y,unit:u.i18n("unit.degree")}},L=i.getText();L.quant=v,L.setText(u.utils.replaceFlags(L.textExpr,L.quant));var T={x:(f.getMidpoint().getX()+C.getMidpoint().getX())/2,y:(f.getMidpoint().getY()+C.getMidpoint().getY())/2-15};i.position(T);var I=33*Math.min(f.getLength(),C.getLength())/100;r.innerRadius(I),r.outerRadius(I),r.angle(y),r.rotation(-D);var P={x:a.x(),y:a.y()};r.position(P)};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.RectangleFactory=function(){this.getNPoints=function(){return 2},this.getTimeout=function(){return 0}},u.tool.RectangleFactory.prototype.create=function(e,t,n){var i=new u.math.Rectangle(e[0],e[1]),r=new o.Rect({x:i.getBegin().getX(),y:i.getBegin().getY(),width:i.getWidth(),height:i.getHeight(),stroke:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),name:"shape"}),a=n.quantifyRect(i),s=new o.Text({fontSize:t.getScaledFontSize(),fontFamily:t.getFontFamily(),fill:t.getLineColour(),name:"text"});s.textExpr="{surface}",s.longText="",s.quant=a,s.setText(u.utils.replaceFlags(s.textExpr,s.quant));var l=new o.Label({x:i.getBegin().getX(),y:i.getEnd().getY()+10,name:"label"});l.add(s),l.add(new o.Tag);var c=new o.Group;return c.name("rectangle-group"),c.add(r),c.add(l),c.visible(!0),c},u.tool.UpdateRect=function(e,t){var n=e.getParent(),i=n.getChildren(function(e){return"shape"===e.name()})[0],r=n.getChildren(function(e){return"label"===e.name()})[0],o=n.getChildren(function(e){return"topLeft"===e.id()})[0],a=n.getChildren(function(e){return"topRight"===e.id()})[0],s=n.getChildren(function(e){return"bottomRight"===e.id()})[0],l=n.getChildren(function(e){return"bottomLeft"===e.id()})[0];switch(e.id()){case"topLeft":o.x(e.x()),o.y(e.y()),a.y(e.y()),l.x(e.x());break;case"topRight":a.x(e.x()),a.y(e.y()),o.y(e.y()),s.x(e.x());break;case"bottomRight":s.x(e.x()),s.y(e.y()),l.y(e.y()),a.x(e.x());break;case"bottomLeft":l.x(e.x()),l.y(e.y()),s.y(e.y()),o.x(e.x());break;default:console.error("Unhandled anchor id: "+e.id())}i.position(o.position());var c=a.x()-o.x(),S=l.y()-o.y();c&&S&&i.size({width:c,height:S});var d=new u.math.Point2D(o.x(),o.y()),x=new u.math.Point2D(s.x(),s.y()),g=new u.math.Rectangle(d,x),m=t.quantifyRect(g),h=r.getText();h.quant=m,h.setText(u.utils.replaceFlags(h.textExpr,h.quant));var p={x:g.getBegin().getX(),y:g.getEnd().getY()+10};r.position(p)};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.RoiFactory=function(){this.getNPoints=function(){return 50},this.getTimeout=function(){return 100}},u.tool.RoiFactory.prototype.create=function(e,t){var n=new u.math.ROI;n.addPoints(e);for(var i=[],r=0;ri.getEnd().getX()?0:-1,g=i.getBegin().getY()>i.getEnd().getY()?-1:.5,m=new o.Label({x:i.getEnd().getX()+25*x,y:i.getEnd().getY()+15*g,name:"label"});m.add(d),m.add(new o.Tag);var h=new o.Group;return h.name("ruler-group"),h.add(r),h.add(s),h.add(c),h.add(m),h.visible(!0),h},u.tool.UpdateRuler=function(e,t){var n=e.getParent(),i=n.getChildren(function(e){return"shape"===e.name()})[0],r=n.getChildren(function(e){return"shape-tick0"===e.name()})[0],o=n.getChildren(function(e){return"shape-tick1"===e.name()})[0],a=n.getChildren(function(e){return"label"===e.name()})[0],s=n.getChildren(function(e){return"begin"===e.id()})[0],l=n.getChildren(function(e){return"end"===e.id()})[0];switch(e.id()){case"begin":s.x(e.x()),s.y(e.y());break;case"end":l.x(e.x()),l.y(e.y())}var c=s.x()-i.x(),S=s.y()-i.y(),d=l.x()-i.x(),x=l.y()-i.y();i.points([c,S,d,x]);var g=new u.math.Point2D(s.x(),s.y()),m=new u.math.Point2D(l.x(),l.y()),h=new u.math.Line(g,m),p=new u.math.Point2D(c,S),f=new u.math.Point2D(d,x),C=u.math.getPerpendicularLine(h,p,10);r.points([C.getBegin().getX(),C.getBegin().getY(),C.getEnd().getX(),C.getEnd().getY()]);var y=u.math.getPerpendicularLine(h,f,10);o.points([y.getBegin().getX(),y.getBegin().getY(),y.getEnd().getX(),y.getEnd().getY()]);var D=t.quantifyLine(h),v=a.getText();v.quant=D,v.setText(u.utils.replaceFlags(v.textExpr,v.quant));var L=h.getBegin().getX()>h.getEnd().getX()?0:-1,T=h.getBegin().getY()>h.getEnd().getY()?-1:.5,I={x:h.getEnd().getX()+25*L,y:h.getEnd().getY()+15*T};a.position(I)};(u=u||{}).tool=u.tool||{},u.tool.Scroll=function(e){function t(t){var n=1!==e.getImage().getGeometry().getSize().getNumberOfSlices(),i=1!==e.getImage().getNumberOfFrames();t?n?e.getViewController().incrementSliceNb():i&&e.getViewController().incrementFrameNb():n?e.getViewController().decrementSliceNb():i&&e.getViewController().decrementFrameNb()}var n=this,i=null;this.started=!1;var r=null;this.mousedown=function(t){e.getViewController().isPlaying()&&e.getViewController().stop(),n.started=!0,n.x0=t._x,n.y0=t._y},this.mousemove=function(t){if(n.started){var i=t._y-n.y0,r=Math.abs(i)>15;r&&(i>0?e.getViewController().decrementSliceNb():e.getViewController().incrementSliceNb());var o=t._x-n.x0,a=Math.abs(o)>15;a&&(o>0?e.getViewController().incrementFrameNb():e.getViewController().decrementFrameNb()),a&&(n.x0=t._x),r&&(n.y0=t._y)}},this.mouseup=function(){n.started&&(n.started=!1)},this.mouseout=function(e){n.mouseup(e)},this.touchstart=function(e){r=setTimeout(n.dblclick,500),n.mousedown(e)},this.touchmove=function(e){null!==r&&(clearTimeout(r),r=null),n.mousemove(e)},this.touchend=function(e){null!==r&&(clearTimeout(r),r=null),n.mouseup(e)},this.DOMMouseScroll=function(e){t(e.detail<0?!0:!1)},this.mousewheel=function(e){t(e.wheelDelta>0?!0:!1)},this.keydown=function(t){e.onKeydown(t)},this.dblclick=function(){e.getViewController().play()},this.setup=function(){(i=new u.gui.Scroll(e)).setup()},this.display=function(e){i&&i.display(e)},this.init=function(){return!e.isMonoSliceData()||1!==e.getImage().getNumberOfFrames()}},u.tool.Scroll.prototype.getHelp=function(){return{title:u.i18n("tool.Scroll.name"),brief:u.i18n("tool.Scroll.brief"),mouse:{mouse_drag:u.i18n("tool.Scroll.mouse_drag"),double_click:u.i18n("tool.Scroll.double_click")},touch:{touch_drag:u.i18n("tool.Scroll.touch_drag"),tap_and_hold:u.i18n("tool.Scroll.tap_and_hold")}}};(u=u||{}).tool=u.tool||{},u.tool.Toolbox=function(e,t){var n=null,i=null,r=null;this.getToolList=function(){return e},this.getSelectedTool=function(){return i},this.setup=function(){if(0!==Object.keys(e).length){(n=new u.gui.Toolbox(t)).setup(e);for(var i in e)e[i].setup()}},this.display=function(t){0!==Object.keys(e).length&&n&&n.display(t)},this.init=function(){if(0!==Object.keys(e).length){r="";var t=[],i=null;for(var o in e)(i=e[o].init())&&""===r&&(r=o),t.push(i);this.setSelectedTool(r),n&&n.initialise(t)}},this.setSelectedTool=function(t){if(!this.hasTool(t))throw new Error("Unknown tool: '"+t+"'");i&&i.display(!1),(i=e[t]).display(!0)},this.reset=function(){i&&i.display(!1),i=null,r=null}},u.tool.Toolbox.prototype.hasTool=function(e){return this.getToolList()[e]};(u=u||{}).tool=u.tool||{},u.tool.UndoStack=function(e){var t=new u.gui.Undo(e),n=[];this.getStack=function(){return n};var i=0;this.add=function(e){(n=n.slice(0,i)).push(e),++i,t.addCommandToUndoHtml(e.getName())},this.undo=function(){i>0&&(n[--i].undo(),t.enableInUndoHtml(!1))},this.redo=function(){i0?e.getViewController().incrementSliceNb():e.getViewController().decrementSliceNb()}else{var s=(o-1)/2;Math.abs(s)%.1<=.05&&e.stepZoom(s,n._xs,n._ys)}}},this.mouseup=function(){t.started&&(t.started=!1)},this.mouseout=function(e){t.mouseup(e)},this.touchstart=function(e){var n=e.targetTouches;1===n.length?t.mousedown(e):2===n.length&&t.twotouchdown(e)},this.touchmove=function(e){var n=e.targetTouches;1===n.length?t.mousemove(e):2===n.length&&t.twotouchmove(e)},this.touchend=function(e){t.mouseup(e)},this.DOMMouseScroll=function(t){var n=-t.detail/30;e.stepZoom(n,t._xs,t._ys)},this.mousewheel=function(t){var n=t.wheelDelta/1200;e.stepZoom(n,t._xs,t._ys)},this.keydown=function(t){e.onKeydown(t)},this.setup=function(){(n=new u.gui.ZoomAndPan(e)).setup()},this.display=function(e){n&&n.display(e)}},u.tool.ZoomAndPan.prototype.getHelp=function(){return{title:u.i18n("tool.ZoomAndPan.name"),brief:u.i18n("tool.ZoomAndPan.brief"),mouse:{mouse_wheel:u.i18n("tool.ZoomAndPan.mouse_wheel"),mouse_drag:u.i18n("tool.ZoomAndPan.mouse_drag")},touch:{twotouch_pinch:u.i18n("tool.ZoomAndPan.twotouch_pinch"),touch_drag:u.i18n("tool.ZoomAndPan.touch_drag")}}},u.tool.ZoomAndPan.prototype.init=function(){return!0};(u=u||{}).browser=u.browser||{};e=e||{};u.browser.hasFileApi=function(){return-1!==navigator.appVersion.indexOf("Safari")&&-1===navigator.appVersion.indexOf("Chrome")&&(-1!==navigator.appVersion.indexOf("5.0.")||-1!==navigator.appVersion.indexOf("5.1."))?(console.warn("Assuming FileAPI support for Safari5..."),!0):e.filereader},u.browser.hasXmlHttpRequest=function(){return e.xhrresponsetype&&e.xhrresponsetypearraybuffer&&e.xhrresponsetypetext&&"XMLHttpRequest"in l&&"withCredentials"in new XMLHttpRequest},u.browser.hasTypedArray=function(){return e.dataview&&e.typedarrays},u.browser.hasInputColor=function(){return e.inputtypes.color},u.browser.hasInputDirectory=function(){return e.fileinputdirectory},u.browser._hasTypedArraySlice=void 0!==Uint8Array.prototype.slice,u.browser.hasTypedArraySlice=function(){return u.browser._hasTypedArraySlice},u.browser._hasFloat64Array="Float64Array"in l,u.browser.hasFloat64Array=function(){return u.browser._hasFloat64Array},u.browser._hasClampedArray="Uint8ClampedArray"in l,u.browser.hasClampedArray=function(){return u.browser._hasClampedArray},u.browser.check=function(){var e="The application cannot be run.",t="";if(!u.browser.hasFileApi())throw t="The File APIs are not supported in this browser. ",alert(t+e),new Error(t);if(!u.browser.hasXmlHttpRequest())throw t="The XMLHttpRequest is not supported in this browser. ",alert(t+e),new Error(t);if(!u.browser.hasTypedArray())throw t="The Typed arrays are not supported in this browser. ",alert(t+e),new Error(t);u.browser.hasTypedArraySlice()||(console.warn("The TypedArray.slice method is not supported in this browser. This may impair performance. "),Uint16Array.prototype.slice=function(e,t){for(var n=t-e,i=new Uint16Array(n),r=0;r0){var r=n.shift();r.run(e),i.push(r)}else t.push(e)},this.abort=function(){t=[];for(var e=0;e0){var o=t.shift();r.run(o)}else{n.push(r);for(var a=0;a1&&console.warn("More than one patient, loading first one.");var o=r[0].getElementsByTagName("Study");o.length>1&&console.warn("More than one study, loading first one.");var a=o[0].getAttribute("StudyInstanceUID"),s=o[0].getElementsByTagName("Series");s.length>1&&console.warn("More than one series, loading first one.");var l=s[0].getAttribute("SeriesInstanceUID"),u=s[0].getElementsByTagName("Instance"),c=u.length;t0)for(var a=0;a0)for(var a=0;a0},u.dicom.getUtfLabel=function(e){var t="utf-8";return"ISO_IR 100"===e?t="iso-8859-1":"ISO_IR 101"===e?t="iso-8859-2":"ISO_IR 109"===e?t="iso-8859-3":"ISO_IR 110"===e?t="iso-8859-4":"ISO_IR 144"===e?t="iso-8859-5":"ISO_IR 127"===e?t="iso-8859-6":"ISO_IR 126"===e?t="iso-8859-7":"ISO_IR 138"===e?t="iso-8859-8":"ISO_IR 148"===e?t="iso-8859-9":"ISO_IR 13"===e?t="shift-jis":"ISO_IR 166"===e?t="iso-8859-11":"ISO 2022 IR 87"===e?t="iso-2022-jp":"ISO 2022 IR 149"===e||"ISO 2022 IR 58"===e||("ISO_IR 192"===e?t="utf-8":"GB18030"===e?t="gb18030":"GB2312"===e?t="gb2312":"GBK"===e&&(t="chinese")),t},u.dicom.DataReader=function(e,t){void 0===t&&(t=!0);var n={};n.decode=function(e){for(var t="",n=0,i=e.length;ns;a--,s++)t=i[s],i[s]=i[a],i[a]=t},this.readUint16=function(e){return a.getUint16(e,t)},this.readUint32=function(e){return a.getUint32(e,t)},this.readInt32=function(e){return a.getInt32(e,t)},this.readUint8Array=function(t,n){return new Uint8Array(e,t,n)},this.readInt8Array=function(t,n){return new Int8Array(e,t,n)},this.readUint16Array=function(n,i){var r=i/Uint16Array.BYTES_PER_ELEMENT,s=null;if(n%Uint16Array.BYTES_PER_ELEMENT==0)s=new Uint16Array(e,n,r),o&&this.flipArrayEndianness(s);else{s=new Uint16Array(r);for(var l=0;l1&&p.length>d){for(var f=p.length/d,C=[],y=0,D=0;D=4?l.substr(2,2):"00")+":"+(l.length>=6?l.substr(4,2):"00")}else for(var c="O"===e.vr[0].toUpperCase(),d="FL"===e.vr||"FD"===e.vr||"DS"===e.vr,S="",x=0,g=e.value.length;x0)for(var c=0;c1&&(o=u.dicom.flattenArrayOfTypedArrays(i)),n=this.writeDataElementValue(e,n,o,r)}else{var a={};a.xFFFEE000={tag:{group:"0xFFFE",element:"0xE000",name:"xFFFEE000"},vr:"UN",vl:0,value:[]};for(var s=0;s255&&(o=200),[0,o,o]}}},u.dicom.generatePixelDataFromJSONTags=function(e,t,n){if(void 0===n&&(n="gradSquare"),void 0===e.TransferSyntaxUID)throw new Error("Missing transfer syntax for pixel generation.");if(void 0===e.Rows)throw new Error("Missing number of rows for pixel generation.");if(void 0===e.Columns)throw new Error("Missing number of columns for pixel generation.");if(void 0===e.BitsAllocated)throw new Error("Missing BitsAllocated for pixel generation.");if(void 0===e.PixelRepresentation)throw new Error("Missing PixelRepresentation for pixel generation.");if(void 0===e.SamplesPerPixel)throw new Error("Missing SamplesPerPixel for pixel generation.");if(void 0===e.PhotometricInterpretation)throw new Error("Missing PhotometricInterpretation for pixel generation.");var i=u.dicom.isImplicitTransferSyntax(e.TransferSyntaxUID),r=e.Rows,o=e.Columns,a=e.BitsAllocated,s=e.PixelRepresentation,l=e.SamplesPerPixel,c=e.PhotometricInterpretation,d=r*o*l;if(1!==l&&3!==l)throw new Error("Unsupported SamplesPerPixel for pixel generation: "+l);if(1===l&&"MONOCHROME1"!==c&&"MONOCHROME2"!==c||3===l&&"RGB"!==c)throw new Error("Unsupported PhotometricInterpretation for pixel generation: "+c+" with SamplesPerPixel: "+l);var S=1,x=1;if(3===l){if(void 0===e.PlanarConfiguration)throw new Error("Missing PlanarConfiguration for pixel generation.");var g=e.PlanarConfiguration;if(0!==g&&1!==g)throw new Error("Unsupported PlanarConfiguration for pixel generation: "+g);0===g?S=3:x=3}var m=u.dicom.getTypedArray(a,s,d);if(void 0===u.dicom.pixelGenerators[n])throw new Error("Unknown PixelData generator: "+n);var h=new u.dicom.pixelGenerators[n](o,r),p=h.getGrey;"RGB"===c&&(p=h.getRGB);for(var f=0,C=0;C";for(var x=1;x10&&((t=Array.prototype.slice.call(t,0,10))[10]="..."),i=Array.prototype.join.call(t,", ")),n.appendChild(document.createTextNode(i))},u.html.appendHCell=function(e,t){var n=document.createElement("th");n.appendChild(document.createTextNode(t)),e.appendChild(n)},u.html.appendRowForArray=function(e,t,n,i,r){for(var o=null,a=0;a=i?(o||(o=e.insertRow(-1)),u.html.appendCell(o,s)):u.html.appendRow(e,s,n+a,i,r)}},u.html.appendRowForObject=function(e,t,n,i,r){for(var o=Object.keys(t),a=null,s=0;s=i?(a||(a=e.insertRow(-1)),0===s&&r&&u.html.appendCell(a,r),u.html.appendCell(a,l)):u.html.appendRow(e,l,n+s,i,o[s])}if(2===n){var c=e.createTHead().insertRow(-1);r&&u.html.appendHCell(c,"");for(var d=0;d]+>/g,"").toLowerCase().indexOf(n[o])<0?i="none":n[o].length&&u.html.highlight(n[o],t.rows[r]),t.rows[r].style.display=i}},u.html.dehighlight=function(e){for(var t=0;t]+>/g,"")),n.parentNode);3!==n.nodeType&&u.html.dehighlight(n)}},u.html.highlight=function(e,t){for(var n=0;n=0){var a=document.createElement("span");i.parentNode.replaceChild(a,i);for(var s;-1!==(s=o.indexOf(e));)a.appendChild(document.createTextNode(r.substr(0,s))),a.appendChild(u.html.createHighlightNode(document.createTextNode(r.substr(s,e.length)))),r=r.substr(s+e.length),o=o.substr(s+e.length);a.appendChild(document.createTextNode(r))}}else u.html.highlight(e,i)}},u.html.createHighlightNode=function(e){var t=document.createElement("span");return t.setAttribute("class","highlighted"),t.attributes.class.value="highlighted",t.appendChild(e),t},u.html.cleanNode=function(e){if(e)for(;e.hasChildNodes();)e.removeChild(e.firstChild)},u.html.removeNode=function(e){if(e){u.html.cleanNode(e);e.parentNode.removeChild(e)}},u.html.removeNodes=function(e){for(var t=0;t=t){var l=s[t].firstChild.data;s[t].firstChild.data=u.i18n(r+l+o)}}},u.html.makeCellEditable=function(e,t,n){if(void 0!==e){var i=document.createElement("input");t?i.onchange=t:i.disabled=!0,i.value=e.firstChild.data,void 0===n||"color"===n&&!u.browser.hasInputColor()?i.type="text":i.type=n,u.html.cleanNode(e);var r=document.createElement("form");r.onsubmit=function(e){e.preventDefault()},r.appendChild(i),e.appendChild(r)}else console.warn("Cannot create input for non existing cell.")},u.html.setCursorToPointer=function(){document.body.style.cursor="pointer"},u.html.setCursorToDefault=function(){document.body.style.cursor="default"},u.html.createHtmlSelect=function(e,t,n,i){var r=document.createElement("select");r.className=e;var o,a=void 0===n?"":n+".",s=void 0!==i,l=function(e){var t=a+e+".name";return s?u.i18nExists(t)?u.i18n(t):e:u.i18n(t)};if(t instanceof Array)for(var c in t)t.hasOwnProperty(c)&&((o=document.createElement("option")).value=t[c],o.appendChild(document.createTextNode(l(t[c]))),r.appendChild(o));else{if("object"!=typeof t)throw new Error("Unsupported input list type.");for(var d in t)(o=document.createElement("option")).value=d,o.appendChild(document.createTextNode(l(d))),r.appendChild(o)}return r},u.html.displayElement=function(e,t){e.style.display=t?"":"none"},u.html.toggleDisplay=function(e){"none"===e.style.display?e.style.display="":e.style.display="none"},u.html.appendElement=function(e,t){e.appendChild(t),u.gui.refreshElement(e)},u.html.createHiddenElement=function(e,t){var n=document.createElement(e);return n.className=t,n.style.display="none",n};(u=u||{}).gui=u.gui||{},u.gui.base=u.gui.base||{},u.gui.info=u.gui.info||{},u.gui.base.plot=function(){},u.gui.info.MiniColourMap=function(e,t){this.create=function(){var t=e.getElementsByClassName("colour-map-info");0!==t.length&&u.html.removeNodes(t);var n=document.createElement("canvas");n.className="colour-map-info",n.width=98,n.height=10,e.appendChild(n)},this.update=function(n){for(var i,r=n.wc,o=n.ww,a=e.getElementsByClassName("colour-map-info")[0],s=a.getContext("2d"),l=t.getViewController().getColourMap(),u=s.getImageData(0,0,a.width,a.height),c=0,d=t.getImage().getRescaledDataRange().min,S=(t.getImage().getRescaledDataRange().max-d)/a.width,x=0,g=r-.5-(o-1)/2,m=r-.5+(o-1)/2,h=0;hm?x=255:(x=255*((c-(r-.5))/(o-1)+.5)+0,x=parseInt(x,10)),i=4*(p+h*a.width),u.data[i]=l.red[x],u.data[i+1]=l.green[x],u.data[i+2]=l.blue[x],u.data[i+3]=255,c+=S}s.putImageData(u,0,0)}},u.gui.info.Plot=function(e,t){this.create=function(){e&&u.html.cleanNode(e),u.gui.plot(e,t.getImage().getHistogram())},this.update=function(n){var i=n.wc,r=n.ww,o=parseInt((r-1)/2,10),a=parseInt(i-.5,10),s=a-o,l=a+o,c=[{color:"#faa",lineWidth:1,xaxis:{from:s,to:s}},{color:"#aaf",lineWidth:1,xaxis:{from:l,to:l}}];u.gui.plot(e,t.getImage().getHistogram(),{markings:c})}},u.gui.info.Overlay=function(e,t,n){var i=this;this.getOverlays=function(){var e=n.getImage();if(e){var i=e.getOverlays();if(i){var r=i[n.getViewController().getCurrentPosition().k];if(r)return r[t]}}},this.create=function(){u.html.cleanNode(e);var n=i.getOverlays();if(n)if("bc"===t||"tc"===t||"cr"===t||"cl"===t)e.textContent=n[0].value;else{for(var r=document.createElement("ul"),o=0;n[o];o++){var a;"window-center"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-window-center",r.appendChild(a)):"window-width"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-window-width",r.appendChild(a)):"zoom"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-zoom",r.appendChild(a)):"offset"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-offset",r.appendChild(a)):"value"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-value",r.appendChild(a)):"position"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-position",r.appendChild(a)):"frame"===n[o].value?((a=document.createElement("li")).className="info-"+t+"-frame",r.appendChild(a)):((a=document.createElement("li")).className="info-"+t+"-"+o,a.appendChild(document.createTextNode(n[o].value)),r.appendChild(a))}e.appendChild(r)}},this.update=function(n){var r=i.getOverlays();if(r)if("bc"===t||"tc"===t||"cr"===t||"cl"===t)e.textContent=r[0].value;else{var o,a;for(a=0;r[a];a++)if("window-center"===r[a].value){if("wl-center-change"===n.type){o=e.getElementsByClassName("info-"+t+"-window-center")[0],u.html.cleanNode(o);var s=u.utils.replaceFlags2(r[a].format,[Math.round(n.wc)]);o&&o.appendChild(document.createTextNode(s))}}else if("window-width"===r[a].value){if("wl-width-change"===n.type){o=e.getElementsByClassName("info-"+t+"-window-width")[0],u.html.cleanNode(o);var l=u.utils.replaceFlags2(r[a].format,[Math.round(n.ww)]);o&&o.appendChild(document.createTextNode(l))}}else if("zoom"===r[a].value){if("zoom-change"===n.type){o=e.getElementsByClassName("info-"+t+"-zoom")[0],u.html.cleanNode(o);var c=Number(n.scale).toPrecision(3),d=u.utils.replaceFlags2(r[a].format,[c]);o&&o.appendChild(document.createTextNode(d))}}else if("offset"===r[a].value){if("zoom-change"===n.type){o=e.getElementsByClassName("info-"+t+"-offset")[0],u.html.cleanNode(o);var S=[Number(n.cx).toPrecision(3),Number(n.cy).toPrecision(3)],x=u.utils.replaceFlags2(r[a].format,S);o&&o.appendChild(document.createTextNode(x))}}else if("value"===r[a].value){if("position-change"===n.type){o=e.getElementsByClassName("info-"+t+"-value")[0],u.html.cleanNode(o);var g=u.utils.replaceFlags2(r[a].format,[n.value]);o&&o.appendChild(document.createTextNode(g))}}else if("position"===r[a].value){if("position-change"===n.type){o=e.getElementsByClassName("info-"+t+"-position")[0],u.html.cleanNode(o);var m=u.utils.replaceFlags2(r[a].format,[n.i,n.j,n.k]);o&&o.appendChild(document.createTextNode(m))}}else if("frame"===r[a].value){if("frame-change"===n.type){o=e.getElementsByClassName("info-"+t+"-frame")[0],u.html.cleanNode(o);var h=u.utils.replaceFlags2(r[a].format,[n.frame]);o&&o.appendChild(document.createTextNode(h))}}else"position-change"===n.type&&(o=e.getElementsByClassName("info-"+t+"-"+a)[0],u.html.cleanNode(o),o&&o.appendChild(document.createTextNode(r[a].value)))}}},u.gui.info.createOverlays=function(e){var t={},n=e.getFromKey("x00080060");if(!n)return t;var i=u.gui.info.overlayMaps;if(!i)return t;for(var r=i[n]||i["*"],o=0;r[o];o++){var a=r[o].value,s=r[o].tags,l=r[o].format,c=r[o].pos;if(void 0!==s&&0!==s.length){for(var d=[],S=0;S=0;--n)t.remove(n);u.gui.refreshElement(t)},this.addCommandToUndoHtml=function(t){var n=e.getElement("history_list"),i=n.length-(n.selectedIndex+1);if(i>0)for(var r=0;rn.getMax()?t:e})},u.image.filter.Sharpen=function(){this.getName=function(){return"Sharpen"};var e=null;this.setOriginalImage=function(t){e=t},this.getOriginalImage=function(){return e}},u.image.filter.Sharpen.prototype.update=function(){return this.getOriginalImage().convolute2D([0,-1,0,-1,5,-1,0,-1,0])},u.image.filter.Sobel=function(){this.getName=function(){return"Sobel"};var e=null;this.setOriginalImage=function(t){e=t},this.getOriginalImage=function(){return e}},u.image.filter.Sobel.prototype.update=function(){var e=this.getOriginalImage(),t=e.convolute2D([1,0,-1,2,0,-2,1,0,-1]),n=e.convolute2D([1,2,1,0,0,0,-1,-2,-1]);return t.compose(n,function(e,t){return Math.sqrt(e*e+t*t)})};(u=u||{}).image=u.image||{},u.image.Size=function(e,t,n){this.getNumberOfColumns=function(){return e},this.getNumberOfRows=function(){return t},this.getNumberOfSlices=function(){return n||1}},u.image.Size.prototype.getSliceSize=function(){return this.getNumberOfColumns()*this.getNumberOfRows()},u.image.Size.prototype.getTotalSize=function(){return this.getSliceSize()*this.getNumberOfSlices()},u.image.Size.prototype.equals=function(e){return null!==e&&this.getNumberOfColumns()===e.getNumberOfColumns()&&this.getNumberOfRows()===e.getNumberOfRows()&&this.getNumberOfSlices()===e.getNumberOfSlices()},u.image.Size.prototype.isInBounds=function(e,t,n){return!(e<0||e>this.getNumberOfColumns()-1||t<0||t>this.getNumberOfRows()-1||n<0||n>this.getNumberOfSlices()-1)},u.image.Size.prototype.toString=function(){return"("+this.getNumberOfColumns()+", "+this.getNumberOfRows()+", "+this.getNumberOfSlices()+")"},u.image.Spacing=function(e,t,n){this.getColumnSpacing=function(){return e},this.getRowSpacing=function(){return t},this.getSliceSpacing=function(){return n||1}},u.image.Spacing.prototype.equals=function(e){return null!==e&&this.getColumnSpacing()===e.getColumnSpacing()&&this.getRowSpacing()===e.getRowSpacing()&&this.getSliceSpacing()===e.getSliceSpacing()},u.image.Spacing.prototype.toString=function(){return"("+this.getColumnSpacing()+", "+this.getRowSpacing()+", "+this.getSliceSpacing()+")"},u.image.Geometry=function(e,t,n,i){void 0===e&&(e=new u.math.Point3D(0,0,0));var r=[e];void 0===i&&(i=new u.math.getIdentityMat33),this.getOrigin=function(){return e},this.getOrigins=function(){return r},this.getSize=function(){return t},this.getSpacing=function(){return n},this.getOrientation=function(){return i},this.getSliceIndex=function(e){for(var t=0,n=e.getDistance(r[0]),o=0,a=0;a0?t+1:t},this.appendOrigin=function(e,n){r.splice(n,0,e),t=new u.image.Size(t.getNumberOfColumns(),t.getNumberOfRows(),t.getNumberOfSlices()+1)}},u.image.Geometry.prototype.equals=function(e){return null!==e&&this.getOrigin()===e.getOrigin()&&this.getSize()===e.getSize()&&this.getSpacing()===e.getSpacing()},u.image.Geometry.prototype.indexToOffset=function(e){var t=this.getSize();return e.getI()+e.getJ()*t.getNumberOfColumns()+e.getK()*t.getSliceSize()},u.image.Geometry.prototype.indexToWorld=function(e){var t=this.getOrigin(),n=this.getSpacing();return new u.math.Point3D(t.getX()+e.getI()*n.getColumnSpacing(),t.getY()+e.getJ()*n.getRowSpacing(),t.getZ()+e.getK()*n.getSliceSpacing())},u.image.Geometry.prototype.worldToIndex=function(e){var t=this.getOrigin(),n=this.getSpacing();return new u.math.Point3D(e.getX()/n.getColumnSpacing()-t.getX(),e.getY()/n.getRowSpacing()-t.getY(),e.getZ()/n.getSliceSpacing()-t.getZ())};(u=u||{}).image=u.image||{},u.image.RescaleSlopeAndIntercept=function(e,t){this.getSlope=function(){return e},this.getIntercept=function(){return t},this.apply=function(n){return n*e+t}},u.image.RescaleSlopeAndIntercept.prototype.equals=function(e){return null!==e&&this.getSlope()===e.getSlope()&&this.getIntercept()===e.getIntercept()},u.image.RescaleSlopeAndIntercept.prototype.toString=function(){return this.getSlope()+", "+this.getIntercept()},u.image.RescaleSlopeAndIntercept.prototype.isID=function(){return 1===this.getSlope()&&0===this.getIntercept()},u.image.Image=function(e,t,n){void 0===n&&(n=t.length),this.getNumberOfFrames=function(){return n};for(var i=[],r=0,o=e.getSize().getNumberOfSlices();r0&&!i[n].equals(i[n-1])&&(s=!1)},this.isIdentityRSI=function(){return a},this.isConstantRSI=function(){return s},this.getPhotometricInterpretation=function(){return l},this.setPhotometricInterpretation=function(e){l=e},this.getPlanarConfiguration=function(){return c},this.setPlanarConfiguration=function(e){c=e},this.getNumberOfComponents=function(){return d},this.getMeta=function(){return S},this.setMeta=function(e){S=e},this.getValueAtOffset=function(e,n){return t[n][e]},this.clone=function(){for(var e=[],n=0,i=this.getNumberOfFrames();nn&&(n=i),in?t:n}}for(var i=this.getGeometry().getSize(),r=this.getRescaledValue(0,0,0),o=r,a=0,s=0;s<1;++s)for(var l=0,u=i.getNumberOfSlices();lo&&(o=a),ai&&(i=r),ra&&(a=s),s=t&&e<2*t?u.image.lut.range_max-1:0},u.image.lut.maxThirdThird=function(e){return e>=2*u.image.lut.range_max/3?u.image.lut.range_max-1:0},u.image.lut.toMaxFirstThird=function(e){var t=3*e;return t>u.image.lut.range_max-1?u.image.lut.range_max-1:t},u.image.lut.toMaxSecondThird=function(e){var t=u.image.lut.range_max/3,n=0;return e>=t&&(n=3*(e-t))>u.image.lut.range_max-1?u.image.lut.range_max-1:n},u.image.lut.toMaxThirdThird=function(e){var t=u.image.lut.range_max/3,n=0;return e>=2*t&&(n=3*(e-2*t))>u.image.lut.range_max-1?u.image.lut.range_max-1:n},u.image.lut.zero=function(){return 0},u.image.lut.id=function(e){return e},u.image.lut.invId=function(e){return u.image.lut.range_max-1-e},u.image.lut.plain={red:u.image.lut.buildLut(u.image.lut.id),green:u.image.lut.buildLut(u.image.lut.id),blue:u.image.lut.buildLut(u.image.lut.id)},u.image.lut.invPlain={red:u.image.lut.buildLut(u.image.lut.invId),green:u.image.lut.buildLut(u.image.lut.invId),blue:u.image.lut.buildLut(u.image.lut.invId)},u.image.lut.rainbow={blue:[0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,247,239,231,223,215,207,199,191,183,175,167,159,151,143,135,127,119,111,103,95,87,79,71,63,55,47,39,31,23,15,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,253,251,249,247,245,243,241,239,237,235,233,231,229,227,225,223,221,219,217,215,213,211,209,207,205,203,201,199,197,195,193,192,189,186,183,180,177,174,171,168,165,162,159,156,153,150,147,144,141,138,135,132,129,126,123,120,117,114,111,108,105,102,99,96,93,90,87,84,81,78,75,72,69,66,63,60,57,54,51,48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3],red:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,62,60,58,56,54,52,50,48,46,44,42,40,38,36,34,32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]},u.image.lut.hot={red:u.image.lut.buildLut(u.image.lut.toMaxFirstThird),green:u.image.lut.buildLut(u.image.lut.toMaxSecondThird),blue:u.image.lut.buildLut(u.image.lut.toMaxThirdThird)},u.image.lut.hot_iron={red:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],blue:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,255]},u.image.lut.pet={red:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,128,126,124,122,120,118,116,114,112,110,108,106,104,102,100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,63,61,59,57,55,53,51,49,47,45,43,41,39,37,35,33,31,29,27,25,23,21,19,17,15,13,11,9,7,5,3,1,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,255],blue:[0,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205,207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,252,248,244,240,236,232,228,224,220,216,212,208,204,200,196,192,188,184,180,176,172,168,164,160,156,152,148,144,140,136,132,128,124,120,116,112,108,104,100,96,92,88,84,80,76,72,68,64,60,56,52,48,44,40,36,32,28,24,20,16,12,8,4,0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,170,174,178,182,186,190,194,198,202,206,210,214,218,222,226,230,234,238,242,246,250,255]},u.image.lut.hot_metal_blue={red:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,52,55,57,59,62,64,66,69,71,74,76,78,81,83,85,88,90,93,96,99,102,105,108,111,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,166,169,172,175,178,181,184,187,190,194,198,201,205,209,213,217,221,224,228,232,236,240,244,247,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,4,6,8,9,11,13,15,17,19,21,23,24,26,28,30,32,34,36,38,40,41,43,45,47,49,51,53,55,56,58,60,62,64,66,68,70,72,73,75,77,79,81,83,85,87,88,90,92,94,96,98,100,102,104,105,107,109,111,113,115,117,119,120,122,124,126,128,130,132,134,136,137,139,141,143,145,147,149,151,152,154,156,158,160,162,164,166,168,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,201,203,205,207,209,211,213,215,216,218,220,222,224,226,228,229,231,233,235,237,239,240,242,244,246,248,250,251,253,255],blue:[0,2,4,6,8,10,12,14,16,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,184,186,188,190,192,194,196,198,200,197,194,191,188,185,182,179,176,174,171,168,165,162,159,156,153,150,144,138,132,126,121,115,109,103,97,91,85,79,74,68,62,56,50,47,44,41,38,35,32,29,26,24,21,18,15,12,9,6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,6,9,12,15,18,21,24,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,176,179,182,185,188,191,194,197,200,203,206,210,213,216,219,223,226,229,232,236,239,242,245,249,252,255]},u.image.lut.pet_20step={red:[0,0,0,0,0,0,0,0,0,0,0,0,0,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192,192,192,192,192,176,176,176,176,176,176,176,176,176,176,176,176,176,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],green:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,112,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,96,96,96,96,96,96,96,96,96,96,96,96,96,144,144,144,144,144,144,144,144,144,144,144,144,144,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,208,208,208,208,208,208,208,208,208,208,208,208,208,176,176,176,176,176,176,176,176,176,176,176,176,176,144,144,144,144,144,144,144,144,144,144,144,144,96,96,96,96,96,96,96,96,96,96,96,96,96,48,48,48,48,48,48,48,48,48,48,48,48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255],blue:[0,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,112,112,112,112,112,112,112,112,112,112,112,112,128,128,128,128,128,128,128,128,128,128,128,128,128,176,176,176,176,176,176,176,176,176,176,176,176,176,192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224,224,224,224,224,224,224,224,224,224,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,80,80,80,80,80,80,80,80,80,80,80,80,80,64,64,64,64,64,64,64,64,64,64,64,64,80,80,80,80,80,80,80,80,80,80,80,80,80,96,96,96,96,96,96,96,96,96,96,96,96,96,64,64,64,64,64,64,64,64,64,64,64,64,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255]},u.image.lut.test={red:u.image.lut.buildLut(u.image.lut.id),green:u.image.lut.buildLut(u.image.lut.zero),blue:u.image.lut.buildLut(u.image.lut.zero)};(u=u||{}).image=u.image||{},u.image.WindowLevel=function(e,t){function n(){var n=e+i;a=n-.5-(t-1)/2,s=n-.5+(t-1)/2,l=(o-r)/(t-1),u=(-(n-.5)/(t-1)+.5)*(o-r)+r}if(0===t)throw new Error("A window level with a width of zero is not possible.");var i=0,r=0,o=255,a=null,s=null,l=null,u=null;n(),this.getCenter=function(){return e},this.getWidth=function(){return t},this.setRange=function(e,t){r=parseInt(e,10),o=parseInt(t,10),n()},this.setSignedOffset=function(e){i=e,n()},this.apply=function(e){return e<=a?r:e>s?o:parseInt(e*l+u,10)}},u.image.WindowLevel.prototype.equals=function(e){return null!==e&&this.getCenter()===e.getCenter()&&this.getWidth()===e.getWidth()},u.image.WindowLevel.prototype.toString=function(){return this.getCenter()+", "+this.getWidth()},u.image.View=function(e){var t={},n={minmax:{name:"minmax"}},i=null,r=u.image.lut.plain,o={i:0,j:0,k:0},a=null;this.getImage=function(){return e},this.setImage=function(t){e=t},this.getCurrentWindowLut=function(r){var o=this.getCurrentPosition().k;void 0===r&&(r=e.getRescaleSlopeAndIntercept(o));var a=t[r.toString()];if(i&&void 0!==n[i]&&void 0!==n[i].perslice&&!0===n[i].perslice){var s=n[i].wl[o];if(!a.getWindowLevel().equals(s)){var l=a.getWindowLevel().getWidth(),u=a.getWindowLevel().getCenter();a.setWindowLevel(s),l!==s.getWidth()&&this.fireEvent({type:"wl-width-change",wc:s.getCenter(),ww:s.getWidth(),skipGenerate:!0}),u!==s.getCenter()&&this.fireEvent({type:"wl-center-change",wc:s.getCenter(),ww:s.getWidth(),skipGenerate:!0})}}return a.update(),a},this.addWindowLut=function(e){var n=e.getRescaleLut().getRSI();t[n.toString()]=e},this.getWindowPresets=function(){return n},this.getWindowPresetsNames=function(){return Object.keys(n)},this.setWindowPresets=function(e){n=e},this.setDefaultColourMap=function(e){r=e},this.addWindowPresets=function(e,t){for(var i=Object.keys(e),r=null,o=0;o=e.getNumberOfFrames())return!1;var n=a;return a=t,n!==a&&1!==e.getNumberOfFrames()&&(this.fireEvent({type:"frame-change",frame:a}),this.setCurrentPosition(this.getCurrentPosition(),!0)),!0},this.append=function(e){var t=this.getImage().appendSlice(e.getImage());t<=this.getCurrentPosition().k&&this.setCurrentPosition({i:this.getCurrentPosition().i,j:this.getCurrentPosition().j,k:this.getCurrentPosition().k+1},!0),this.addWindowPresets(e.getWindowPresets(),t)},this.appendFrameBuffer=function(e){this.getImage().appendFrameBuffer(e)},this.setWindowLevel=function(n,r,o){if(r>=1){var a=this.getCurrentPosition().k,s=null,l=e.getRescaleSlopeAndIntercept(a);if(l&&void 0!==l){var c=t[l.toString()];c&&void 0!==c&&(s=c.getWindowLevel())}void 0===o&&(o="manual"),i=o;var d=new u.image.WindowLevel(n,r);if(0===Object.keys(t).length){var S=new u.image.lut.Rescale(e.getRescaleSlopeAndIntercept(0),e.getMeta().BitsStored),x=new u.image.lut.Window(S,e.getMeta().IsSigned);this.addWindowLut(x)}for(var g in t)t[g].setWindowLevel(d);s&&void 0!==s?(s.getWidth()!==r&&this.fireEvent({type:"wl-width-change",wc:n,ww:r}),s.getCenter()!==n&&this.fireEvent({type:"wl-center-change",wc:n,ww:r})):(this.fireEvent({type:"wl-width-change",wc:n,ww:r}),this.fireEvent({type:"wl-center-change",wc:n,ww:r}))}},this.setWindowLevelPreset=function(e){var t=this.getWindowPresets()[e];if(void 0===t)throw new Error("Unknown window level preset: '"+e+"'");"minmax"===e&&void 0===t.wl&&(t.wl=this.getWindowLevelMinMax()),void 0!==t.perslice&&!0===t.perslice&&(t={wl:t.wl[this.getCurrentPosition().k]}),this.setWindowLevel(t.wl.getCenter(),t.wl.getWidth(),e)},this.setWindowLevelPresetById=function(e){var t=Object.keys(this.getWindowPresets());this.setWindowLevelPreset(t[e])},this.clone=function(){var e=new u.image.View(this.getImage());for(var n in t)e.addWindowLut(t[n]);return e.setListeners(this.getListeners()),e};var s={};this.getListeners=function(){return s},this.setListeners=function(e){s=e}},u.image.View.prototype.getWindowLevelMinMax=function(){var e=this.getImage().getRescaledDataRange(),t=e.min,n=e.max-t,i=t+n/2;return new u.image.WindowLevel(i,n)},u.image.View.prototype.setWindowLevelMinMax=function(){var e=this.getWindowLevelMinMax();this.setWindowLevel(e.getCenter(),e.getWidth(),"minmax")},u.image.View.prototype.generateImageData=function(e){var t=this.getCurrentWindowLut(),n=this.getImage(),i=n.getGeometry().getSize().getSliceSize(),r=i*this.getCurrentPosition().k,o=this.getCurrentFrame()?this.getCurrentFrame():0,a=0,s=0,l=0,u=n.getPhotometricInterpretation();switch(u){case"MONOCHROME1":case"MONOCHROME2":for(var c=this.getColourMap(),d=r+i,S=r;S.33?0:1;t[i][e[i].length-2]=1,t[i][e[i].length-1]=1}t[e.length-2]=[],t[e.length-1]=[];for(var o=1;on&&(n=l),r+=l,o+=l*l;return i=r/e.length,s=o/e.length-i*i,a=Math.sqrt(s),{min:t,max:n,mean:i,stdDev:a}},u.math.guid=function(){return Math.random().toString(36).substring(2,15)};(u=u||{}).math=u.math||{},u.math.Vector3D=function(e,t,n){this.getX=function(){return e},this.getY=function(){return t},this.getZ=function(){return n}},u.math.Vector3D.prototype.equals=function(e){return null!==e&&this.getX()===e.getX()&&this.getY()===e.getY()&&this.getZ()===e.getZ()},u.math.Vector3D.prototype.toString=function(){return"("+this.getX()+", "+this.getY()+", "+this.getZ()+")"},u.math.Vector3D.prototype.norm=function(){return Math.sqrt(this.getX()*this.getX()+this.getY()*this.getY()+this.getZ()*this.getZ())},u.math.Vector3D.prototype.crossProduct=function(e){return new u.math.Vector3D(this.getY()*e.getZ()-e.getY()*this.getZ(),this.getZ()*e.getX()-e.getZ()*this.getX(),this.getX()*e.getY()-e.getX()*this.getY())},u.math.Vector3D.prototype.dotProduct=function(e){return this.getX()*e.getX()+this.getY()*e.getY()+this.getZ()*e.getZ()};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.ArrowFactory=function(){this.getNPoints=function(){return 2},this.getTimeout=function(){return 0}},u.tool.ArrowFactory.prototype.create=function(e,t){var n=new u.math.Line(e[0],e[1]),i=new o.Line({points:[n.getBegin().getX(),n.getBegin().getY(),n.getEnd().getX(),n.getEnd().getY()],stroke:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),name:"shape"}),r=u.math.getPerpendicularLine(n,e[0],10),a=u.math.getPerpendicularLine(n,e[1],10);i.hitFunc(function(e){e.beginPath(),e.moveTo(r.getBegin().getX(),r.getBegin().getY()),e.lineTo(r.getEnd().getX(),r.getEnd().getY()),e.lineTo(a.getEnd().getX(),a.getEnd().getY()),e.lineTo(a.getBegin().getX(),a.getBegin().getY()),e.closePath(),e.fillStrokeShape(this)});var s=new u.math.Point2D(n.getBegin().getX(),n.getBegin().getY()-10),l=new u.math.Line(n.getBegin(),s),c=u.math.getAngle(n,l),d=c*Math.PI/180,S=new o.RegularPolygon({x:n.getBegin().getX()+5*Math.sin(d),y:n.getBegin().getY()+5*Math.cos(d),sides:3,radius:5,rotation:-c,fill:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),name:"shape-triangle"}),x=new o.Text({fontSize:t.getScaledFontSize(),fontFamily:t.getFontFamily(),fill:t.getLineColour(),name:"text"});x.textExpr="",x.longText="",x.quant=null,x.setText(x.textExpr);var g=n.getBegin().getX()>n.getEnd().getX()?0:-1,m=n.getBegin().getY()>n.getEnd().getY()?-1:.5,h=new o.Label({x:n.getEnd().getX()+25*g,y:n.getEnd().getY()+15*m,name:"label"});h.add(x),h.add(new o.Tag);var p=new o.Group;return p.name("line-group"),p.add(i),p.add(S),p.add(h),p.visible(!0),p},u.tool.UpdateArrow=function(e){var t=e.getParent(),n=t.getChildren(function(e){return"shape"===e.name()})[0],i=t.getChildren(function(e){return"shape-triangle"===e.name()})[0],r=t.getChildren(function(e){return"label"===e.name()})[0],o=t.getChildren(function(e){return"begin"===e.id()})[0],a=t.getChildren(function(e){return"end"===e.id()})[0];switch(e.id()){case"begin":o.x(e.x()),o.y(e.y());break;case"end":a.x(e.x()),a.y(e.y())}var s=o.x()-n.x(),l=o.y()-n.y(),c=a.x()-n.x(),d=a.y()-n.y();n.points([s,l,c,d]);var S=new u.math.Point2D(o.x(),o.y()),x=new u.math.Point2D(a.x(),a.y()),g=new u.math.Line(S,x),m=new u.math.Point2D(s,l),h=new u.math.Point2D(c,d),p=u.math.getPerpendicularLine(g,m,10),f=u.math.getPerpendicularLine(g,h,10);n.hitFunc(function(e){e.beginPath(),e.moveTo(p.getBegin().getX(),p.getBegin().getY()),e.lineTo(p.getEnd().getX(),p.getEnd().getY()),e.lineTo(f.getEnd().getX(),f.getEnd().getY()),e.lineTo(f.getBegin().getX(),f.getBegin().getY()),e.closePath(),e.fillStrokeShape(this)});var C=new u.math.Point2D(g.getBegin().getX(),g.getBegin().getY()-10),y=new u.math.Line(g.getBegin(),C),D=u.math.getAngle(g,y),v=D*Math.PI/180;i.x(g.getBegin().getX()+i.radius()*Math.sin(v)),i.y(g.getBegin().getY()+i.radius()*Math.cos(v)),i.rotation(-D);var L=r.getText();L.quant=null,L.setText(L.textExpr);var T=g.getBegin().getX()>g.getEnd().getX()?0:-1,I=g.getBegin().getY()>g.getEnd().getY()?-1:.5,P={x:g.getEnd().getX()+25*T,y:g.getEnd().getY()+15*I};r.position(P)};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.Draw=function(e,t){function n(){i(!1),y=e.getCurrentDrawLayer(),i(!0)}function i(t){y.listening(t),y.hitGraphEnabled(t);for(var n=y.getChildren(),i=[],r=function(e){return"shape"===e.name()},o=0;o0||Math.abs(t._y-g.getY())>0)){g=new u.math.Point2D(t._x,t._y),1!=x.length&&x.pop(),x.push(g);var n=new s.shapeFactoryList[s.shapeName];x.length1){S&&S.destroy();var t=(new s.shapeFactoryList[s.shapeName]).create(x,s.style,e.getImage());t.id(u.math.guid()),y.hitGraphEnabled(!0),(d=new u.tool.DrawGroupCommand(t,s.shapeName,y)).onExecute=a,d.onUndo=a,d.execute(),e.addToUndoStack(d);var n=t.getChildren(function(e){return"shape"===e.name()})[0];s.setShapeOn(n)}c=!1},this.mouseout=function(e){s.mouseup(e)},this.touchstart=function(e){s.mousedown(e)},this.touchmove=function(e){s.mousemove(e)},this.touchend=function(e){s.mouseup(e)},this.keydown=function(t){e.onKeydown(t)},this.setup=function(){(l=new u.gui.Draw(e)).setup(this.shapeFactoryList)},this.display=function(t){l&&l.display(t),m.disable(),m.setShape(null),m.setImage(null),document.body.style.cursor="default",e.getDrawStage().listening(t),y=e.getCurrentDrawLayer(),i(t),t?(e.addEventListener("slice-change",n),e.addEventListener("frame-change",n)):(e.removeEventListener("slice-change",n),e.removeEventListener("frame-change",n))},this.setShapeOn=function(t){t.on("mouseover",function(){document.body.style.cursor="pointer"}),t.on("mouseout",function(){document.body.style.cursor="default"}),t.draggable(!0);var n=null,i=null,o=u.tool.GetShapeDisplayName(t),s=null;n={x:t.x(),y:t.y()},t.on("dragstart",function(){s=t.stroke();var n=e.getDrawStage(),i=n.scale(),r={x:1/i.x,y:1/i.y};h.x(n.offset().x+256/i.x),h.y(n.offset().y+20/i.y),h.scale(r),y.add(h),m.setAnchorsActive(!1),y.draw()}),t.on("dragmove",function(e){var o,a={x:this.x(),y:this.y()};o=i?{x:a.x-i.x,y:a.y-i.y}:{x:a.x-n.x,y:a.y-n.y},i=a;var l=r(u.html.getEventOffset(e.evt)[0]);Math.abs(l.x-h.x())<10&&Math.abs(l.y-h.y())<10?(h.getChildren().each(function(e){e.stroke("orange")}),t.stroke("red")):(h.getChildren().each(function(e){e.stroke("red")}),t.stroke(s));this.getParent().getChildren().each(function(e){e!==t&&(e.x(e.x()+o.x),e.y(e.y()+o.y))}),m.resetAnchors(),y.draw()}),t.on("dragend",function(l){var c=this.x(),d=this.y();i=null,h.remove();var S=r(u.html.getEventOffset(l.evt)[0]);if(Math.abs(S.x-h.x())<10&&Math.abs(S.y-h.y())<10){var x=S.x-n.x,g=S.y-n.y;this.getParent().getChildren().each(function(e){e.x(e.x()-x),e.y(e.y()-g)}),m.disable(),m.setShape(null),m.setImage(null),t.stroke(s),document.body.style.cursor="default";var p=new u.tool.DeleteGroupCommand(this.getParent(),o,y);p.onExecute=a,p.onUndo=a,p.execute(),e.addToUndoStack(p)}else{var f={x:c-n.x,y:d-n.y};if(0!==f.x||0!==f.y){var C=new u.tool.MoveGroupCommand(this.getParent(),o,f,y);C.onExecute=a,C.onUndo=a,e.addToUndoStack(C),n={x:this.x(),y:this.y()},a({type:"draw-move"})}m.setAnchorsActive(!0),m.resetAnchors()}y.draw()}),t.on("dblclick",function(){var e=this.getParent().find("Label");if(1!==e.length)throw new Error("Could not find the shape label.");var t=e[0].getText(),n=u.gui.prompt("Shape label",t.textExpr);null!==n&&n!==t.textExpr&&(t.textExpr=n,t.setText(u.utils.replaceFlags(t.textExpr,t.quant)),a({type:"draw-change"}),y.draw())})},this.init=function(){var t=0;for(var n in this.shapeFactoryList){t=n;break}return this.setShapeName(t),l&&(this.style.setScale(e.getWindowScale()),this.setLineColour(this.style.getLineColour()),l.initialise()),!0},this.addEventListener=function(e,t){void 0===C[e]&&(C[e]=[]),C[e].push(t)},this.removeEventListener=function(e,t){if(void 0!==C[e])for(var n=0;n0&&s[0].points[0].x){if(r)return s[0].points;for(var l=0,c=s[0].points.length;lc&&C(s,o);u--)e.getViewController().decrementSliceNb();e.getViewController().setCurrentPosition(i)},this.modifyThreshold=function(e,t){if(t||!S)throw"No shape found";t=S.getChildren(function(e){return"shape"===e.name()})[0],clearTimeout(l),l=setTimeout(function(){if(!(x=f(s,e,!0)))return!1;for(var n=[],i=0,r=x.length;i180&&(d+=c=360-c);var S={angle:{value:c,unit:u.i18n("unit.degree")}},x=new o.Text({fontSize:t.getScaledFontSize(),fontFamily:t.getFontFamily(),fill:t.getLineColour(),name:"text"});x.textExpr="{angle}",x.longText="",x.quant=S,x.setText(u.utils.replaceFlags(x.textExpr,x.quant));var g=(n.getMidpoint().getX()+l.getMidpoint().getX())/2,m=(n.getMidpoint().getY()+l.getMidpoint().getY())/2,h=new o.Label({x:g,y:m-15,name:"label"});h.add(x),h.add(new o.Tag);var p=33*Math.min(n.getLength(),l.getLength())/100,f=new o.Arc({innerRadius:p,outerRadius:p,stroke:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),angle:c,rotation:-d,x:e[1].getX(),y:e[1].getY(),name:"shape-arc"});s.add(h),s.add(f)}return s},u.tool.UpdateProtractor=function(e){var t=e.getParent(),n=t.getChildren(function(e){return"shape"===e.name()})[0],i=t.getChildren(function(e){return"label"===e.name()})[0],r=t.getChildren(function(e){return"shape-arc"===e.name()})[0],o=t.getChildren(function(e){return"begin"===e.id()})[0],a=t.getChildren(function(e){return"mid"===e.id()})[0],s=t.getChildren(function(e){return"end"===e.id()})[0];switch(e.id()){case"begin":o.x(e.x()),o.y(e.y());break;case"mid":a.x(e.x()),a.y(e.y());break;case"end":s.x(e.x()),s.y(e.y())}var l=o.x()-n.x(),c=o.y()-n.y(),d=a.x()-n.x(),S=a.y()-n.y(),x=s.x()-n.x(),g=s.y()-n.y();n.points([l,c,d,S,x,g]),n.hitFunc(function(e){e.beginPath(),e.moveTo(l,c),e.lineTo(d,S),e.lineTo(x,g),e.closePath(),e.fillStrokeShape(this)});var m=new u.math.Point2D(o.x(),o.y()),h=new u.math.Point2D(a.x(),a.y()),p=new u.math.Point2D(s.x(),s.y()),f=new u.math.Line(m,h),C=new u.math.Line(h,p),y=u.math.getAngle(f,C),D=f.getInclination();y>180&&(D+=y=360-y);var v={angle:{value:y,unit:u.i18n("unit.degree")}},L=i.getText();L.quant=v,L.setText(u.utils.replaceFlags(L.textExpr,L.quant));var T={x:(f.getMidpoint().getX()+C.getMidpoint().getX())/2,y:(f.getMidpoint().getY()+C.getMidpoint().getY())/2-15};i.position(T);var I=33*Math.min(f.getLength(),C.getLength())/100;r.innerRadius(I),r.outerRadius(I),r.angle(y),r.rotation(-D);var P={x:a.x(),y:a.y()};r.position(P)};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.RectangleFactory=function(){this.getNPoints=function(){return 2},this.getTimeout=function(){return 0}},u.tool.RectangleFactory.prototype.create=function(e,t,n){var i=new u.math.Rectangle(e[0],e[1]),r=new o.Rect({x:i.getBegin().getX(),y:i.getBegin().getY(),width:i.getWidth(),height:i.getHeight(),stroke:t.getLineColour(),strokeWidth:t.getScaledStrokeWidth(),name:"shape"}),a=n.quantifyRect(i),s=new o.Text({fontSize:t.getScaledFontSize(),fontFamily:t.getFontFamily(),fill:t.getLineColour(),name:"text"});s.textExpr="{surface}",s.longText="",s.quant=a,s.setText(u.utils.replaceFlags(s.textExpr,s.quant));var l=new o.Label({x:i.getBegin().getX(),y:i.getEnd().getY()+10,name:"label"});l.add(s),l.add(new o.Tag);var c=new o.Group;return c.name("rectangle-group"),c.add(r),c.add(l),c.visible(!0),c},u.tool.UpdateRect=function(e,t){var n=e.getParent(),i=n.getChildren(function(e){return"shape"===e.name()})[0],r=n.getChildren(function(e){return"label"===e.name()})[0],o=n.getChildren(function(e){return"topLeft"===e.id()})[0],a=n.getChildren(function(e){return"topRight"===e.id()})[0],s=n.getChildren(function(e){return"bottomRight"===e.id()})[0],l=n.getChildren(function(e){return"bottomLeft"===e.id()})[0];switch(e.id()){case"topLeft":o.x(e.x()),o.y(e.y()),a.y(e.y()),l.x(e.x());break;case"topRight":a.x(e.x()),a.y(e.y()),o.y(e.y()),s.x(e.x());break;case"bottomRight":s.x(e.x()),s.y(e.y()),l.y(e.y()),a.x(e.x());break;case"bottomLeft":l.x(e.x()),l.y(e.y()),s.y(e.y()),o.x(e.x());break;default:console.error("Unhandled anchor id: "+e.id())}i.position(o.position());var c=a.x()-o.x(),d=l.y()-o.y();c&&d&&i.size({width:c,height:d});var S=new u.math.Point2D(o.x(),o.y()),x=new u.math.Point2D(s.x(),s.y()),g=new u.math.Rectangle(S,x),m=t.quantifyRect(g),h=r.getText();h.quant=m,h.setText(u.utils.replaceFlags(h.textExpr,h.quant));var p={x:g.getBegin().getX(),y:g.getEnd().getY()+10};r.position(p)};(u=u||{}).tool=u.tool||{};o=o||{};u.tool.RoiFactory=function(){this.getNPoints=function(){return 50},this.getTimeout=function(){return 100}},u.tool.RoiFactory.prototype.create=function(e,t){var n=new u.math.ROI;n.addPoints(e);for(var i=[],r=0;ri.getEnd().getX()?0:-1,g=i.getBegin().getY()>i.getEnd().getY()?-1:.5,m=new o.Label({x:i.getEnd().getX()+25*x,y:i.getEnd().getY()+15*g,name:"label"});m.add(S),m.add(new o.Tag);var h=new o.Group;return h.name("ruler-group"),h.add(r),h.add(s),h.add(c),h.add(m),h.visible(!0),h},u.tool.UpdateRuler=function(e,t){var n=e.getParent(),i=n.getChildren(function(e){return"shape"===e.name()})[0],r=n.getChildren(function(e){return"shape-tick0"===e.name()})[0],o=n.getChildren(function(e){return"shape-tick1"===e.name()})[0],a=n.getChildren(function(e){return"label"===e.name()})[0],s=n.getChildren(function(e){return"begin"===e.id()})[0],l=n.getChildren(function(e){return"end"===e.id()})[0];switch(e.id()){case"begin":s.x(e.x()),s.y(e.y());break;case"end":l.x(e.x()),l.y(e.y())}var c=s.x()-i.x(),d=s.y()-i.y(),S=l.x()-i.x(),x=l.y()-i.y();i.points([c,d,S,x]);var g=new u.math.Point2D(s.x(),s.y()),m=new u.math.Point2D(l.x(),l.y()),h=new u.math.Line(g,m),p=new u.math.Point2D(c,d),f=new u.math.Point2D(S,x),C=u.math.getPerpendicularLine(h,p,10);r.points([C.getBegin().getX(),C.getBegin().getY(),C.getEnd().getX(),C.getEnd().getY()]);var y=u.math.getPerpendicularLine(h,f,10);o.points([y.getBegin().getX(),y.getBegin().getY(),y.getEnd().getX(),y.getEnd().getY()]),i.hitFunc(function(e){e.beginPath(),e.moveTo(C.getBegin().getX(),C.getBegin().getY()),e.lineTo(C.getEnd().getX(),C.getEnd().getY()),e.lineTo(y.getEnd().getX(),y.getEnd().getY()),e.lineTo(y.getBegin().getX(),y.getBegin().getY()),e.closePath(),e.fillStrokeShape(this)});var D=t.quantifyLine(h),v=a.getText();v.quant=D,v.setText(u.utils.replaceFlags(v.textExpr,v.quant));var L=h.getBegin().getX()>h.getEnd().getX()?0:-1,T=h.getBegin().getY()>h.getEnd().getY()?-1:.5,I={x:h.getEnd().getX()+25*L,y:h.getEnd().getY()+15*T};a.position(I)};(u=u||{}).tool=u.tool||{},u.tool.Scroll=function(e){function t(t){var n=1!==e.getImage().getGeometry().getSize().getNumberOfSlices(),i=1!==e.getImage().getNumberOfFrames();t?n?e.getViewController().incrementSliceNb():i&&e.getViewController().incrementFrameNb():n?e.getViewController().decrementSliceNb():i&&e.getViewController().decrementFrameNb()}var n=this,i=null;this.started=!1;var r=null;this.mousedown=function(t){e.getViewController().isPlaying()&&e.getViewController().stop(),n.started=!0,n.x0=t._x,n.y0=t._y},this.mousemove=function(t){if(n.started){var i=t._y-n.y0,r=Math.abs(i)>15;r&&(i>0?e.getViewController().decrementSliceNb():e.getViewController().incrementSliceNb());var o=t._x-n.x0,a=Math.abs(o)>15;a&&(o>0?e.getViewController().incrementFrameNb():e.getViewController().decrementFrameNb()),a&&(n.x0=t._x),r&&(n.y0=t._y)}},this.mouseup=function(){n.started&&(n.started=!1)},this.mouseout=function(e){n.mouseup(e)},this.touchstart=function(e){r=setTimeout(n.dblclick,500),n.mousedown(e)},this.touchmove=function(e){null!==r&&(clearTimeout(r),r=null),n.mousemove(e)},this.touchend=function(e){null!==r&&(clearTimeout(r),r=null),n.mouseup(e)},this.DOMMouseScroll=function(e){e.detail<0?t(!0):t(!1)},this.mousewheel=function(e){e.wheelDelta>0?t(!0):t(!1)},this.keydown=function(t){e.onKeydown(t)},this.dblclick=function(){e.getViewController().play()},this.setup=function(){(i=new u.gui.Scroll(e)).setup()},this.display=function(e){i&&i.display(e)},this.init=function(){return!e.isMonoSliceData()||1!==e.getImage().getNumberOfFrames()}},u.tool.Scroll.prototype.getHelp=function(){return{title:u.i18n("tool.Scroll.name"),brief:u.i18n("tool.Scroll.brief"),mouse:{mouse_drag:u.i18n("tool.Scroll.mouse_drag"),double_click:u.i18n("tool.Scroll.double_click")},touch:{touch_drag:u.i18n("tool.Scroll.touch_drag"),tap_and_hold:u.i18n("tool.Scroll.tap_and_hold")}}};(u=u||{}).tool=u.tool||{},u.tool.Toolbox=function(e,t){var n=null,i=null,r=null;this.getToolList=function(){return e},this.getSelectedTool=function(){return i},this.setup=function(){if(0!==Object.keys(e).length){(n=new u.gui.Toolbox(t)).setup(e);for(var i in e)e[i].setup()}},this.display=function(t){0!==Object.keys(e).length&&n&&n.display(t)},this.init=function(){if(0!==Object.keys(e).length){r="";var t=[],i=null;for(var o in e)(i=e[o].init())&&""===r&&(r=o),t.push(i);this.setSelectedTool(r),n&&n.initialise(t)}},this.setSelectedTool=function(t){if(!this.hasTool(t))throw new Error("Unknown tool: '"+t+"'");i&&i.display(!1),(i=e[t]).display(!0)},this.reset=function(){i&&i.display(!1),i=null,r=null}},u.tool.Toolbox.prototype.hasTool=function(e){return this.getToolList()[e]};(u=u||{}).tool=u.tool||{},u.tool.UndoStack=function(e){var t=new u.gui.Undo(e),n=[];this.getStack=function(){return n};var i=0;this.add=function(e){(n=n.slice(0,i)).push(e),++i,t.addCommandToUndoHtml(e.getName())},this.undo=function(){i>0&&(n[--i].undo(),t.enableInUndoHtml(!1))},this.redo=function(){i0?e.getViewController().incrementSliceNb():e.getViewController().decrementSliceNb()}else{var s=(o-1)/2;Math.abs(s)%.1<=.05&&e.stepZoom(s,n._xs,n._ys)}}},this.mouseup=function(){t.started&&(t.started=!1)},this.mouseout=function(e){t.mouseup(e)},this.touchstart=function(e){var n=e.targetTouches;1===n.length?t.mousedown(e):2===n.length&&t.twotouchdown(e)},this.touchmove=function(e){var n=e.targetTouches;1===n.length?t.mousemove(e):2===n.length&&t.twotouchmove(e)},this.touchend=function(e){t.mouseup(e)},this.DOMMouseScroll=function(t){var n=-t.detail/30;e.stepZoom(n,t._xs,t._ys)},this.mousewheel=function(t){var n=t.wheelDelta/1200;e.stepZoom(n,t._xs,t._ys)},this.keydown=function(t){e.onKeydown(t)},this.setup=function(){(n=new u.gui.ZoomAndPan(e)).setup()},this.display=function(e){n&&n.display(e)}},u.tool.ZoomAndPan.prototype.getHelp=function(){return{title:u.i18n("tool.ZoomAndPan.name"),brief:u.i18n("tool.ZoomAndPan.brief"),mouse:{mouse_wheel:u.i18n("tool.ZoomAndPan.mouse_wheel"),mouse_drag:u.i18n("tool.ZoomAndPan.mouse_drag")},touch:{twotouch_pinch:u.i18n("tool.ZoomAndPan.twotouch_pinch"),touch_drag:u.i18n("tool.ZoomAndPan.touch_drag")}}},u.tool.ZoomAndPan.prototype.init=function(){return!0};(u=u||{}).browser=u.browser||{};e=e||{};u.browser.hasFileApi=function(){return-1!==navigator.appVersion.indexOf("Safari")&&-1===navigator.appVersion.indexOf("Chrome")&&(-1!==navigator.appVersion.indexOf("5.0.")||-1!==navigator.appVersion.indexOf("5.1."))?(console.warn("Assuming FileAPI support for Safari5..."),!0):e.filereader},u.browser.hasXmlHttpRequest=function(){return e.xhrresponsetype&&e.xhrresponsetypearraybuffer&&e.xhrresponsetypetext&&"XMLHttpRequest"in l&&"withCredentials"in new XMLHttpRequest},u.browser.hasTypedArray=function(){return e.dataview&&e.typedarrays},u.browser.hasInputColor=function(){return e.inputtypes.color},u.browser.hasInputDirectory=function(){return e.fileinputdirectory},u.browser._hasTypedArraySlice=void 0!==Uint8Array.prototype.slice,u.browser.hasTypedArraySlice=function(){return u.browser._hasTypedArraySlice},u.browser._hasFloat64Array="Float64Array"in l,u.browser.hasFloat64Array=function(){return u.browser._hasFloat64Array},u.browser._hasClampedArray="Uint8ClampedArray"in l,u.browser.hasClampedArray=function(){return u.browser._hasClampedArray},u.browser.check=function(){var e="The application cannot be run.",t="";if(!u.browser.hasFileApi())throw t="The File APIs are not supported in this browser. ",alert(t+e),new Error(t);if(!u.browser.hasXmlHttpRequest())throw t="The XMLHttpRequest is not supported in this browser. ",alert(t+e),new Error(t);if(!u.browser.hasTypedArray())throw t="The Typed arrays are not supported in this browser. ",alert(t+e),new Error(t);u.browser.hasTypedArraySlice()||(console.warn("The TypedArray.slice method is not supported in this browser. This may impair performance. "),Uint16Array.prototype.slice=function(e,t){for(var n=t-e,i=new Uint16Array(n),r=0;r0){var r=n.shift();r.run(e),i.push(r)}else t.push(e)},this.abort=function(){t=[];for(var e=0;e0){var o=t.shift();r.run(o)}else{n.push(r);for(var a=0;a1&&console.warn("More than one patient, loading first one.");var o=r[0].getElementsByTagName("Study");o.length>1&&console.warn("More than one study, loading first one.");var a=o[0].getAttribute("StudyInstanceUID"),s=o[0].getElementsByTagName("Series");s.length>1&&console.warn("More than one series, loading first one.");var l=s[0].getAttribute("SeriesInstanceUID"),u=s[0].getElementsByTagName("Instance"),c=u.length;t