diff --git a/src/verification/espece.ts b/src/verification/espece.ts index bb4d70a8076ea8df4dbfd2872e8ae5e410611de1..12c78dd7c9d5449fa2dcfd37274c28d8806f3dab 100644 --- a/src/verification/espece.ts +++ b/src/verification/espece.ts @@ -953,6 +953,33 @@ export class Espece extends Nub implements Observer { } } } + + /** + * Load ICE tables values into parameters, for a given species + * (used in GUI for loading predefined species) + */ + public loadPredefinedSpecies(sp: FishSpecies) { + let found: boolean; + // for each param + for (const p of this.prms) { + if (p.symbol !== "OK") { + // reset current value + p.singleValue = undefined; + // whatever the pass type (criteria are supposed to apply to 1 pass type only) + found = false; + for (const pt of Object.keys(this.presets)) { + const preset = this.presets[pt]; + if (! found && preset !== undefined && preset[sp] !== undefined && preset[sp][p.symbol] !== undefined) { + found = true; + // if (preset[sp][p.symbol] !== undefined) console.log(`-> setting ${p.symbol} to ${preset[sp][p.symbol]}`); + // apply preset + p.singleValue = preset[sp][p.symbol]; + } + } + } + } + } + /** Parameters other than OK are just settings here, nothing can vary or be calculated */ protected setParametersCalculability(): void { for (const p of this._prms) {