diff --git a/panther2d.js b/panther2d.js
index 685bc8e08fc3b99fb95a5401ec78515e13c59593..4d0919f521d8779cac2f2e0ace6ba790ce045e05 100644
--- a/panther2d.js
+++ b/panther2d.js
@@ -32,10 +32,11 @@
 	for (let i=0; i<pa.length; i++) {const p = pa[i].split('='); parameters[p[0]] = p[1];}
 	const machineCaseSensitive = document.location.search.indexOf('machine=')>-1? document.location.search.split('machine=')[1].split('&')[0]: 'elettra';
 	const machine = machineCaseSensitive.toLowerCase();
-	const backgroundColor = document.location.search.indexOf('backgroundColor=')>-1? document.location.search.split('backgroundColor=')[1].split('&')[0]: '#333333';
-	const trajectoryWidth = document.location.search.indexOf('trajectoryWidth=')>-1? document.location.search.split('trajectoryWidth=')[1].split('&')[0]-0: 2;
+	const backgroundColor = document.location.search.indexOf('backgroundColor=')>-1? document.location.search.split('backgroundColor=')[1].split('&')[0]: '#000'; //'#333333';
+	let trajectoryWidth = document.location.search.indexOf('trajectoryWidth=')>-1? document.location.search.split('trajectoryWidth=')[1].split('&')[0]-0: 2;
 	const main = document.getElementById('main');
 	const facilityStatus = {};
+	let ruler = document.location.search.indexOf('ruler')>-1;
 
 	$('body').css('backgroundColor', backgroundColor);
 	let measurementStart = false;
@@ -52,8 +53,13 @@
 	}
 	else $('#bm').hide();
 	let measurement = typeof measurementType == "object" || measurementType;
+	function pad(n, width, z) {
+		z = z || '0';
+		n = n + '';
+		return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
+	}
 	function getRulerPosition(main, event, facility) {
-		// console.log('clickStat', clickStat);
+		// console.log('getRulerPosition', main, event, facility);
 		if (clickStat) return;
 		const rect = main.getBoundingClientRect();
 		const x = event.clientX - rect.left;
@@ -78,29 +84,39 @@
 		$('#rulerg').attr('transform', 'translate('+ (p.x)+' '+(p.y)+'),rotate('+alpha+')');
 	}
 	function rulerInit() {
+		if ($('#rulerg')[0]) return;
 		const cx=0, cy=0;
 		appendSvg("g", {id: 'rulerg'}, false, false, 'rulerclass');
-		appendSvg("line", {id: 'ruler1', x1: cx-10100, y1: cy, x2: cx+10100, y2: cy, style:"display: block", stroke:"yellow", "stroke-width":100}, false, false, 'rulerclass', '#rulerg');
+		appendSvg("line", {id: 'ruler1', x1: cx-10050, y1: cy, x2: cx+10050, y2: cy, style:"display: block", stroke:"yellow", "stroke-width":100}, false, false, 'rulerclass', '#rulerg');
 		for (let i=-10; i<=10; i++) {
 			const xt = (cx+i*1000);
 			appendSvg("line", {id: 'tick1'+(100-i), x1: xt, y1: cy, x2: xt, y2: cy+300, style:"display: block", stroke:"yellow","stroke-width":100}, false, false, 'rulerclass', '#rulerg');
 			appendSvg("text", {id: 'label'+(100-i), x: xt-300, y: cy+600, fill:"yellow", stroke:"black","stroke-width":1, "font-family":"Arial", "font-size":300, "font-weight":"bold", "text-anchor": "start"}, false, false, 'rulerclass', '#rulerg');
 			if (i) $('#label'+(100-i)).html(Math.abs(i)+' m');
 		}
-		appendSvg("line", {id: 'redruler1', x1: cx, y1: cy, x2: cx, y2: cy+10100, style:"display: block", stroke:"red", "stroke-width":100}, false, false, 'rulerclass', '#rulerg');
+		appendSvg("line", {id: 'redruler1', x1: cx, y1: cy, x2: cx, y2: cy+10050, style:"display: block", stroke:"red", "stroke-width":100}, false, false, 'rulerclass', '#rulerg');
 		for (let i=0; i<=10; i++) {
 			const yt = (cy+i*1000);
 			appendSvg("line", {id: 'redtick1'+(100-i), x1: cx, y1: yt, x2: cx+300, y2: yt, style:"display: block", stroke:"red","stroke-width":100}, false, false, 'rulerclass', '#rulerg');
 			appendSvg("text", {id: 'redlabel'+(100-i), x: cx+400, y: yt, fill:"red", stroke:"black","stroke-width":1, "font-family":"Arial", "font-size":300, "font-weight":"bold", "text-anchor": "start"}, false, false, 'rulerclass', '#rulerg');
 		}
-		appendSvg("line", {id: 'greenruler1', x1: cx, y1: cy, x2: cx, y2: cy-10100, style:"display: block", stroke:"green", "stroke-width":100}, false, false, 'rulerclass', '#rulerg');
+		appendSvg("line", {id: 'greenruler1', x1: cx, y1: cy, x2: cx, y2: cy-10050, style:"display: block", stroke:"green", "stroke-width":100}, false, false, 'rulerclass', '#rulerg');
 		for (let i=0; i<=10; i++) {
 			const yt = (cy-i*1000);
 			appendSvg("line", {id: 'greentick1'+(100-i), x1: cx, y1: yt, x2: cx+300, y2: yt, style:"display: block", stroke:"green","stroke-width":100}, false, false, 'rulerclass', '#rulerg');
 			appendSvg("text", {id: 'greenlabel'+(100-i), x: cx+400, y: yt, fill:"green", stroke:"black","stroke-width":1, "font-family":"Arial", "font-size":300, "font-weight":"bold", "text-anchor": "start"}, false, false, 'rulerclass', '#rulerg');
 		}
 	}
