init
This commit is contained in:
149
nv/html/dwv/viewers/simplistic/alert.js
Normal file
149
nv/html/dwv/viewers/simplistic/alert.js
Normal file
@@ -0,0 +1,149 @@
|
||||
// namespaces
|
||||
var dwv = dwv || {};
|
||||
dwv.tool = dwv.tool || {};
|
||||
|
||||
/**
|
||||
* Alert tool: demo tool that does a lot of logging and alerts.
|
||||
* In order to activate it:
|
||||
* - include it in your html
|
||||
* - add it in the app tools when calling app.init
|
||||
* @constructor
|
||||
* @param {Object} app The associated application.
|
||||
*/
|
||||
dwv.tool.Alert = function (app)
|
||||
{
|
||||
/**
|
||||
* Associated GUI.
|
||||
* @type Object
|
||||
*/
|
||||
var gui = null;
|
||||
|
||||
/**
|
||||
* Handle mouse down event.
|
||||
* @param {Object} event The mouse down event.
|
||||
*/
|
||||
this.mousedown = function (event) {
|
||||
console.log("[alert:tool:mousedown]");
|
||||
console.log(event);
|
||||
alert("Alert: mousedown.");
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle mouse move event.
|
||||
* @param {Object} event The mouse move event.
|
||||
*/
|
||||
this.mousemove = function (event) {
|
||||
console.log("[alert:tool:mousemove]");
|
||||
console.log(event);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle mouse up event.
|
||||
* @param {Object} event The mouse up event.
|
||||
*/
|
||||
this.mouseup = function (event) {
|
||||
console.log("[alert:tool:mouseup]");
|
||||
console.log(event);
|
||||
alert("Alert: mouseup.");
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup the tool GUI.
|
||||
* Called when the app is created.
|
||||
*/
|
||||
this.setup = function () {
|
||||
console.log("[alert:tool:setup]");
|
||||
|
||||
gui = new dwv.gui.Alert(app);
|
||||
gui.setup();
|
||||
};
|
||||
|
||||
/**
|
||||
* Display the tool.
|
||||
* Called when switching tools: the last enabled tool is hidden and the current one shown.
|
||||
* @param {Boolean} bool The flag to display or not.
|
||||
*/
|
||||
this.display = function (bool) {
|
||||
console.log("[alert:tool:display]");
|
||||
console.log("bool: "+bool);
|
||||
|
||||
gui.display(bool);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise the tool.
|
||||
* Called once an image has been loaded.
|
||||
*/
|
||||
this.init = function () {
|
||||
console.log("[alert:tool:init]");
|
||||
|
||||
gui.initialise();
|
||||
};
|
||||
|
||||
}; // Alert class
|
||||
|
||||
/**
|
||||
* Help for this tool.
|
||||
* @return {Object} The help content.
|
||||
*/
|
||||
dwv.tool.Alert.prototype.getHelp = function ()
|
||||
{
|
||||
return {
|
||||
"title": "Alert",
|
||||
"brief": "Keeps calling alert!",
|
||||
"mouse": {
|
||||
"mouse_drag": "This will launch an alert!"
|
||||
},
|
||||
"touch": {
|
||||
"touch_drag": "This will launch an alert!"
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Alert tool GUI.
|
||||
* @param {Object} app The associated application.
|
||||
*/
|
||||
dwv.gui.Alert = function (app)
|
||||
{
|
||||
/**
|
||||
* Setup the tool GUI.
|
||||
* Called by the tool setup method.
|
||||
*/
|
||||
this.setup = function () {
|
||||
console.log("[alert:gui:setup]");
|
||||
|
||||
var button = document.createElement("button");
|
||||
button.className = "alert-button";
|
||||
button.value = "Alert";
|
||||
// let the app handle the tool change
|
||||
button.onclick = app.onChangeTool;
|
||||
button.appendChild(document.createTextNode("Alert!"));
|
||||
|
||||
// the app handles finding the document HTML element
|
||||
// so that they are all in the same div.
|
||||
var node = app.getElement("toolbar");
|
||||
node.appendChild(button);
|
||||
};
|
||||
|
||||
/**
|
||||
* Display the tool.
|
||||
* Called by the tool display method.
|
||||
* @param {Boolean} bool The flag to display or not.
|
||||
*/
|
||||
this.display = function (bool) {
|
||||
console.log("[alert:gui:display]");
|
||||
console.log("bool: "+bool);
|
||||
|
||||
var button = app.getElement("alert-button");
|
||||
button.disabled = bool;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise the tool.
|
||||
* Called by the tool init method.
|
||||
*/
|
||||
this.initialise = function () {
|
||||
console.log("[alert:gui:initialise]");
|
||||
};
|
||||
};
|
||||
149
nv/html/dwv/viewers/simplistic/appgui.js
Normal file
149
nv/html/dwv/viewers/simplistic/appgui.js
Normal file
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* Application GUI.
|
||||
*/
|
||||
|
||||
// Default window level presets.
|
||||
dwv.tool.defaultpresets = {};
|
||||
// Default window level presets for CT.
|
||||
dwv.tool.defaultpresets.CT = {
|
||||
"mediastinum": {"center": 40, "width": 400},
|
||||
"lung": {"center": -500, "width": 1500},
|
||||
"bone": {"center": 500, "width": 2000},
|
||||
};
|
||||
|
||||
// decode query
|
||||
dwv.utils.decodeQuery = dwv.utils.base.decodeQuery;
|
||||
|
||||
// Window
|
||||
dwv.gui.getWindowSize = dwv.gui.base.getWindowSize;
|
||||
// Progress
|
||||
dwv.gui.displayProgress = function (/*percent*/) { /*does nothing*/ };
|
||||
// get element
|
||||
dwv.gui.getElement = dwv.gui.base.getElement;
|
||||
// refresh
|
||||
dwv.gui.refreshElement = dwv.gui.base.refreshElement;
|
||||
// Slider
|
||||
dwv.gui.Slider = null;
|
||||
// Tags table
|
||||
dwv.gui.DicomTags = null;
|
||||
|
||||
// Toolbox
|
||||
dwv.gui.Toolbox = function (app)
|
||||
{
|
||||
this.setup = function (/*list*/)
|
||||
{
|
||||
// does nothing
|
||||
};
|
||||
this.display = function (/*bool*/)
|
||||
{
|
||||
// does nothing
|
||||
};
|
||||
this.initialise = function (list)
|
||||
{
|
||||
// not wonderful: first one should be scroll is more than one slice
|
||||
if ( list[0] === false ) {
|
||||
var inputScroll = app.getElement("scroll-button");
|
||||
inputScroll.style.display = "none";
|
||||
var inputZoom = app.getElement("zoom-button");
|
||||
inputZoom.checked = true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Window/level
|
||||
dwv.gui.WindowLevel = function (app)
|
||||
{
|
||||
this.setup = function ()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.className = "wl-button";
|
||||
button.value = "WindowLevel";
|
||||
button.onclick = app.onChangeTool;
|
||||
button.appendChild(document.createTextNode(dwv.i18n("tool.WindowLevel.name")));
|
||||
|
||||
var node = app.getElement("toolbar");
|
||||
node.appendChild(button);
|
||||
};
|
||||
this.display = function (bool)
|
||||
{
|
||||
var button = app.getElement("wl-button");
|
||||
button.disabled = bool;
|
||||
};
|
||||
this.initialise = function ()
|
||||
{
|
||||
// clear previous
|
||||
dwv.html.removeNode(app.getElement("presetSelect"));
|
||||
dwv.html.removeNode(app.getElement("presetLabel"));
|
||||
|
||||
// create preset select
|
||||
var select = dwv.html.createHtmlSelect("presetSelect",
|
||||
app.getViewController().getWindowLevelPresetsNames(), "wl.presets", true);
|
||||
select.className = "presetSelect";
|
||||
select.onchange = app.onChangeWindowLevelPreset;
|
||||
select.title = "Select w/l preset.";
|
||||
select.setAttribute("data-inline","true");
|
||||
var label = document.createElement("label");
|
||||
label.className = "presetLabel";
|
||||
label.setAttribute("for", "presetSelect");
|
||||
label.appendChild(document.createTextNode(dwv.i18n("basics.presets") + ": "));
|
||||
|
||||
var node = app.getElement("toolbar");
|
||||
node.appendChild(label);
|
||||
node.appendChild(select);
|
||||
};
|
||||
};
|
||||
|
||||
// Zoom
|
||||
dwv.gui.ZoomAndPan = function (app)
|
||||
{
|
||||
this.setup = function ()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.className = "zoom-button";
|
||||
button.value = "ZoomAndPan";
|
||||
button.onclick = app.onChangeTool;
|
||||
button.appendChild(document.createTextNode(dwv.i18n("tool.ZoomAndPan.name")));
|
||||
|
||||
var node = app.getElement("toolbar");
|
||||
node.appendChild(button);
|
||||
};
|
||||
this.display = function (bool)
|
||||
{
|
||||
var button = app.getElement("zoom-button");
|
||||
button.disabled = bool;
|
||||
};
|
||||
};
|
||||
|
||||
// Scroll
|
||||
dwv.gui.Scroll = function (app)
|
||||
{
|
||||
this.setup = function ()
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.className = "scroll-button";
|
||||
button.value = "Scroll";
|
||||
button.onclick = app.onChangeTool;
|
||||
button.appendChild(document.createTextNode(dwv.i18n("tool.Scroll.name")));
|
||||
|
||||
var node = app.getElement("toolbar");
|
||||
node.appendChild(button);
|
||||
};
|
||||
this.display = function (bool)
|
||||
{
|
||||
var button = app.getElement("scroll-button");
|
||||
button.disabled = bool;
|
||||
};
|
||||
};
|
||||
|
||||
//Reset
|
||||
dwv.gui.appendResetHtml = function (app)
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.className = "reset-button";
|
||||
button.value = "reset";
|
||||
button.onclick = app.onDisplayReset;
|
||||
button.appendChild(document.createTextNode(dwv.i18n("basics.reset")));
|
||||
|
||||
var node = app.getElement("toolbar");
|
||||
node.appendChild(button);
|
||||
};
|
||||
51
nv/html/dwv/viewers/simplistic/applauncher.js
Normal file
51
nv/html/dwv/viewers/simplistic/applauncher.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Application launcher.
|
||||
*/
|
||||
|
||||
// start app function
|
||||
function startApp() {
|
||||
// main application
|
||||
var myapp = new dwv.App();
|
||||
// initialise the application
|
||||
myapp.init({
|
||||
"containerDivId": "dwv",
|
||||
"fitToWindow": true,
|
||||
"gui": ["tool"],
|
||||
"tools": ["Scroll", "ZoomAndPan", "WindowLevel"],
|
||||
"isMobile": true
|
||||
});
|
||||
dwv.gui.appendResetHtml(myapp);
|
||||
}
|
||||
|
||||
// Image decoders (for web workers)
|
||||
dwv.image.decoderScripts = {
|
||||
"jpeg2000": "../../decoders/pdfjs/decode-jpeg2000.js",
|
||||
"jpeg-lossless": "../../decoders/rii-mango/decode-jpegloss.js",
|
||||
"jpeg-baseline": "../../decoders/pdfjs/decode-jpegbaseline.js"
|
||||
};
|
||||
|
||||
// status flags
|
||||
var domContentLoaded = false;
|
||||
var i18nInitialised = false;
|
||||
// launch when both DOM and i18n are ready
|
||||
function launchApp() {
|
||||
if ( domContentLoaded && i18nInitialised ) {
|
||||
startApp();
|
||||
}
|
||||
}
|
||||
// i18n ready?
|
||||
dwv.i18nOnInitialised( function () {
|
||||
i18nInitialised = true;
|
||||
launchApp();
|
||||
});
|
||||
|
||||
// check browser support
|
||||
dwv.browser.check();
|
||||
// initialise i18n
|
||||
dwv.i18nInitialise();
|
||||
|
||||
// DOM ready?
|
||||
document.addEventListener("DOMContentLoaded", function (/*event*/) {
|
||||
domContentLoaded = true;
|
||||
launchApp();
|
||||
});
|
||||
128
nv/html/dwv/viewers/simplistic/index.html
Normal file
128
nv/html/dwv/viewers/simplistic/index.html
Normal file
@@ -0,0 +1,128 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>DICOM Web Viewer</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="DICOM Web Viewer (DWV) simple version">
|
||||
<meta name="keywords" content="DICOM,HTML5,JavaScript,medical,imaging,DWV">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<link type="text/css" rel="stylesheet" href="../../css/style.css" />
|
||||
<style type="text/css" >
|
||||
body { background: #252525; color: #fff; }
|
||||
button {
|
||||
margin: 5px; padding: 10px 10px;
|
||||
border: 0 none; border-radius: 4px;
|
||||
font-size: 14px; font-weight: 600;
|
||||
color: #fff; background-color: #444; }
|
||||
button:hover { background-color: #555; }
|
||||
button:disabled { background-color: #08b; }
|
||||
.toolbar { font: 14px arial, sans-serif; margin-bottom: 5px; text-align: center; }
|
||||
.wl-button, .reset-button { margin-right: 5px; }
|
||||
.layerContainer { margin: auto; text-align: center; }
|
||||
.imageLayer { left: 0px; }
|
||||
</style>
|
||||
<!-- mobile web app -->
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<link rel="shortcut icon" sizes="16x16" href="../../resources/icons/dwv-16.png" />
|
||||
<link rel="shortcut icon" sizes="60x60" href="../../resources/icons/dwv-60.png" />
|
||||
<link rel="shortcut icon" sizes="128x128" href="../../resources/icons/dwv-128.png" />
|
||||
<!-- apple specific -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
<link rel="apple-touch-icon" sizes="16x16" href="../../resources/icons/dwv-16.png" />
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="../../resources/icons/dwv-60.png" />
|
||||
<link rel="apple-touch-icon" sizes="128x128" href="../../resources/icons/dwv-128.png" />
|
||||
<!-- Third party (dwv) -->
|
||||
<script type="text/javascript" src="../../ext/modernizr/modernizr.js"></script>
|
||||
<script type="text/javascript" src="../../ext/i18next/i18next.min.js"></script>
|
||||
<script type="text/javascript" src="../../ext/i18next/i18nextXHRBackend.min.js"></script>
|
||||
<script type="text/javascript" src="../../ext/i18next/i18nextBrowserLanguageDetector.min.js"></script>
|
||||
<!-- decoders -->
|
||||
<script type="text/javascript" src="../../decoders/pdfjs/jpx.js"></script>
|
||||
<script type="text/javascript" src="../../decoders/pdfjs/util.js"></script>
|
||||
<script type="text/javascript" src="../../decoders/pdfjs/arithmetic_decoder.js"></script>
|
||||
<script type="text/javascript" src="../../decoders/pdfjs/jpg.js"></script>
|
||||
<script type="text/javascript" src="../../decoders/rii-mango/lossless-min.js"></script>
|
||||
<!-- Local -->
|
||||
<script type="text/javascript" src="../../src/app/application.js"></script>
|
||||
<script type="text/javascript" src="../../src/app/drawController.js"></script>
|
||||
<script type="text/javascript" src="../../src/app/infoController.js"></script>
|
||||
<script type="text/javascript" src="../../src/app/toolboxController.js"></script>
|
||||
<script type="text/javascript" src="../../src/app/viewController.js"></script>
|
||||
<script type="text/javascript" src="../../src/dicom/dicomParser.js"></script>
|
||||
<script type="text/javascript" src="../../src/dicom/dictionary.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/filter.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/generic.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/help.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/html.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/info.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/layer.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/loader.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/style.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/tools.js"></script>
|
||||
<script type="text/javascript" src="../../src/gui/undo.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/decoder.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/dicomBufferToView.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/domReader.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/filter.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/geometry.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/image.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/luts.js"></script>
|
||||
<script type="text/javascript" src="../../src/image/view.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/filesLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/urlsLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/memoryLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/dicomDataLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/jsonTextLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/rawImageLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/io/rawVideoLoader.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/matrix.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/bucketQueue.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/point.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/scissors.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/shapes.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/stats.js"></script>
|
||||
<script type="text/javascript" src="../../src/math/vector.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/draw.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/drawCommands.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/ellipse.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/filter.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/livewire.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/rectangle.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/roi.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/ruler.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/scroll.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/toolbox.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/undo.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/windowLevel.js"></script>
|
||||
<script type="text/javascript" src="../../src/tools/zoomPan.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/browser.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/i18n.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/progress.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/listen.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/string.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/uri.js"></script>
|
||||
<script type="text/javascript" src="../../src/utils/thread.js"></script>
|
||||
|
||||
<!-- Launch the app -->
|
||||
<script type="text/javascript" src="appgui.js"></script>
|
||||
<script type="text/javascript" src="applauncher.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- DWV -->
|
||||
<div id="dwv">
|
||||
|
||||
<!-- Toolbar -->
|
||||
<div class="toolbar"></div>
|
||||
<!-- Layer Container -->
|
||||
<div class="layerContainer">
|
||||
<canvas class="imageLayer">Only for HTML5 compatible browsers...</canvas>
|
||||
</div><!-- /layerContainer -->
|
||||
|
||||
</div><!-- /dwv -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user