/** * GUI module. * @module gui */ var dwv = dwv || {}; /** * Namespace for GUI functions. * @class gui * @namespace dwv * @static */ dwv.gui = dwv.gui || {}; dwv.gui.base = dwv.gui.base || {}; /** * Append the toolbox HTML to the page. * @method appendToolboxHtml * @static */ dwv.gui.base.appendToolboxHtml = function() { // tool select var toolSelector = dwv.html.createHtmlSelect("toolSelect",dwv.tool.tools); toolSelector.onchange = dwv.gui.onChangeTool; // tool list element var toolLi = document.createElement("li"); toolLi.id = "toolLi"; toolLi.style.display = "none"; toolLi.appendChild(toolSelector); toolLi.setAttribute("class","ui-block-a"); // node var node = document.getElementById("toolList"); // clear it while(node.hasChildNodes()) { node.removeChild(node.firstChild); } // append node.appendChild(toolLi); // trigger create event (mobile) $("#toolList").trigger("create"); }; /** * Display the toolbox HTML. * @method displayToolboxHtml * @static * @param {Boolean} bool True to display, false to hide. */ dwv.gui.base.displayToolboxHtml = function(bool) { // tool list element dwv.html.displayElement("toolLi", bool); }; /** * Initialise the toolbox HTML. * @method initToolboxHtml * @static */ dwv.gui.base.initToolboxHtml = function() { // tool select: reset selected option var toolSelector = document.getElementById("toolSelect"); toolSelector.selectedIndex = 0; dwv.gui.refreshSelect("#toolSelect"); }; /** * Append the window/level HTML to the page. * @method appendWindowLevelHtml * @static */ dwv.gui.base.appendWindowLevelHtml = function() { // preset select var wlSelector = dwv.html.createHtmlSelect("presetSelect",dwv.tool.presets); wlSelector.onchange = dwv.gui.onChangeWindowLevelPreset; // colour map select var cmSelector = dwv.html.createHtmlSelect("colourMapSelect",dwv.tool.colourMaps); cmSelector.onchange = dwv.gui.onChangeColourMap; // preset list element var wlLi = document.createElement("li"); wlLi.id = "wlLi"; wlLi.style.display = "none"; wlLi.appendChild(wlSelector); wlLi.setAttribute("class","ui-block-b"); // color map list element var cmLi = document.createElement("li"); cmLi.id = "cmLi"; cmLi.style.display = "none"; cmLi.appendChild(cmSelector); cmLi.setAttribute("class","ui-block-c"); // node var node = document.getElementById("toolList"); // append preset node.appendChild(wlLi); // append color map node.appendChild(cmLi); // trigger create event (mobile) $("#toolList").trigger("create"); }; /** * Display the window/level HTML. * @method displayWindowLevelHtml * @static * @param {Boolean} bool True to display, false to hide. */ dwv.gui.base.displayWindowLevelHtml = function(bool) { // presets list element dwv.html.displayElement("wlLi", bool); // color map list element dwv.html.displayElement("cmLi", bool); }; /** * Initialise the window/level HTML. * @method initWindowLevelHtml * @static */ dwv.gui.base.initWindowLevelHtml = function() { // create new preset select var wlSelector = dwv.html.createHtmlSelect("presetSelect",dwv.tool.presets); wlSelector.onchange = dwv.gui.onChangeWindowLevelPreset; wlSelector.title = "Select w/l preset."; // copy html list var wlLi = document.getElementById("wlLi"); // clear node dwv.html.cleanNode(wlLi); // add children wlLi.appendChild(wlSelector); $("#toolList").trigger("create"); // colour map select var cmSelector = document.getElementById("colourMapSelect"); cmSelector.selectedIndex = 0; // special monochrome1 case if( app.getImage().getPhotometricInterpretation() === "MONOCHROME1" ) { cmSelector.selectedIndex = 1; } dwv.gui.refreshSelect("#colourMapSelect"); }; /** * Append the draw HTML to the page. * @method appendDrawHtml * @static */ dwv.gui.base.appendDrawHtml = function() { // shape select var shapeSelector = dwv.html.createHtmlSelect("shapeSelect",dwv.tool.shapes); shapeSelector.onchange = dwv.gui.onChangeShape; // colour select var colourSelector = dwv.html.createHtmlSelect("colourSelect",dwv.tool.colors); colourSelector.onchange = dwv.gui.onChangeLineColour; // shape list element var shapeLi = document.createElement("li"); shapeLi.id = "shapeLi"; shapeLi.style.display = "none"; shapeLi.appendChild(shapeSelector); shapeLi.setAttribute("class","ui-block-c"); // colour list element var colourLi = document.createElement("li"); colourLi.id = "colourLi"; colourLi.style.display = "none"; colourLi.appendChild(colourSelector); colourLi.setAttribute("class","ui-block-b"); // node var node = document.getElementById("toolList"); // apend shape node.appendChild(shapeLi); // append color node.appendChild(colourLi); // trigger create event (mobile) $("#toolList").trigger("create"); }; /** * Display the draw HTML. * @method displayDrawHtml * @static * @param {Boolean} bool True to display, false to hide. */ dwv.gui.base.displayDrawHtml = function(bool) { // color list element dwv.html.displayElement("colourLi", bool); // shape list element dwv.html.displayElement("shapeLi", bool); }; /** * Initialise the draw HTML. * @method displayDrawHtml * @static * */ dwv.gui.base.initDrawHtml = function() { // shape select: reset selected option var shapeSelector = document.getElementById("shapeSelect"); shapeSelector.selectedIndex = 0; dwv.gui.refreshSelect("#shapeSelect"); // color select: reset selected option var colourSelector = document.getElementById("colourSelect"); colourSelector.selectedIndex = 0; dwv.gui.refreshSelect("#colourSelect"); }; /** * Append the color chooser HTML to the page. * @method appendLivewireHtml * @static */ dwv.gui.base.appendLivewireHtml = function() { // colour select var colourSelector = dwv.html.createHtmlSelect("lwColourSelect",dwv.tool.colors); colourSelector.onchange = dwv.gui.onChangeLineColour; // colour list element var colourLi = document.createElement("li"); colourLi.id = "lwColourLi"; colourLi.style.display = "none"; colourLi.setAttribute("class","ui-block-b"); colourLi.appendChild(colourSelector); // node var node = document.getElementById("toolList"); // apend colour node.appendChild(colourLi); // trigger create event (mobile) $("#toolList").trigger("create"); }; /** * Display the livewire HTML. * @method displayLivewireHtml * @static * @param {Boolean} bool True to display, false to hide. */ dwv.gui.base.displayLivewireHtml = function(bool) { // colour list dwv.html.displayElement("lwColourLi", bool); }; /** * Initialise the livewire HTML. * @method initLivewireHtml * @static */ dwv.gui.base.initLivewireHtml = function() { var colourSelector = document.getElementById("lwColourSelect"); colourSelector.selectedIndex = 0; dwv.gui.refreshSelect("#lwColourSelect"); }; /** * Append the ZoomAndPan HTML to the page. * @method appendZoomAndPanHtml * @static */ dwv.gui.base.appendZoomAndPanHtml = function() { // reset button var button = document.createElement("button"); button.id = "zoomResetButton"; button.name = "zoomResetButton"; button.onclick = dwv.gui.onZoomReset; button.setAttribute("style","width:100%; margin-top:0.5em;"); button.setAttribute("class","ui-btn ui-btn-b"); var text = document.createTextNode("Reset"); button.appendChild(text); // list element var liElement = document.createElement("li"); liElement.id = "zoomLi"; liElement.style.display = "none"; liElement.setAttribute("class","ui-block-c"); liElement.appendChild(button); // node var node = document.getElementById("toolList"); // append element node.appendChild(liElement); // trigger create event (mobile) $("#toolList").trigger("create"); }; /** * Display the ZoomAndPan HTML. * @method displayZoomAndPanHtml * @static * @param {Boolean} bool True to display, false to hide. */ dwv.gui.base.displayZoomAndPanHtml = function(bool) { // display list element dwv.html.displayElement("zoomLi", bool); }; /** * Append the Scroll HTML to the page. * @method appendScrollHtml * @static */ dwv.gui.base.appendScrollHtml = function() { // list element var liElement = document.createElement("li"); liElement.id = "scrollLi"; liElement.style.display = "none"; liElement.setAttribute("class","ui-block-c"); // node var node = document.getElementById("toolList"); // append element node.appendChild(liElement); // trigger create event (mobile) $("#toolList").trigger("create"); }; /** * Display the Scroll HTML. * @method displayScrollHtml * @static * @param {Boolean} bool True to display, false to hide. */ dwv.gui.base.displayScrollHtml = function(bool) { // display list element dwv.html.displayElement("scrollLi", bool); };