+	function trajectoryWidthSet(a) {
+		console.log(a, zoom);
+		trajectoryWidth = a;
+		$('.trajectory').css('stroke-width', 75*trajectoryWidth/zoom);
+	}
+	function rulerSwitch() {
+		$('#rulerg').toggle();
+	}
 	function rulerScale(scaleprefix, cfactor=1) {
+		if (scaleprefix != '' && $('#scaleh')[0].style.display != 'none') return;
 		const units = [' m', '00 mm', '0 mm', ' mm', '00 &mu;', '0 &mu;', '&mu;', '00 nm', '0 nm', ' nm'];
 		const scaleh = ($('#'+scaleprefix+'scaleh').children().eq(1).children()[1].value-0)*cfactor;
 		const scalehunit = Math.ceil(Math.log10(scaleh));
@@ -109,8 +125,8 @@
 		const scalevunit = Math.ceil(Math.log10(scalev));
 		const scalevfactor = scalev/Math.pow(10, scalevunit);
 		console.log('scaleh', scaleh, 'scalehunit', scalehunit, 'scalehfactor', scalehfactor);
-		$('#redruler1').attr('y2', -10000*scalehfactor);
-		$('#greenruler1').attr('y2', 10000*scalevfactor);
+		$('#redruler1').attr('y2', -10100*scalehfactor);
+		$('#greenruler1').attr('y2', 10100*scalevfactor);
 		for (let i=0; i<=10; i++) {
 			const yh = (-i*1000*scalehfactor);
 			$('#redtick1'+(100-i)).attr('y1', yh);
@@ -420,6 +436,11 @@
 	function shrinkName(name) {
 		return name.replaceAll('FEL0', 'FEL').replaceAll('PS_', 'PS').replaceAll('SIP_', 'SIP').replaceAll('KG0', 'KG').replaceAll('BC0', 'BC').replaceAll('_L0', 'L').replaceAll('_F0', 'F').replaceAll('_0', '').replaceAll('_', '');
 	}
+	function guiconf(gui, id) {
+		const i = gui.children.length - 1;
+		gui.children[i].domElement.style.display = 'none';
+		gui.children[i].domElement.setAttribute('id', id);
+	}
 	// if (navigator.userAgent.indexOf('Firefox/63')==-1) {gui.add(menuParams, 'machine', conf.machineList).onChange(function() {toggleMachine(menuParams.machine);});}
 	gui.add(menuParams, 'machine', conf.machineList).onChange(function() {toggleMachine(menuParams.machine);});
 	gui.add(menuParams, 'search');
@@ -598,6 +619,22 @@
 				if (document.location.search.indexOf('measurement')==-1) measurementToggle(false);
 				if (document.location.search.indexOf('servicearea')>-1) initSearch(lattice.servicearea.sections, 'servicearea');
 				if (typeof blm != 'undefined') blmMenu(lattice, facilities, menuParams);
+				
+				menuParams.trajectoryWidth = trajectoryWidth;
+				gui.add(menuParams, 'trajectoryWidth', 1, 10, 0.2).onChange(function(e) {trajectoryWidthSet(e);});
+				guiconf(gui, 'trajectoryWidth');
+				menuParams.ruler = ruler;
+				gui.add(menuParams, 'ruler').onChange(function() {rulerSwitch();});
+				guiconf(gui, 'ruler');
+				rulerInit();
+				main.addEventListener('mousemove', function(e) {getRulerPosition(main, e, facilities.indexOf('sr')>-1? 'sr': 'fel1');});
+				if (ruler) {
+					main.style.cursor = 'crosshair';
+				}
+				else {
+					$('#rulerg').hide();
+					$('#trajectoryWidth').hide();
+				}
 				bpmInit(facilities); 
 				if (typeof bpmData != 'undefined') bpmMenu(lattice, facilities, menuParams);
 				if (lattice.conf && lattice.conf.shortcut && lattice.conf.shortcut["2d"]) initShortcut(lattice);
@@ -1188,7 +1225,7 @@
 			$('.bending').css('translate', '('+(newScale<1? 1200: 600)+',0)');
 			$('.label').hide();
 		}
-		$('.trajectory').css('stroke-width', 100*trajectoryWidth/newScale);
+		$('.trajectory').css('stroke-width', 75*trajectoryWidth/newScale);
 		for (let i=1; i<=15; i++) if (newScale>i) $('.zoom'+i).show(); else $('.zoom'+i).hide();
 		for (let i=1; i<facilities.length; i++) if(!menuParams[facilities[i]]) $('.'+facilities[i]).hide();
 		if (myPanZoomTimer == null && document.location.search.indexOf('&autoPanZoom')==-1) myPanZoomTimer = setTimeout(myPanZoomDelayed, panZoomTime);