From 8335d995945977174d677d77c805aa9df56db5a0 Mon Sep 17 00:00:00 2001
From: Lucio Zambon <lucio.zambon@elettra.eu>
Date: Mon, 4 Nov 2024 07:57:57 +0000
Subject: [PATCH] Update panther2d.js

---
 panther2d.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/panther2d.js b/panther2d.js
index 24cb579..5fb31a9 100644
--- a/panther2d.js
+++ b/panther2d.js
@@ -461,13 +461,20 @@
 		}
 		$('body').append('<div style="position: absolute; left: 5px; bottom: 5px;">'+index.join(' ')+'</div>');
 	}
+	function toggleFacility(value) {
+		console.log('toggleFacility', value, this);
+		if (value) $('.'+this.property).show(); else $('.'+this.property).hide();
+	}
 	function init() {
 		fetch(latticeFile).then((response) => {return response.json();}).then((flattice) => {
 			lattice = flattice;
 			if (Object.keys(lattice).length>0) {
 				gui.add(menuParams, 'measurement button', {Left: 'left', Right: 'right'}).onChange(measurementFacility);
 				const measurementDevice = {'': ''};
+				const machineFolder = gui.addFolder('toggle facility');
 				for (let i in lattice) {if (i!='conf') facilities.push(i);}
+				menuParams[' '] = false; machineFolder.add(menuParams, ' ').onChange(toggleFacility);
+				for (let i=0; i<facilities.length; i++) if (facilities[i]!='') {menuParams[facilities[i]] = true; machineFolder.add(menuParams, facilities[i]).onChange(toggleFacility);}
 				for (let i in lattice) {
 					if (i == 'conf') continue;
 					menuParams[i] = false;
@@ -477,6 +484,7 @@
 						if (document.location.search.indexOf('+servicearea')>-1) initLattice(lattice[i].sections, i); else initSearch(lattice[i].sections, i);
 					}
 				}
+				machineFolder.close();
 				gui.add(menuParams, 'measurement device', measurementDevice).onChange(measurementFacility);
 				if (document.location.search.indexOf('measurement')==-1) measurementToggle(false);
 				if (document.location.search.indexOf('servicearea')>-1) initSearch(lattice.servicearea.sections, 'servicearea');
@@ -812,7 +820,7 @@
 					appendLabel(components[i].name, comp+' label '+section+facility+compClass, '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');
+					appendLabel('', 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]));
@@ -914,7 +922,7 @@
 				appendSvg("path", {d: d, fill: "none", stroke: "#f0fff0", "stroke-width": w+20, id:"chamber"+facility});
 				appendSvg("path", {d: d, fill: "none", stroke: "#ff0000", "stroke-width": w, id:"chamber"+facility});
 			}
-			else appendSvg("path", {d: d, fill: "none", stroke: "#999999", "stroke-width": 20, id:"chamber"+facility});
+			else appendSvg("path", {d: d, fill: "none", stroke: "#999999", "stroke-width": 20, id:"chamber"+facility, class: facility});
 		}
 		// bending
 		let j = 0;
-- 
GitLab