From 03015f72a8f408e380136912234e721d176d08e8 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 16 Jul 2020 11:30:03 +0200
Subject: [PATCH] PreBarrage: new not-really-fixed results component for
 Cloison

---
 src/app/app.module.ts                         |  2 +
 .../fixed-results.component.ts                | 39 +++++++++--
 .../pb-cloison-results.component.ts           | 35 ++++++++++
 .../pb-results/pb-results-table.component.ts  | 32 ++-------
 .../pb-results/pb-results.component.html      |  2 +-
 .../pb-results/pb-results.component.ts        | 36 ++++------
 .../formulaire/definition/form-definition.ts  | 64 +++++-------------
 .../formulaire/definition/form-fixedvar.ts    |  8 +--
 .../formulaire/definition/form-prebarrage.ts  | 66 ++++++++-----------
 src/app/results/multidimension-results.ts     | 11 +++-
 src/app/results/pb-cloison-results.ts         | 11 ++++
 src/app/results/prebarrage-results.ts         | 19 +++++-
 src/app/util.ts                               | 22 ++++++-
 src/styles.scss                               |  2 +-
 14 files changed, 196 insertions(+), 153 deletions(-)
 create mode 100644 src/app/components/pb-results/pb-cloison-results.component.ts
 create mode 100644 src/app/results/pb-cloison-results.ts

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index d9b61bed6..77599ae82 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -89,6 +89,7 @@ import { ParamLinkComponent } from "./components/param-link/param-link.component
 import { PabProfileChartComponent } from "./components/pab-profile-chart/pab-profile-chart.component";
 import { PabTableComponent } from "./components/pab-table/pab-table.component";
 import { PbSchemaComponent } from "./components/pb-schema/pb-schema.component";
+import { PbCloisonResultsComponent } from "./components/pb-results/pb-cloison-results.component";
 import { VariableResultsSelectorComponent } from "./components/variable-results-selector/variable-results-selector.component";
 import { QuicknavComponent } from "./components/quicknav/quicknav.component";
 import { ModulesDiagramComponent } from "./components/modules-diagram/modules-diagram.component";
