From 15800ebdc31edc4cea639bcca90d096adc5aa794 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 | 6 ++-- .../pab-table/pab-table.component.ts | 22 ++++++++++-- .../variable-results-selector.component.ts | 18 ++-------- src/app/formulaire/definition/form-pab.ts | 17 ++++++++- src/app/results/calculator-results.ts | 35 ++++++++++++++++++- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 7 files changed, 77 insertions(+), 23 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 4b47585b7..4294f6088 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", @@ -452,13 +453,14 @@ export class PabProfileChartComponent extends ResultsComponentDirective { * @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.symbol} = ${value}`; - }).join(", "); + }).join(", "); */ + return CalculatorResults.variatingModalityLabel(this.varValues, this._results.variatedParameters, n); } } diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 129a109c5..782afe95a 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 af8dfe927..7d2a04a2e 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 @@ -3,6 +3,7 @@ import { Component, Output, EventEmitter } from "@angular/core"; import { I18nService } from "../../services/internationalisation.service"; import { fv, longestVarNgParam } from "../../util"; import { MultiDimensionResults } from "../../results/multidimension-results"; +import { CalculatorResults } from "../../results/calculator-results"; @Component({ selector: "variable-results-selector", @@ -72,22 +73,7 @@ export class VariableResultsSelectorComponent { } 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.symbol; - // is vp a parameter of a child Nub ? - if ( - vp.paramDefinition.parentNub - && vp.paramDefinition.parentNub !== vp.paramDefinition.originNub - ) { - const pos = vp.paramDefinition.parentNub.findPositionInParent() + 1; - symbol = this.intlService.localizeText("INFO_LIB_RADIER_N_COURT") + pos + "_" + symbol; - } - kv.push(`${symbol} = ${vv[index]}`); - } - return kv.join(", "); + return CalculatorResults.variatingModalityLabel(this.varValues, this._results.variatedParameters, index); } public get selectedValue(): number { diff --git a/src/app/formulaire/definition/form-pab.ts b/src/app/formulaire/definition/form-pab.ts index 593aa219a..99c40635b 100644 --- a/src/app/formulaire/definition/form-pab.ts +++ b/src/app/formulaire/definition/form-pab.ts @@ -2,7 +2,7 @@ import { Pab, Result } 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 { longestVarNgParam } 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 36c23bbf9..4b9689ec4 100644 --- a/src/app/results/calculator-results.ts +++ b/src/app/results/calculator-results.ts @@ -1,4 +1,4 @@ -import { Nub, capitalize } from "jalhyd"; +import { Nub, capitalize, MacrorugoCompound, Pab } from "jalhyd"; import { NgParameter } from "../formulaire/elements/ngparam"; import { ServiceFactory } from "../services/service-factory"; @@ -45,6 +45,39 @@ 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[], variatedParameters: NgParameter[], index: number): string { + const kv = []; + for (let i = 0; i < varValues.length; i++) { + const vv = varValues[i]; + const vp = variatedParameters[i]; + let symbol = vp.symbol; + // is vp a parameter of a child Nub ? + if ( + vp.paramDefinition.parentNub + && vp.paramDefinition.parentNub !== vp.paramDefinition.originNub + ) { + let nCourt = ""; + if (vp.paramDefinition.originNub instanceof MacrorugoCompound) { + nCourt = ServiceFactory.i18nService.localizeText("INFO_LIB_RADIER_N_COURT"); + } else if (vp.paramDefinition.originNub instanceof Pab) { + nCourt = ServiceFactory.i18nService.localizeText("INFO_LIB_CLOISON_N_COURT"); + } + const pos = vp.paramDefinition.parentNub.findPositionInParent() + 1; + symbol = nCourt + pos + "_" + 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 e5991f549..cfd25007c 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -254,6 +254,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 cae8286ea..f0e27f526 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -255,6 +255,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