From 0bd5f64488f888e79f4189e6b25af7593297b148 Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Thu, 28 Mar 2024 00:26:14 -0400 Subject: [PATCH 01/12] Native and Boxcraft --- dist/boostlet.min.js | 221 ++++++++++++++++++++------------ dist/boostlet.min.js.map | 2 +- examples/segmentanything.js | 52 +++++++- index.html | 4 +- src/frameworks/cornerstone2d.js | 76 +++++++++-- src/frameworks/niivue.js | 75 ++++++----- src/frameworks/openseadragon.js | 108 +++++++++++----- 7 files changed, 374 insertions(+), 164 deletions(-) diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index c4d40fec..013e28da 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -303,21 +303,50 @@ class $febea0d4681e2ae0$export$1ec7e9f19103cb25 extends (0, $bsgU1.Framework) { return this.canvasFallback.set_mask(new_mask); } select_box(callback) { - this.cornerstonetools_instance.setToolActive("RectangleRoi", { - mouseButtonMask: 1 - }); - let element = this.instance.getEnabledElements()[0]; - let canvas = element.canvas; - canvas.onmouseup = (function() { - let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); - let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; - let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; - let topleft_c = this.instance.pixelToCanvas(element.element, topleft); - let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); - this.cornerstonetools_instance.clearToolState(element.element, "RectangleRoi"); - this.instance.renderGrayscaleImage(element, true); - callback(topleft_c, bottomright_c); - }).bind(this); + // this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 }) + // let element = this.instance.getEnabledElements()[0]; + // let canvas = element.canvas; + // canvas.onmouseup = function() { + // let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); + // let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; + // let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; + // let topleft_c = this.instance.pixelToCanvas(element.element, topleft); + // let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); + // this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi'); + // this.instance.renderGrayscaleImage(element, true); + // callback(topleft_c, bottomright_c); + // }.bind(this); + if (this.cornerstonetools_instance.RectangleRoiTool === undefined) { + console.log("Using Boxcraft library to handle box selection."); + let element = this.instance.getEnabledElements()[0]; + let canvas = element.canvas; + // Disable the Wwwc tool + cornerstoneTools.setToolDisabled("Wwwc"); + BoxCraft.createDraggableBBox(canvas, function(topleft, bottomright) { + callback(topleft, bottomright); + }); + // BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) { + // console.log("Inside Draggable BBox",topleft, bottomright); + // callback(topleft, bottomright); + // }); + } else { + console.log("Using Cornerstonetools to handle box selection."); + this.cornerstonetools_instance.setToolActive("RectangleRoi", { + mouseButtonMask: 1 + }); + let element = this.instance.getEnabledElements()[0]; + let canvas = element.canvas; + canvas.onmouseup = (function() { + let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); + let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; + let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; + let topleft_c = this.instance.pixelToCanvas(element.element, topleft); + let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); + this.cornerstonetools_instance.clearToolState(element.element, "RectangleRoi"); + this.instance.renderGrayscaleImage(element, true); + callback(topleft_c, bottomright_c); + }).bind(this); + } } } @@ -424,10 +453,13 @@ $parcel$export(module.exports, "NiiVue", () => $fbafa14c3ac31938$export$3d6843c2 var $bsgU1 = parcelRequire("bsgU1"); var $gk9zP = parcelRequire("gk9zP"); + +var $1lpSl = parcelRequire("1lpSl"); class $fbafa14c3ac31938$export$3d6843c2c4a1bd6c extends (0, $bsgU1.Framework) { constructor(instance){ super(instance); this.name = "niivue"; + this.canvasFallback = new (0, $1lpSl.CanvasFallback)(); this.flip_on_png = true; this.onMouseDown = false; this.x1 = null; @@ -534,41 +566,42 @@ class $fbafa14c3ac31938$export$3d6843c2c4a1bd6c extends (0, $bsgU1.Framework) { } select_box(callback) { // TODO also hacky until official API supports this + // let canvas = this.instance.canvas; + // canvas.addEventListener('mousedown', function (e) { + // this.isMouseDown = true; + // var rect = e.currentTarget.getBoundingClientRect(), + // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, + // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + // this.x1 = offsetX; + // this.y1 = offsetY; + // }.bind(this)); + // canvas.addEventListener('mousemove', function (e) { + // if (this.isMouseDown) { + // var rect = e.currentTarget.getBoundingClientRect(), + // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, + // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + // this.x2 = offsetX; + // this.y2 = offsetY; + // this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]); + // } + // }.bind(this)); + // canvas.addEventListener('mouseup', function (e) { + // var rect = e.currentTarget.getBoundingClientRect(), + // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, + // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + // this.x2 = offsetX; + // this.y2 = offsetY; + // this.isMouseDown = false; + // let topleft = {x: this.x1, y: this.y1}; + // let bottomright = {x: this.x2, y: this.y2}; + // callback(topleft, bottomright); + // }.bind(this)); + // return this.canvasFallback.select_box(callback); + console.log("Using Boxcraft library to handle box selection."); let canvas = this.instance.canvas; - canvas.addEventListener("mousedown", (function(e) { - this.isMouseDown = true; - var rect = e.currentTarget.getBoundingClientRect(), offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - this.x1 = offsetX; - this.y1 = offsetY; - }).bind(this)); - canvas.addEventListener("mousemove", (function(e) { - if (this.isMouseDown) { - var rect = e.currentTarget.getBoundingClientRect(), offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - this.x2 = offsetX; - this.y2 = offsetY; - this.instance.drawSelectionBox([ - this.x1, - this.y1, - this.x2 - this.x1, - this.y2 - this.y1 - ]); - } - }).bind(this)); - canvas.addEventListener("mouseup", (function(e) { - var rect = e.currentTarget.getBoundingClientRect(), offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - this.x2 = offsetX; - this.y2 = offsetY; - this.isMouseDown = false; - let topleft = { - x: this.x1, - y: this.y1 - }; - let bottomright = { - x: this.x2, - y: this.y2 - }; + BoxCraft.createDraggableBBox(canvas, function(topleft, bottomright) { callback(topleft, bottomright); - }).bind(this)); + }); } } @@ -579,7 +612,8 @@ parcelRegister("7Srn3", function(module, exports) { $parcel$export(module.exports, "OpenSeaDragon", () => $5bc2ced335fcdbf6$export$ac966f05fb2ad3); var $bsgU1 = parcelRequire("bsgU1"); -parcelRequire("gk9zP"); + +var $gk9zP = parcelRequire("gk9zP"); var $1lpSl = parcelRequire("1lpSl"); class $5bc2ced335fcdbf6$export$ac966f05fb2ad3 extends (0, $bsgU1.Framework) { @@ -595,42 +629,63 @@ class $5bc2ced335fcdbf6$export$ac966f05fb2ad3 extends (0, $bsgU1.Framework) { return this.canvasFallback.set_image(new_pixels); } set_mask(new_mask) { - return this.canvasFallback.set_mask(new_mask); + // return this.canvasFallback.set_mask(new_mask); + let viewer = null; + let vs = this.instance._viewers; + vs.forEach(function(e) { + if (e.id == "viewer") viewer = e; + }); + if (!viewer) throw "OpenSeaDragon viewer not found."; + let canvas = viewer.canvas.children[0]; + width = canvas.width; + height = canvas.height; + let ctx = canvas.getContext("2d"); + let imagedata = ctx.getImageData(0, 0, width, height); + let pixels = imagedata.data; + let masked_image = (0, $gk9zP.Util).harden_mask(pixels, new_mask); + let masked_image_as_imagedata = new ImageData(masked_image, width, height); + ctx.putImageData(masked_image_as_imagedata, 0, 0); } select_box(callback) { - Boostlet.hint("Click on top left and bottom right coordinated of the desired selection box."); - let isFirstClick = true; - let x1, y1, x2, y2; - // Function to handle the mouse click event - function handleClick(event) { - if (isFirstClick) { - // Capture x1 and y1 on the first click - x1 = event.clientX; - y1 = event.clientY; - console.log(`First click: (X1: ${x1}, Y1: ${y1})`); - isFirstClick = false; - } else { - // Capture x2 and y2 on the second click - x2 = event.clientX; - y2 = event.clientY; - console.log(`Second click: (X2: ${x2}, Y2: ${y2})`); - isFirstClick = true; - let topleft = { - x: x1, - y: y1 - }; - let bottomright = { - x: x2, - y: y2 - }; - callback(topleft, bottomright); - } - // let topleft = {x: 529, y: 480}; - // let bottomright = {x: 667, y: 588}; - // callback(topleft, bottomright); - } - // Add a click event listener to the document - document.addEventListener("click", handleClick); + // Boostlet.hint("Click on top left and bottom right coordinated of the desired selection box.") + // let isFirstClick = true; + // let x1, y1, x2, y2; + // // Function to handle the mouse click event + // function handleClick(event) { + // if (isFirstClick) { + // // Capture x1 and y1 on the first click + // x1 = event.clientX; + // y1 = event.clientY; + // console.log(`First click: (X1: ${x1}, Y1: ${y1})`); + // isFirstClick = false; + // } else { + // // Capture x2 and y2 on the second click + // x2 = event.clientX; + // y2 = event.clientY; + // console.log(`Second click: (X2: ${x2}, Y2: ${y2})`); + // isFirstClick = true; + // let topleft = {x: x1, y: y1}; + // let bottomright = {x: x2, y: y2}; + // callback(topleft, bottomright); + // } + // // let topleft = {x: 529, y: 480}; + // // let bottomright = {x: 667, y: 588}; + // // callback(topleft, bottomright); + // } + // // Add a click event listener to the document + // document.addEventListener("click", handleClick); + // return this.canvasFallback.select_box(callback); + console.log("Using Boxcraft library to handle box selection."); + let viewer = null; + let vs = this.instance._viewers; + vs.forEach(function(e) { + if (e.id == "viewer") viewer = e; + }); + if (!viewer) throw "OpenSeaDragon viewer not found."; + let canvas = viewer.canvas; + BoxCraft.createDraggableBBox(canvas, function(topleft, bottomright) { + callback(topleft, bottomright); + }); } } diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index 693d9d71..fff3d30d 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,YAAY,IAAI,CAAA,GAAA,qBAAa;QAE/B;QAEA,OAAO;IAET;IAEA,aAAa,YAAY,GAAG,EAAE,QAAQ,EAAE;QAEtC,iDAAiD;QACjD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,SAAS,EAAE,UAAU;YAC9D;gBACE,OAAO;YACT;YACA,KAAI,SAAS;gBACX,aAAa;YACf;QACF;QAEA,MAAM,SAAS,OAAO,QAAQ,CAAC,aAAa,CAAC;QA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SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,UAAU,UAAU,EAAE;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\r\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\r\nimport {NiiVue} from './frameworks/niivue.js';\r\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\r\nimport { Xtk } from './frameworks/xtk.js';\r\nimport { Papaya } from './frameworks/papaya.js';\r\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\r\n\r\nexport class Util {\r\n \r\n static detect_framework() {\r\n\r\n let framework = null;\r\n\r\n if (Util.is_defined(window.nv)) {\r\n \r\n framework = new NiiVue(window.nv);\r\n \r\n } else if (Util.is_defined(window.niivue)) {\r\n \r\n framework = new NiiVue(window.niivue);\r\n\r\n } else if (Util.is_defined(window.cornerstone)) {\r\n\r\n framework = new Cornerstone2D(window.cornerstone);\r\n\r\n } else if (Util.is_defined(window.r)) {\r\n \r\n framework = new Xtk(window.r);\r\n \r\n } else if (Util.is_defined(window.OpenSeadragon)) {\r\n\r\n framework = new OpenSeaDragon(window.OpenSeadragon);\r\n \r\n } else if (Util.is_defined(window.papayaContainers)) {\r\n \r\n framework = new Papaya(window.papayaContainers)\r\n\r\n } else {\r\n // Canvas fallback\r\n \r\n console.log(\"No framework detected, falling back to canvas rendering\");\r\n framework = new CanvasFallback();\r\n \r\n }\r\n\r\n return framework;\r\n\r\n }\r\n\r\n static async load_script(url, callback) {\r\n\r\n // introducing hack to make it work for openneuro\r\n window.Object.defineProperty(window.Object.prototype, 'global', {\r\n get( ){\r\n return window;\r\n },\r\n set(newGlobal) {\r\n globalThis = newGlobal;\r\n }\r\n });\r\n\r\n const script = window.document.createElement(\"script\")\r\n script.type = \"text/javascript\"\r\n script.src = url;\r\n\r\n if (Util.is_defined(callback)) {\r\n script.onload = callback;\r\n }\r\n\r\n window.document.head.appendChild(script);\r\n eval(script);\r\n\r\n }\r\n\r\n static async send_http_post(url, data, callback) {\r\n\r\n let xhr = new XMLHttpRequest();\r\n xhr.open(\"POST\", url);\r\n xhr.onreadystatechange = function () {\r\n if (xhr.readyState === 4) {\r\n // request done\r\n callback( xhr.response );\r\n\r\n return;\r\n\r\n }\r\n }\r\n\r\n xhr.send(data)\r\n\r\n }\r\n\r\n static convert_to_png(uint8array, width, height, flip) {\r\n\r\n // we are using an offscreen canvas for this\r\n let offscreen = window.document.createElement('canvas');\r\n offscreen.width = width;\r\n offscreen.height = height;\r\n\r\n let offscreen_ctx = offscreen.getContext('2d');\r\n\r\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\r\n let pxdata = imgdata.data;\r\n\r\n for (var i =0; i c.charCodeAt(0));\r\n\r\n return pngpixels;\r\n\r\n }\r\n\r\n static filter(pixels, width, height, kernel) {\r\n\r\n const kernelSize = Math.sqrt(kernel.length);\r\n const halfKernelSize = Math.floor(kernelSize / 2);\r\n\r\n const new_pixels = pixels.slice();\r\n\r\n for (let y = 0; y < height; y++) {\r\n for (let x = 0; x < width; x++) {\r\n const dstIndex = y * width + x;\r\n\r\n let newValue = 0;\r\n for (let ky = 0; ky < kernelSize; ky++) {\r\n for (let kx = 0; kx < kernelSize; kx++) {\r\n const srcX = x + kx - halfKernelSize;\r\n const srcY = y + ky - halfKernelSize;\r\n const srcIndex = srcY * width + srcX;\r\n\r\n const kernelValue = kernel[ky * kernelSize + kx];\r\n newValue += pixels[srcIndex] * kernelValue;\r\n }\r\n }\r\n\r\n new_pixels[dstIndex] = newValue;\r\n\r\n }\r\n }\r\n\r\n return new_pixels;\r\n\r\n }\r\n\r\n static grayscale_to_rgba(grayscale) {\r\n\r\n const rgba = new Uint8Array(grayscale.length * 4);\r\n\r\n for (let i = 0; i < grayscale.length; i++) {\r\n const g = grayscale[i];\r\n const index = i * 4;\r\n\r\n rgba[index] = g;\r\n rgba[index + 1] = g;\r\n rgba[index + 2] = g;\r\n rgba[index + 3] = 255; \r\n }\r\n\r\n return rgba;\r\n\r\n }\r\n\r\n static rgba_to_grayscale(rgba) {\r\n\r\n const grayscale = new Uint8Array(rgba.length / 4);\r\n\r\n for (let i = 0; i < rgba.length; i += 4) {\r\n\r\n grayscale[i / 4] = rgba[i];\r\n\r\n }\r\n\r\n return grayscale;\r\n\r\n }\r\n\r\n /**\r\n * Harden a mask into a grayscale pixel array.\r\n * \r\n * pixels needs to be RGBA\r\n * \r\n * and mask binary.\r\n * \r\n * maskcolor is optional and falls back to blue.\r\n * \r\n **/\r\n static harden_mask(pixels, mask, maskcolor) {\r\n\r\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\r\n // Copyright (c) Meta Platforms, Inc. and affiliates.\r\n // All rights reserved.\r\n\r\n\r\n let maskcolor_ = [0, 114, 189, 255];\r\n\r\n if (Util.is_defined(maskcolor)) {\r\n \r\n maskcolor_ = maskcolor;\r\n \r\n } \r\n\r\n for (var i = 0; i < mask.length; i++) {\r\n\r\n if (mask[i] > 0.0) {\r\n pixels[4 * i + 0] = maskcolor_[0];\r\n pixels[4 * i + 1] = maskcolor_[1];\r\n pixels[4 * i + 2] = maskcolor_[2];\r\n pixels[4 * i + 3] = maskcolor_[3];\r\n }\r\n\r\n }\r\n\r\n return pixels;\r\n\r\n }\r\n\r\n static is_defined(variable) {\r\n\r\n return (typeof variable != 'undefined');\r\n\r\n }\r\n \r\n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\r\n static hint(message, duration) {\r\n\r\n let hint = window.document.createElement('div');\r\n hint.id = 'BoostletHint';\r\n\r\n hint.style.position = 'fixed';\r\n hint.style.left = '10px';\r\n hint.style.top = '10px';\r\n hint.style.padding = '10px';\r\n hint.style.background = '#fff';\r\n hint.style.color = '#000';\r\n hint.style.zIndex = '100000';\r\n hint.style.border = '1px solid #007ec6';\r\n hint.style.borderRadius = '5px';\r\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\r\n hint.style.fontSize = '14px';\r\n hint.style.fontWeight = 'bold';\r\n hint.style.textAlign = 'center';\r\n\r\n hint.innerHTML = message;\r\n \r\n window.document.body.appendChild(hint);\r\n\r\n if (typeof duration === 'number' && duration > 0) {\r\n setTimeout(function() {\r\n hint.remove();\r\n }, duration);\r\n }\r\n\r\n }\r\n\r\n}","import {Util} from './util.js';\r\n\r\nexport class Framework {\r\n\r\n constructor(instance) {\r\n\r\n this.name = 'generic';\r\n this.instance = instance;\r\n\r\n this.flip_on_png = false;\r\n\r\n }\r\n\r\n get_image(from_canvas) {\r\n\r\n throw \"Missing Implementation.\";\r\n\r\n }\r\n\r\n set_image(new_pixels) {\r\n\r\n throw \"Missing Implementation.\";\r\n\r\n }\r\n\r\n set_mask(new_mask) {\r\n\r\n throw \"Missing Implementation.\";\r\n \r\n }\r\n\r\n select_box(callback) {\r\n\r\n throw \"Missing Implementation.\";\r\n\r\n }\r\n\r\n convert_to_png(uint8array, width, height) {\r\n\r\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\r\n\r\n }\r\n\r\n}\r\n","import {Framework} from '../framework.js';\r\n\r\nimport {Util} from '../util.js';\r\n\r\nimport {CanvasFallback} from './canvasFallback.js';\r\n\r\nexport class Cornerstone2D extends Framework {\r\n \r\n constructor(instance) {\r\n\r\n super(instance);\r\n this.name = 'cornerstone2D';\r\n this.canvasFallback = new CanvasFallback();\r\n\r\n this.cornerstonetools_instance = null;\r\n\r\n if (typeof window.cornerstoneTools != 'undefined') {\r\n\r\n // TODO probably not too robust\r\n this.cornerstonetools_instance = window.cornerstoneTools;\r\n\r\n }\r\n\r\n this.flip_on_png = false;\r\n\r\n }\r\n\r\n get_image(from_canvas) {\r\n\r\n let element = this.instance.getEnabledElements()[0];\r\n let pixels = null;\r\n let width = null;\r\n let height = null;\r\n\r\n if (typeof from_canvas != 'undefined') {\r\n\r\n // TODO this is hacky going through the canvas\r\n // later should grab the real volume data\r\n\r\n let canvas = element.canvas;\r\n width = canvas.width;\r\n height = canvas.height;\r\n\r\n let ctx = canvas.getContext('2d');\r\n\r\n let imagedata = ctx.getImageData(0, 0, width, height);\r\n pixels = imagedata.data;\r\n\r\n } else {\r\n\r\n // this is the real image slice data\r\n let imagedata = element.image;\r\n pixels = imagedata.getPixelData();\r\n width = imagedata.width;\r\n height = imagedata.height;\r\n\r\n }\r\n\r\n return {'data':pixels, 'width':width, 'height':height};\r\n\r\n }\r\n\r\n set_image(new_pixels) {\r\n\r\n let element = this.instance.getEnabledElements()[0];\r\n let pixels = element.image.getPixelData();\r\n\r\n // Set the new pixel values\r\n pixels.set(new_pixels);\r\n\r\n // Re-render the current slice\r\n cornerstone.renderGrayscaleImage(element, true);\r\n\r\n }\r\n\r\n set_mask(new_mask) {\r\n\r\n return this.canvasFallback.set_mask(new_mask);\r\n \r\n }\r\n\r\n select_box(callback) {\r\n\r\n this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 })\r\n\r\n let element = this.instance.getEnabledElements()[0];\r\n let canvas = element.canvas;\r\n\r\n canvas.onmouseup = function() {\r\n\r\n let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\r\n\r\n let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\r\n let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\r\n\r\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\r\n let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright);\r\n\r\n this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi');\r\n this.instance.renderGrayscaleImage(element, true);\r\n\r\n callback(topleft_c, bottomright_c);\r\n\r\n }.bind(this);\r\n\r\n }\r\n\r\n}","import { Framework } from \"../framework.js\";\r\n\r\nimport { Util } from \"../util.js\";\r\n\r\n\r\nexport class CanvasFallback extends Framework {\r\n constructor() {\r\n super();\r\n this.name = \"canvasFallback\";\r\n }\r\n\r\n get_canvas() {\r\n let canvases = document.querySelectorAll('canvas');\r\n let largestCanvas = canvases[0];\r\n let largestArea = largestCanvas.width * largestCanvas.height;\r\n\r\n for (let i = 1; i < canvases.length; i++) {\r\n let area = canvases[i].width * canvases[i].height;\r\n if (area > largestArea) {\r\n largestCanvas = canvases[i];\r\n largestArea = area;\r\n }\r\n }\r\n\r\n return largestCanvas;\r\n }\r\n\r\n get_image(from_canvas) {\r\n\r\n let canvas = this.get_canvas();\r\n\r\n let ctx = canvas.getContext(\"2d\");\r\n\r\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\r\n let rgba_image = Util.rgba_to_grayscale(image.data);\r\n\r\n if (from_canvas) {\r\n return { data: image.data, width: image.width, height: image.height };\r\n } else {\r\n return { data: rgba_image, width: image.width, height: image.height };\r\n }\r\n }\r\n\r\n set_image(new_pixels) {\r\n let originalcanvas = this.get_canvas();\r\n\r\n let newcanvas = window.document.createElement(\"canvas\");\r\n\r\n newcanvas.width = originalcanvas.width;\r\n newcanvas.height = originalcanvas.height;\r\n\r\n let ctx = newcanvas.getContext(\"2d\");\r\n\r\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\r\n\r\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\r\n\r\n let newImageData = new ImageData(\r\n newPixelsClamped,\r\n newcanvas.width,\r\n newcanvas.height\r\n );\r\n\r\n // Draw the new image data onto the canvas\r\n ctx.putImageData(newImageData, 0, 0);\r\n\r\n newcanvas.onclick = function () {\r\n // on click, we will restore the nv canvas\r\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\r\n };\r\n\r\n // replace nv canvas with new one\r\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\r\n }\r\n\r\n set_mask(new_mask) {\r\n let image = this.get_image(true);\r\n\r\n let originalcanvas = this.get_canvas();\r\n\r\n let newcanvas = window.document.createElement('canvas');\r\n\r\n newcanvas.width = originalcanvas.width;\r\n newcanvas.height = originalcanvas.height;\r\n\r\n let ctx = newcanvas.getContext('2d');\r\n\r\n let imageclamped = new Uint8ClampedArray(image.data);\r\n\r\n let newImageData = new ImageData(\r\n imageclamped,\r\n newcanvas.width,\r\n newcanvas.height\r\n );\r\n\r\n // Draw the new image data onto the canvas\r\n ctx.putImageData(newImageData, 0, 0);\r\n\r\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\r\n\r\n let masked_image = Util.harden_mask(image.data, new_mask);\r\n\r\n let masked_image_as_imagedata = new ImageData(\r\n masked_image,\r\n newcanvas.width,\r\n newcanvas.height\r\n );\r\n\r\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\r\n\r\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\r\n }\r\n\r\n select_box(callback) {\r\n let scriptBoxCraft = document.createElement(\"script\");\r\n scriptBoxCraft.type = \"text/javascript\";\r\n scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\r\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\r\n let canvas = this.get_canvas();\r\n document.head.appendChild(scriptBoxCraft);\r\n\r\n scriptBoxCraft.onload = function() {\r\n\r\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\r\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\r\n callback(topleft, bottomright);\r\n });\r\n }\r\n\r\n }\r\n\r\n}","import {Framework} from '../framework.js';\r\n\r\nimport {Util} from '../util.js';\r\n\r\nexport class NiiVue extends Framework {\r\n \r\n constructor(instance) {\r\n\r\n super(instance);\r\n this.name = 'niivue';\r\n\r\n this.flip_on_png = true;\r\n\r\n this.onMouseDown = false;\r\n this.x1 = null;\r\n this.y1 = null;\r\n this.x2 = null;\r\n this.y2 = null;\r\n\r\n }\r\n\r\n get_image(from_canvas) {\r\n\r\n let element = this.instance.canvas;\r\n let pixels = null;\r\n let width = null;\r\n let height = null;\r\n\r\n\r\n // TODO this is hacky going through the canvas\r\n // later should grab the real volume data\r\n\r\n let old_crosshaircolor = this.instance.opts.crosshairColor;\r\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\r\n\r\n this.instance.setCrosshairColor([0,0,0,0]);\r\n this.instance.opts.crosshairWidth=0;\r\n this.instance.updateGLVolume();\r\n\r\n\r\n let ctx = this.instance.gl;\r\n\r\n \r\n width = ctx.drawingBufferWidth;\r\n height = ctx.drawingBufferHeight;\r\n\r\n pixels = new Uint8Array(width * height * 4);\r\n ctx.readPixels(\r\n 0, \r\n 0, \r\n width, \r\n height, \r\n ctx.RGBA, \r\n ctx.UNSIGNED_BYTE, \r\n pixels);\r\n\r\n // restore crosshairs\r\n this.instance.setCrosshairColor(old_crosshaircolor);\r\n this.instance.opts.crosshairWidth = old_crosshairwidth;\r\n\r\n if (!Util.is_defined(from_canvas)) {\r\n\r\n // convert rgba pixels to grayscale\r\n pixels = Util.rgba_to_grayscale(pixels);\r\n\r\n } else {\r\n\r\n // TODO\r\n // not easily possible yet\r\n // we could hack it using \r\n // nv.back.get_value(x,y,z)\r\n // based on the dimensions\r\n // nv.back.dims.slice(1);\r\n // but devs promised easy access in the future\r\n\r\n }\r\n\r\n\r\n return {'data':pixels, 'width':width, 'height':height};\r\n\r\n }\r\n\r\n /**\r\n * Sets the NiiVue.js image.\r\n * \r\n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\r\n **/\r\n set_image(new_pixels, is_rgba, no_flip) {\r\n\r\n // TODO this is hacky since we dont work with the real volume yet\r\n // create new canvas\r\n // put pixels on canvas\r\n // show canvas\r\n // hide on click\r\n\r\n let originalcanvas = this.instance.canvas;\r\n\r\n let newcanvas = window.document.createElement('canvas');\r\n newcanvas.width = originalcanvas.width;\r\n newcanvas.height = originalcanvas.height;\r\n\r\n // put new_pixels down\r\n let ctx = newcanvas.getContext('2d');\r\n\r\n let new_pixels_rgba = null;\r\n\r\n if (Util.is_defined(is_rgba)) {\r\n\r\n new_pixels_rgba = new_pixels;\r\n\r\n } else {\r\n\r\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\r\n\r\n\r\n }\r\n\r\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\r\n\r\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\r\n \r\n\r\n ctx.putImageData(new_image_data, 0, 0);\r\n\r\n if (!Util.is_defined(no_flip)) {\r\n // some flipping action\r\n ctx.save();\r\n ctx.scale(1, -1);\r\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\r\n ctx.restore();\r\n }\r\n\r\n\r\n newcanvas.onclick = function() {\r\n\r\n // on click, we will restore the nv canvas\r\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\r\n\r\n }\r\n\r\n // replace nv canvas with new one\r\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\r\n newcanvas.style.width = originalcanvas.clientWidth+'px';\r\n newcanvas.style.height = originalcanvas.clientHeight+'px';\r\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\r\n\r\n }\r\n\r\n set_mask(new_mask) {\r\n\r\n // merge image + mask\r\n // and then call set_image with that information\r\n\r\n let image = this.get_image(true);\r\n\r\n // TODO here we need to flip one more time, this is until\r\n // we use the official niivue infrastructure for adding\r\n // a segmentation layer\r\n let originalcanvas = this.instance.canvas;\r\n\r\n let newcanvas = window.document.createElement('canvas');\r\n newcanvas.width = originalcanvas.width;\r\n newcanvas.height = originalcanvas.height;\r\n // put new_pixels down\r\n let ctx = newcanvas.getContext('2d');\r\n let imageclamped = new Uint8ClampedArray(image.data);\r\n let imagedata = new ImageData(imageclamped, image.width, image.height);\r\n ctx.putImageData(imagedata, 0, 0);\r\n ctx.save();\r\n ctx.scale(1, -1);\r\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\r\n ctx.restore();\r\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\r\n // end of flip\r\n\r\n let masked_image = Util.harden_mask(image.data, new_mask);\r\n\r\n this.set_image(masked_image, true, true); // rgba data, no flip\r\n\r\n\r\n }\r\n\r\n select_box(callback) {\r\n\r\n // TODO also hacky until official API supports this\r\n\r\n let canvas = this.instance.canvas;\r\n\r\n \r\n canvas.addEventListener('mousedown', function (e) {\r\n this.isMouseDown = true;\r\n\r\n var rect = e.currentTarget.getBoundingClientRect(),\r\n offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\r\n offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\r\n\r\n this.x1 = offsetX;\r\n this.y1 = offsetY;\r\n }.bind(this));\r\n\r\n canvas.addEventListener('mousemove', function (e) {\r\n if (this.isMouseDown) {\r\n\r\n var rect = e.currentTarget.getBoundingClientRect(),\r\n offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\r\n offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\r\n\r\n this.x2 = offsetX;\r\n this.y2 = offsetY;\r\n this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]);\r\n }\r\n }.bind(this));\r\n\r\n\r\n canvas.addEventListener('mouseup', function (e) {\r\n var rect = e.currentTarget.getBoundingClientRect(),\r\n offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\r\n offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\r\n \r\n this.x2 = offsetX;\r\n this.y2 = offsetY;\r\n this.isMouseDown = false;\r\n\r\n let topleft = {x: this.x1, y: this.y1};\r\n let bottomright = {x: this.x2, y: this.y2};\r\n\r\n callback(topleft, bottomright);\r\n\r\n }.bind(this));\r\n\r\n }\r\n\r\n}\r\n","import {Framework} from '../framework.js';\r\n\r\nimport {Util} from '../util.js';\r\n\r\nimport {CanvasFallback} from './canvasFallback.js';\r\n\r\nexport class OpenSeaDragon extends Framework {\r\n constructor(instance) {\r\n super(instance);\r\n this.name = 'opensedragon';\r\n this.canvasFallback = new CanvasFallback();\r\n\r\n }\r\n\r\n get_image(from_canvas) {\r\n return this.canvasFallback.get_image(from_canvas);\r\n }\r\n\r\n set_image(new_pixels) {\r\n return this.canvasFallback.set_image(new_pixels);\r\n }\r\n\r\n set_mask(new_mask) {\r\n return this.canvasFallback.set_mask(new_mask);\r\n }\r\n\r\n select_box(callback) {\r\n \r\n Boostlet.hint(\"Click on top left and bottom right coordinated of the desired selection box.\")\r\n\r\n let isFirstClick = true;\r\n let x1, y1, x2, y2;\r\n \r\n // Function to handle the mouse click event\r\n function handleClick(event) {\r\n if (isFirstClick) {\r\n // Capture x1 and y1 on the first click\r\n x1 = event.clientX;\r\n y1 = event.clientY;\r\n console.log(`First click: (X1: ${x1}, Y1: ${y1})`);\r\n isFirstClick = false;\r\n } else {\r\n // Capture x2 and y2 on the second click\r\n x2 = event.clientX;\r\n y2 = event.clientY;\r\n console.log(`Second click: (X2: ${x2}, Y2: ${y2})`);\r\n isFirstClick = true;\r\n\r\n let topleft = {x: x1, y: y1};\r\n let bottomright = {x: x2, y: y2};\r\n\r\n callback(topleft, bottomright);\r\n }\r\n\r\n // let topleft = {x: 529, y: 480};\r\n // let bottomright = {x: 667, y: 588};\r\n // callback(topleft, bottomright);\r\n\r\n }\r\n \r\n // Add a click event listener to the document\r\n document.addEventListener(\"click\", handleClick);\r\n\r\n }\r\n\r\n \r\n\r\n}\r\n \r\n","import { Framework } from \"../framework.js\";\r\n\r\nimport { Util } from \"../util.js\";\r\n\r\nimport { CanvasFallback } from \"./canvasFallback.js\";\r\n\r\nexport class Xtk extends Framework {\r\n constructor(instance) {\r\n super(instance);\r\n this.name = \"xtk\";\r\n this.canvasFallback = new CanvasFallback();\r\n\r\n }\r\n\r\n get_image(from_canvas) {\r\n return this.canvasFallback.get_image(from_canvas);\r\n }\r\n\r\n set_image(new_pixels) {\r\n return this.canvasFallback.set_image(new_pixels);\r\n }\r\n\r\n set_mask(new_mask) {\r\n return this.canvasFallback.set_mask(new_mask);\r\n }\r\n\r\n select_box(callback) {\r\n return this.canvasFallback.select_box(callback);\r\n }\r\n}","import { Framework } from \"../framework.js\";\r\n\r\nimport { Util } from \"../util.js\";\r\n\r\nimport { CanvasFallback } from \"./canvasFallback.js\";\r\n\r\nexport class Papaya extends Framework {\r\n constructor(instance) {\r\n super(instance);\r\n this.name = \"papaya\";\r\n this.canvasFallback = new CanvasFallback();\r\n }\r\n\r\n get_image(from_canvas) {\r\n return this.canvasFallback.get_image(from_canvas);\r\n }\r\n\r\n set_image(new_pixels) {\r\n return this.canvasFallback.set_image(new_pixels);\r\n }\r\n\r\n set_mask(new_mask) {\r\n return this.canvasFallback.set_mask(new_mask);\r\n }\r\n\r\n select_box(callback) {\r\n return this.canvasFallback.select_box(callback);\r\n }\r\n}\r\n","\r\nimport {Boostlet} from \"./boostlet.js\"\r\n\r\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\r\n\r\n// register global namespace with a new boostlet instance\r\n// later we might want to support multiple active boostlets\r\nwindow.Boostlet = new Boostlet();\r\n","import {Util} from './util.js';\r\n\r\nimport {Framework} from './framework.js';\r\n\r\nexport class Boostlet {\r\n\r\n constructor() {\r\n\r\n this.framework = null;\r\n\r\n }\r\n\r\n /**\r\n * Initializes the Boostlet.\r\n * \r\n * This includes several steps such as identifying the \r\n * visualization/rendering framework that is available. \r\n * \r\n * TODO: Later we want to have fallbacks in place if the framework\r\n * is not detected.\r\n * \r\n */\r\n init(name, instance) {\r\n\r\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\r\n\r\n console.log('Framework forced by user!');\r\n throw \"Forced Framework Not Implemented.\";\r\n // TODO\r\n\r\n } else {\r\n\r\n this.framework = Util.detect_framework();\r\n\r\n }\r\n\r\n if (this.framework) {\r\n\r\n console.log('Found', this.framework, '!')\r\n \r\n } else {\r\n\r\n throw \"Framework Not Found.\";\r\n\r\n }\r\n\r\n }\r\n\r\n /**\r\n * Let's the user select a region of interest box.\r\n */\r\n async select_box(callback) {\r\n\r\n this.framework.select_box(callback);\r\n\r\n }\r\n\r\n /**\r\n * Let's the user select (multiple) seeds.\r\n */\r\n async select_seed(howmany) {\r\n\r\n throw \"Missing Implementation.\";\r\n\r\n }\r\n\r\n /**\r\n * Loads an external javascript file asynchronously. \r\n */\r\n async load_script(url, callback) {\r\n\r\n Util.load_script(url, callback);\r\n\r\n }\r\n\r\n /**\r\n * Sends a HTTP POST request to a url with some data.\r\n */\r\n async send_http_post(url, data, callback) {\r\n\r\n Util.send_http_post(url, data, callback);\r\n\r\n }\r\n\r\n /**\r\n * Gets the current image (2D).\r\n * \r\n * TODO: Optional bounding box should be supported.\r\n * \r\n */\r\n get_image(from_canvas) {\r\n\r\n return this.framework.get_image(from_canvas);\r\n\r\n }\r\n\r\n /**\r\n * Sets the current image (2D).\r\n * \r\n */\r\n set_image(new_pixels) {\r\n\r\n return this.framework.set_image(new_pixels);\r\n\r\n }\r\n\r\n /**\r\n * Sets the current mask (2D).\r\n * \r\n */\r\n set_mask(new_mask) {\r\n\r\n return this.framework.set_mask(new_mask);\r\n\r\n }\r\n\r\n /**\r\n * Encode raw image data to PNG.\r\n */\r\n convert_to_png(uint8array, width, height) {\r\n\r\n return this.framework.convert_to_png(uint8array, width, height);\r\n\r\n }\r\n\r\n filter(pixels, width, height, kernel) {\r\n\r\n return Util.filter(pixels, width, height, kernel);\r\n\r\n }\r\n\r\n /**\r\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\r\n * \r\n */\r\n hint(message, duration) {\r\n\r\n return Util.hint(message, duration);\r\n\r\n }\r\n\r\n}\r\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,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AAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n // this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 })\n\n // let element = this.instance.getEnabledElements()[0];\n // let canvas = element.canvas;\n\n // canvas.onmouseup = function() {\n\n // let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n // let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n // let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n // let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n // let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright);\n\n // this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi');\n // this.instance.renderGrayscaleImage(element, true);\n\n // callback(topleft_c, bottomright_c);\n\n // }.bind(this);\n\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n // BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n // console.log(\"Inside Draggable BBox\",topleft, bottomright);\n // callback(topleft, bottomright);\n // });\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n\n // TODO also hacky until official API supports this\n\n // let canvas = this.instance.canvas;\n\n \n // canvas.addEventListener('mousedown', function (e) {\n // this.isMouseDown = true;\n\n // var rect = e.currentTarget.getBoundingClientRect(),\n // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\n // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n // this.x1 = offsetX;\n // this.y1 = offsetY;\n // }.bind(this));\n\n // canvas.addEventListener('mousemove', function (e) {\n // if (this.isMouseDown) {\n\n // var rect = e.currentTarget.getBoundingClientRect(),\n // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\n // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n // this.x2 = offsetX;\n // this.y2 = offsetY;\n // this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]);\n // }\n // }.bind(this));\n\n\n // canvas.addEventListener('mouseup', function (e) {\n // var rect = e.currentTarget.getBoundingClientRect(),\n // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\n // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n \n // this.x2 = offsetX;\n // this.y2 = offsetY;\n // this.isMouseDown = false;\n\n // let topleft = {x: this.x1, y: this.y1};\n // let bottomright = {x: this.x2, y: this.y2};\n\n // callback(topleft, bottomright);\n\n // }.bind(this));\n\n\n\n\n // return this.canvasFallback.select_box(callback);\n\n \n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let canvas = this.instance.canvas;\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n \n // Boostlet.hint(\"Click on top left and bottom right coordinated of the desired selection box.\")\n\n // let isFirstClick = true;\n // let x1, y1, x2, y2;\n \n // // Function to handle the mouse click event\n // function handleClick(event) {\n // if (isFirstClick) {\n // // Capture x1 and y1 on the first click\n // x1 = event.clientX;\n // y1 = event.clientY;\n // console.log(`First click: (X1: ${x1}, Y1: ${y1})`);\n // isFirstClick = false;\n // } else {\n // // Capture x2 and y2 on the second click\n // x2 = event.clientX;\n // y2 = event.clientY;\n // console.log(`Second click: (X2: ${x2}, Y2: ${y2})`);\n // isFirstClick = true;\n\n // let topleft = {x: x1, y: y1};\n // let bottomright = {x: x2, y: y2};\n\n // callback(topleft, bottomright);\n // }\n\n // // let topleft = {x: 529, y: 480};\n // // let bottomright = {x: 667, y: 588};\n // // callback(topleft, bottomright);\n\n // }\n \n // // Add a click event listener to the document\n // document.addEventListener(\"click\", handleClick);\n\n\n\n // return this.canvasFallback.select_box(callback);\n\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/examples/segmentanything.js b/examples/segmentanything.js index 0c9f93bc..cb9b011c 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -1,10 +1,50 @@ -script = document.createElement("script"); -script.type = "text/javascript"; -script.src = "https://boostlet.org/dist/boostlet.min.js"; +// script = document.createElement("script"); +// script.type = "text/javascript"; +// // script.src = "https://boostlet.org/dist/boostlet.min.js"; +// script.src = "http://localhost:8000/dist/boostlet.min.js"; + +// script.onload = run; +// document.head.appendChild(script); +// eval(script); + + +let boostletLoaded = false; +let boxCraftLoaded = false; + +function tryRun() { + if (boostletLoaded && boxCraftLoaded) { + run(); + + } +} + +// Load Boostlet script +let scriptBoostlet = document.createElement("script"); +scriptBoostlet.type = "text/javascript"; +// scriptBoostlet.src = "https://boostlet.org/dist/boostlet.min.js"; +scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; +// scriptBoostlet.src = "http://localhost:8000/dist/boostlet.min.js"; +scriptBoostlet.onload = function() { + boostletLoaded = true; + tryRun(); +}; + +// scriptBoostlet.onload = run; + +document.head.appendChild(scriptBoostlet); + +// Load BoxCraft script +let scriptBoxCraft = document.createElement("script"); +scriptBoxCraft.type = "text/javascript"; +scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; +// scriptBoxCraft.src = "http://localhost:8888/dist/boxcraft.min.js"; +scriptBoxCraft.onload = function() { + boxCraftLoaded = true; + tryRun(); +}; +document.head.appendChild(scriptBoxCraft); + -script.onload = run; -document.head.appendChild(script); -eval(script); function run() { diff --git a/index.html b/index.html index 8c51c450..2c23d711 100644 --- a/index.html +++ b/index.html @@ -232,9 +232,11 @@ var examples = ['sobel.js', 'segmentanything.js', 'imageCaptioning.js', 'plotly.js', 'trako.js', 'melanoma.js']; - var baseurl = 'https://raw.githubusercontent.com/mpsych/boostlet/main/examples/'; + // var baseurl = 'https://raw.githubusercontent.com/mpsych/boostlet/main/examples/'; // var baseurl = 'https://raw.githubusercontent.com/gaiborjosue/boostlet/melanoma/examples/'; // var baseurl = 'http://localhost:5500/examples/'; + // var baseurl = 'http://localhost:8000/examples/'; + var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/development/examples/'; for (e in examples) { diff --git a/src/frameworks/cornerstone2d.js b/src/frameworks/cornerstone2d.js index 73a1279d..4d9112e0 100644 --- a/src/frameworks/cornerstone2d.js +++ b/src/frameworks/cornerstone2d.js @@ -81,27 +81,77 @@ export class Cornerstone2D extends Framework { select_box(callback) { - this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 }) + // this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 }) - let element = this.instance.getEnabledElements()[0]; - let canvas = element.canvas; + // let element = this.instance.getEnabledElements()[0]; + // let canvas = element.canvas; + + // canvas.onmouseup = function() { + + // let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); - canvas.onmouseup = function() { + // let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; + // let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; - let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); + // let topleft_c = this.instance.pixelToCanvas(element.element, topleft); + // let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); - let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; - let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; + // this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi'); + // this.instance.renderGrayscaleImage(element, true); - let topleft_c = this.instance.pixelToCanvas(element.element, topleft); - let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); + // callback(topleft_c, bottomright_c); - this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi'); - this.instance.renderGrayscaleImage(element, true); + // }.bind(this); + + + if(this.cornerstonetools_instance.RectangleRoiTool === undefined) { + console.log("Using Boxcraft library to handle box selection."); + let element = this.instance.getEnabledElements()[0]; + let canvas = element.canvas; + // Disable the Wwwc tool + cornerstoneTools.setToolDisabled("Wwwc"); - callback(topleft_c, bottomright_c); + BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) { + callback(topleft, bottomright); + }); - }.bind(this); + // BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) { + // console.log("Inside Draggable BBox",topleft, bottomright); + // callback(topleft, bottomright); + // }); + } + else{ + console.log("Using Cornerstonetools to handle box selection."); + this.cornerstonetools_instance.setToolActive("RectangleRoi", { + mouseButtonMask: 1, + }); + + let element = this.instance.getEnabledElements()[0]; + let canvas = element.canvas; + + canvas.onmouseup = function () { + let state = + this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); + + let topleft = + state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; + let bottomright = + state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; + + let topleft_c = this.instance.pixelToCanvas(element.element, topleft); + let bottomright_c = this.instance.pixelToCanvas( + element.element, + bottomright + ); + + this.cornerstonetools_instance.clearToolState( + element.element, + "RectangleRoi" + ); + this.instance.renderGrayscaleImage(element, true); + callback(topleft_c, bottomright_c); + }.bind(this); + } } diff --git a/src/frameworks/niivue.js b/src/frameworks/niivue.js index fcd1fb0f..ff71dc9e 100644 --- a/src/frameworks/niivue.js +++ b/src/frameworks/niivue.js @@ -1,6 +1,7 @@ import {Framework} from '../framework.js'; import {Util} from '../util.js'; +import {CanvasFallback} from './canvasFallback.js'; export class NiiVue extends Framework { @@ -8,6 +9,7 @@ export class NiiVue extends Framework { super(instance); this.name = 'niivue'; + this.canvasFallback = new CanvasFallback(); this.flip_on_png = true; @@ -184,49 +186,62 @@ export class NiiVue extends Framework { // TODO also hacky until official API supports this - let canvas = this.instance.canvas; + // let canvas = this.instance.canvas; - canvas.addEventListener('mousedown', function (e) { - this.isMouseDown = true; + // canvas.addEventListener('mousedown', function (e) { + // this.isMouseDown = true; - var rect = e.currentTarget.getBoundingClientRect(), - offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + // var rect = e.currentTarget.getBoundingClientRect(), + // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, + // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - this.x1 = offsetX; - this.y1 = offsetY; - }.bind(this)); + // this.x1 = offsetX; + // this.y1 = offsetY; + // }.bind(this)); - canvas.addEventListener('mousemove', function (e) { - if (this.isMouseDown) { + // canvas.addEventListener('mousemove', function (e) { + // if (this.isMouseDown) { - var rect = e.currentTarget.getBoundingClientRect(), - offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + // var rect = e.currentTarget.getBoundingClientRect(), + // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, + // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - this.x2 = offsetX; - this.y2 = offsetY; - this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]); - } - }.bind(this)); + // this.x2 = offsetX; + // this.y2 = offsetY; + // this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]); + // } + // }.bind(this)); - canvas.addEventListener('mouseup', function (e) { - var rect = e.currentTarget.getBoundingClientRect(), - offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + // canvas.addEventListener('mouseup', function (e) { + // var rect = e.currentTarget.getBoundingClientRect(), + // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, + // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - this.x2 = offsetX; - this.y2 = offsetY; - this.isMouseDown = false; + // this.x2 = offsetX; + // this.y2 = offsetY; + // this.isMouseDown = false; + + // let topleft = {x: this.x1, y: this.y1}; + // let bottomright = {x: this.x2, y: this.y2}; + + // callback(topleft, bottomright); + + // }.bind(this)); + - let topleft = {x: this.x1, y: this.y1}; - let bottomright = {x: this.x2, y: this.y2}; - callback(topleft, bottomright); - }.bind(this)); + // return this.canvasFallback.select_box(callback); + + + + console.log("Using Boxcraft library to handle box selection."); + let canvas = this.instance.canvas; + BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) { + callback(topleft, bottomright); + }); } diff --git a/src/frameworks/openseadragon.js b/src/frameworks/openseadragon.js index 4b116056..e118f83e 100644 --- a/src/frameworks/openseadragon.js +++ b/src/frameworks/openseadragon.js @@ -21,45 +21,93 @@ export class OpenSeaDragon extends Framework { } set_mask(new_mask) { - return this.canvasFallback.set_mask(new_mask); + // return this.canvasFallback.set_mask(new_mask); + + let viewer = null; + let vs = this.instance._viewers; + vs.forEach(function (e) { + if (e.id == "viewer") { + viewer = e; + } + }); + + if (!viewer) { + throw "OpenSeaDragon viewer not found."; + } + + let canvas = viewer.canvas.children[0]; + width = canvas.width; + height = canvas.height; + + let ctx = canvas.getContext("2d"); + let imagedata = ctx.getImageData(0, 0, width, height); + let pixels = imagedata.data; + + let masked_image = Util.harden_mask(pixels, new_mask); + let masked_image_as_imagedata = new ImageData(masked_image, width, height); + ctx.putImageData(masked_image_as_imagedata, 0, 0); } select_box(callback) { - Boostlet.hint("Click on top left and bottom right coordinated of the desired selection box.") + // Boostlet.hint("Click on top left and bottom right coordinated of the desired selection box.") - let isFirstClick = true; - let x1, y1, x2, y2; + // let isFirstClick = true; + // let x1, y1, x2, y2; - // Function to handle the mouse click event - function handleClick(event) { - if (isFirstClick) { - // Capture x1 and y1 on the first click - x1 = event.clientX; - y1 = event.clientY; - console.log(`First click: (X1: ${x1}, Y1: ${y1})`); - isFirstClick = false; - } else { - // Capture x2 and y2 on the second click - x2 = event.clientX; - y2 = event.clientY; - console.log(`Second click: (X2: ${x2}, Y2: ${y2})`); - isFirstClick = true; - - let topleft = {x: x1, y: y1}; - let bottomright = {x: x2, y: y2}; - - callback(topleft, bottomright); - } + // // Function to handle the mouse click event + // function handleClick(event) { + // if (isFirstClick) { + // // Capture x1 and y1 on the first click + // x1 = event.clientX; + // y1 = event.clientY; + // console.log(`First click: (X1: ${x1}, Y1: ${y1})`); + // isFirstClick = false; + // } else { + // // Capture x2 and y2 on the second click + // x2 = event.clientX; + // y2 = event.clientY; + // console.log(`Second click: (X2: ${x2}, Y2: ${y2})`); + // isFirstClick = true; + + // let topleft = {x: x1, y: y1}; + // let bottomright = {x: x2, y: y2}; + + // callback(topleft, bottomright); + // } + + // // let topleft = {x: 529, y: 480}; + // // let bottomright = {x: 667, y: 588}; + // // callback(topleft, bottomright); + + // } + + // // Add a click event listener to the document + // document.addEventListener("click", handleClick); - // let topleft = {x: 529, y: 480}; - // let bottomright = {x: 667, y: 588}; - // callback(topleft, bottomright); + + // return this.canvasFallback.select_box(callback); + + + console.log("Using Boxcraft library to handle box selection."); + let viewer = null; + let vs = this.instance._viewers; + vs.forEach(function (e) { + if (e.id == "viewer") { + viewer = e; } - - // Add a click event listener to the document - document.addEventListener("click", handleClick); + }); + + if (!viewer) { + throw "OpenSeaDragon viewer not found."; + } + + let canvas = viewer.canvas; + + BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) { + callback(topleft, bottomright); + }); } From 6036c838f0204ac867ae1ad8a75e3795fee6c7f9 Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Sat, 30 Mar 2024 00:46:31 -0400 Subject: [PATCH 02/12] Partially working canvas fallback --- dist/boostlet.min.js | 88 +++----------------------------- dist/boostlet.min.js.map | 2 +- src/frameworks/canvasFallback.js | 1 + src/frameworks/cornerstone2d.js | 37 ++++---------- src/frameworks/niivue.js | 60 +--------------------- src/frameworks/openseadragon.js | 74 ++++++--------------------- src/frameworks/xtk.js | 3 +- 7 files changed, 36 insertions(+), 229 deletions(-) diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index 013e28da..44c14f26 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -303,19 +303,6 @@ class $febea0d4681e2ae0$export$1ec7e9f19103cb25 extends (0, $bsgU1.Framework) { return this.canvasFallback.set_mask(new_mask); } select_box(callback) { - // this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 }) - // let element = this.instance.getEnabledElements()[0]; - // let canvas = element.canvas; - // canvas.onmouseup = function() { - // let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); - // let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; - // let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; - // let topleft_c = this.instance.pixelToCanvas(element.element, topleft); - // let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); - // this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi'); - // this.instance.renderGrayscaleImage(element, true); - // callback(topleft_c, bottomright_c); - // }.bind(this); if (this.cornerstonetools_instance.RectangleRoiTool === undefined) { console.log("Using Boxcraft library to handle box selection."); let element = this.instance.getEnabledElements()[0]; @@ -325,10 +312,11 @@ class $febea0d4681e2ae0$export$1ec7e9f19103cb25 extends (0, $bsgU1.Framework) { BoxCraft.createDraggableBBox(canvas, function(topleft, bottomright) { callback(topleft, bottomright); }); - // BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) { - // console.log("Inside Draggable BBox",topleft, bottomright); - // callback(topleft, bottomright); - // }); + BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) { + console.log("Inside Draggable BBox", topleft, bottomright); + callback(topleft, bottomright); + }); + // return this.canvasFallback.select_box(callback); } else { console.log("Using Cornerstonetools to handle box selection."); this.cornerstonetools_instance.setToolActive("RectangleRoi", { @@ -565,43 +553,7 @@ class $fbafa14c3ac31938$export$3d6843c2c4a1bd6c extends (0, $bsgU1.Framework) { this.set_image(masked_image, true, true); // rgba data, no flip } select_box(callback) { - // TODO also hacky until official API supports this - // let canvas = this.instance.canvas; - // canvas.addEventListener('mousedown', function (e) { - // this.isMouseDown = true; - // var rect = e.currentTarget.getBoundingClientRect(), - // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - // this.x1 = offsetX; - // this.y1 = offsetY; - // }.bind(this)); - // canvas.addEventListener('mousemove', function (e) { - // if (this.isMouseDown) { - // var rect = e.currentTarget.getBoundingClientRect(), - // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - // this.x2 = offsetX; - // this.y2 = offsetY; - // this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]); - // } - // }.bind(this)); - // canvas.addEventListener('mouseup', function (e) { - // var rect = e.currentTarget.getBoundingClientRect(), - // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - // this.x2 = offsetX; - // this.y2 = offsetY; - // this.isMouseDown = false; - // let topleft = {x: this.x1, y: this.y1}; - // let bottomright = {x: this.x2, y: this.y2}; - // callback(topleft, bottomright); - // }.bind(this)); - // return this.canvasFallback.select_box(callback); - console.log("Using Boxcraft library to handle box selection."); - let canvas = this.instance.canvas; - BoxCraft.createDraggableBBox(canvas, function(topleft, bottomright) { - callback(topleft, bottomright); - }); + return this.canvasFallback.select_box(callback); } } @@ -647,34 +599,6 @@ class $5bc2ced335fcdbf6$export$ac966f05fb2ad3 extends (0, $bsgU1.Framework) { ctx.putImageData(masked_image_as_imagedata, 0, 0); } select_box(callback) { - // Boostlet.hint("Click on top left and bottom right coordinated of the desired selection box.") - // let isFirstClick = true; - // let x1, y1, x2, y2; - // // Function to handle the mouse click event - // function handleClick(event) { - // if (isFirstClick) { - // // Capture x1 and y1 on the first click - // x1 = event.clientX; - // y1 = event.clientY; - // console.log(`First click: (X1: ${x1}, Y1: ${y1})`); - // isFirstClick = false; - // } else { - // // Capture x2 and y2 on the second click - // x2 = event.clientX; - // y2 = event.clientY; - // console.log(`Second click: (X2: ${x2}, Y2: ${y2})`); - // isFirstClick = true; - // let topleft = {x: x1, y: y1}; - // let bottomright = {x: x2, y: y2}; - // callback(topleft, bottomright); - // } - // // let topleft = {x: 529, y: 480}; - // // let bottomright = {x: 667, y: 588}; - // // callback(topleft, bottomright); - // } - // // Add a click event listener to the document - // document.addEventListener("click", handleClick); - // return this.canvasFallback.select_box(callback); console.log("Using Boxcraft library to handle box selection."); let viewer = null; let vs = this.instance._viewers; diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index fff3d30d..4cb5c7da 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CA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C,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n // this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 })\n\n // let element = this.instance.getEnabledElements()[0];\n // let canvas = element.canvas;\n\n // canvas.onmouseup = function() {\n\n // let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n // let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n // let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n // let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n // let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright);\n\n // this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi');\n // this.instance.renderGrayscaleImage(element, true);\n\n // callback(topleft_c, bottomright_c);\n\n // }.bind(this);\n\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n // BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n // console.log(\"Inside Draggable BBox\",topleft, bottomright);\n // callback(topleft, bottomright);\n // });\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n\n // TODO also hacky until official API supports this\n\n // let canvas = this.instance.canvas;\n\n \n // canvas.addEventListener('mousedown', function (e) {\n // this.isMouseDown = true;\n\n // var rect = e.currentTarget.getBoundingClientRect(),\n // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\n // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n // this.x1 = offsetX;\n // this.y1 = offsetY;\n // }.bind(this));\n\n // canvas.addEventListener('mousemove', function (e) {\n // if (this.isMouseDown) {\n\n // var rect = e.currentTarget.getBoundingClientRect(),\n // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\n // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n // this.x2 = offsetX;\n // this.y2 = offsetY;\n // this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]);\n // }\n // }.bind(this));\n\n\n // canvas.addEventListener('mouseup', function (e) {\n // var rect = e.currentTarget.getBoundingClientRect(),\n // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio,\n // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n \n // this.x2 = offsetX;\n // this.y2 = offsetY;\n // this.isMouseDown = false;\n\n // let topleft = {x: this.x1, y: this.y1};\n // let bottomright = {x: this.x2, y: this.y2};\n\n // callback(topleft, bottomright);\n\n // }.bind(this));\n\n\n\n\n // return this.canvasFallback.select_box(callback);\n\n \n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let canvas = this.instance.canvas;\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n \n // Boostlet.hint(\"Click on top left and bottom right coordinated of the desired selection box.\")\n\n // let isFirstClick = true;\n // let x1, y1, x2, y2;\n \n // // Function to handle the mouse click event\n // function handleClick(event) {\n // if (isFirstClick) {\n // // Capture x1 and y1 on the first click\n // x1 = event.clientX;\n // y1 = event.clientY;\n // console.log(`First click: (X1: ${x1}, Y1: ${y1})`);\n // isFirstClick = false;\n // } else {\n // // Capture x2 and y2 on the second click\n // x2 = event.clientX;\n // y2 = event.clientY;\n // console.log(`Second click: (X2: ${x2}, Y2: ${y2})`);\n // isFirstClick = true;\n\n // let topleft = {x: x1, y: y1};\n // let bottomright = {x: x2, y: y2};\n\n // callback(topleft, bottomright);\n // }\n\n // // let topleft = {x: 529, y: 480};\n // // let bottomright = {x: 667, y: 588};\n // // callback(topleft, bottomright);\n\n // }\n \n // // Add a click event listener to the document\n // document.addEventListener(\"click\", handleClick);\n\n\n\n // return this.canvasFallback.select_box(callback);\n\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC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GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/src/frameworks/canvasFallback.js b/src/frameworks/canvasFallback.js index 7efbf2b8..16933e48 100644 --- a/src/frameworks/canvasFallback.js +++ b/src/frameworks/canvasFallback.js @@ -3,6 +3,7 @@ import { Framework } from "../framework.js"; import { Util } from "../util.js"; + export class CanvasFallback extends Framework { constructor() { super(); diff --git a/src/frameworks/cornerstone2d.js b/src/frameworks/cornerstone2d.js index 4d9112e0..b11c2a43 100644 --- a/src/frameworks/cornerstone2d.js +++ b/src/frameworks/cornerstone2d.js @@ -74,40 +74,17 @@ export class Cornerstone2D extends Framework { } set_mask(new_mask) { - return this.canvasFallback.set_mask(new_mask); } select_box(callback) { - // this.cornerstonetools_instance.setToolActive('RectangleRoi', { mouseButtonMask: 1 }) - - // let element = this.instance.getEnabledElements()[0]; - // let canvas = element.canvas; - - // canvas.onmouseup = function() { - - // let state = this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState(); - - // let topleft = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start; - // let bottomright = state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end; - - // let topleft_c = this.instance.pixelToCanvas(element.element, topleft); - // let bottomright_c = this.instance.pixelToCanvas(element.element, bottomright); - - // this.cornerstonetools_instance.clearToolState(element.element, 'RectangleRoi'); - // this.instance.renderGrayscaleImage(element, true); - - // callback(topleft_c, bottomright_c); - - // }.bind(this); - - if(this.cornerstonetools_instance.RectangleRoiTool === undefined) { console.log("Using Boxcraft library to handle box selection."); let element = this.instance.getEnabledElements()[0]; let canvas = element.canvas; + // Disable the Wwwc tool cornerstoneTools.setToolDisabled("Wwwc"); @@ -115,10 +92,14 @@ export class Cornerstone2D extends Framework { callback(topleft, bottomright); }); - // BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) { - // console.log("Inside Draggable BBox",topleft, bottomright); - // callback(topleft, bottomright); - // }); + BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) { + console.log("Inside Draggable BBox",topleft, bottomright); + callback(topleft, bottomright); + }); + + // return this.canvasFallback.select_box(callback); + + } else{ console.log("Using Cornerstonetools to handle box selection."); diff --git a/src/frameworks/niivue.js b/src/frameworks/niivue.js index ff71dc9e..598eefe7 100644 --- a/src/frameworks/niivue.js +++ b/src/frameworks/niivue.js @@ -183,65 +183,7 @@ export class NiiVue extends Framework { } select_box(callback) { - - // TODO also hacky until official API supports this - - // let canvas = this.instance.canvas; - - - // canvas.addEventListener('mousedown', function (e) { - // this.isMouseDown = true; - - // var rect = e.currentTarget.getBoundingClientRect(), - // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - - // this.x1 = offsetX; - // this.y1 = offsetY; - // }.bind(this)); - - // canvas.addEventListener('mousemove', function (e) { - // if (this.isMouseDown) { - - // var rect = e.currentTarget.getBoundingClientRect(), - // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - - // this.x2 = offsetX; - // this.y2 = offsetY; - // this.instance.drawSelectionBox([this.x1, this.y1, this.x2-this.x1, this.y2-this.y1]); - // } - // }.bind(this)); - - - // canvas.addEventListener('mouseup', function (e) { - // var rect = e.currentTarget.getBoundingClientRect(), - // offsetX = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio, - // offsetY = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; - - // this.x2 = offsetX; - // this.y2 = offsetY; - // this.isMouseDown = false; - - // let topleft = {x: this.x1, y: this.y1}; - // let bottomright = {x: this.x2, y: this.y2}; - - // callback(topleft, bottomright); - - // }.bind(this)); - - - - - // return this.canvasFallback.select_box(callback); - - - - console.log("Using Boxcraft library to handle box selection."); - let canvas = this.instance.canvas; - BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) { - callback(topleft, bottomright); - }); + return this.canvasFallback.select_box(callback); } diff --git a/src/frameworks/openseadragon.js b/src/frameworks/openseadragon.js index e118f83e..36af1b56 100644 --- a/src/frameworks/openseadragon.js +++ b/src/frameworks/openseadragon.js @@ -26,13 +26,13 @@ export class OpenSeaDragon extends Framework { let viewer = null; let vs = this.instance._viewers; vs.forEach(function (e) { - if (e.id == "viewer") { + if (e.id == "viewer") { viewer = e; - } + } }); if (!viewer) { - throw "OpenSeaDragon viewer not found."; + throw "OpenSeaDragon viewer not found."; } let canvas = viewer.canvas.children[0]; @@ -49,65 +49,25 @@ export class OpenSeaDragon extends Framework { } select_box(callback) { - - // Boostlet.hint("Click on top left and bottom right coordinated of the desired selection box.") - - // let isFirstClick = true; - // let x1, y1, x2, y2; - - // // Function to handle the mouse click event - // function handleClick(event) { - // if (isFirstClick) { - // // Capture x1 and y1 on the first click - // x1 = event.clientX; - // y1 = event.clientY; - // console.log(`First click: (X1: ${x1}, Y1: ${y1})`); - // isFirstClick = false; - // } else { - // // Capture x2 and y2 on the second click - // x2 = event.clientX; - // y2 = event.clientY; - // console.log(`Second click: (X2: ${x2}, Y2: ${y2})`); - // isFirstClick = true; - - // let topleft = {x: x1, y: y1}; - // let bottomright = {x: x2, y: y2}; - - // callback(topleft, bottomright); - // } - - // // let topleft = {x: 529, y: 480}; - // // let bottomright = {x: 667, y: 588}; - // // callback(topleft, bottomright); - - // } - - // // Add a click event listener to the document - // document.addEventListener("click", handleClick); - - - - // return this.canvasFallback.select_box(callback); + console.log("Using Boxcraft library to handle box selection."); + let viewer = null; + let vs = this.instance._viewers; + vs.forEach(function (e) { + if (e.id == "viewer") { + viewer = e; + } + }); - console.log("Using Boxcraft library to handle box selection."); - let viewer = null; - let vs = this.instance._viewers; - vs.forEach(function (e) { - if (e.id == "viewer") { - viewer = e; + if (!viewer) { + throw "OpenSeaDragon viewer not found."; } - }); - - if (!viewer) { - throw "OpenSeaDragon viewer not found."; - } - let canvas = viewer.canvas; + let canvas = viewer.canvas; - BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) { - callback(topleft, bottomright); - }); + BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) { + callback(topleft, bottomright); + }); } diff --git a/src/frameworks/xtk.js b/src/frameworks/xtk.js index a5bc591d..3c00b676 100644 --- a/src/frameworks/xtk.js +++ b/src/frameworks/xtk.js @@ -9,7 +9,6 @@ export class Xtk extends Framework { super(instance); this.name = "xtk"; this.canvasFallback = new CanvasFallback(); - } get_image(from_canvas) { @@ -27,4 +26,4 @@ export class Xtk extends Framework { select_box(callback) { return this.canvasFallback.select_box(callback); } -} \ No newline at end of file +} From d37908479c8235f597c2b3bee5016dbee4ce5ef5 Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Tue, 9 Apr 2024 14:24:23 -0400 Subject: [PATCH 03/12] Added submodules with boxcraft and canvas fallback --- .gitmodules | 3 +++ dist/boostlet.min.js | 3 ++- dist/boostlet.min.js.map | 2 +- examples/segmentanything.js | 19 +++++-------------- index.html | 2 +- package.json | 4 +++- src/frameworks/canvasFallback.js | 3 ++- submodule/BoxCraft | 1 + 8 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 .gitmodules create mode 160000 submodule/BoxCraft diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..3a87344f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "submodule/BoxCraft"] + path = submodule/BoxCraft + url = git@github.com:shrutivarade/BoxCraft.git diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index 44c14f26..1201e95d 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -418,8 +418,9 @@ class $0fabd2f4a96087f5$export$48eecc33595f906d extends (0, $bsgU1.Framework) { select_box(callback) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; - scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; + // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; // scriptBoxCraft.src = "http://localhost:8888/dist/boxcraft.min.js"; + scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); scriptBoxCraft.onload = function() { diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index 4cb5c7da..f7b83a13 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IA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AAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,UAAU,UAAU,EAAE;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,YAAY,IAAI,CAAA,GAAA,qBAAa;QAE/B;QAEA,OAAO;IAET;IAEA,aAAa,YAAY,GAAG,EAAE,QAAQ,EAAE;QAEtC,iDAAiD;QACjD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,SAAS,EAAE,UAAU;YAC9D;gBACE,OAAO;YACT;YACA,KAAI,SAAS;gBACX,aAAa;YACf;QACF;QAEA,MAAM,SAAS,OAAO,QAAQ,CAAC,aAAa,CAAC;QAC7C,OAA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AY,OAAO,EAAE;QAEzB,MAAM;IAER;IAEA;;GAEC,GACD,MAAM,YAAY,GAAG,EAAE,QAAQ,EAAE;QAE/B,CAAA,GAAA,WAAG,EAAE,WAAW,CAAC,KAAK;IAExB;IAEA;;GAEC,GACD,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;QAExC,CAAA,GAAA,WAAG,EAAE,cAAc,CAAC,KAAK,MAAM;IAEjC;IAEA;;;;;GAKC,GACD,UAAU,WAAW,EAAE;QAErB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,UAAU,UAAU,EAAE;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\n scriptBoxCraft.src = \"http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/examples/segmentanything.js b/examples/segmentanything.js index cb9b011c..8f82305d 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -1,13 +1,3 @@ -// script = document.createElement("script"); -// script.type = "text/javascript"; -// // script.src = "https://boostlet.org/dist/boostlet.min.js"; -// script.src = "http://localhost:8000/dist/boostlet.min.js"; - -// script.onload = run; -// document.head.appendChild(script); -// eval(script); - - let boostletLoaded = false; let boxCraftLoaded = false; @@ -22,8 +12,8 @@ function tryRun() { let scriptBoostlet = document.createElement("script"); scriptBoostlet.type = "text/javascript"; // scriptBoostlet.src = "https://boostlet.org/dist/boostlet.min.js"; -scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; -// scriptBoostlet.src = "http://localhost:8000/dist/boostlet.min.js"; +// scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; +scriptBoostlet.src = "http://localhost:8000/dist/boostlet.min.js"; scriptBoostlet.onload = function() { boostletLoaded = true; tryRun(); @@ -36,8 +26,9 @@ document.head.appendChild(scriptBoostlet); // Load BoxCraft script let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; -scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; -// scriptBoxCraft.src = "http://localhost:8888/dist/boxcraft.min.js"; +// scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; +// scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; +scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; scriptBoxCraft.onload = function() { boxCraftLoaded = true; tryRun(); diff --git a/index.html b/index.html index 2c23d711..189f55b1 100644 --- a/index.html +++ b/index.html @@ -236,7 +236,7 @@ // var baseurl = 'https://raw.githubusercontent.com/gaiborjosue/boostlet/melanoma/examples/'; // var baseurl = 'http://localhost:5500/examples/'; // var baseurl = 'http://localhost:8000/examples/'; - var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/development/examples/'; + var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/main/examples/'; for (e in examples) { diff --git a/package.json b/package.json index c5ff1952..304f4c0f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "dist/boostlet.min.js", "scripts": { "dev": "npx live-server --port=5501 --no-browser", - "test": "node --experimental-modules ./tests/scripts/index.js" + "test": "node --experimental-modules ./tests/scripts/index.js", + "build-boxcraft": "npx parcel build submodule/BoxCraft/src/index.js --dist-dir ./dist/BoxCraft", + "build": "npx parcel build src/index.js && npm run build-boxcraft" }, "devDependencies": { "cross-env": "^7.0.3", diff --git a/src/frameworks/canvasFallback.js b/src/frameworks/canvasFallback.js index 16933e48..2a84f52b 100644 --- a/src/frameworks/canvasFallback.js +++ b/src/frameworks/canvasFallback.js @@ -115,8 +115,9 @@ export class CanvasFallback extends Framework { select_box(callback) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; - scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; + // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; // scriptBoxCraft.src = "http://localhost:8888/dist/boxcraft.min.js"; + scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); diff --git a/submodule/BoxCraft b/submodule/BoxCraft new file mode 160000 index 00000000..549e7b20 --- /dev/null +++ b/submodule/BoxCraft @@ -0,0 +1 @@ +Subproject commit 549e7b2056bd13e746e48149e099f0d64b554e75 From 83b09445c54f7ed3a0a0a0490ade3f2709ebaa2b Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Tue, 9 Apr 2024 14:33:13 -0400 Subject: [PATCH 04/12] url change --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 189f55b1..4680cd0a 100644 --- a/index.html +++ b/index.html @@ -236,7 +236,7 @@ // var baseurl = 'https://raw.githubusercontent.com/gaiborjosue/boostlet/melanoma/examples/'; // var baseurl = 'http://localhost:5500/examples/'; // var baseurl = 'http://localhost:8000/examples/'; - var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/main/examples/'; + var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/canvasFallback_boxcraft_submodules/examples/'; for (e in examples) { From 0ab148c93f49f07b0b8c433c938b46f4dc112632 Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Tue, 9 Apr 2024 14:39:21 -0400 Subject: [PATCH 05/12] url change --- examples/segmentanything.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/segmentanything.js b/examples/segmentanything.js index 8f82305d..74f4572e 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -12,8 +12,8 @@ function tryRun() { let scriptBoostlet = document.createElement("script"); scriptBoostlet.type = "text/javascript"; // scriptBoostlet.src = "https://boostlet.org/dist/boostlet.min.js"; -// scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; -scriptBoostlet.src = "http://localhost:8000/dist/boostlet.min.js"; +scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; +// scriptBoostlet.src = "http://localhost:8000/dist/boostlet.min.js"; scriptBoostlet.onload = function() { boostletLoaded = true; tryRun(); From d67dce097dda9c093a155748657c33d0e27cc56c Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Wed, 10 Apr 2024 22:24:03 -0400 Subject: [PATCH 06/12] url changes --- dist/boostlet.min.js | 4 ++-- dist/boostlet.min.js.map | 2 +- examples/segmentanything.js | 2 +- src/frameworks/canvasFallback.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index 1201e95d..3eb4ec1d 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -419,8 +419,8 @@ class $0fabd2f4a96087f5$export$48eecc33595f906d extends (0, $bsgU1.Framework) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; - // scriptBoxCraft.src = "http://localhost:8888/dist/boxcraft.min.js"; - scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; + scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; + // scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); scriptBoxCraft.onload = function() { diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index f7b83a13..1ee78cdc 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;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G,EAAE,cAAc,CAAC,KAAK,MAAM;IAEjC;IAEA;;;;;GAKC,GACD,UAAU,WAAW,EAAE;QAErB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,UAAU,UAAU,EAAE;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8888/dist/boxcraft.min.js\";\n scriptBoxCraft.src = \"http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,YAAY,IAAI,CAAA,GAAA,qBAAa;QAE/B;QAEA,OAAO;IAET;IAEA,aAAa,YAAY,GAAG,EAAE,QAAQ,EAAE;QAEtC,iDAAiD;QACjD,OAAO,MAAM,CAAC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","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/examples/segmentanything.js b/examples/segmentanything.js index 74f4572e..fe6c4b7d 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -27,8 +27,8 @@ document.head.appendChild(scriptBoostlet); let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; -// scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; +// scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; scriptBoxCraft.onload = function() { boxCraftLoaded = true; tryRun(); diff --git a/src/frameworks/canvasFallback.js b/src/frameworks/canvasFallback.js index 2a84f52b..95919b22 100644 --- a/src/frameworks/canvasFallback.js +++ b/src/frameworks/canvasFallback.js @@ -116,8 +116,8 @@ export class CanvasFallback extends Framework { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; - // scriptBoxCraft.src = "http://localhost:8888/dist/boxcraft.min.js"; - scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; + scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; + // scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); From 2adead43204f5923d1bfb85a0089ea6b80d60b1e Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Wed, 10 Apr 2024 23:08:16 -0400 Subject: [PATCH 07/12] hacky fix for submodule --- examples/segmentanything.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/segmentanything.js b/examples/segmentanything.js index fe6c4b7d..8516359e 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -27,7 +27,7 @@ document.head.appendChild(scriptBoostlet); let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; -scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; +scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; // scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; scriptBoxCraft.onload = function() { boxCraftLoaded = true; From c8755b25ba5d5035b82fca9944fa3008a7b0b017 Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Sun, 14 Apr 2024 18:38:23 -0400 Subject: [PATCH 08/12] Boxcraft.min.js added to dist --- dist/boostlet.min.js | 4 +- dist/boostlet.min.js.map | 2 +- dist/boxcraft.min.js | 301 +++++++++++++++++++++++++++++++ dist/boxcraft.min.js.map | 1 + examples/segmentanything.js | 2 +- package.json | 4 +- src/frameworks/canvasFallback.js | 4 +- 7 files changed, 310 insertions(+), 8 deletions(-) create mode 100644 dist/boxcraft.min.js create mode 100644 dist/boxcraft.min.js.map diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index 3eb4ec1d..9fc8615a 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -419,8 +419,8 @@ class $0fabd2f4a96087f5$export$48eecc33595f906d extends (0, $bsgU1.Framework) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; - scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; - // scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; + scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; + // scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); scriptBoxCraft.onload = function() { diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index 1ee78cdc..a7f2859c 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MA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,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,YAAY,IAAI,CAAA,GAAA,qBAAa;QAE/B;QAEA,OAAO;IAET;IAEA,aAAa,YAAY,GAAG,EAAE,QAAQ,EAAE;QAEtC,iDAAiD;QACjD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,SAAS,EAAE,UAAU;YAC9D;gBACE,OAAO;YACT;YACA,KAAI,SAAS;gBACX,aAAa;YACf;QACF;QAEA,MAAM,SAAS,OAAO,QAAQ,CAAC,aAA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GAEC,GACD,MAAM,YAAY,OAAO,EAAE;QAEzB,MAAM;IAER;IAEA;;GAEC,GACD,MAAM,YAAY,GAAG,EAAE,QAAQ,EAAE;QAE/B,CAAA,GAAA,WAAG,EAAE,WAAW,CAAC,KAAK;IAExB;IAEA;;GAEC,GACD,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;QAExC,CAAA,GAAA,WAAG,EAAE,cAAc,CAAC,KAAK,MAAM;IAEjC;IAEA;;;;;GAKC,GACD,UAAU,WAAW,EAAE;QAErB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,UAAU,UAAU,EAAE;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8000/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/dist/boxcraft.min.js b/dist/boxcraft.min.js new file mode 100644 index 00000000..771ddd1b --- /dev/null +++ b/dist/boxcraft.min.js @@ -0,0 +1,301 @@ +class $fca228c3af8a0080$export$a829527ff4e4114a { + constructor(element, callback){ + this.element = element; + this.callback = callback; + // Bind the 'resizeCanvas' method to the current context + this.resizeCanvas = this.resizeCanvas.bind(this); + } + init() { + // Create a new canvas element + this.overlayCanvas = document.createElement("canvas"); + // Set the dimensions of the canvas to match the base image + this.overlayCanvas.width = this.element.clientWidth; + this.overlayCanvas.height = this.element.clientHeight; + // Style the canvas to overlay the base image + this.overlayCanvas.style.position = "absolute"; + this.overlayCanvas.style.left = this.element.offsetLeft + "px"; + this.overlayCanvas.style.top = this.element.offsetTop + "px"; + this.overlayCanvas.style.zIndex = "1000"; // High value to ensure it's on top + this.ctx = this.overlayCanvas.getContext("2d"); + this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height); + // Append the overlay canvas to the same parent element as the base image + this.element.parentElement.appendChild(this.overlayCanvas); + // Add the resize event listener + window.addEventListener("resize", this.resizeCanvas); + // Call resizeCanvas initially to set the correct size from the start + this.resizeCanvas(); + } + resizeCanvas() { + // Update the canvas dimensions to match the parent element's size + this.overlayCanvas.width = this.element.clientWidth; + this.overlayCanvas.height = this.element.clientHeight; + // Update the style to reflect the new position if necessary + this.overlayCanvas.style.left = this.element.offsetLeft + "px"; + this.overlayCanvas.style.top = this.element.offsetTop + "px"; + // Clear the canvas and call the callback if any drawing is required + this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height); + if (this.callback) this.callback(); + } + hide() { + // Implement the hide functionality if needed + this.overlayCanvas.style.display = "none"; + } + show() { + // Implement the show functionality if needed + this.overlayCanvas.style.display = "block"; + } + // Make sure to remove the event listener when the widget is no longer needed + destroy() { + window.removeEventListener("resize", this.resizeCanvas); + // Perform any additional cleanup like removing the canvas if necessary + } +} + + + +class $f52c7bfdf3db710e$export$dd23631818154ff extends (0, $fca228c3af8a0080$export$a829527ff4e4114a) { + constructor(element, callback){ + super(element, callback); + this.rect = {}; + this.handleRadius = 2; + this.dragTL = this.dragBL = this.dragTR = this.dragBR = false; + this.dragWholeRect = false; + super.init(); + this.initRect(); + this.drawRectInCanvas(); + this.attachResizeListeners(); + } + initRect() { + this.rect.height = 50; + this.rect.width = 50; + // this.rect.left = (window.innerWidth - this.rect.width) / 2; + // this.rect.top = (window.innerHeight - this.rect.height) / 2; + this.rect.left = (this.element.width - this.rect.width) / 2; + this.rect.top = (this.element.height - this.rect.height) / 2; + } + drawRectInCanvas() { + var ctx = this.overlayCanvas.getContext("2d"); + ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height); + ctx.beginPath(); + ctx.lineWidth = "1"; + ctx.fillStyle = "rgba(255, 255, 255, 0.5)"; + ctx.strokeStyle = "#000000"; + ctx.rect(this.rect.left, this.rect.top, this.rect.width, this.rect.height); + ctx.fill(); + ctx.stroke(); + } + attachResizeListeners() { + this.overlayCanvas.addEventListener("mousedown", this.mouseDown.bind(this), false); + this.overlayCanvas.addEventListener("mouseup", this.mouseUp.bind(this), false); + this.overlayCanvas.addEventListener("mousemove", this.mouseMove.bind(this), false); + } + mouseDown(e) { + // ... implementation of mouseDown + let pos = this.getMousePos(e); + let mouseX = pos.x; + let mouseY = pos.y; + // 0. inside movable rectangle + if (this.checkInRect(mouseX, mouseY, this.rect)) { + this.dragWholeRect = true; + this.startX = mouseX; + this.startY = mouseY; + } else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top)) this.dragTL = true; + else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top)) this.dragTR = true; + else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) this.dragBL = true; + else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) this.dragBR = true; + this.drawRectInCanvas(); + } + // Add the rest of the helper functions like getMousePos, checkInRect, checkCloseEnough here. + getMousePos(evt) { + let clx = evt.clientX; + let cly = evt.clientY; + let boundingRect = this.element.getBoundingClientRect(); + return { + x: clx - boundingRect.left, + y: cly - boundingRect.top + }; + } + checkInRect(x, y, r) { + return x > r.left && x < r.width + r.left && y > r.top && y < r.top + r.height; + } + checkCloseEnough(p1, p2) { + return Math.abs(p1 - p2) < this.handleRadius; + } + mouseMove(e) { + let pos = this.getMousePos(e); + let mouseX = pos.x; + let mouseY = pos.y; + // Update the cursor style based on mouse position + this.updateCursorStyle(mouseX, mouseY); + if (this.dragWholeRect) { + e.preventDefault(); + e.stopPropagation(); + let dx = mouseX - this.startX; + let dy = mouseY - this.startY; + if (this.rect.left + dx > 0 && this.rect.left + dx + this.rect.width < this.overlayCanvas.width) this.rect.left += dx; + if (this.rect.top + dy > 0 && this.rect.top + dy + this.rect.height < this.overlayCanvas.height) this.rect.top += dy; + this.startX = mouseX; + this.startY = mouseY; + } else if (this.dragTL) { + e.preventDefault(); + e.stopPropagation(); + let newSide = (Math.abs(this.rect.left + this.rect.width - mouseX) + Math.abs(this.rect.height + this.rect.top - mouseY)) / 2; + if (newSide > 50) { + this.rect.left = this.rect.left + this.rect.width - newSide; + this.rect.top = this.rect.height + this.rect.top - newSide; + this.rect.width = this.rect.height = newSide; + } + } else if (this.dragTR) { + e.preventDefault(); + e.stopPropagation(); + let newSide = (Math.abs(mouseX - this.rect.left) + Math.abs(this.rect.height + this.rect.top - mouseY)) / 2; + if (newSide > 50) { + this.rect.top = this.rect.height + this.rect.top - newSide; + this.rect.width = this.rect.height = newSide; + } + } else if (this.dragBL) { + e.preventDefault(); + e.stopPropagation(); + let newSide = (Math.abs(this.rect.left + this.rect.width - mouseX) + Math.abs(this.rect.top - mouseY)) / 2; + if (newSide > 50) { + this.rect.left = this.rect.left + this.rect.width - newSide; + this.rect.width = this.rect.height = newSide; + } + } else if (this.dragBR) { + e.preventDefault(); + e.stopPropagation(); + let newSide = (Math.abs(mouseX - this.rect.left) + Math.abs(mouseY - this.rect.top)) / 2; + if (newSide > 50) this.rect.width = this.rect.height = newSide; + } + this.drawRectInCanvas(); + } + updateCursorStyle(mouseX, mouseY) { + if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top)) this.overlayCanvas.style.cursor = "nwse-resize"; // Top left corner + else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top)) this.overlayCanvas.style.cursor = "nesw-resize"; // Top right corner + else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) this.overlayCanvas.style.cursor = "nesw-resize"; // Bottom left corner + else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) this.overlayCanvas.style.cursor = "nwse-resize"; // Bottom right corner + else this.overlayCanvas.style.cursor = "default"; // Default cursor elsewhere + } + mouseUp(e) { + this.dragTL = this.dragTR = this.dragBL = this.dragBR = false; + this.dragWholeRect = false; + this.storeCoordinates(); + } + storeCoordinates() { + // ... implementation of storeCoordinates + let topleft = { + x: this.rect.left, + y: this.rect.top + }; + let bottomright = { + x: this.rect.left + this.rect.width, + y: this.rect.top + this.rect.height + }; + // console.log("Top Left:", topleft, "Bottom Right:", bottomright); + this.callback(topleft, bottomright); // Invoke the callback with the coordinates + } +} // Usage: + // Assuming `callback` is a function that handles the top-left and bottom-right coordinates + // And `element` is the canvas element to which the bounding box should be applied + // let element = document.getElementById('canvas'); + // let resizableBox = new ResizableBBox(element); + // resizableBox.init(); + + + +class $e0e05d850538fde1$export$8a7a1b898028e86c extends (0, $fca228c3af8a0080$export$a829527ff4e4114a) { + constructor(element, callback){ + super(element); + this.callback = callback; + this.isDrawing = false; + this.startX = 0; + this.startY = 0; + this.x1 = 0; + this.y1 = 0; + this.x2 = 0; + this.y2 = 0; + super.init(); + this.overlayCanvas.style.cursor = "crosshair"; // Set the cursor to crosshair + this.attachEventListeners(); + } + attachEventListeners() { + this.overlayCanvas.addEventListener("mousedown", this.mouseDown.bind(this)); + this.overlayCanvas.addEventListener("mousemove", this.mouseMove.bind(this)); + this.overlayCanvas.addEventListener("mouseup", this.mouseUp.bind(this)); + this.overlayCanvas.addEventListener("mouseout", this.mouseOut.bind(this)); + } + mouseDown(e1) { + var rect = e1.currentTarget.getBoundingClientRect(); + this.isDrawing = true; + this.x1 = e1.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio; + this.y1 = e1.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + this.startX = e1.offsetX; + this.startY = e1.offsetY; + console.log("Mouse down at:", this.x1, this.y1); + } + mouseMove(e1) { + if (!this.isDrawing) return; + this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height); // Clear canvas + let width = e1.offsetX - this.startX; + let height = e1.offsetY - this.startY; + console.log("Mouse Move at:", this.x1, this.y1); + this.ctx.strokeRect(this.startX, this.startY, width, height); + } + mouseUp(e1) { + this.isDrawing = false; + var rect = e1.currentTarget.getBoundingClientRect(); + this.x2 = e1.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio; + this.y2 = e1.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + console.log("Mouse up at: ", this.x2, this.y2); + this.storeCoordinates(); + } + mouseOut() { + if (this.isDrawing) { + // Store coordinates also when the mouse accidentally leaves the canvas + var rect = e.currentTarget.getBoundingClientRect(); + this.x2 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio; + this.y2 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio; + console.log("Mouse out at: ", this.x2, this.y2); + this.storeCoordinates(); + } + this.isDrawing = false; + } + storeCoordinates() { + let topleft = { + x: this.x1, + y: this.y1 + }; + let bottomright = { + x: this.x2, + y: this.y2 + }; + this.callback(topleft, bottomright); // Invoke the callback with the coordinates + } +} // Usage: + // Assuming `callback` is a function that handles the top-left and bottom-right coordinates + // And `element` is the canvas element to which the bounding box should be applied + // let element = document.getElementById('canvas'); + // let bbox = new BBox(element, callback); + // bbox.init(); + + +class $5018ea9c30d774e7$export$247262aa28c26769 { + constructor(){} + createResizableBBox(element, callback) { + console.log("Resizable BBox"); + return new (0, $f52c7bfdf3db710e$export$dd23631818154ff)(element, callback); + } + createDraggableBBox(element, callback) { + console.log("Draggable BBox"); + return new (0, $e0e05d850538fde1$export$8a7a1b898028e86c)(element, callback); + } +} + + + +// register global namespace with a new BoxCraft instance +window.BoxCraft = new (0, $5018ea9c30d774e7$export$247262aa28c26769)(); +window.console.log("BoxCraft VERSION 0.1-alpha"); + + +//# sourceMappingURL=boxCraft.min.js.map diff --git a/dist/boxcraft.min.js.map b/dist/boxcraft.min.js.map new file mode 100644 index 00000000..33f762bf --- /dev/null +++ b/dist/boxcraft.min.js.map @@ -0,0 +1 @@ +{"mappings":"AEAO,MAAM;IAEX,YAAY,OAAO,EAAE,QAAQ,CAAE;QAE7B,IAAI,CAAC,OAAO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AAO,gBAAgB;YACnF,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,gBAAgB,GAAG,KAAK,GAAG,GAAG,OAAO,gBAAgB;YAElF,QAAQ,GAAG,CAAC,kBAAkB,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE;YAE9C,IAAI,CAAC,gBAAgB;QACvB;QACA,IAAI,CAAC,SAAS,GAAG;IACnB;IAEA,mBAAmB;QACjB,IAAI,UAAU;YAAE,GAAG,IAAI,CAAC,EAAE;YAAE,GAAG,IAAI,CAAC,EAAE;QAAC;QACvC,IAAI,cAAc;YAAE,GAAG,IAAI,CAAC,EAAE;YAAE,GAAG,IAAI,CAAC,EAAE;QAAC;QAC3C,IAAI,CAAC,QAAQ,CAAC,SAAS,cAAc,2CAA2C;IAClF;AACF,EAEA,SAAS;CACT,2FAA2F;CAC3F,kFAAkF;CAClF,mDAAmD;CACnD,0CAA0C;CAC1C,eAAe;;;AH1FR,MAAM;IAEX,aAAc,CACd;IAEA,oBAAoB,OAAO,EAAE,QAAQ,EAAE;QACrC,QAAQ,GAAG,CAAC;QACZ,OAAO,IAAI,CAAA,GAAA,wCAAY,EAAE,SAAS;IAEpC;IAEA,oBAAoB,OAAO,EAAE,QAAQ,EAAE;QACrC,QAAQ,GAAG,CAAC;QACZ,OAAO,IAAI,CAAA,GAAA,yCAAY,EAAE,SAAS;IAEpC;AAEF;;;;ADlBA,yDAAyD;AACzD,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,yCAAO;AAE7B,OAAO,OAAO,CAAC,GAAG,CAAC","sources":["src/index.js","src/boxCraft.js","src/widget.js","src/widgets/resizableBBox.js","src/widgets/draggableBBox.js"],"sourcesContent":["import { BoxCraft } from \"./boxCraft.js\";\nimport { Widget } from \"./widget.js\";\n\n// register global namespace with a new BoxCraft instance\nwindow.BoxCraft = new BoxCraft();\n\nwindow.console.log('BoxCraft VERSION 0.1-alpha');\n\n\n\n\n\n\n\n\n","import { Widget } from \"./widget.js\";\nimport { ResizableBBox } from \"./widgets/resizableBBox.js\";\nimport { DraggableBBox } from \"./widgets/draggableBBox.js\";\n\nexport class BoxCraft {\n\n constructor() {\n }\n\n createResizableBBox(element, callback) {\n console.log(\"Resizable BBox\")\n return new ResizableBBox(element, callback);\n\n }\n\n createDraggableBBox(element, callback) {\n console.log(\"Draggable BBox\")\n return new DraggableBBox(element, callback);\n\n }\n\n}\n","export class Widget {\n\n constructor(element, callback) {\n\n this.element = element;\n this.callback = callback;\n // Bind the 'resizeCanvas' method to the current context\n this.resizeCanvas = this.resizeCanvas.bind(this);\n \n }\n\n\n init(){\n \n // Create a new canvas element\n this.overlayCanvas = document.createElement('canvas');\n // Set the dimensions of the canvas to match the base image\n this.overlayCanvas.width = this.element.clientWidth;\n this.overlayCanvas.height = this.element.clientHeight;\n\n\n // Style the canvas to overlay the base image\n this.overlayCanvas.style.position = 'absolute';\n this.overlayCanvas.style.left = this.element.offsetLeft + 'px';\n this.overlayCanvas.style.top = this.element.offsetTop + 'px';\n this.overlayCanvas.style.zIndex = '1000'; // High value to ensure it's on top\n\n this.ctx = this.overlayCanvas.getContext('2d');\n this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height);\n\n // Append the overlay canvas to the same parent element as the base image\n this.element.parentElement.appendChild(this.overlayCanvas);\n\n\n // Add the resize event listener\n window.addEventListener('resize', this.resizeCanvas);\n\n // Call resizeCanvas initially to set the correct size from the start\n this.resizeCanvas();\n\n }\n\n resizeCanvas() {\n\n \n // Update the canvas dimensions to match the parent element's size\n this.overlayCanvas.width = this.element.clientWidth;\n this.overlayCanvas.height = this.element.clientHeight;\n\n // Update the style to reflect the new position if necessary\n this.overlayCanvas.style.left = this.element.offsetLeft + 'px';\n this.overlayCanvas.style.top = this.element.offsetTop + 'px';\n\n // Clear the canvas and call the callback if any drawing is required\n this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height);\n if (this.callback) {\n this.callback();\n }\n }\n\n hide() {\n // Implement the hide functionality if needed\n this.overlayCanvas.style.display = 'none';\n }\n\n show() {\n // Implement the show functionality if needed\n this.overlayCanvas.style.display = 'block';\n }\n\n // Make sure to remove the event listener when the widget is no longer needed\n destroy() {\n window.removeEventListener('resize', this.resizeCanvas);\n // Perform any additional cleanup like removing the canvas if necessary\n }\n\n}\n","import { Widget } from \"../widget.js\";\n\nexport class ResizableBBox extends Widget {\n\n constructor(element, callback) {\n super(element, callback);\n \n this.rect = {};\n this.handleRadius = 2;\n this.dragTL = this.dragBL = this.dragTR = this.dragBR = false;\n this.dragWholeRect = false;\n\n super.init();\n\n\n this.initRect();\n this.drawRectInCanvas();\n this.attachResizeListeners();\n }\n \n initRect() {\n this.rect.height = 50;\n this.rect.width = 50;\n // this.rect.left = (window.innerWidth - this.rect.width) / 2;\n // this.rect.top = (window.innerHeight - this.rect.height) / 2;\n\n\n this.rect.left = (this.element.width - this.rect.width) / 2;\n this.rect.top = (this.element.height - this.rect.height) / 2;\n\n }\n\n drawRectInCanvas() {\n var ctx = this.overlayCanvas.getContext(\"2d\");\n ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height);\n ctx.beginPath();\n ctx.lineWidth = \"1\";\n ctx.fillStyle = \"rgba(255, 255, 255, 0.5)\";\n ctx.strokeStyle = \"#000000\";\n ctx.rect(this.rect.left, this.rect.top, this.rect.width, this.rect.height);\n ctx.fill();\n ctx.stroke();\n }\n\n attachResizeListeners() {\n this.overlayCanvas.addEventListener('mousedown', this.mouseDown.bind(this), false);\n this.overlayCanvas.addEventListener('mouseup', this.mouseUp.bind(this), false);\n this.overlayCanvas.addEventListener('mousemove', this.mouseMove.bind(this), false);\n }\n\n mouseDown(e) {\n // ... implementation of mouseDown\n let pos = this.getMousePos(e);\n let mouseX = pos.x;\n let mouseY = pos.y;\n\n // 0. inside movable rectangle\n if (this.checkInRect(mouseX, mouseY, this.rect)){\n this.dragWholeRect=true;\n this.startX = mouseX;\n this.startY = mouseY;\n }\n // 1. top left\n else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.dragTL = true;\n }\n // 2. top right\n else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.dragTR = true;\n }\n // 3. bottom left\n else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.dragBL = true;\n }\n // 4. bottom right\n else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.dragBR = true;\n }\n // (5.) none of them\n else {\n // handle not resizing\n }\n this.drawRectInCanvas();\n\n }\n\n // Add the rest of the helper functions like getMousePos, checkInRect, checkCloseEnough here.\n getMousePos(evt) {\n let clx = evt.clientX;\n let cly = evt.clientY;\n let boundingRect = this.element.getBoundingClientRect();\n return {\n x: clx - boundingRect.left,\n y: cly - boundingRect.top\n };\n }\n\n checkInRect(x, y, r) {\n return (x > r.left && x < (r.width + r.left)) && (y > r.top && y < (r.top + r.height));\n }\n\n checkCloseEnough(p1, p2) {\n return Math.abs(p1 - p2) < this.handleRadius;\n }\n\n mouseMove(e) {\n let pos = this.getMousePos(e);\n let mouseX = pos.x;\n let mouseY = pos.y;\n\n // Update the cursor style based on mouse position\n this.updateCursorStyle(mouseX, mouseY);\n \n if (this.dragWholeRect) {\n e.preventDefault();\n e.stopPropagation();\n let dx = mouseX - this.startX;\n let dy = mouseY - this.startY;\n if ((this.rect.left + dx) > 0 && (this.rect.left + dx + this.rect.width) < this.overlayCanvas.width) {\n this.rect.left += dx;\n }\n if ((this.rect.top + dy) > 0 && (this.rect.top + dy + this.rect.height) < this.overlayCanvas.height) {\n this.rect.top += dy;\n }\n this.startX = mouseX;\n this.startY = mouseY;\n } else if (this.dragTL) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(this.rect.left + this.rect.width - mouseX) + Math.abs(this.rect.height + this.rect.top - mouseY)) / 2;\n if (newSide > 50) {\n this.rect.left = this.rect.left + this.rect.width - newSide;\n this.rect.top = this.rect.height + this.rect.top - newSide;\n this.rect.width = this.rect.height = newSide;\n }\n } else if (this.dragTR) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(mouseX - this.rect.left) + Math.abs(this.rect.height + this.rect.top - mouseY)) / 2;\n if (newSide > 50) {\n this.rect.top = this.rect.height + this.rect.top - newSide;\n this.rect.width = this.rect.height = newSide;\n }\n } else if (this.dragBL) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(this.rect.left + this.rect.width - mouseX) + Math.abs(this.rect.top - mouseY)) / 2;\n if (newSide > 50) {\n this.rect.left = this.rect.left + this.rect.width - newSide;\n this.rect.width = this.rect.height = newSide;\n }\n } else if (this.dragBR) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(mouseX - this.rect.left) + Math.abs(mouseY - this.rect.top)) / 2;\n if (newSide > 50) {\n this.rect.width = this.rect.height = newSide;\n }\n }\n this.drawRectInCanvas();\n }\n\n updateCursorStyle(mouseX, mouseY) {\n if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.overlayCanvas.style.cursor = 'nwse-resize'; // Top left corner\n } else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.overlayCanvas.style.cursor = 'nesw-resize'; // Top right corner\n } else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.overlayCanvas.style.cursor = 'nesw-resize'; // Bottom left corner\n } else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.overlayCanvas.style.cursor = 'nwse-resize'; // Bottom right corner\n } else {\n this.overlayCanvas.style.cursor = 'default'; // Default cursor elsewhere\n }\n }\n \n\n mouseUp(e) {\n this.dragTL = this.dragTR = this.dragBL = this.dragBR = false;\n this.dragWholeRect = false;\n this.storeCoordinates();\n }\n\n storeCoordinates() {\n // ... implementation of storeCoordinates\n let topleft = { x: this.rect.left, y: this.rect.top };\n let bottomright = { x: this.rect.left + this.rect.width, y: this.rect.top + this.rect.height };\n\n // console.log(\"Top Left:\", topleft, \"Bottom Right:\", bottomright);\n this.callback(topleft, bottomright); // Invoke the callback with the coordinates\n\n }\n}\n\n// Usage:\n// Assuming `callback` is a function that handles the top-left and bottom-right coordinates\n// And `element` is the canvas element to which the bounding box should be applied\n// let element = document.getElementById('canvas');\n// let resizableBox = new ResizableBBox(element);\n// resizableBox.init();\n","import { Widget } from \"../widget.js\";\n\nexport class DraggableBBox extends Widget {\n \n constructor(element, callback) {\n super(element);\n this.callback = callback;\n \n this.isDrawing = false;\n this.startX = 0;\n this.startY = 0;\n this.x1 = 0;\n this.y1 = 0;\n this.x2 = 0;\n this.y2 = 0;\n \n super.init();\n\n this.overlayCanvas.style.cursor = 'crosshair'; // Set the cursor to crosshair\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n this.overlayCanvas.addEventListener('mousedown', this.mouseDown.bind(this));\n this.overlayCanvas.addEventListener('mousemove', this.mouseMove.bind(this));\n this.overlayCanvas.addEventListener('mouseup', this.mouseUp.bind(this));\n this.overlayCanvas.addEventListener('mouseout', this.mouseOut.bind(this));\n }\n\n mouseDown(e) {\n\n var rect = e.currentTarget.getBoundingClientRect()\n\n this.isDrawing = true;\n\n this.x1 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio;\n this.y1 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n this.startX = e.offsetX;\n this.startY = e.offsetY;\n\n console.log(\"Mouse down at:\", this.x1, this.y1);\n }\n\n mouseMove(e) {\n if (!this.isDrawing) return;\n this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height); // Clear canvas\n let width = e.offsetX - this.startX;\n let height = e.offsetY - this.startY;\n console.log(\"Mouse Move at:\", this.x1, this.y1);\n this.ctx.strokeRect(this.startX , this.startY, width, height);\n\n }\n\n mouseUp(e) {\n this.isDrawing = false;\n\n var rect = e.currentTarget.getBoundingClientRect()\n\n this.x2 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio;\n this.y2 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n console.log(\"Mouse up at: \", this.x2, this.y2);\n this.storeCoordinates();\n }\n\n mouseOut() {\n if (this.isDrawing) {\n // Store coordinates also when the mouse accidentally leaves the canvas\n\n var rect = e.currentTarget.getBoundingClientRect()\n\n this.x2 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio;\n this.y2 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n \n console.log(\"Mouse out at: \", this.x2, this.y2);\n\n this.storeCoordinates();\n }\n this.isDrawing = false;\n }\n\n storeCoordinates() {\n let topleft = { x: this.x1, y: this.y1 };\n let bottomright = { x: this.x2, y: this.y2 };\n this.callback(topleft, bottomright); // Invoke the callback with the coordinates\n }\n}\n\n// Usage:\n// Assuming `callback` is a function that handles the top-left and bottom-right coordinates\n// And `element` is the canvas element to which the bounding box should be applied\n// let element = document.getElementById('canvas');\n// let bbox = new BBox(element, callback);\n// bbox.init();\n"],"names":[],"version":3,"file":"boxCraft.min.js.map"} \ No newline at end of file diff --git a/examples/segmentanything.js b/examples/segmentanything.js index 8516359e..5fa7ecc6 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -28,7 +28,7 @@ let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; -// scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; +// scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; scriptBoxCraft.onload = function() { boxCraftLoaded = true; tryRun(); diff --git a/package.json b/package.json index 304f4c0f..8eb95934 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "dev": "npx live-server --port=5501 --no-browser", "test": "node --experimental-modules ./tests/scripts/index.js", - "build-boxcraft": "npx parcel build submodule/BoxCraft/src/index.js --dist-dir ./dist/BoxCraft", - "build": "npx parcel build src/index.js && npm run build-boxcraft" + "build-boxcraft": "npx parcel build submodule/BoxCraft/src/index.js --dist-dir ./dist && cp submodule/BoxCraft/dist/boxcraft.min.js ./dist/boxcraft.min.js && cp submodule/BoxCraft/dist/boxcraft.min.js.map ./dist/boxcraft.min.js.map", + "build": "npx parcel build --no-cache && npm run build-boxcraft" }, "devDependencies": { "cross-env": "^7.0.3", diff --git a/src/frameworks/canvasFallback.js b/src/frameworks/canvasFallback.js index 95919b22..26689bf7 100644 --- a/src/frameworks/canvasFallback.js +++ b/src/frameworks/canvasFallback.js @@ -116,8 +116,8 @@ export class CanvasFallback extends Framework { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; - scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/submodule/BoxCraft/dist/boxcraft.min.js"; - // scriptBoxCraft.src = "http://localhost:8000/submodule/BoxCraft/dist/boxcraft.min.js"; + scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; + // scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); From e1cac04ae5d57aec23996e2332e4d9c96bcbe8ef Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Sun, 14 Apr 2024 18:50:52 -0400 Subject: [PATCH 09/12] prebuild initialization and updation for boxcraft submodule --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8eb95934..2c77b370 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "npx live-server --port=5501 --no-browser", "test": "node --experimental-modules ./tests/scripts/index.js", + "prebuild": "git submodule init && git submodule update", "build-boxcraft": "npx parcel build submodule/BoxCraft/src/index.js --dist-dir ./dist && cp submodule/BoxCraft/dist/boxcraft.min.js ./dist/boxcraft.min.js && cp submodule/BoxCraft/dist/boxcraft.min.js.map ./dist/boxcraft.min.js.map", "build": "npx parcel build --no-cache && npm run build-boxcraft" }, From bb75e355b4c9b1dcb0d6e7ec5daf3ee7014c8a22 Mon Sep 17 00:00:00 2001 From: Shruti Varade <37963866+shrutivarade@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:51:31 -0400 Subject: [PATCH 10/12] Create README.md --- submodule/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 submodule/README.md diff --git a/submodule/README.md b/submodule/README.md new file mode 100644 index 00000000..0de768a2 --- /dev/null +++ b/submodule/README.md @@ -0,0 +1,10 @@ +# Boostlet with Submodule + +This submodule will help us link to the latest commit of the Project **Boxcraft** hosted at repository [https://github.com/shrutivarade/BoxCraft]. + +## Local Build process + +Run the following command to build both the projects sequentially and create boostlet.min.js and boxcraft.min.js at ./dist of the min project: +```bash + npm run build +``` From 457924328024c2b1c0e0adb5985dfc393b56c67a Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Mon, 15 Apr 2024 15:55:14 -0400 Subject: [PATCH 11/12] urls changed --- dist/boostlet.min.js | 3 ++- dist/boostlet.min.js.map | 2 +- examples/segmentanything.js | 7 ++++--- index.html | 4 ++-- src/frameworks/canvasFallback.js | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index 9fc8615a..f33fc3f6 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -418,8 +418,9 @@ class $0fabd2f4a96087f5$export$48eecc33595f906d extends (0, $bsgU1.Framework) { select_box(callback) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; + scriptBoostlet.src = "https://boostlet.org/dist/boxcraft.min.js"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; - scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; + // scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; // scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index a7f2859c..2d3fd561 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,YAAY,IAAI,CA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F;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8000/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CA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AAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n scriptBoostlet.src = \"https://boostlet.org/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8000/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/examples/segmentanything.js b/examples/segmentanything.js index 5fa7ecc6..711e77de 100644 --- a/examples/segmentanything.js +++ b/examples/segmentanything.js @@ -11,8 +11,8 @@ function tryRun() { // Load Boostlet script let scriptBoostlet = document.createElement("script"); scriptBoostlet.type = "text/javascript"; -// scriptBoostlet.src = "https://boostlet.org/dist/boostlet.min.js"; -scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; +scriptBoostlet.src = "https://boostlet.org/dist/boostlet.min.js"; +// scriptBoostlet.src = "https://shrutivarade.github.io/boostlet/dist/boostlet.min.js"; // scriptBoostlet.src = "http://localhost:8000/dist/boostlet.min.js"; scriptBoostlet.onload = function() { boostletLoaded = true; @@ -26,8 +26,9 @@ document.head.appendChild(scriptBoostlet); // Load BoxCraft script let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; +scriptBoostlet.src = "https://boostlet.org/dist/boxcraft.min.js"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; -scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; +// scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; // scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; scriptBoxCraft.onload = function() { boxCraftLoaded = true; diff --git a/index.html b/index.html index 4680cd0a..6def4ec6 100644 --- a/index.html +++ b/index.html @@ -232,11 +232,11 @@ var examples = ['sobel.js', 'segmentanything.js', 'imageCaptioning.js', 'plotly.js', 'trako.js', 'melanoma.js']; - // var baseurl = 'https://raw.githubusercontent.com/mpsych/boostlet/main/examples/'; + var baseurl = 'https://raw.githubusercontent.com/mpsych/boostlet/main/examples/'; // var baseurl = 'https://raw.githubusercontent.com/gaiborjosue/boostlet/melanoma/examples/'; // var baseurl = 'http://localhost:5500/examples/'; // var baseurl = 'http://localhost:8000/examples/'; - var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/canvasFallback_boxcraft_submodules/examples/'; + // var baseurl = 'https://raw.githubusercontent.com/shrutivarade/boostlet/main/examples/'; for (e in examples) { diff --git a/src/frameworks/canvasFallback.js b/src/frameworks/canvasFallback.js index 26689bf7..daf79c39 100644 --- a/src/frameworks/canvasFallback.js +++ b/src/frameworks/canvasFallback.js @@ -115,8 +115,9 @@ export class CanvasFallback extends Framework { select_box(callback) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; + scriptBoostlet.src = "https://boostlet.org/dist/boxcraft.min.js"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; - scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; + // scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; // scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); From 1526c077488df5da3a5f7f8efb75e4fa0c4444d4 Mon Sep 17 00:00:00 2001 From: Shruti Varade Date: Mon, 22 Apr 2024 14:47:31 -0400 Subject: [PATCH 12/12] detect OS and change the copy command --- dist/boostlet.min.js | 4 ++-- dist/boostlet.min.js.map | 2 +- dist/boxcraft.min.js.map | 1 - operatingSystem.js | 24 ++++++++++++++++++++++++ package.json | 6 ++++-- 5 files changed, 31 insertions(+), 6 deletions(-) delete mode 100644 dist/boxcraft.min.js.map create mode 100644 operatingSystem.js diff --git a/dist/boostlet.min.js b/dist/boostlet.min.js index f33fc3f6..bf52159f 100644 --- a/dist/boostlet.min.js +++ b/dist/boostlet.min.js @@ -418,10 +418,10 @@ class $0fabd2f4a96087f5$export$48eecc33595f906d extends (0, $bsgU1.Framework) { select_box(callback) { let scriptBoxCraft = document.createElement("script"); scriptBoxCraft.type = "text/javascript"; - scriptBoostlet.src = "https://boostlet.org/dist/boxcraft.min.js"; + // scriptBoostlet.src = "https://boostlet.org/dist/boxcraft.min.js"; // scriptBoxCraft.src = "https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js"; // scriptBoxCraft.src = "https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js"; - // scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; + scriptBoxCraft.src = "http://localhost:8000/dist/boxcraft.min.js"; let canvas = this.get_canvas(); document.head.appendChild(scriptBoxCraft); scriptBoxCraft.onload = function() { diff --git a/dist/boostlet.min.js.map b/dist/boostlet.min.js.map index 2d3fd561..a07ff7ed 100644 --- a/dist/boostlet.min.js.map +++ b/dist/boostlet.min.js.map @@ -1 +1 @@ -{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,MAAM;aAE/B,IAAI,KAAK,UAAU,CAAC,OAAO,WAAW,GAE3C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,WAAW;aAE3C,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,GAEjC,YAAY,IAAI,CAAA,GAAA,UAAE,EAAE,OAAO,CAAC;aAEvB,IAAI,KAAK,UAAU,CAAC,OAAO,aAAa,GAE7C,YAAY,IAAI,CAAA,GAAA,oBAAY,EAAE,OAAO,aAAa;aAE7C,IAAI,KAAK,UAAU,CAAC,OAAO,gBAAgB,GAEhD,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,gBAAgB;aAEzC;YACL,kBAAkB;YAElB,QAAQ,GAAG,CAAC;YACZ,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,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n scriptBoostlet.src = \"https://boostlet.org/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"http://localhost:8000/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file +{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM;IAEX,OAAO,mBAAmB;QAExB,IAAI,YAAY;QAEhB,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,GAE3B,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,OAAO,EAAE;aAE3B,IAAI,KAAK,UAAU,CAAC,OAAO,MAAM,GAEtC,YAAY,IAAI,CAAA,GAAA,aAAK,EAAE,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SAAS,CAAC;IAElC;IAEA;;;GAGC,GACD,SAAS,QAAQ,EAAE;QAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAEjC;IAEA;;GAEC,GACD,eAAe,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;QAExC,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,OAAO;IAE1D;IAEA,OAAO,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEpC,OAAO,CAAA,GAAA,WAAG,EAAE,MAAM,CAAC,QAAQ,OAAO,QAAQ;IAE5C;IAEA;;;GAGC,GACD,KAAK,OAAO,EAAE,QAAQ,EAAE;QAEtB,OAAO,CAAA,GAAA,WAAG,EAAE,IAAI,CAAC,SAAS;IAE5B;AAEF;;;AD1IA,OAAO,OAAO,CAAC,GAAG,CAAC;AAEnB,yDAAyD;AACzD,2DAA2D;AAC3D,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,wCAAO","sources":["src/util.js","src/framework.js","src/frameworks/cornerstone2d.js","src/frameworks/canvasFallback.js","src/frameworks/niivue.js","src/frameworks/openseadragon.js","src/frameworks/xtk.js","src/frameworks/papaya.js","src/index.js","src/boostlet.js"],"sourcesContent":["import {Framework} from './framework.js';\nimport {Cornerstone2D} from './frameworks/cornerstone2d.js';\nimport {NiiVue} from './frameworks/niivue.js';\nimport { OpenSeaDragon } from './frameworks/openseadragon.js';\nimport { Xtk } from './frameworks/xtk.js';\nimport { Papaya } from './frameworks/papaya.js';\nimport { CanvasFallback } from './frameworks/canvasFallback.js';\n\nexport class Util {\n \n static detect_framework() {\n\n let framework = null;\n\n if (Util.is_defined(window.nv)) {\n \n framework = new NiiVue(window.nv);\n \n } else if (Util.is_defined(window.niivue)) {\n \n framework = new NiiVue(window.niivue);\n\n } else if (Util.is_defined(window.cornerstone)) {\n\n framework = new Cornerstone2D(window.cornerstone);\n\n } else if (Util.is_defined(window.r)) {\n \n framework = new Xtk(window.r);\n \n } else if (Util.is_defined(window.OpenSeadragon)) {\n\n framework = new OpenSeaDragon(window.OpenSeadragon);\n \n } else if (Util.is_defined(window.papayaContainers)) {\n \n framework = new Papaya(window.papayaContainers)\n\n } else {\n // Canvas fallback\n \n console.log(\"No framework detected, falling back to canvas rendering\");\n framework = new CanvasFallback();\n \n }\n\n return framework;\n\n }\n\n static async load_script(url, callback) {\n\n // introducing hack to make it work for openneuro\n window.Object.defineProperty(window.Object.prototype, 'global', {\n get( ){\n return window;\n },\n set(newGlobal) {\n globalThis = newGlobal;\n }\n });\n\n const script = window.document.createElement(\"script\")\n script.type = \"text/javascript\"\n script.src = url;\n\n if (Util.is_defined(callback)) {\n script.onload = callback;\n }\n\n window.document.head.appendChild(script);\n eval(script);\n\n }\n\n static async send_http_post(url, data, callback) {\n\n let xhr = new XMLHttpRequest();\n xhr.open(\"POST\", url);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n // request done\n callback( xhr.response );\n\n return;\n\n }\n }\n\n xhr.send(data)\n\n }\n\n static convert_to_png(uint8array, width, height, flip) {\n\n // we are using an offscreen canvas for this\n let offscreen = window.document.createElement('canvas');\n offscreen.width = width;\n offscreen.height = height;\n\n let offscreen_ctx = offscreen.getContext('2d');\n\n let imgdata = offscreen_ctx.createImageData(offscreen.width, offscreen.height);\n let pxdata = imgdata.data;\n\n for (var i =0; i c.charCodeAt(0));\n\n return pngpixels;\n\n }\n\n static filter(pixels, width, height, kernel) {\n\n const kernelSize = Math.sqrt(kernel.length);\n const halfKernelSize = Math.floor(kernelSize / 2);\n\n const new_pixels = pixels.slice();\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const dstIndex = y * width + x;\n\n let newValue = 0;\n for (let ky = 0; ky < kernelSize; ky++) {\n for (let kx = 0; kx < kernelSize; kx++) {\n const srcX = x + kx - halfKernelSize;\n const srcY = y + ky - halfKernelSize;\n const srcIndex = srcY * width + srcX;\n\n const kernelValue = kernel[ky * kernelSize + kx];\n newValue += pixels[srcIndex] * kernelValue;\n }\n }\n\n new_pixels[dstIndex] = newValue;\n\n }\n }\n\n return new_pixels;\n\n }\n\n static grayscale_to_rgba(grayscale) {\n\n const rgba = new Uint8Array(grayscale.length * 4);\n\n for (let i = 0; i < grayscale.length; i++) {\n const g = grayscale[i];\n const index = i * 4;\n\n rgba[index] = g;\n rgba[index + 1] = g;\n rgba[index + 2] = g;\n rgba[index + 3] = 255; \n }\n\n return rgba;\n\n }\n\n static rgba_to_grayscale(rgba) {\n\n const grayscale = new Uint8Array(rgba.length / 4);\n\n for (let i = 0; i < rgba.length; i += 4) {\n\n grayscale[i / 4] = rgba[i];\n\n }\n\n return grayscale;\n\n }\n\n /**\n * Harden a mask into a grayscale pixel array.\n * \n * pixels needs to be RGBA\n * \n * and mask binary.\n * \n * maskcolor is optional and falls back to blue.\n * \n **/\n static harden_mask(pixels, mask, maskcolor) {\n\n // Modified from: https://github.com/facebookresearch/segment-anything/blob/40df6e4046d8b07ab8c4519e083408289eb43032/demo/src/components/helpers/maskUtils.tsx\n // Copyright (c) Meta Platforms, Inc. and affiliates.\n // All rights reserved.\n\n\n let maskcolor_ = [0, 114, 189, 255];\n\n if (Util.is_defined(maskcolor)) {\n \n maskcolor_ = maskcolor;\n \n } \n\n for (var i = 0; i < mask.length; i++) {\n\n if (mask[i] > 0.0) {\n pixels[4 * i + 0] = maskcolor_[0];\n pixels[4 * i + 1] = maskcolor_[1];\n pixels[4 * i + 2] = maskcolor_[2];\n pixels[4 * i + 3] = maskcolor_[3];\n }\n\n }\n\n return pixels;\n\n }\n\n static is_defined(variable) {\n\n return (typeof variable != 'undefined');\n\n }\n \n // \"Boostlet Tooltips\" - This is a hint mechanism that allows to display a message for a certain amount of time (ms).\n static hint(message, duration) {\n\n let hint = window.document.createElement('div');\n hint.id = 'BoostletHint';\n\n hint.style.position = 'fixed';\n hint.style.left = '10px';\n hint.style.top = '10px';\n hint.style.padding = '10px';\n hint.style.background = '#fff';\n hint.style.color = '#000';\n hint.style.zIndex = '100000';\n hint.style.border = '1px solid #007ec6';\n hint.style.borderRadius = '5px';\n hint.style.boxShadow = '0px 0px 20px 5px rgba(0,0,0, 0.3)';\n hint.style.fontSize = '14px';\n hint.style.fontWeight = 'bold';\n hint.style.textAlign = 'center';\n\n hint.innerHTML = message;\n \n window.document.body.appendChild(hint);\n\n if (typeof duration === 'number' && duration > 0) {\n setTimeout(function() {\n hint.remove();\n }, duration);\n }\n\n }\n\n}","import {Util} from './util.js';\n\nexport class Framework {\n\n constructor(instance) {\n\n this.name = 'generic';\n this.instance = instance;\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_image(new_pixels) {\n\n throw \"Missing Implementation.\";\n\n }\n\n set_mask(new_mask) {\n\n throw \"Missing Implementation.\";\n \n }\n\n select_box(callback) {\n\n throw \"Missing Implementation.\";\n\n }\n\n convert_to_png(uint8array, width, height) {\n\n return Util.convert_to_png(uint8array, width, height, this.flip_on_png);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class Cornerstone2D extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'cornerstone2D';\n this.canvasFallback = new CanvasFallback();\n\n this.cornerstonetools_instance = null;\n\n if (typeof window.cornerstoneTools != 'undefined') {\n\n // TODO probably not too robust\n this.cornerstonetools_instance = window.cornerstoneTools;\n\n }\n\n this.flip_on_png = false;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = null;\n let width = null;\n let height = null;\n\n if (typeof from_canvas != 'undefined') {\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let canvas = element.canvas;\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext('2d');\n\n let imagedata = ctx.getImageData(0, 0, width, height);\n pixels = imagedata.data;\n\n } else {\n\n // this is the real image slice data\n let imagedata = element.image;\n pixels = imagedata.getPixelData();\n width = imagedata.width;\n height = imagedata.height;\n\n }\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n set_image(new_pixels) {\n\n let element = this.instance.getEnabledElements()[0];\n let pixels = element.image.getPixelData();\n\n // Set the new pixel values\n pixels.set(new_pixels);\n\n // Re-render the current slice\n cornerstone.renderGrayscaleImage(element, true);\n\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n \n }\n\n select_box(callback) {\n\n if(this.cornerstonetools_instance.RectangleRoiTool === undefined) {\n console.log(\"Using Boxcraft library to handle box selection.\");\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n // Disable the Wwwc tool\n cornerstoneTools.setToolDisabled(\"Wwwc\");\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n BoxCraft.createResizableBBox(canvas, function(topleft, bottomright) {\n console.log(\"Inside Draggable BBox\",topleft, bottomright);\n callback(topleft, bottomright);\n });\n\n // return this.canvasFallback.select_box(callback);\n\n\n }\n else{\n console.log(\"Using Cornerstonetools to handle box selection.\");\n this.cornerstonetools_instance.setToolActive(\"RectangleRoi\", {\n mouseButtonMask: 1,\n });\n\n let element = this.instance.getEnabledElements()[0];\n let canvas = element.canvas;\n\n canvas.onmouseup = function () {\n let state =\n this.cornerstonetools_instance.globalImageIdSpecificToolStateManager.saveToolState();\n\n let topleft =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.start;\n let bottomright =\n state[Object.keys(state).pop()].RectangleRoi.data[0].handles.end;\n\n let topleft_c = this.instance.pixelToCanvas(element.element, topleft);\n let bottomright_c = this.instance.pixelToCanvas(\n element.element,\n bottomright\n );\n\n this.cornerstonetools_instance.clearToolState(\n element.element,\n \"RectangleRoi\"\n );\n this.instance.renderGrayscaleImage(element, true);\n callback(topleft_c, bottomright_c);\n }.bind(this);\n }\n\n }\n\n}","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\n\n\nexport class CanvasFallback extends Framework {\n constructor() {\n super();\n this.name = \"canvasFallback\";\n }\n\n get_canvas() {\n let canvases = document.querySelectorAll('canvas');\n let largestCanvas = canvases[0];\n let largestArea = largestCanvas.width * largestCanvas.height;\n\n for (let i = 1; i < canvases.length; i++) {\n let area = canvases[i].width * canvases[i].height;\n if (area > largestArea) {\n largestCanvas = canvases[i];\n largestArea = area;\n }\n }\n\n return largestCanvas;\n }\n\n get_image(from_canvas) {\n\n let canvas = this.get_canvas();\n\n let ctx = canvas.getContext(\"2d\");\n\n let image = ctx.getImageData(0, 0, canvas.width, canvas.height);\n let rgba_image = Util.rgba_to_grayscale(image.data);\n\n if (from_canvas) {\n return { data: image.data, width: image.width, height: image.height };\n } else {\n return { data: rgba_image, width: image.width, height: image.height };\n }\n }\n\n set_image(new_pixels) {\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement(\"canvas\");\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext(\"2d\");\n\n let newPixelsRgba = Util.grayscale_to_rgba(new_pixels);\n\n let newPixelsClamped = new Uint8ClampedArray(newPixelsRgba);\n\n let newImageData = new ImageData(\n newPixelsClamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n newcanvas.onclick = function () {\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n };\n\n // replace nv canvas with new one\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n set_mask(new_mask) {\n let image = this.get_image(true);\n\n let originalcanvas = this.get_canvas();\n\n let newcanvas = window.document.createElement('canvas');\n\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n let ctx = newcanvas.getContext('2d');\n\n let imageclamped = new Uint8ClampedArray(image.data);\n\n let newImageData = new ImageData(\n imageclamped,\n newcanvas.width,\n newcanvas.height\n );\n\n // Draw the new image data onto the canvas\n ctx.putImageData(newImageData, 0, 0);\n\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n let masked_image_as_imagedata = new ImageData(\n masked_image,\n newcanvas.width,\n newcanvas.height\n );\n\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n }\n\n select_box(callback) {\n let scriptBoxCraft = document.createElement(\"script\");\n scriptBoxCraft.type = \"text/javascript\";\n // scriptBoostlet.src = \"https://boostlet.org/dist/boxcraft.min.js\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/BoxCraft/dist/boxCraft.min.js\";\n // scriptBoxCraft.src = \"https://shrutivarade.github.io/boostlet/dist/boxcraft.min.js\";\n scriptBoxCraft.src = \"http://localhost:8000/dist/boxcraft.min.js\";\n let canvas = this.get_canvas();\n document.head.appendChild(scriptBoxCraft);\n\n scriptBoxCraft.onload = function() {\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n console.log(\"Inside Draggable BBox\", topleft, bottomright);\n callback(topleft, bottomright);\n });\n }\n\n }\n\n}","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class NiiVue extends Framework {\n \n constructor(instance) {\n\n super(instance);\n this.name = 'niivue';\n this.canvasFallback = new CanvasFallback();\n\n this.flip_on_png = true;\n\n this.onMouseDown = false;\n this.x1 = null;\n this.y1 = null;\n this.x2 = null;\n this.y2 = null;\n\n }\n\n get_image(from_canvas) {\n\n let element = this.instance.canvas;\n let pixels = null;\n let width = null;\n let height = null;\n\n\n // TODO this is hacky going through the canvas\n // later should grab the real volume data\n\n let old_crosshaircolor = this.instance.opts.crosshairColor;\n let old_crosshairwidth = this.instance.opts.crosshairWidth;\n\n this.instance.setCrosshairColor([0,0,0,0]);\n this.instance.opts.crosshairWidth=0;\n this.instance.updateGLVolume();\n\n\n let ctx = this.instance.gl;\n\n \n width = ctx.drawingBufferWidth;\n height = ctx.drawingBufferHeight;\n\n pixels = new Uint8Array(width * height * 4);\n ctx.readPixels(\n 0, \n 0, \n width, \n height, \n ctx.RGBA, \n ctx.UNSIGNED_BYTE, \n pixels);\n\n // restore crosshairs\n this.instance.setCrosshairColor(old_crosshaircolor);\n this.instance.opts.crosshairWidth = old_crosshairwidth;\n\n if (!Util.is_defined(from_canvas)) {\n\n // convert rgba pixels to grayscale\n pixels = Util.rgba_to_grayscale(pixels);\n\n } else {\n\n // TODO\n // not easily possible yet\n // we could hack it using \n // nv.back.get_value(x,y,z)\n // based on the dimensions\n // nv.back.dims.slice(1);\n // but devs promised easy access in the future\n\n }\n\n\n return {'data':pixels, 'width':width, 'height':height};\n\n }\n\n /**\n * Sets the NiiVue.js image.\n * \n * If is_rgba==true, we do *not* convert to RGBA before setting on canvas.\n **/\n set_image(new_pixels, is_rgba, no_flip) {\n\n // TODO this is hacky since we dont work with the real volume yet\n // create new canvas\n // put pixels on canvas\n // show canvas\n // hide on click\n\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n\n let new_pixels_rgba = null;\n\n if (Util.is_defined(is_rgba)) {\n\n new_pixels_rgba = new_pixels;\n\n } else {\n\n new_pixels_rgba = Util.grayscale_to_rgba(new_pixels);\n\n\n }\n\n let new_pixels_clamped = new Uint8ClampedArray(new_pixels_rgba);\n\n let new_image_data = new ImageData(new_pixels_clamped, newcanvas.width, newcanvas.height);\n \n\n ctx.putImageData(new_image_data, 0, 0);\n\n if (!Util.is_defined(no_flip)) {\n // some flipping action\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n }\n\n\n newcanvas.onclick = function() {\n\n // on click, we will restore the nv canvas\n newcanvas.parentNode.replaceChild(originalcanvas, newcanvas);\n\n }\n\n // replace nv canvas with new one\n // originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n newcanvas.style.width = originalcanvas.clientWidth+'px';\n newcanvas.style.height = originalcanvas.clientHeight+'px';\n originalcanvas.parentNode.replaceChild(newcanvas, originalcanvas);\n\n }\n\n set_mask(new_mask) {\n\n // merge image + mask\n // and then call set_image with that information\n\n let image = this.get_image(true);\n\n // TODO here we need to flip one more time, this is until\n // we use the official niivue infrastructure for adding\n // a segmentation layer\n let originalcanvas = this.instance.canvas;\n\n let newcanvas = window.document.createElement('canvas');\n newcanvas.width = originalcanvas.width;\n newcanvas.height = originalcanvas.height;\n // put new_pixels down\n let ctx = newcanvas.getContext('2d');\n let imageclamped = new Uint8ClampedArray(image.data);\n let imagedata = new ImageData(imageclamped, image.width, image.height);\n ctx.putImageData(imagedata, 0, 0);\n ctx.save();\n ctx.scale(1, -1);\n ctx.drawImage(newcanvas, 0, -newcanvas.height);\n ctx.restore();\n image = ctx.getImageData(0, 0, newcanvas.width, newcanvas.height);\n // end of flip\n\n let masked_image = Util.harden_mask(image.data, new_mask);\n\n this.set_image(masked_image, true, true); // rgba data, no flip\n\n\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n\n }\n\n}\n","import {Framework} from '../framework.js';\n\nimport {Util} from '../util.js';\n\nimport {CanvasFallback} from './canvasFallback.js';\n\nexport class OpenSeaDragon extends Framework {\n constructor(instance) {\n super(instance);\n this.name = 'opensedragon';\n this.canvasFallback = new CanvasFallback();\n\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n // return this.canvasFallback.set_mask(new_mask);\n\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas.children[0];\n width = canvas.width;\n height = canvas.height;\n\n let ctx = canvas.getContext(\"2d\");\n let imagedata = ctx.getImageData(0, 0, width, height);\n let pixels = imagedata.data;\n\n let masked_image = Util.harden_mask(pixels, new_mask);\n let masked_image_as_imagedata = new ImageData(masked_image, width, height);\n ctx.putImageData(masked_image_as_imagedata, 0, 0);\n }\n\n select_box(callback) {\n\n console.log(\"Using Boxcraft library to handle box selection.\");\n let viewer = null;\n let vs = this.instance._viewers;\n vs.forEach(function (e) {\n if (e.id == \"viewer\") {\n viewer = e;\n }\n });\n\n if (!viewer) {\n throw \"OpenSeaDragon viewer not found.\";\n }\n\n let canvas = viewer.canvas;\n\n BoxCraft.createDraggableBBox(canvas, function (topleft, bottomright) {\n callback(topleft, bottomright);\n });\n\n }\n\n \n\n}\n \n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Xtk extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"xtk\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","import { Framework } from \"../framework.js\";\n\nimport { Util } from \"../util.js\";\n\nimport { CanvasFallback } from \"./canvasFallback.js\";\n\nexport class Papaya extends Framework {\n constructor(instance) {\n super(instance);\n this.name = \"papaya\";\n this.canvasFallback = new CanvasFallback();\n }\n\n get_image(from_canvas) {\n return this.canvasFallback.get_image(from_canvas);\n }\n\n set_image(new_pixels) {\n return this.canvasFallback.set_image(new_pixels);\n }\n\n set_mask(new_mask) {\n return this.canvasFallback.set_mask(new_mask);\n }\n\n select_box(callback) {\n return this.canvasFallback.select_box(callback);\n }\n}\n","\nimport {Boostlet} from \"./boostlet.js\"\n\nwindow.console.log('BOOSTLET VERSION 0.1-beta');\n\n// register global namespace with a new boostlet instance\n// later we might want to support multiple active boostlets\nwindow.Boostlet = new Boostlet();\n","import {Util} from './util.js';\n\nimport {Framework} from './framework.js';\n\nexport class Boostlet {\n\n constructor() {\n\n this.framework = null;\n\n }\n\n /**\n * Initializes the Boostlet.\n * \n * This includes several steps such as identifying the \n * visualization/rendering framework that is available. \n * \n * TODO: Later we want to have fallbacks in place if the framework\n * is not detected.\n * \n */\n init(name, instance) {\n\n if (typeof name != 'undefined' && typeof instance != 'undefined') {\n\n console.log('Framework forced by user!');\n throw \"Forced Framework Not Implemented.\";\n // TODO\n\n } else {\n\n this.framework = Util.detect_framework();\n\n }\n\n if (this.framework) {\n\n console.log('Found', this.framework, '!')\n \n } else {\n\n throw \"Framework Not Found.\";\n\n }\n\n }\n\n /**\n * Let's the user select a region of interest box.\n */\n async select_box(callback) {\n\n this.framework.select_box(callback);\n\n }\n\n /**\n * Let's the user select (multiple) seeds.\n */\n async select_seed(howmany) {\n\n throw \"Missing Implementation.\";\n\n }\n\n /**\n * Loads an external javascript file asynchronously. \n */\n async load_script(url, callback) {\n\n Util.load_script(url, callback);\n\n }\n\n /**\n * Sends a HTTP POST request to a url with some data.\n */\n async send_http_post(url, data, callback) {\n\n Util.send_http_post(url, data, callback);\n\n }\n\n /**\n * Gets the current image (2D).\n * \n * TODO: Optional bounding box should be supported.\n * \n */\n get_image(from_canvas) {\n\n return this.framework.get_image(from_canvas);\n\n }\n\n /**\n * Sets the current image (2D).\n * \n */\n set_image(new_pixels) {\n\n return this.framework.set_image(new_pixels);\n\n }\n\n /**\n * Sets the current mask (2D).\n * \n */\n set_mask(new_mask) {\n\n return this.framework.set_mask(new_mask);\n\n }\n\n /**\n * Encode raw image data to PNG.\n */\n convert_to_png(uint8array, width, height) {\n\n return this.framework.convert_to_png(uint8array, width, height);\n\n }\n\n filter(pixels, width, height, kernel) {\n\n return Util.filter(pixels, width, height, kernel);\n\n }\n\n /**\n * Displays a small div located at the top left corner of the screen with message and will disappear after the specified time (ms).\n * \n */\n hint(message, duration) {\n\n return Util.hint(message, duration);\n\n }\n\n}\n"],"names":[],"version":3,"file":"boostlet.min.js.map"} \ No newline at end of file diff --git a/dist/boxcraft.min.js.map b/dist/boxcraft.min.js.map deleted file mode 100644 index 33f762bf..00000000 --- a/dist/boxcraft.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"mappings":"AEAO,MAAM;IAEX,YAAY,OAAO,EAAE,QAAQ,CAAE;QAE7B,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,wDAAwD;QACxD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI;IAEjD;IAGA,OAAM;QAEJ,8BAA8B;QAC9B,IAAI,CAAC,aAAa,GAAG,SAAS,aAAa,CAAC;QAC5C,2DAA2D;QAC3D,IAAI,CAAC,aAAa,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;QACnD,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY;QAGrD,6CAA6C;QAC7C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,GAAG;QACpC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG;QAC1D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG;QACxD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,GAAG,QAAS,mCAAmC;QAE9E,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,M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ADlBA,yDAAyD;AACzD,OAAO,QAAQ,GAAG,IAAI,CAAA,GAAA,yCAAO;AAE7B,OAAO,OAAO,CAAC,GAAG,CAAC","sources":["src/index.js","src/boxCraft.js","src/widget.js","src/widgets/resizableBBox.js","src/widgets/draggableBBox.js"],"sourcesContent":["import { BoxCraft } from \"./boxCraft.js\";\nimport { Widget } from \"./widget.js\";\n\n// register global namespace with a new BoxCraft instance\nwindow.BoxCraft = new BoxCraft();\n\nwindow.console.log('BoxCraft VERSION 0.1-alpha');\n\n\n\n\n\n\n\n\n","import { Widget } from \"./widget.js\";\nimport { ResizableBBox } from \"./widgets/resizableBBox.js\";\nimport { DraggableBBox } from \"./widgets/draggableBBox.js\";\n\nexport class BoxCraft {\n\n constructor() {\n }\n\n createResizableBBox(element, callback) {\n console.log(\"Resizable BBox\")\n return new ResizableBBox(element, callback);\n\n }\n\n createDraggableBBox(element, callback) {\n console.log(\"Draggable BBox\")\n return new DraggableBBox(element, callback);\n\n }\n\n}\n","export class Widget {\n\n constructor(element, callback) {\n\n this.element = element;\n this.callback = callback;\n // Bind the 'resizeCanvas' method to the current context\n this.resizeCanvas = this.resizeCanvas.bind(this);\n \n }\n\n\n init(){\n \n // Create a new canvas element\n this.overlayCanvas = document.createElement('canvas');\n // Set the dimensions of the canvas to match the base image\n this.overlayCanvas.width = this.element.clientWidth;\n this.overlayCanvas.height = this.element.clientHeight;\n\n\n // Style the canvas to overlay the base image\n this.overlayCanvas.style.position = 'absolute';\n this.overlayCanvas.style.left = this.element.offsetLeft + 'px';\n this.overlayCanvas.style.top = this.element.offsetTop + 'px';\n this.overlayCanvas.style.zIndex = '1000'; // High value to ensure it's on top\n\n this.ctx = this.overlayCanvas.getContext('2d');\n this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height);\n\n // Append the overlay canvas to the same parent element as the base image\n this.element.parentElement.appendChild(this.overlayCanvas);\n\n\n // Add the resize event listener\n window.addEventListener('resize', this.resizeCanvas);\n\n // Call resizeCanvas initially to set the correct size from the start\n this.resizeCanvas();\n\n }\n\n resizeCanvas() {\n\n \n // Update the canvas dimensions to match the parent element's size\n this.overlayCanvas.width = this.element.clientWidth;\n this.overlayCanvas.height = this.element.clientHeight;\n\n // Update the style to reflect the new position if necessary\n this.overlayCanvas.style.left = this.element.offsetLeft + 'px';\n this.overlayCanvas.style.top = this.element.offsetTop + 'px';\n\n // Clear the canvas and call the callback if any drawing is required\n this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height);\n if (this.callback) {\n this.callback();\n }\n }\n\n hide() {\n // Implement the hide functionality if needed\n this.overlayCanvas.style.display = 'none';\n }\n\n show() {\n // Implement the show functionality if needed\n this.overlayCanvas.style.display = 'block';\n }\n\n // Make sure to remove the event listener when the widget is no longer needed\n destroy() {\n window.removeEventListener('resize', this.resizeCanvas);\n // Perform any additional cleanup like removing the canvas if necessary\n }\n\n}\n","import { Widget } from \"../widget.js\";\n\nexport class ResizableBBox extends Widget {\n\n constructor(element, callback) {\n super(element, callback);\n \n this.rect = {};\n this.handleRadius = 2;\n this.dragTL = this.dragBL = this.dragTR = this.dragBR = false;\n this.dragWholeRect = false;\n\n super.init();\n\n\n this.initRect();\n this.drawRectInCanvas();\n this.attachResizeListeners();\n }\n \n initRect() {\n this.rect.height = 50;\n this.rect.width = 50;\n // this.rect.left = (window.innerWidth - this.rect.width) / 2;\n // this.rect.top = (window.innerHeight - this.rect.height) / 2;\n\n\n this.rect.left = (this.element.width - this.rect.width) / 2;\n this.rect.top = (this.element.height - this.rect.height) / 2;\n\n }\n\n drawRectInCanvas() {\n var ctx = this.overlayCanvas.getContext(\"2d\");\n ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height);\n ctx.beginPath();\n ctx.lineWidth = \"1\";\n ctx.fillStyle = \"rgba(255, 255, 255, 0.5)\";\n ctx.strokeStyle = \"#000000\";\n ctx.rect(this.rect.left, this.rect.top, this.rect.width, this.rect.height);\n ctx.fill();\n ctx.stroke();\n }\n\n attachResizeListeners() {\n this.overlayCanvas.addEventListener('mousedown', this.mouseDown.bind(this), false);\n this.overlayCanvas.addEventListener('mouseup', this.mouseUp.bind(this), false);\n this.overlayCanvas.addEventListener('mousemove', this.mouseMove.bind(this), false);\n }\n\n mouseDown(e) {\n // ... implementation of mouseDown\n let pos = this.getMousePos(e);\n let mouseX = pos.x;\n let mouseY = pos.y;\n\n // 0. inside movable rectangle\n if (this.checkInRect(mouseX, mouseY, this.rect)){\n this.dragWholeRect=true;\n this.startX = mouseX;\n this.startY = mouseY;\n }\n // 1. top left\n else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.dragTL = true;\n }\n // 2. top right\n else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.dragTR = true;\n }\n // 3. bottom left\n else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.dragBL = true;\n }\n // 4. bottom right\n else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.dragBR = true;\n }\n // (5.) none of them\n else {\n // handle not resizing\n }\n this.drawRectInCanvas();\n\n }\n\n // Add the rest of the helper functions like getMousePos, checkInRect, checkCloseEnough here.\n getMousePos(evt) {\n let clx = evt.clientX;\n let cly = evt.clientY;\n let boundingRect = this.element.getBoundingClientRect();\n return {\n x: clx - boundingRect.left,\n y: cly - boundingRect.top\n };\n }\n\n checkInRect(x, y, r) {\n return (x > r.left && x < (r.width + r.left)) && (y > r.top && y < (r.top + r.height));\n }\n\n checkCloseEnough(p1, p2) {\n return Math.abs(p1 - p2) < this.handleRadius;\n }\n\n mouseMove(e) {\n let pos = this.getMousePos(e);\n let mouseX = pos.x;\n let mouseY = pos.y;\n\n // Update the cursor style based on mouse position\n this.updateCursorStyle(mouseX, mouseY);\n \n if (this.dragWholeRect) {\n e.preventDefault();\n e.stopPropagation();\n let dx = mouseX - this.startX;\n let dy = mouseY - this.startY;\n if ((this.rect.left + dx) > 0 && (this.rect.left + dx + this.rect.width) < this.overlayCanvas.width) {\n this.rect.left += dx;\n }\n if ((this.rect.top + dy) > 0 && (this.rect.top + dy + this.rect.height) < this.overlayCanvas.height) {\n this.rect.top += dy;\n }\n this.startX = mouseX;\n this.startY = mouseY;\n } else if (this.dragTL) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(this.rect.left + this.rect.width - mouseX) + Math.abs(this.rect.height + this.rect.top - mouseY)) / 2;\n if (newSide > 50) {\n this.rect.left = this.rect.left + this.rect.width - newSide;\n this.rect.top = this.rect.height + this.rect.top - newSide;\n this.rect.width = this.rect.height = newSide;\n }\n } else if (this.dragTR) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(mouseX - this.rect.left) + Math.abs(this.rect.height + this.rect.top - mouseY)) / 2;\n if (newSide > 50) {\n this.rect.top = this.rect.height + this.rect.top - newSide;\n this.rect.width = this.rect.height = newSide;\n }\n } else if (this.dragBL) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(this.rect.left + this.rect.width - mouseX) + Math.abs(this.rect.top - mouseY)) / 2;\n if (newSide > 50) {\n this.rect.left = this.rect.left + this.rect.width - newSide;\n this.rect.width = this.rect.height = newSide;\n }\n } else if (this.dragBR) {\n e.preventDefault();\n e.stopPropagation();\n let newSide = (Math.abs(mouseX - this.rect.left) + Math.abs(mouseY - this.rect.top)) / 2;\n if (newSide > 50) {\n this.rect.width = this.rect.height = newSide;\n }\n }\n this.drawRectInCanvas();\n }\n\n updateCursorStyle(mouseX, mouseY) {\n if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.overlayCanvas.style.cursor = 'nwse-resize'; // Top left corner\n } else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top)) {\n this.overlayCanvas.style.cursor = 'nesw-resize'; // Top right corner\n } else if (this.checkCloseEnough(mouseX, this.rect.left) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.overlayCanvas.style.cursor = 'nesw-resize'; // Bottom left corner\n } else if (this.checkCloseEnough(mouseX, this.rect.left + this.rect.width) && this.checkCloseEnough(mouseY, this.rect.top + this.rect.height)) {\n this.overlayCanvas.style.cursor = 'nwse-resize'; // Bottom right corner\n } else {\n this.overlayCanvas.style.cursor = 'default'; // Default cursor elsewhere\n }\n }\n \n\n mouseUp(e) {\n this.dragTL = this.dragTR = this.dragBL = this.dragBR = false;\n this.dragWholeRect = false;\n this.storeCoordinates();\n }\n\n storeCoordinates() {\n // ... implementation of storeCoordinates\n let topleft = { x: this.rect.left, y: this.rect.top };\n let bottomright = { x: this.rect.left + this.rect.width, y: this.rect.top + this.rect.height };\n\n // console.log(\"Top Left:\", topleft, \"Bottom Right:\", bottomright);\n this.callback(topleft, bottomright); // Invoke the callback with the coordinates\n\n }\n}\n\n// Usage:\n// Assuming `callback` is a function that handles the top-left and bottom-right coordinates\n// And `element` is the canvas element to which the bounding box should be applied\n// let element = document.getElementById('canvas');\n// let resizableBox = new ResizableBBox(element);\n// resizableBox.init();\n","import { Widget } from \"../widget.js\";\n\nexport class DraggableBBox extends Widget {\n \n constructor(element, callback) {\n super(element);\n this.callback = callback;\n \n this.isDrawing = false;\n this.startX = 0;\n this.startY = 0;\n this.x1 = 0;\n this.y1 = 0;\n this.x2 = 0;\n this.y2 = 0;\n \n super.init();\n\n this.overlayCanvas.style.cursor = 'crosshair'; // Set the cursor to crosshair\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n this.overlayCanvas.addEventListener('mousedown', this.mouseDown.bind(this));\n this.overlayCanvas.addEventListener('mousemove', this.mouseMove.bind(this));\n this.overlayCanvas.addEventListener('mouseup', this.mouseUp.bind(this));\n this.overlayCanvas.addEventListener('mouseout', this.mouseOut.bind(this));\n }\n\n mouseDown(e) {\n\n var rect = e.currentTarget.getBoundingClientRect()\n\n this.isDrawing = true;\n\n this.x1 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio;\n this.y1 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n this.startX = e.offsetX;\n this.startY = e.offsetY;\n\n console.log(\"Mouse down at:\", this.x1, this.y1);\n }\n\n mouseMove(e) {\n if (!this.isDrawing) return;\n this.ctx.clearRect(0, 0, this.overlayCanvas.width, this.overlayCanvas.height); // Clear canvas\n let width = e.offsetX - this.startX;\n let height = e.offsetY - this.startY;\n console.log(\"Mouse Move at:\", this.x1, this.y1);\n this.ctx.strokeRect(this.startX , this.startY, width, height);\n\n }\n\n mouseUp(e) {\n this.isDrawing = false;\n\n var rect = e.currentTarget.getBoundingClientRect()\n\n this.x2 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio;\n this.y2 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n\n console.log(\"Mouse up at: \", this.x2, this.y2);\n this.storeCoordinates();\n }\n\n mouseOut() {\n if (this.isDrawing) {\n // Store coordinates also when the mouse accidentally leaves the canvas\n\n var rect = e.currentTarget.getBoundingClientRect()\n\n this.x2 = e.clientX * window.devicePixelRatio - rect.left * window.devicePixelRatio;\n this.y2 = e.clientY * window.devicePixelRatio - rect.top * window.devicePixelRatio;\n \n console.log(\"Mouse out at: \", this.x2, this.y2);\n\n this.storeCoordinates();\n }\n this.isDrawing = false;\n }\n\n storeCoordinates() {\n let topleft = { x: this.x1, y: this.y1 };\n let bottomright = { x: this.x2, y: this.y2 };\n this.callback(topleft, bottomright); // Invoke the callback with the coordinates\n }\n}\n\n// Usage:\n// Assuming `callback` is a function that handles the top-left and bottom-right coordinates\n// And `element` is the canvas element to which the bounding box should be applied\n// let element = document.getElementById('canvas');\n// let bbox = new BBox(element, callback);\n// bbox.init();\n"],"names":[],"version":3,"file":"boxCraft.min.js.map"} \ No newline at end of file diff --git a/operatingSystem.js b/operatingSystem.js new file mode 100644 index 00000000..aef498a9 --- /dev/null +++ b/operatingSystem.js @@ -0,0 +1,24 @@ +const { execSync } = require('child_process'); +const os = require('os'); + +// Define source and destination files +const source = './submodule/BoxCraft/dist/boxcraft.min.js'; +const destination = './dist/'; + +// Commands for different OSes +const copyCommand = { + 'win32': `copy ${source} ${destination}`, + 'linux': `cp ${source} ${destination}`, + 'darwin': `cp ${source} ${destination}` // macOS +}; + +// Get the current OS platform +const platform = os.platform(); + +// Execute the command for the current OS +try { + execSync(`${copyCommand[platform]} && ${copyCommand[platform]}.map`); + console.log('Files copied successfully.'); +} catch (error) { + console.error('Error during file copying:', error); +} diff --git a/package.json b/package.json index 2c77b370..cef9f918 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,10 @@ "dev": "npx live-server --port=5501 --no-browser", "test": "node --experimental-modules ./tests/scripts/index.js", "prebuild": "git submodule init && git submodule update", - "build-boxcraft": "npx parcel build submodule/BoxCraft/src/index.js --dist-dir ./dist && cp submodule/BoxCraft/dist/boxcraft.min.js ./dist/boxcraft.min.js && cp submodule/BoxCraft/dist/boxcraft.min.js.map ./dist/boxcraft.min.js.map", - "build": "npx parcel build --no-cache && npm run build-boxcraft" + "build-boxcraft": "npx parcel build submodule/BoxCraft/src/index.js --dist-dir ./dist && node operatingSystem.js", + "build-boostlet": "npx parcel build --no-cache", + "build": "npm run build-boostlet && npm run build-boxcraft" + }, "devDependencies": { "cross-env": "^7.0.3",