From e50cb8fb16efa6953ad0e9c509d79b1ce83a70bd Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sat, 24 Oct 2026 11:59:54 -0400 Subject: [PATCH] FilterReview: prompt to show estimated post-filter after recalculating filters --- FilterReview/FilterReview.js | 50 ++++++++++++++++++++++++++++++++++++ FilterReview/index.html | 7 +++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/FilterReview/FilterReview.js b/FilterReview/FilterReview.js index 9f0bdea5..6e8b2ac7 100644 --- a/FilterReview/FilterReview.js +++ b/FilterReview/FilterReview.js @@ -378,6 +378,7 @@ function reset() { document.getElementById("filter_version_1").checked = true document.getElementById("calculate").disabled = true document.getElementById("calculate_filters").disabled = true + document.getElementById("EstimateHint").hidden = true document.getElementById("OpenFilterTool").disabled = true document.getElementById("SaveParams").disabled = true document.getElementById("LoadParams").disabled = true @@ -1833,6 +1834,55 @@ function update_hidden(source) { Plotly.redraw("FFTPlot") + // Hide estimate hint once any estimate is shown + if (!document.getElementById("EstimateHint").hidden) { + update_estimate_hint() + } + +} + +// Get estimated post filter checkboxes that can be selected +function get_estimate_checkboxes() { + let ret = [] + for (let i = 0; i < 3; i++) { + for (let j = 0; j < axis.length; j++) { + const checkbox = document.getElementById("Gyro" + i + "PostEst" + axis[j]) + if (!checkbox.disabled) { + ret.push({ checkbox, gyro: i, axis: axis[j] }) + } + } + } + return ret +} + +// Prompt to show the estimated post filter lines if they are all hidden +function update_estimate_hint() { + const estimates = get_estimate_checkboxes() + const hidden = (estimates.length > 0) && !estimates.some((estimate) => estimate.checkbox.checked) + document.getElementById("EstimateHint").hidden = !hidden +} + +// Show estimated post filter lines for the axes that are shown, or all if none are shown +function show_estimated() { + const estimates = get_estimate_checkboxes() + let shown = estimates.filter((estimate) => { + const pre = document.getElementById("Gyro" + estimate.gyro + "Pre" + estimate.axis) + const post = document.getElementById("Gyro" + estimate.gyro + "Post" + estimate.axis) + return pre.checked || post.checked + }) + if (shown.length == 0) { + shown = estimates + } + for (const estimate of shown) { + estimate.checkbox.checked = true + update_hidden(estimate.checkbox) + } +} + +// Recalculate after filter parameter change +function recalculate_filters() { + re_calc() + update_estimate_hint() } function get_HNotch_param_names() { diff --git a/FilterReview/index.html b/FilterReview/index.html index caec117a..ce39ead1 100644 --- a/FilterReview/index.html +++ b/FilterReview/index.html @@ -445,18 +445,21 @@