// The mode browser: a table of the modes of the linear model (frequency and // decay time), with a filter by frequency; clicking a row selects the mode, // whose shape the host then draws on the plate. import { t60Text } from "../loss.ts"; export interface ModeRow { freq: number; // [Hz] /** Decay time of the mode [s], and the decay time each mechanism alone would give (Infinity when it contributes nothing). */ t60: number; radiation: number; material: number; thermoelastic: number; } const fmtT60 = t60Text; export class ModeBrowser { private info: HTMLDivElement; private tableWrap: HTMLDivElement; private tbody: HTMLTableSectionElement; private minInput: HTMLInputElement; private maxInput: HTMLInputElement; private clearBtn: HTMLButtonElement; private progress: HTMLDivElement; private progressBar: HTMLDivElement; private rows: ModeRow[] = []; private sel: number | null = null; constructor(container: HTMLElement, private onSelect: (m: number | null) => void) { container.classList.add("modes"); const head = document.createElement("div"); head.className = "modes-head"; const lab = (t: string) => { const l = document.createElement("label"); l.textContent = t; return l; }; this.minInput = document.createElement("input"); this.minInput.type = "number"; this.minInput.placeholder = "min"; this.minInput.min = "0"; this.minInput.step = "10"; this.maxInput = document.createElement("input"); this.maxInput.type = "number"; this.maxInput.placeholder = "max"; this.maxInput.min = "0"; this.maxInput.step = "10"; this.clearBtn = document.createElement("button"); this.clearBtn.textContent = "Deselect"; this.clearBtn.disabled = true; head.append(lab("Show"), this.minInput, lab("to"), this.maxInput, lab("Hz"), this.clearBtn); this.info = document.createElement("div"); this.info.className = "modes-info"; this.progress = document.createElement("div"); this.progress.className = "progress"; this.progress.hidden = true; this.progressBar = document.createElement("div"); this.progress.append(this.progressBar); this.tableWrap = document.createElement("div"); this.tableWrap.className = "modes-table"; const table = document.createElement("table"); const thead = document.createElement("thead"); thead.innerHTML = "