@@ -227,6 +228,7 @@ const appRoutes: Routes = [
     PabResultsTableComponent,
     PabTableComponent,
     PbResultsComponent,
+    PbCloisonResultsComponent,
     PbResultsTableComponent,
     PbSchemaComponent,
     VariableResultsSelectorComponent,
diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts
index 7607bb47e..2f0a18213 100644
--- a/src/app/components/fixedvar-results/fixed-results.component.ts
+++ b/src/app/components/fixedvar-results/fixed-results.component.ts
@@ -1,12 +1,11 @@
 import { Component, ViewChild, ElementRef } from "@angular/core";
 
 import { FixedResults } from "../../results/fixed-results";
-import { NgParameter } from "../../formulaire/elements/ngparam";
-import { CalculatorResults } from "../../results/calculator-results";
 import { I18nService } from "../../services/internationalisation.service";
 import { FormulaireService } from "../../services/formulaire.service";
 import { ResultsComponentDirective } from "./results.component";
 import { AppComponent } from "../../app.component";
+import { NgParameter } from "../../formulaire/elements/ngparam";
 
 import { capitalize } from "jalhyd";
 
@@ -20,8 +19,9 @@ import { sprintf } from "sprintf-js";
     ]
 })
 export class FixedResultsComponent extends ResultsComponentDirective {
+
     /** résultats non mis en forme */
-    private _fixedResults: FixedResults;
+    protected _fixedResults: FixedResults;
 
     @ViewChild("tableContainer")
     table: ElementRef;
@@ -86,6 +86,29 @@ export class FixedResultsComponent extends ResultsComponentDirective {
     protected buildCustomOrderedDataset() {
         const data = [];
         let resultFound: boolean;
+        for (const symbol of this._fixedResults.variablesOrder) {
+
+            // is it a fixed parameter ?
+            for (const fp of this.fixedParams) {
+                if (fp.symbol === symbol) {
+                    let label = this.formattedLabel(fp);
+                    const nub = fp.paramDefinition.parentNub;
+                    // add child type and position before label
+                    if (nub && nub.parent && nub.parent.childrenType) {
+                        const pos = nub.findPositionInParent();
+                        // label = this.intlService.localizeText("INFO_OUVRAGE") + " n°" + (pos + 1) + ": " + label;
+                        const cn = capitalize(this.intlService.childName(nub.parent));
+                        label = sprintf(this.intlService.localizeText("INFO_STUFF_N"), cn)
+                            + (pos + 1) + ": " + label;
+                    }
+                    label += this._fixedResults.getHelpLink(symbol);
+                    data.push({
+                        label: label,
+                        value: this.getFixedParamValue(fp),
+                        isCalcResult: false // for CSS
+                    });
+                }
+            }
 
         for (const symbol of this._fixedResults.variablesOrder) {
             resultFound = false;
@@ -206,7 +229,7 @@ export class FixedResultsComponent extends ResultsComponentDirective {
             label += this._fixedResults.getHelpLink(fp.symbol);
             data.push({
                 label: label,
-                value: this.formattedValue(fp),
+                value: this.getFixedParamValue(fp),
                 isCalcResult: false // for CSS
             });
         }
@@ -272,6 +295,14 @@ export class FixedResultsComponent extends ResultsComponentDirective {
         return data;
     }
 
+    /**
+     * Retourne la valeur du paramètre fixe; redéfini
+     * dans PbCloisonResultsComponent notamment
+     */
+    protected getFixedParamValue(fp: NgParameter): string {
+        return this.formattedValue(fp);
+    }
+
     public exportAsSpreadsheet() {
         AppComponent.exportAsSpreadsheet(this.table.nativeElement, true);
     }
diff --git a/src/app/components/pb-results/pb-cloison-results.component.ts b/src/app/components/pb-results/pb-cloison-results.component.ts
new file mode 100644
index 000000000..404680865
--- /dev/null
+++ b/src/app/components/pb-results/pb-cloison-results.component.ts
@@ -0,0 +1,35 @@
+import { Component } from "@angular/core";
+
+import { FixedResultsComponent } from "../fixedvar-results/fixed-results.component";
+import { NgParameter } from "../../formulaire/elements/ngparam";
+import { getIthValue } from "../../util";
+import { PbCloisonResults } from "../../results/pb-cloison-results";
+
+@Component({
+    selector: "pb-cloison-results",
+    templateUrl: "../fixedvar-results/fixed-results.component.html",
+    styleUrls: [
+        "../fixedvar-results/fixed-results.component.scss"
+    ]
+})
+export class PbCloisonResultsComponent extends FixedResultsComponent {
+
+    public set results(r: PbCloisonResults) {
+        this._fixedResults = r;
+    }
+
+    public get results(): PbCloisonResults {
+        return this._fixedResults as PbCloisonResults;
+    }
+
+    /** Retourne la valeur du paramètre fixe… qui n'en est pas forcément un ici ! */
+    protected getFixedParamValue(fp: NgParameter): string {
+        let val: string;
+        if (fp.paramDefinition.hasMultipleValues) {
+            val = getIthValue(fp.paramDefinition, this.results.variableIndex, this.results.size);
+        } else {
+            val = this.formattedValue(fp.getValue());
+        }
+        return val;
+    }
+}
diff --git a/src/app/components/pb-results/pb-results-table.component.ts b/src/app/components/pb-results/pb-results-table.component.ts
index c064fabb9..925eab960 100644
--- a/src/app/components/pb-results/pb-results-table.component.ts
+++ b/src/app/components/pb-results/pb-results-table.component.ts
@@ -1,11 +1,11 @@
 import { Component, ViewChild, ElementRef } from "@angular/core";
 
-import { PreBarrage, PbBassin, ParamDefinition, ParamValueMode } from "jalhyd";
+import { PreBarrage, PbBassin } from "jalhyd";
 
 import { I18nService } from "../../services/internationalisation.service";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 import { AppComponent } from "../../app.component";
-import { fv } from "../../util";
+import { fv, getIthValue } from "../../util";
 import { PrebarrageResults } from "../../results/prebarrage-results";
 
 @Component({
@@ -35,26 +35,6 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
         super();
     }
 
-    /**
-     * Returns value at index i for parameter p, whether it is variating
-     * or not, calculated or not
-     * @param p parameter
-     * @param i index
-     */
-    protected getIthValue(p: ParamDefinition, i: number, extendTo: number): string {
-        let value: number;
-        if (p.hasMultipleValues) {
-            if (p.valueMode === ParamValueMode.CALCUL) {
-                value = p.parentNub.result.resultElements[i].vCalc;
-            } else {
-                value = p.getInferredValuesList(extendTo)[i];
-            }
-        } else {
-            value = p.V;
-        }
-        return fv(value);
-    }
-
     public set results(r: PrebarrageResults) {
         this._pbResults = r;
 
@@ -81,9 +61,9 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
                 this._dataSet.push([
                     this.intlService.localizeText("INFO_LIB_AMONT"),
                     "", "",
-                    this.getIthValue(pb.prms.Z1, vi, this._pbResults.size),
+                    getIthValue(pb.prms.Z1, vi, this._pbResults.size),
                     "", "",
-                    this.getIthValue(pb.prms.Q, vi, this._pbResults.size),
+                    getIthValue(pb.prms.Q, vi, this._pbResults.size),
                 ]);
             }
 
@@ -111,9 +91,9 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
                 this._dataSet.push([
                     this.intlService.localizeText("INFO_LIB_AVAL"),
                     "", "",
-                    this.getIthValue(pb.prms.Z2, vi, this._pbResults.size),
+                    getIthValue(pb.prms.Z2, vi, this._pbResults.size),
                     "", "",
-                    this.getIthValue(pb.prms.Q, vi, this._pbResults.size),
+                    getIthValue(pb.prms.Q, vi, this._pbResults.size),
                 ]);
             }
         }
diff --git a/src/app/components/pb-results/pb-results.component.html b/src/app/components/pb-results/pb-results.component.html
index a4a603342..80a7d4501 100644
--- a/src/app/components/pb-results/pb-results.component.html
+++ b/src/app/components/pb-results/pb-results.component.html
@@ -10,7 +10,7 @@
     <pb-results-table *ngIf="hasBasinResults" [results]="pbResults"></pb-results-table>
 
     <!-- table des résultats fixés -->
-    <fixed-results *ngIf="hasWallResults" [results]="pbResults.cloisonResults"></fixed-results>
+    <pb-cloison-results *ngIf="hasWallResults" [results]="pbResults.cloisonResults"></pb-cloison-results>
 
     <!-- <quicknav *ngIf="hasDisplayableResults" [items]="[ 'input', 'results', 'charts' ]"
         [currentItem]="'charts'" [align]="'left'"></quicknav> -->
diff --git a/src/app/components/pb-results/pb-results.component.ts b/src/app/components/pb-results/pb-results.component.ts
index 6623a32ac..0362c6b8b 100644
--- a/src/app/components/pb-results/pb-results.component.ts
+++ b/src/app/components/pb-results/pb-results.component.ts
@@ -6,7 +6,7 @@ import { PbResultsTableComponent } from "./pb-results-table.component";
 import { PrebarrageResults } from "../../results/prebarrage-results";
 import { VariableResultsSelectorComponent } from "../variable-results-selector/variable-results-selector.component";
 import { I18nService } from "../../services/internationalisation.service";
-import { FixedResultsComponent } from "../fixedvar-results/fixed-results.component";
+import { PbCloisonResultsComponent } from "./pb-cloison-results.component";
 import { FixedResults } from "../../results/fixed-results";
 
 import { Result } from "jalhyd";
@@ -32,8 +32,8 @@ export class PbResultsComponent implements DoCheck {
     @ViewChild(VariableResultsSelectorComponent)
     private variableResultsSelectorComponent: VariableResultsSelectorComponent;
 
-    @ViewChild(FixedResultsComponent)
-    private fixedResultsComponent: FixedResultsComponent;
+    @ViewChild(PbCloisonResultsComponent)
+    private pbCloisonResultsComponent: PbCloisonResultsComponent;
 
     @ViewChild("generalLog")
     private generalLogComponent: LogComponent;
@@ -79,8 +79,8 @@ export class PbResultsComponent implements DoCheck {
 
     /**
      * update results table and chart when the variable index changed (event sent by
-     * PabVariableResultsSelectorComponent); variable index is already set in
-     * pabResults at this time
+     * VariableResultsSelectorComponent); variable index is already set in
+     * pbResults at this time
      */
     public variableIndexChanged() {
         this.updateView();
@@ -99,8 +99,8 @@ export class PbResultsComponent implements DoCheck {
         if (this.variableResultsSelectorComponent) {
             this.variableResultsSelectorComponent.results = undefined;
         }
-        if (this.fixedResultsComponent) {
-            this.fixedResultsComponent.results = undefined;
+        if (this.pbCloisonResultsComponent) {
+            this.pbCloisonResultsComponent.results = undefined;
         }
         /* if (this.profileChartComponent) {
             this.profileChartComponent.results = undefined;
@@ -286,7 +286,7 @@ export class PbResultsComponent implements DoCheck {
         let pbTableUpdated: boolean;
         let profileChartUpdated: boolean;
         let selectorUpdated: boolean;
-        let fixedResultsUpdated: boolean;
+        let cloisonResultsUpdated: boolean;
 
         // results or not, there might be a log
         const logUpdated = (this.iterationLogComponent !== undefined || this.generalLogComponent !== undefined); // gne ?
@@ -320,25 +320,15 @@ export class PbResultsComponent implements DoCheck {
             profileChartUpdated = true;
         }
         if (this.hasWallResults) {
-            fixedResultsUpdated = this.fixedResultsComponent !== undefined;
-            if (fixedResultsUpdated) {
-                // trick to show only the result of a given iteration, without
-                // modifying FixedResultsComponent
-                const iterationResult = new FixedResults();
-                for (const fp of this._pbResults.cloisonResults.fixedParameters) {
-                    iterationResult.addFixedParameter(fp);
-                }
-                iterationResult.result = new Result(
-                    this._pbResults.cloisonResults.result.resultElements[this._pbResults.variableIndex],
-                    this._pbResults.cloisonResults.result.sourceNub
-                );
-                this.fixedResultsComponent.results = iterationResult;
+            cloisonResultsUpdated = this.pbCloisonResultsComponent !== undefined;
+            if (cloisonResultsUpdated) {
+                this.pbCloisonResultsComponent.results = this._pbResults.cloisonResults;
             }
         } else {
-            fixedResultsUpdated = true;
+            cloisonResultsUpdated = true;
         }
 
-        return pbTableUpdated && logUpdated && profileChartUpdated && selectorUpdated && fixedResultsUpdated;
+        return pbTableUpdated && logUpdated && profileChartUpdated && selectorUpdated && cloisonResultsUpdated;
     }
 
     public get uitextGeneralLogTitle(): string {
diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts
index 424c4cf41..e70898a3a 100644
--- a/src/app/formulaire/definition/form-definition.ts
+++ b/src/app/formulaire/definition/form-definition.ts
@@ -13,12 +13,11 @@ import {
 } from "jalhyd";
 
 import { FormulaireElement } from "../elements/formulaire-element";
-import { NgParameter, ParamRadioConfig } from "../elements/ngparam";
+import { NgParameter } from "../elements/ngparam";
 import { Field } from "../elements/field";
 import { FormulaireNode } from "../elements/formulaire-node";
 import { FieldSet } from "../elements/fieldset";
 import { FieldsetContainer } from "../elements/fieldset-container";
-import { SelectField } from "../elements/select-field";
 import { DeepFieldsetIterator } from "../form-iterator/deep-fieldset-iterator";
 import { TopFormulaireElementIterator } from "../form-iterator/top-element-iterator";
 import { CalculatorResults } from "../../results/calculator-results";
@@ -296,6 +295,11 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
         return false;
     }
 
+    /**
+     * Trouve le Ngparameter correspondant au symbole "symbol", parmi tous les
+     * éléments du formulaire
+     * @param symbol string
+     */
     public getParamFromSymbol(symbol: string): NgParameter {
         for (const p of this.allFormElements) {
             if (p instanceof NgParameter) {
@@ -306,26 +310,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
         }
     }
 
-    public getDisplayedParamFromState(st: ParamRadioConfig): NgParameter {
-        for (const p of this.allFormElements) {
-            if (p.isDisplayed && p instanceof NgParameter) {
-                if (p.radioState === st) {
-                    return p;
-                }
-            }
-        }
-    }
-
-    public getDisplayedParamListFromState(st: ParamRadioConfig): NgParameter[] {
-        const res = [];
-        for (const p of this.allFormElements) {
-            if (p.isDisplayed && p instanceof NgParameter && p.radioState === st) {
-                res.push(p);
-            }
-        }
-        return res;
-    }
-
     public getFieldById(id: string): Field {
         const res = this.getFormulaireNodeById(id);
         if (res instanceof Field) {
@@ -333,31 +317,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
         }
     }
 
-    public getFieldsetById(id: string): FieldSet {
-        const res = this.getFormulaireNodeById(id);
-        if (res instanceof FieldSet) {
-            return res;
-        }
-    }
-
-    public getParameterValue(symbol: string): number {
-        for (const fs of this.allFieldsets) {
-            const p = fs.getNodeParameter(symbol);
-            if (p !== undefined) {
-                switch (p.radioState) {
-                    case ParamRadioConfig.FIX:
-                        return p.getValue();
-
-                    case ParamRadioConfig.VAR:
-                    case ParamRadioConfig.CAL:
-                        return undefined;
-                }
-            }
-        }
-
-        throw new Error(`Formulaire.getNodeParameterValue() : pas de paramètre ${symbol} trouvé`);
-    }
-
     protected notifyReset() {
         this.notifyObservers({
             "action": "resetForm"
@@ -523,6 +482,17 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
         return this._currentNub.findVariatedParams();
     }
 
+    /** find fixed (possibly linked) parameters from the given Nub */
+    public getFixedParameters(): NgParameter[] {
+        const fixedParams: ParamDefinition[] = this._currentNub.findFixedParams();
+        let fnp: NgParameter[] = [];
+        for (const fp of fixedParams) {
+            fnp.push(this.getParamFromSymbol(fp.symbol));
+        }
+        fnp = fnp.filter((e) => e !== undefined);
+        return fnp;
+    }
+
     /**
      * Triggers computation of the Nub, updates form results
      */
diff --git a/src/app/formulaire/definition/form-fixedvar.ts b/src/app/formulaire/definition/form-fixedvar.ts
index a23e5a623..acd265fa2 100644
--- a/src/app/formulaire/definition/form-fixedvar.ts
+++ b/src/app/formulaire/definition/form-fixedvar.ts
@@ -45,15 +45,9 @@ export class FormulaireFixedVar extends FormulaireDefinition {
     }
 
     public addFixedParameters() {
-        for (const p of this.getDisplayedParamListFromState(ParamRadioConfig.FIX)) {
+        for (const p of this.getFixedParameters()) {
             this._fixedResults.addFixedParameter(p);
         }
-
-        for (const p of this.getDisplayedParamListFromState(ParamRadioConfig.LINK)) {
-            if (!p.paramDefinition.hasMultipleValues) {
-                this._fixedResults.addFixedParameter(p);
-            }
-        }
     }
 
     public set graphType(t: ChartType) {
diff --git a/src/app/formulaire/definition/form-prebarrage.ts b/src/app/formulaire/definition/form-prebarrage.ts
index 43f7900af..f6bc246a7 100644
--- a/src/app/formulaire/definition/form-prebarrage.ts
+++ b/src/app/formulaire/definition/form-prebarrage.ts
@@ -1,4 +1,4 @@
-import { CalculatorType, PbBassin, PbCloison, IObservable, PreBarrage, VariatedDetails, ParamDefinition, ParamDomainValue } from "jalhyd";
+import { CalculatorType, PbBassin, PbCloison, IObservable, PreBarrage, VariatedDetails } from "jalhyd";
 
 import { FormulaireFixedVar } from "./form-fixedvar";
 import { PbSchema } from "../elements/pb-schema";
@@ -8,7 +8,7 @@ import { FormulairePbCloison } from "./form-pb-cloison";
 import { FieldsetContainer } from "../elements/fieldset-container";
 import { CalculatorResults } from "../../results/calculator-results";
 import { PrebarrageResults } from "../../results/prebarrage-results";
-import { NgParameter, ParamRadioConfig } from "../elements/ngparam";
+import { NgParameter } from "../elements/ngparam";
 import { longestVarParam } from "../../util";
 
 /**
@@ -25,6 +25,9 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
     /** configuration for re-creating basin form every time needed */
     private basinFormConfig: string;
 
+    /** child form for walls */
+    private wallForm: FormulairePbCloison;
+
     /** configuration for re-creating wall form every time needed */
     private wallFormConfig: string;
 
@@ -138,18 +141,18 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
             this.showFormElements(this.basinForm);
 
         } else if (node instanceof PbCloison) {
-            const wallForm = new FormulairePbCloison(this);
-            wallForm.defaultProperties["calcType"] = CalculatorType.PbCloison;
-            wallForm.currentNub = node;
-            wallForm.preparseConfig(this.wallFormConfig);
-            wallForm.parseConfig(this.wallFormConfig);
+            this.wallForm = new FormulairePbCloison(this);
+            this.wallForm.defaultProperties["calcType"] = CalculatorType.PbCloison;
+            this.wallForm.currentNub = node;
+            this.wallForm.preparseConfig(this.wallFormConfig);
+            this.wallForm.parseConfig(this.wallFormConfig);
             // subscribe to upstream/downstream basin change
-            wallForm.addObserver(this); // @TODO why not this.form ? wallForm is just a dummy form to extract elements from…
-            ServiceFactory.instance.formulaireService.loadUpdateFormulaireLocalisation(wallForm);
+            this.wallForm.addObserver(this); // @TODO why not this.form ? wallForm is just a dummy form to extract elements from…
+            ServiceFactory.instance.formulaireService.loadUpdateFormulaireLocalisation(this.wallForm);
             // add fieldsets for existing Structures
             if (node.structures.length > 0) {
                 for (const struct of node.structures) {
-                    for (const e of wallForm.allFormElements) {
+                    for (const e of this.wallForm.allFormElements) {
                         if (e instanceof FieldsetContainer) { // @TODO manage many containers one day ?
                             e.addFromTemplate(0, undefined, struct, { resetResults: false });
                         }
@@ -157,14 +160,14 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
                 }
             } else {
                 // if there was no existing structure, add a default one
-                for (const e of wallForm.allFormElements) {
+                for (const e of this.wallForm.allFormElements) {
                     if (e instanceof FieldsetContainer) {
                         e.addFromTemplate(0, undefined, undefined, { resetResults: false });
                         break;
                     }
                 }
             }
-            this.showFormElements(wallForm);
+            this.showFormElements(this.wallForm);
         }
         this.reaffectResultComponents();
     }
@@ -222,6 +225,7 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
             this.pbResults.variatedParameters = varParams;
             const lvp = longestVarParam(this._pbResults.variatedParameters);
             this._pbResults.size = lvp.size;
+            this._pbResults.cloisonResults.size = lvp.size;
         }
 
         // résultats selon l'objet sélectionné sur le schéma
@@ -231,30 +235,19 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
             if (computedParam !== undefined) {
                 this.pbResults.cloisonResults.calculatedParameter = computedParam;
             }
-            // transmission des suffixes de cloisons calculés par l'algo de tri de PbSchemaComponent,
-            // pour le sélecteur de conditions limites
-        const pbs = this.kids[0] as PbSchema;
-            this.pbResults.wallsSuffixes = pbs.wallsSuffixes;
-            // astuce clodo : si un paramètre d'un ouvrage de cette cloison varie, on
-            // l'ajoute sous forme de faux paramètre fixe
-            /* for (const s of this._selectedItem.structures) {
+            // if some parameter is variating, add id too (trick with PbResultsComponent
+            for (const s of this._selectedItem.structures) {
                 for (const p of s.parameterIterator) {
                     if (p.hasMultipleValues) {
-                        this._pbResults.cloisonResults.addFixedParameter(
-                            new NgParameter(
-                                new ParamDefinition(
-                                    undefined,
-                                    p.symbol,
-                                    ParamDomainValue.ANY,
-                                    p.unit,
-                                    p.getInferredValuesList(this.pbResults.size)[this.pbResults.variableIndex]
-                                ),
-                                this
-                            )
-                        );
+                        const ngp = this.getParamFromSymbol(p.symbol);
+                        this._pbResults.cloisonResults.addFixedParameter(ngp);
                     }
                 }
-            } */
+            }
+            // transmission des suffixes de cloisons calculés par l'algo de tri de PbSchemaComponent,
+            // pour le sélecteur de conditions limites
+            const pbs = this.kids[0] as PbSchema;
+            this.pbResults.wallsSuffixes = pbs.wallsSuffixes;
         } else {
             // afficher les résultats des bassins
             // résultat général du Nub (amont, aval, débit)
@@ -268,13 +261,8 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
     }
 
     public addFixedParameters() {
-        // @TODO lire dans le modèle !
-        for (const p of this.getDisplayedParamListFromState(ParamRadioConfig.FIX)) {
-            this._pbResults.cloisonResults.addFixedParameter(p);
-        }
-
-        for (const p of this.getDisplayedParamListFromState(ParamRadioConfig.LINK)) {
-            if (!p.paramDefinition.hasMultipleValues) {
+        if (this.wallForm !== undefined) {
+            for (const p of this.wallForm.getFixedParameters()) {
                 this._pbResults.cloisonResults.addFixedParameter(p);
             }
         }
diff --git a/src/app/results/multidimension-results.ts b/src/app/results/multidimension-results.ts
index c3669acfd..44967427c 100644
--- a/src/app/results/multidimension-results.ts
+++ b/src/app/results/multidimension-results.ts
@@ -9,5 +9,14 @@ export class MultiDimensionResults extends CalculatedParamResults {
     public variatedParameters: VariatedDetails[];
 
     /** index de la valeur du paramètre varié à afficher dans les résultats */
-    public variableIndex = 0;
+    protected _variableIndex = 0;
+
+    public get variableIndex(): number {
+        return this._variableIndex;
+    }
+
+    /** redéfini par PrebarrageResults notamment */
+    public set variableIndex(v: number) {
+        this._variableIndex = v;
+    }
 }
diff --git a/src/app/results/pb-cloison-results.ts b/src/app/results/pb-cloison-results.ts
new file mode 100644
index 000000000..44524dfac
--- /dev/null
+++ b/src/app/results/pb-cloison-results.ts
@@ -0,0 +1,11 @@
+import { FixedResults } from "./fixed-results";
+
+/** Fixed results, that are not really fixed (trick for PreBarrage) */
+export class PbCloisonResults extends FixedResults {
+
+    /** index de la valeur du paramètre varié à afficher dans les résultats */
+    public variableIndex = 0;
+
+    /** size of the longest variating parameter */
+    public size = 1;
+}
diff --git a/src/app/results/prebarrage-results.ts b/src/app/results/prebarrage-results.ts
index fb92d9fb6..301b8248c 100644
--- a/src/app/results/prebarrage-results.ts
+++ b/src/app/results/prebarrage-results.ts
@@ -2,7 +2,7 @@ import { Result } from "jalhyd";
 
 import { ServiceFactory } from "../services/service-factory";
 import { MultiDimensionResults } from "./multidimension-results";
-import { FixedResults } from "./fixed-results";
+import { PbCloisonResults } from "./pb-cloison-results";
 
 export class PrebarrageResults extends MultiDimensionResults {
 
@@ -10,7 +10,7 @@ export class PrebarrageResults extends MultiDimensionResults {
     public bassinsResults: Result[];
 
     /** résultat de la cloison actuellement sélectionnée (nourrit le FixedResultsComponent) */
-    public cloisonResults: FixedResults;
+    public cloisonResults: PbCloisonResults;
 
     /** symboles des colonnes de résultat */
     protected _columns: string[];
@@ -57,10 +57,23 @@ export class PrebarrageResults extends MultiDimensionResults {
         });
     }
 
+    // redéfinir le set() implique de redéfinir le get(), sinon /i
+    public get variableIndex(): number {
+        return this._variableIndex;
+    }
+
+    public set variableIndex(v: number) {
+        this._variableIndex = v;
+        // set index in pseudo-fixed Cloison results too
+        this.cloisonResults.variableIndex = v;
+    }
+
     public reset() {
         super.reset();
         this.bassinsResults = [];
-        this.cloisonResults = new FixedResults();
+        this.cloisonResults = new PbCloisonResults();
+        this.cloisonResults.variableIndex = this._variableIndex;
+        this.cloisonResults.size = this.size;
         this.result = undefined;
     }
 
diff --git a/src/app/util.ts b/src/app/util.ts
index ecb8604a8..74d0f3329 100644
--- a/src/app/util.ts
+++ b/src/app/util.ts
@@ -1,7 +1,7 @@
 import { NgParameter } from "./formulaire/elements/ngparam";
 import { ServiceFactory } from "./services/service-factory";
 
-import { formattedValue, Nub, VariatedDetails, ParamDefinition } from "jalhyd";
+import { formattedValue, Nub, VariatedDetails, ParamDefinition, ParamValueMode } from "jalhyd";
 
 export function logObject(obj: {}, m?: string) {
     // évite le message "Value below was evaluated just now" dans le debugger de Chrome
@@ -31,6 +31,26 @@ export function fv(p: NgParameter | number): string {
     return formattedValue(value, nDigits);
 }
 
+/**
+ * Returns value at index i for parameter p, whether it is variating
+ * or not, calculated or not
+ * @param p parameter
+ * @param i index
+ */
+export function getIthValue(p: ParamDefinition, i: number, extendTo: number): string {
+    let value: number;
+    if (p.hasMultipleValues) {
+        if (p.valueMode === ParamValueMode.CALCUL) {
+            value = p.parentNub.result.resultElements[i].vCalc;
+        } else {
+            value = p.getInferredValuesList(extendTo)[i];
+        }
+    } else {
+        value = p.V;
+    }
+    return fv(value);
+}
+
 /**
  * Trick to decode HTML entities in a string
  * https://stackoverflow.com/a/7394787/5986614
diff --git a/src/styles.scss b/src/styles.scss
index 11ffd2a86..4f086079e 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -365,7 +365,7 @@ var-results {
     }
 }
 
-fixed-results {
+fixed-results, pb-cloison-results {
 
     table.mat-table {
 
-- 
GitLab