diff --git a/src/MeasurementControl/measurementsPanel.js b/src/MeasurementControl/measurementsPanel.js index 0e66fe5..8f5f12b 100644 --- a/src/MeasurementControl/measurementsPanel.js +++ b/src/MeasurementControl/measurementsPanel.js @@ -196,6 +196,10 @@ window.initMeasurementsPanel = function initMeasurementsPanel(viewer) { } } } + requestAnimationFrame(() => { + roundCoordinates(originalPropertiesPanel) + initCoordObserver() + }) } function restorePanelToOriginal() { if (!originalPropertiesPanel || !placeholder || !originalParent) return @@ -222,6 +226,58 @@ window.initMeasurementsPanel = function initMeasurementsPanel(viewer) { targetContainer.appendChild(msg2) } + // Helper: round only the coordinates table (x,y,z header row) to 1 decimal + let coordRoundObserver = null + function initCoordObserver() { + if (!originalPropertiesPanel || coordRoundObserver) return + coordRoundObserver = new MutationObserver(() => { + requestAnimationFrame(() => roundCoordinates(originalPropertiesPanel)) + }) + coordRoundObserver.observe(originalPropertiesPanel, { + childList: true, + subtree: true + }) + } + + function roundCoordinates(rootEl) { + if (!rootEl) return + // Find first table that has a header row with th: x y z + const tables = rootEl.querySelectorAll('table.measurement_value_table') + let coordTable = null + for (const tbl of tables) { + const headerRow = tbl.querySelector('tr') + if (!headerRow) continue + const ths = [...headerRow.querySelectorAll('th')].map(th => + (th.textContent || '').trim().toLowerCase() + ) + if (ths.length >= 3 && ths[0] === 'x' && ths[1] === 'y' && ths[2] === 'z') { + coordTable = tbl + break + } + } + if (!coordTable) return + + const dataRows = [...coordTable.querySelectorAll('tr')].slice(1) + dataRows.forEach(row => { + row.querySelectorAll('td').forEach(td => { + if (td.querySelector('button, input, select')) return + const raw = (td.textContent || '').trim() + if (!raw) return + // Allow formats with commas, spaces, possible degree sign, trailing labels + // Extract leading numeric with optional sign & decimal + const cleaned = raw + .replace(/[^\d+.\-]/g, c => (c === ',' ? '' : '')) // clean data + .replace(/,+/g, '') + if (!cleaned || !/[-+]?\d*\.?\d+/.test(cleaned)) return + const num = Number(cleaned) + if (!Number.isFinite(num)) return + const rounded = num.toFixed(1) + if (td.textContent !== rounded) { + td.textContent = rounded + } + }) + }) + } // Helper to decide if a uuid is a measurement-like object function isMeasurementUUID(uuid) { if (!uuid) return false