From 44e7b677a4c24582f532db7ef4db4e47091796cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Fri, 4 Nov 2022 11:03:16 +0100
Subject: [PATCH 1/3] feature: PAB table: remove rounding using display
 precision

refs #543
---
 .../pab-table/pab-table.component.ts          | 20 ++-----------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts
index f22816c7d..d21fa2838 100644
--- a/src/app/components/pab-table/pab-table.component.ts
+++ b/src/app/components/pab-table/pab-table.component.ts
@@ -460,21 +460,6 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
     private refresh() {
         const maxNbDevices = this.findMaxNumberOfDevices();
 
-        // adjuste precision once before anything else
-        const nDigits = this.appSetupService.displayPrecision;
-        for (const c of this.model.children) {
-            for (const p of c.parameterIterator) {
-                if (p.visible && p.symbol !== "QA") { // QA might vary !
-                    p.singleValue = round(p.singleValue, nDigits);
-                }
-            }
-        }
-        for (const p of this.model.downWall.parameterIterator) {
-            if (p.visible) {
-                p.singleValue = round(p.singleValue, nDigits);
-            }
-        }
-
         // 0. build spanned headers over real columns
         this.headers = [];
         // 1 header for basin
@@ -1348,7 +1333,6 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
 
                         case "interpolate":
                             if (result.variableDetails.occurrences > 1) {
-                                const nDigits = this.appSetupService.displayPrecision;
                                 const interpolatedValues: number[] = [];
                                 const variableRange = result.variableDetails.last - result.variableDetails.first;
                                 let totalBasinsLengths = 0;
@@ -1391,7 +1375,7 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
                                             /* console.log(`Wall ${i} : length = ${currentLength} / ${totalBasinsLengths}`
                                                 + ` (${currentBasinLengthPercentage}), applying step of ${step}`); */
                                             currentValue += step;
-                                            interpolatedValues.push(round(currentValue, nDigits));
+                                            interpolatedValues.push(currentValue);
                                         }
                                     } else {
                                         // for other interpolable elevations, exclude last basin
@@ -1403,7 +1387,7 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
                                             /* console.log(`Wall ${i} : length = ${currentBasinLength} / ${totalBasinsLengths}`
                                                 + ` (${currentBasinLengthPercentage}), applying step of ${step}`); */
                                             currentValue += step;
-                                            interpolatedValues.push(round(currentValue, nDigits));
+                                            interpolatedValues.push(currentValue);
                                         }
                                     }
                                 }
-- 
GitLab


From c7ec804e41178849d70e1d56081cb938675cf028 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Wed, 7 Dec 2022 10:49:36 +0100
Subject: [PATCH 2/3] fix: fish ladder generation dialog: set rounding
 precision to 3 digits

refs #543
---
 .../dialog-generate-pab/dialog-generate-pab.component.ts        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
index 202aa1fd8..ebbeb1450 100644
--- a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
+++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
@@ -26,7 +26,7 @@ export class DialogGeneratePABComponent {
         private appSetupService: ApplicationSetupService,
         @Inject(MAT_DIALOG_DATA) public data: any
     ) {
-        const nDigits = this.appSetupService.displayPrecision;
+        const nDigits = 3;  // nghyd#543
         this.coteAmont = data.coteAmont ? round(data.coteAmont, nDigits) : undefined;
         this.debit = data.debit ? round(data.debit, nDigits) : undefined;
         this.nbBassins = data.nbBassins;
-- 
GitLab


From f0c51eb08cc6c25570bf1775de47683c18c8024f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Wed, 7 Dec 2022 12:45:27 +0100
Subject: [PATCH 3/3] fix: fish ladder calculator: set precision display in
 table to 3 digits

refs #543
---
 src/app/components/pab-table/pab-table.component.ts | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts
index d21fa2838..8ef4e14c1 100644
--- a/src/app/components/pab-table/pab-table.component.ts
+++ b/src/app/components/pab-table/pab-table.component.ts
@@ -77,6 +77,9 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
     /** used for shift+click implementation */
     private latestClickedCell: any;
 
+    /** number of digits (after decimal point) to use to display number in the table */
+    private readonly nDigits = 3; // 3 -> cf. nghyd#543
+
     public constructor(
         private i18nService: I18nService,
         private formService: FormulaireService,
@@ -1427,7 +1430,7 @@ export class PabTableComponent implements AfterViewInit, AfterViewChecked, OnIni
     }
 
     public getCellValue(cell) {
-        return cell.model.singleValue;
+        return round(cell.model.singleValue, this.nDigits);
     }
 
     public setCellValue(cell, event) {
-- 
GitLab