From fe2b55edddd8b6d7bf82d2f0c1fbb1a02034c452 Mon Sep 17 00:00:00 2001 From: salman Date: Wed, 15 Apr 2026 08:49:59 +0200 Subject: [PATCH] Highlight calculated density values --- TrimSPlib.js | 44 ++++++++++++++++++++++++++++++++++---------- ZGUI.css | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/TrimSPlib.js b/TrimSPlib.js index 103c165..4522f38 100644 --- a/TrimSPlib.js +++ b/TrimSPlib.js @@ -3090,6 +3090,24 @@ function showTransientWarning(message, targetElement, duration = 4000) { }, duration); } +function markDensityEstimated(fieldId, isEstimated) { + const field = document.getElementById(fieldId); + if (!field) { return; } + field.classList.toggle('estimated-density', isEstimated); + if (isEstimated) { + field.title = 'Calculated density estimate'; + } else { + field.removeAttribute('title'); + } +} + +function clearDensityEstimateHighlight() { + if (this && this.classList) { + this.classList.remove('estimated-density'); + this.removeAttribute('title'); + } +} + function rho_fun() { @@ -3099,16 +3117,19 @@ function rho_fun() var rhoLi = "L"+irow+"rho"; var rho = 0; + var estimatedDensity = 0; if (elemPars[chem]) { rho = elemPars[chem].rho; + markDensityEstimated(rhoLi, false); } else { // Did not find density in elements list if (isFinite(rhos[chem])) { // Found in densities list of compositions rho = rhos[chem]; - } else { - // suggest a material density based on composition (when it's undefined) + markDensityEstimated(rhoLi, false); + } else { + // suggest a material density based on composition (when it's undefined) let layer_formula = parse_formula(chem); // determine the stoichiometry sum (for normalization) @@ -3141,10 +3162,12 @@ function rho_fun() rho = total_molar_mass / total_molar_volume; } if (rho > 0) { - showTransientWarning("Warning: Estimated density from additive elemental molar volumes; please verify manually.", document.getElementById(rhoLi)); + estimatedDensity = 1; + showTransientWarning("Warning: Estimated density from additive elemental molar volumes; please verify manually.", document.getElementById(rhoLi)); + } + markDensityEstimated(rhoLi, estimatedDensity); + } } - } - } // Set value in appropriate cell document.getElementById(rhoLi).value = rho; } @@ -3194,11 +3217,12 @@ function adjust_table() if (Comps[i-1]) {compCell.value = Comps[i-1];}else{compCell.value = 'SrTiO3';} compL.appendChild(compCell); var rhoL = row.insertCell(2); - var rhoCell = document.createElement("input"); - rhoCell.id = "L"+i+"rho"; - rhoCell.name = "L"+i+"rho"; - rhoCell.size = 5; - rhoL.appendChild(rhoCell); + var rhoCell = document.createElement("input"); + rhoCell.id = "L"+i+"rho"; + rhoCell.name = "L"+i+"rho"; + rhoCell.size = 5; + rhoCell.oninput = clearDensityEstimateHighlight; + rhoL.appendChild(rhoCell); if (Rhos[i-1]) {rhoCell.value = Rhos[i-1];}else{rhoCell.value = '5.12';} var thickL = row.insertCell(3); var thickCell = document.createElement("input"); diff --git a/ZGUI.css b/ZGUI.css index 1c39454..19d2cfa 100644 --- a/ZGUI.css +++ b/ZGUI.css @@ -92,6 +92,11 @@ td { opacity: 1; } +.estimated-density { + background-color: #fff4cc; + border: 1px solid #c5a100; +} + .group_name { padding-left:1em; padding-right:1em; diff --git a/package-lock.json b/package-lock.json index 0908b7e..ef51c5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "TrimSP", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "TrimSP", - "version": "1.0.3", + "version": "1.0.4", "license": "GPL2", "dependencies": { "plotly.js-dist": "^1.58.4" diff --git a/package.json b/package.json index 4fff8d0..592c492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "TrimSP", - "version": "1.0.3", + "version": "1.0.4", "description": "Trim.SP simulation to calculate stopping profile of implanted probes.", "main": "main.js", "scripts": {