diff --git a/panther2d.js b/panther2d.js index d8fd3c20b7ea1098e33f1eeec61293822426c6e3..639dbd893613449f5edb47b27df714c36593172f 100644 --- a/panther2d.js +++ b/panther2d.js @@ -525,7 +525,8 @@ if (document.location.search.indexOf('pan=')>-1) pan = document.location.search.split('pan=')[1].split('&')[0].split(','); if (document.location.search.indexOf('search=')>-1) findComponent(document.location.search.split('search=')[1].split('&')[0]); else { - const zoom = document.location.search.indexOf('zoom=')>-1? document.location.search.split('zoom=')[1].split('&')[0]-0: 0.5; + const default_zoom = typeof conf.default_zoom[machine.split('_')[0]]=='undefined'? conf.default_zoom.default: conf.default_zoom[machine.split('_')[0]]; + const zoom = document.location.search.indexOf('zoom=')>-1? document.location.search.split('zoom=')[1].split('&')[0]-0: default_zoom; panZoomPanther.zoom(zoom); setTimeout(panZoomPanther.pan, 600, {x: pan[0], y: pan[1]}); } @@ -568,6 +569,11 @@ setInterval(updateVlv, 1000); } $("#sname").on("keydown", searchText); + if (lattice.conf.modules) { + for (let i=0; i<lattice.conf.modules.length; i++) { + window[lattice.conf.modules[i]](lattice); + } + } }); } function showStatus(i, stat) { @@ -673,34 +679,7 @@ return labelReverse==180? "translate("+rescale(x)+" "+rescale(y)+") rotate("+(beta-90)+") translate(1800 100)": "translate("+rescale(x)+" "+rescale(y)+") rotate("+(beta+90)+") translate("+(labelReverse? -350: 350)+" "+(labelReverse? 100: 200)+")"; } - function appendLabel(id, labelclass, display, x, y, beta, labelReverse) { - if ((beta+3600)%360 <180 && typeof labelReverse != 'object') labelReverse = [-90, -250, -100]; - appendSvg("text", { - id: id+'label', - class: labelclass, - x:0, y:0, style:"display: "+display, fill:"white", stroke:"#101020","stroke-width":5, "font-family":"Arial", "font-size":100, "font-weight":"900", - "text-anchor": (labelReverse? "end": "start"), - transform: transformLabel(x, y, beta, labelReverse) - }, false, id); - } - function appendLabel2(param, labelclass, display, x, y, beta, labelReverse) { - const id = param.name; - const fontsize = labelclass.indexOf('bl')>-1? 800: 500; - // console.log("appendLabel2()",param, labelclass, display, x, y, beta, labelReverse); - if (labelclass.indexOf('bl')>-1 && typeof labelReverse != 'object') { - labelReverse = [180, 17000, param.type=='beamlineUp'? -500: +800]; - if ((beta+3690)%360 < 180) labelReverse = [0, -14000, param.type=='beamlineUp'? 1000: -300]; - } - else if ((beta+3600)%360 < 180 && typeof labelReverse != 'object') labelReverse = [-90, -250, -100]; - appendSvg("text", { - id: id+'label', - class: labelclass, - x:0, y:0, style:"display: block", fill:"red", stroke:"pink","stroke-width":5, "font-family":"Arial", "font-size":fontsize, "font-weight":"900", - "text-anchor": (labelReverse? "end": "start"), - transform: transformLabel(x, y, beta, labelReverse) - }, false, id); - } - function appendSvg(tagName, attrib, onClickCall=false, text=false, myclass=false) { + function appendSvg(tagName, attrib, onClickCall=false, text=false, myclass=false, appendTo="svg") { const elem = document.createElementNS("http://www.w3.org/2000/svg", tagName); if (onClickCall) elem.addEventListener("click", onClickCall, false); const titelem = document.createElementNS("http://www.w3.org/2000/svg", 'title'); @@ -710,15 +689,15 @@ titelem.appendChild(title); elem.appendChild(titelem); if (text) { - const textNode = document.createTextNode(text); - elem.appendChild(textNode); + // const textNode = document.createTextNode(text); elem.appendChild(textNode); + elem.innerHTML = text; } const jelem = $(elem); if (myclass) {/*mylog(elem, jelem, myclass);*/ elem.classList.add(myclass);} for (let i in attrib) { jelem.attr(i, attrib[i]); } - $("svg").append(jelem); + $(appendTo.replace('.','_').replace(' ','_')).append(jelem); } function appendSearch(component, facility) { // mylog('appendSearch()',component, facility); @@ -746,6 +725,33 @@ } } } + function appendLabel(id, labelclass, display, x, y, beta, labelReverse, suffix='label', fontSize=1, appendTo="svg") { + if ((beta+3600)%360 <180 && typeof labelReverse != 'object') labelReverse = [-90, -250, -100]; + appendSvg("text", { + id: (id+suffix).replace(' ','_'), + class: labelclass, + x:0, y:0, style:"display: "+display, fill:"white", stroke:"#101020","stroke-width":5, "font-family":"Arial", "font-size":100*fontSize, "font-weight":"900", + "text-anchor": (labelReverse? "end": "start"), + transform: transformLabel(x, y, beta, labelReverse) + }, false, id, false, appendTo); + } + function appendLabel2(param, labelclass, display, x, y, beta, labelReverse, suffix='label') { + const id = param.name; + const fontsize = labelclass.indexOf('bl')>-1? 800: 500; + // console.log("appendLabel2()",param, labelclass, display, x, y, beta, labelReverse); + if (labelclass.indexOf('bl')>-1 && typeof labelReverse != 'object') { + labelReverse = [180, 17000, param.type=='beamlineUp'? -500: +800]; + if ((beta+3690)%360 < 180) labelReverse = [0, -14000, param.type=='beamlineUp'? 1000: -300]; + } + else if ((beta+3600)%360 < 180 && typeof labelReverse != 'object') labelReverse = [-90, -250, -100]; + appendSvg("text", { + id: id+suffix, + class: labelclass, + x:0, y:0, style:"display: block", fill:"red", stroke:"pink","stroke-width":5, "font-family":"Arial", "font-size":fontsize, "font-weight":"900", + "text-anchor": (labelReverse? "end": "start"), + transform: transformLabel(x, y, beta, labelReverse) + }, false, id); + } function appendComponent(components, x0, y0, x1, y1, facility) { const dx = x1 - x0; const dy = y1 - y0; @@ -787,6 +793,10 @@ appendLabel2(components[i], section+facility, 'none', x, y, beta, components[i].labelReverse); else appendLabel(components[i].name, comp+' label '+section+facility, 'none', x, y, beta, components[i].labelReverse); + if (id[0].indexOf('<')==-1) { + appendSvg("g", {"id": id[0]+'_g'}); + appendLabel(components[i].name, comp+' value '+section+facility, 'none', x+600, y+400, 90, true, 'value', 0.7, '#'+id[0]+'_g'); + } names.push(id[0]); shrinkedNames.push(shrinkName(id[0]));