From 7b8271250a863d4bdb233317d727144574e6e791 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 27 Aug 2020 15:17:04 +0200 Subject: [PATCH] Work on #431 - proper display of variating QA in boundaries selector and chart --- .../pab-profile-chart.component.ts | 8 ++- .../pab-table/pab-table.component.ts | 22 ++++++- .../variable-results-selector.component.ts | 43 +------------- src/app/formulaire/definition/form-pab.ts | 17 +++++- src/app/results/calculator-results.ts | 59 ++++++++++++++++++- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 7 files changed, 102 insertions(+), 49 deletions(-) diff --git a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts index 5d9220b27..449c050ff 100644 --- a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts +++ b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts @@ -12,6 +12,7 @@ import { AppComponent } from "../../app.component"; import { CloisonAval, Cloisons, LoiDebit } from "jalhyd"; import { sprintf } from "sprintf-js"; +import { CalculatorResults } from 'app/results/calculator-results'; @Component({ selector: "pab-profile-chart", @@ -453,13 +454,14 @@ export class PabProfileChartComponent extends ResultsComponentDirective implemen * @param n index of the variating parameter(s) iteration */ private getLegendForSeries(n: number): string { - let i = 0; + /* let i = 0; return this.varValues.map((vv) => { const vp = this._results.variatedParameters[i]; i++; let value = "0"; value = vv[n]; - return `${vp.param.symbol} = ${value}`; - }).join(", "); + return `${vp.symbol} = ${value}`; + }).join(", "); */ + return CalculatorResults.variatingModalityLabel(this.varValues, this._results, n); } } diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 5f8455f9a..225d7da87 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -1,6 +1,6 @@ import { Component, Input, Output, EventEmitter, OnInit, AfterViewInit } from "@angular/core"; -import { LoiDebit } from "jalhyd"; +import { LoiDebit, ParamValueMode } from "jalhyd"; import { MatDialog } from "@angular/material/dialog"; @@ -1057,7 +1057,10 @@ export class PabTableComponent implements AfterViewInit, OnInit { ); // copy parameter values for (const p of si.prms) { - newChild.getParameter(p.symbol).singleValue = p.singleValue; + // @TODO QA may vary + if (p.visible && p.symbol !== "QA") { // QA might vary ! + newChild.getParameter(p.symbol).singleValue = p.singleValue; + } } // copy children if (si instanceof ParallelStructure) { @@ -1242,7 +1245,8 @@ export class PabTableComponent implements AfterViewInit, OnInit { for (const av of availableVariables) { for (const c of this.selectedItems) { for (const p of c.parameterIterator) { - if (p.visible && p.symbol === av.value) { + // @TODO what todo when p varies (QA only) ? + if (p.visible && p.symbol === av.value && ! p.hasMultipleValues) { av.occurrences ++; if (av.first === undefined) { av.first = p.singleValue; @@ -1319,6 +1323,10 @@ export class PabTableComponent implements AfterViewInit, OnInit { case "set-value": for (const s of this.selectedItems) { for (const p of s.parameterIterator) { // deep + // force single mode (QA only) + if (p.hasMultipleValues) { + p.valueMode = ParamValueMode.SINGLE; + } if (p.symbol === result.variable) { p.singleValue = result.value; } @@ -1329,6 +1337,10 @@ export class PabTableComponent implements AfterViewInit, OnInit { case "delta": for (const s of this.selectedItems) { for (const p of s.parameterIterator) { // deep + // force single mode (QA only) + if (p.hasMultipleValues) { + p.valueMode = ParamValueMode.SINGLE; + } if (p.symbol === result.variable) { p.singleValue += result.delta; } @@ -1405,6 +1417,10 @@ export class PabTableComponent implements AfterViewInit, OnInit { // for ZRMB, interpolatedValues length is shorter by 1 element if (interpolatedValues[idx] !== undefined) { for (const p of s.parameterIterator) { // deep + // force single mode (QA only) + if (p.hasMultipleValues) { + p.valueMode = ParamValueMode.SINGLE; + } if (p.symbol === result.variable) { p.singleValue = interpolatedValues[idx]; idx ++; diff --git a/src/app/components/variable-results-selector/variable-results-selector.component.ts b/src/app/components/variable-results-selector/variable-results-selector.component.ts index 9f91c26b0..663f1f0e5 100644 --- a/src/app/components/variable-results-selector/variable-results-selector.component.ts +++ b/src/app/components/variable-results-selector/variable-results-selector.component.ts @@ -4,8 +4,8 @@ import { I18nService } from "../../services/internationalisation.service"; import { fv, longestVarParam } from "../../util"; import { MultiDimensionResults } from "../../results/multidimension-results"; import { PrebarrageResults } from "../../results/prebarrage-results"; - import { CalculatorType, PbBassin, PbCloison, Structure, VariatedDetails } from "jalhyd"; +import { CalculatorResults } from "../../results/calculator-results"; @Component({ selector: "variable-results-selector", @@ -81,46 +81,7 @@ export class VariableResultsSelectorComponent implements OnChanges { } protected entryLabel(index: number): string { - const kv = []; - for (let i = 0; i < this.varValues.length; i++) { - const vv = this.varValues[i]; - const vp = this.results.variatedParameters[i]; - let symbol = vp.param.symbol; - // is vp a parameter of a child Nub ? - if ( - vp.param.parentNub - && vp.param.parentNub !== vp.param.originNub - ) { - let childPrefix: string; - // prefix the label depending on (grand)children type - switch (vp.param.originNub.calcType) { - case CalculatorType.PreBarrage: - const pbRes = this.results as PrebarrageResults; - if (vp.param.parentNub instanceof Structure) { - const struct = vp.param.parentNub as Structure; - const wall = struct.parent as PbCloison; - const posS = struct.findPositionInParent() + 1; - childPrefix = this.intlService.localizeMessage(wall.description); - // there might be multiple walls between the same pair of basins - if (wall.uid in pbRes.wallsSuffixes) { - childPrefix += " (" + pbRes.wallsSuffixes[wall.uid] + ")"; - } - childPrefix += "_" + this.intlService.localizeText("INFO_LIB_STRUCTURE_N_COURT") + posS; - } else if (vp.param.parentNub instanceof PbBassin) { - const bassin = vp.param.parentNub as PbBassin; - childPrefix = this.intlService.localizeMessage(bassin.description); - } - break; - case CalculatorType.MacroRugoCompound: - const posMR = vp.param.parentNub.findPositionInParent() + 1; - childPrefix = this.intlService.localizeText("INFO_LIB_RADIER_N_COURT") + posMR; - break; - } - symbol = childPrefix + "_" + symbol; - } - kv.push(`${symbol} = ${vv[index]}`); - } - return kv.join(", "); + return CalculatorResults.variatingModalityLabel(this.varValues, this.results, index); } public get selectedValue(): number { diff --git a/src/app/formulaire/definition/form-pab.ts b/src/app/formulaire/definition/form-pab.ts index d88ae7826..0bafb5760 100644 --- a/src/app/formulaire/definition/form-pab.ts +++ b/src/app/formulaire/definition/form-pab.ts @@ -2,7 +2,7 @@ import { Pab, Result, VariatedDetails } from "jalhyd"; import { FormulaireDefinition } from "./form-definition"; import { PabResults } from "../../results/pab-results"; -import { NgParameter } from "../elements/ngparam"; +import { NgParameter, ParamRadioConfig } from "../elements/ngparam"; import { longestVarParam } from "../../util"; import { CalculatorResults } from "../../results/calculator-results"; @@ -78,6 +78,21 @@ export class FormulairePab extends FormulaireDefinition { } } + public getVariatedParameters(): NgParameter[] { + const res: NgParameter[] = super.getVariatedParameters(); + // add artificial NgParameters for any variated QA @WARNING clodo trick + if (this.pabNub) { + for (const c of this.pabNub.children) { + if (c.prms.QA.hasMultipleValues) { + const qaParam = new NgParameter(c.prms.QA, this); + qaParam.radioConfig = ParamRadioConfig.VAR; + res.push(qaParam); + } + } + } + return res; + } + public get pabResults() { return this._pabResults; } diff --git a/src/app/results/calculator-results.ts b/src/app/results/calculator-results.ts index f573b6c99..95954608a 100644 --- a/src/app/results/calculator-results.ts +++ b/src/app/results/calculator-results.ts @@ -1,9 +1,11 @@ -import { Nub, capitalize } from "jalhyd"; +import { CalculatorType, Nub, capitalize, MacrorugoCompound, Pab, Structure, PbCloison, PbBassin } from "jalhyd"; import { NgParameter } from "../formulaire/elements/ngparam"; import { ServiceFactory } from "../services/service-factory"; import { sprintf } from "sprintf-js"; +import { MultiDimensionResults } from "./multidimension-results"; +import { PrebarrageResults } from "./prebarrage-results"; export abstract class CalculatorResults { @@ -45,6 +47,61 @@ export abstract class CalculatorResults { return res; } + /** + * Returns a label showing the boundary conditions values of all variating parameters, + * for the given iteration + * @param varvalues array of values: one element per variating parameter, itself an array of + * values, one per iteration + * @param variatedParameters array of variating parameters, in the same order as varvalues + * @param n index of the variating parameter(s) iteration + */ + public static variatingModalityLabel(varValues: any[], results: MultiDimensionResults, index: number): string { + const kv = []; + for (let i = 0; i < varValues.length; i++) { + const vv = varValues[i]; + const vp = results.variatedParameters[i]; + let symbol = vp.param.symbol; + // is vp a parameter of a child Nub ? + if ( + vp.param.parentNub + && vp.param.parentNub !== vp.param.originNub + ) { + let childPrefix: string; + // prefix the label depending on (grand)children type + switch (vp.param.originNub.calcType) { + case CalculatorType.PreBarrage: + const pbRes = results as PrebarrageResults; + if (vp.param.parentNub instanceof Structure) { + const struct = vp.param.parentNub as Structure; + const wall = struct.parent as PbCloison; + const posS = struct.findPositionInParent() + 1; + childPrefix = ServiceFactory.i18nService.localizeMessage(wall.description); + // there might be multiple walls between the same pair of basins + if (wall.uid in pbRes.wallsSuffixes) { + childPrefix += " (" + pbRes.wallsSuffixes[wall.uid] + ")"; + } + childPrefix += "_" + ServiceFactory.i18nService.localizeText("INFO_LIB_STRUCTURE_N_COURT") + posS; + } else if (vp.param.parentNub instanceof PbBassin) { + const bassin = vp.param.parentNub as PbBassin; + childPrefix = ServiceFactory.i18nService.localizeMessage(bassin.description); + } + break; + case CalculatorType.MacroRugoCompound: + const posMR = vp.param.parentNub.findPositionInParent() + 1; + childPrefix = ServiceFactory.i18nService.localizeText("INFO_LIB_RADIER_N_COURT") + posMR; + break; + case CalculatorType.PAB: + const posPAB = vp.param.parentNub.findPositionInParent() + 1; + childPrefix = ServiceFactory.i18nService.localizeText("INFO_LIB_CLOISON_N_COURT") + posPAB; + break; + } + symbol = childPrefix + "_" + symbol; + } + kv.push(`${symbol} = ${vv[index]}`); + } + return kv.join(", "); + } + /** * remet tous les résultats à zero */ diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index d8e491c12..009ebec32 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -285,6 +285,7 @@ "INFO_LIB_CDT": "Discharge coefficient triangular weir", "INFO_LIB_CDO": "Discharge coefficient orifice", "INFO_LIB_CLOISON": "Cross wall #", + "INFO_LIB_CLOISON_N_COURT": "W", "INFO_LIB_COTE": "Elevation (m)", "INFO_LIB_COTE_VANNE_LEVANTE": "Lift gate elevation", "INFO_LIB_CV": "Cv: Velocity coefficient", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index ca8fc400d..b018c642d 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -286,6 +286,7 @@ "INFO_LIB_CDT": "Coefficient de débit seuil triangulaire", "INFO_LIB_CDO": "Coefficient de débit orifice", "INFO_LIB_CLOISON": "Cloison n°", + "INFO_LIB_CLOISON_N_COURT": "C", "INFO_LIB_COTE": "Cote (m)", "INFO_LIB_COTE_VANNE_LEVANTE": "Cote vanne levante", "INFO_LIB_CV": "Cv : Coefficient de vitesse d'approche", -- GitLab