Skip to content

Commit

Permalink
refactor(47): 💄 remove all unused values from measurement panel
Browse files Browse the repository at this point in the history
pruned the table with all the values related to the point selected, in order to delete all unused and useless attributes while keeping origianl behaviour
  • Loading branch information
franmagn committed Oct 28, 2025
1 parent 1315491 commit 1514c98
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/MeasurementControl/measurementsPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@
#measurements_list td {
padding: 2px 4px;
}
#measurements_list tr:nth-child(even) {
#measurements_list table.measurement_value_table tr.alt-even td {
background: #3a454b;
}

/* Fallback: ensure odd rows are neutral unless other row-type rules apply */
#measurements_list table.measurement_value_table tr.alt-odd td {
background: transparent;
}
#measurements_list .coordRow td {
background: #2f383d;
font-family: monospace;
Expand Down
46 changes: 45 additions & 1 deletion src/MeasurementControl/measurementsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ export function initMeasurementsPanel(viewer) {
function initCoordObserver() {
if (!originalPropertiesPanel || coordRoundObserver) return
coordRoundObserver = new MutationObserver(() => {
requestAnimationFrame(() => roundCoordinates(originalPropertiesPanel))
requestAnimationFrame(() => {
roundCoordinates(originalPropertiesPanel)
pruneMeasurementRows(originalPropertiesPanel)
})
})
coordRoundObserver.observe(originalPropertiesPanel, {
childList: true,
Expand Down Expand Up @@ -283,6 +286,47 @@ export function initMeasurementsPanel(viewer) {
})
})
}

// Hide unwanted measurement attribute rows (keep only relevant ones)
function pruneMeasurementRows(rootEl) {
if (!rootEl) rootEl = originalPropertiesPanel
if (!rootEl) return
const tables = rootEl.querySelectorAll('table.measurement_value_table')
if (!tables || tables.length === 0) return
// Labels we want to keep
const keep = new Set(['point source id', 'accepted', 'tvu', 'thu'])
tables.forEach((tbl) => {
// Detect coordinate table (header with th: x y z) and skip pruning for it
const headerRow = tbl.querySelector('tr')
if (headerRow) {
const ths = [...headerRow.querySelectorAll('th')].map((th) =>
(th.textContent || '').trim().toLowerCase()
)
if (ths.length >= 3 && ths[0] === 'x' && ths[1] === 'y' && ths[2] === 'z') {
return
}
}
;[...tbl.querySelectorAll('tr')].forEach((row) => {
const firstTd = row.querySelector('td')
if (!firstTd) return
const txt = (firstTd.textContent || '').trim().toLowerCase()
if (!keep.has(txt)) {
row.style.display = 'none'
} else {
row.style.display = ''
}
})
// After hiding rows, reapply alternating classes to visible rows so
// zebra striping remains correct even when some rows are display:none
const visibleRows = [...tbl.querySelectorAll('tr')].filter(
(r) => r.style.display !== 'none'
)
visibleRows.forEach((r, i) => {
r.classList.remove('alt-even', 'alt-odd')
r.classList.add(i % 2 === 0 ? 'alt-odd' : 'alt-even')
})
})
}
// Helper to decide if a uuid is a measurement-like object
function isMeasurementUUID(uuid) {
if (!uuid) return false
Expand Down

0 comments on commit 1514c98

Please sign in to comment.