From 4d31552b61ab969bd9cc25cb238e72b1f95c3458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Thu, 3 Nov 2022 10:15:51 +0100 Subject: [PATCH 01/12] feature: add component to open a new section detail form refs #496 --- src/app/app.module.ts | 4 +- .../section-details-entry.component.html | 6 +++ .../section-details-entry.component.scss | 0 .../section-details-entry.component.ts | 42 +++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/app/components/section-details-entry/section-details-entry.component.html create mode 100644 src/app/components/section-details-entry/section-details-entry.component.scss create mode 100644 src/app/components/section-details-entry/section-details-entry.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c39a646e4..c5fd9324b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -123,6 +123,7 @@ import { DialogConfirmLoadSessionURLComponent } from "./components/dialog-confir import { StructureFieldsetContainerComponent } from "./components/structure-fieldset-container/structure-fieldset-container.component"; import { BasinFieldsetContainerComponent } from "./components/basin-fieldset-container/basin-fieldset-container.component"; import { PrebarrageService } from "./services/prebarrage.service"; +import { SectionDetailsEntryComponent } from "./components/section-details-entry/section-details-entry.component"; const appRoutes: Routes = [ { path: "list/search", component: CalculatorListComponent }, @@ -257,7 +258,8 @@ const appRoutes: Routes = [ SelectFieldLineComponent, SessionPropertiesComponent, VarResultsComponent, - VerificateurResultsComponent + VerificateurResultsComponent, + SectionDetailsEntryComponent ], providers: [ // services ApplicationSetupService, diff --git a/src/app/components/section-details-entry/section-details-entry.component.html b/src/app/components/section-details-entry/section-details-entry.component.html new file mode 100644 index 000000000..7ce439984 --- /dev/null +++ b/src/app/components/section-details-entry/section-details-entry.component.html @@ -0,0 +1,6 @@ +<div fxLayout="row wrap" fxLayoutGap="10px"> + <p>{{label}}</p> + <button mat-raised-button color="accent" id="generate-cr-sp" (click)="generateCrSp()"> + {{ uitextGenerateRuSp }} + </button> +</div> diff --git a/src/app/components/section-details-entry/section-details-entry.component.scss b/src/app/components/section-details-entry/section-details-entry.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/components/section-details-entry/section-details-entry.component.ts b/src/app/components/section-details-entry/section-details-entry.component.ts new file mode 100644 index 000000000..01503d59e --- /dev/null +++ b/src/app/components/section-details-entry/section-details-entry.component.ts @@ -0,0 +1,42 @@ +import { Component, Input } from '@angular/core'; +import { I18nService } from 'app/services/internationalisation.service'; + +/** + * Bouton d'ouverture des détails de section hydraulique pour chaque point du graphe de "courbes de remous". + * Utilisé comme entrées d'un select. + */ + +@Component({ + selector: 'section-details-entry', + templateUrl: './section-details-entry.component.html', + styleUrls: ['./section-details-entry.component.scss'] +}) +export class SectionDetailsEntryComponent { + private _abscissa: number; + + @Input() + private set abscissa(n: number) { + this._abscissa = n; + } + + constructor( + private intlService: I18nService, + ) { } + + public get label(): string { + if (this._abscissa === undefined) { + return undefined; + } + return "x : " + this._abscissa.toString(); + } + + public get uitextGenerateRuSp() { + return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_RU_SP"); + } + + /** + * Génère une SectionParametree à partir du module en cours + */ + public async generateCrSp() { + } +} -- GitLab From 70d3d72e1efec7d5f767327f4f415bbb86738133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Thu, 3 Nov 2022 10:25:02 +0100 Subject: [PATCH 02/12] refactor: move parametric section form generation to form service refs #496 --- .../calculator.component.ts | 18 ++-------- src/app/services/formulaire.service.ts | 36 ++++++++++++++++++- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 901fa1343..fc57d1653 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -965,25 +965,11 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe * Génère une SectionParametree à partir du module RegimeUniforme en cours */ public async generateRuSp() { - const ru = (this._formulaire.currentNub as RegimeUniforme); - // copy section - const serialisedSection = ru.section.serialise(); - const sectionCopy = Session.getInstance().unserialiseSingleNub(serialisedSection, false).nub; - const secParam = new SectionParametree(sectionCopy as acSection); - // copy value of calculated param - const cp = ru.calculatedParam; - const scp = secParam.section.getParameter(cp.symbol); - if (cp.hasMultipleValues) { - scp.setValues(ru.result.getCalculatedValues().map(v => round(v, this.appSetupService.displayPrecision))); - } else { - scp.singleValue = ru.result.vCalc; - } - Session.getInstance().registerNub(secParam); - - const f: FormulaireDefinition = await this.formulaireService.createFormulaire(CalculatorType.SectionParametree, secParam); + const f = await this.formulaireService.generateParametricSectionForm(); // calculate f.doCompute(); // go to new SP + this.router.navigate(["/calculator", f.uid]); } public get generatePARSimulationEnabled(): boolean { diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 4c9e42baa..90095e6df 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -21,7 +21,13 @@ import { LoiDebit, PbCloison, CreateStructure, - Structure + Structure, + SectionNub, + SectionParametree, + acSection, + round, + RegimeUniforme, + CourbeRemous } from "jalhyd"; import { ApplicationSetupService } from "./app-setup.service"; @@ -851,4 +857,32 @@ export class FormulaireService extends Observable { } } } + + /** + * Génère un formulaire SectionParametree à partir du module courant + * s'il est du type régime uniforme ou courbe de remous + */ + public async generateParametricSectionForm(): Promise<FormulaireDefinition> { + if (this.currentForm.currentNub instanceof SectionNub) { + const sn: SectionNub = this.currentForm.currentNub; + if (sn instanceof RegimeUniforme || sn instanceof CourbeRemous) { + // copy section + const serialisedSection = sn.section.serialise(); + const sectionCopy = Session.getInstance().unserialiseSingleNub(serialisedSection, false).nub; + const secParam = new SectionParametree(sectionCopy as acSection); + // copy value of calculated param + const cp: ParamDefinition = sn.calculatedParam; + const scp: ParamDefinition = secParam.section.getParameter(cp.symbol); + if (cp.hasMultipleValues) { + scp.setValues(sn.result.getCalculatedValues().map(v => round(v, this.appSetupService.displayPrecision))); + } else { + scp.singleValue = sn.result.vCalc; + } + Session.getInstance().registerNub(secParam); + + return await this.createFormulaire(CalculatorType.SectionParametree, secParam); + } + } + return Promise.reject("cannot create parametric section from current form"); + } } -- GitLab From b5675b9e6d8e14c55cbc02d13169eb3d949809b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Thu, 3 Nov 2022 10:25:35 +0100 Subject: [PATCH 03/12] feature: section detail entry: use form service to generate parametric section form refs #496 --- .../section-details-entry.component.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/components/section-details-entry/section-details-entry.component.ts b/src/app/components/section-details-entry/section-details-entry.component.ts index 01503d59e..6f5c77a06 100644 --- a/src/app/components/section-details-entry/section-details-entry.component.ts +++ b/src/app/components/section-details-entry/section-details-entry.component.ts @@ -1,11 +1,13 @@ import { Component, Input } from '@angular/core'; +import { Router } from '@angular/router'; +import { FormulaireDefinition } from 'app/formulaire/definition/form-definition'; +import { FormulaireService } from 'app/services/formulaire.service'; import { I18nService } from 'app/services/internationalisation.service'; /** * Bouton d'ouverture des détails de section hydraulique pour chaque point du graphe de "courbes de remous". * Utilisé comme entrées d'un select. */ - @Component({ selector: 'section-details-entry', templateUrl: './section-details-entry.component.html', @@ -21,6 +23,8 @@ export class SectionDetailsEntryComponent { constructor( private intlService: I18nService, + private formulaireService: FormulaireService, + private router: Router ) { } public get label(): string { @@ -38,5 +42,12 @@ export class SectionDetailsEntryComponent { * Génère une SectionParametree à partir du module en cours */ public async generateCrSp() { + const f: FormulaireDefinition = await this.formulaireService.generateParametricSectionForm(); + + // calculate form + f.doCompute(); + + // go to new form + this.router.navigate(["/calculator", f.uid]); } } -- GitLab From 3bddb33536ee5d6a7a4f86c16d4a29350ae6bac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 4 Nov 2022 08:28:55 +0100 Subject: [PATCH 04/12] feature : backwater curves: add select to open a parametric section calculator for a given abscissa refs #496 --- src/app/app.module.ts | 4 ++- .../calculator.component.html | 2 ++ .../calculator.component.ts | 21 ++++++++++++ .../select-section-details.component.html | 5 +++ .../select-section-details.component.scss | 3 ++ .../select-section-details.component.ts | 33 +++++++++++++++++++ src/app/results/remous-results.ts | 9 +++++ src/app/services/formulaire.service.ts | 16 +++++---- 8 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 src/app/components/select-section-details/select-section-details.component.html create mode 100644 src/app/components/select-section-details/select-section-details.component.scss create mode 100644 src/app/components/select-section-details/select-section-details.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c5fd9324b..702dabc0e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -124,6 +124,7 @@ import { StructureFieldsetContainerComponent } from "./components/structure-fiel import { BasinFieldsetContainerComponent } from "./components/basin-fieldset-container/basin-fieldset-container.component"; import { PrebarrageService } from "./services/prebarrage.service"; import { SectionDetailsEntryComponent } from "./components/section-details-entry/section-details-entry.component"; +import { SelectSectionDetailsComponent } from "./components/select-section-details/select-section-details.component"; const appRoutes: Routes = [ { path: "list/search", component: CalculatorListComponent }, @@ -259,7 +260,8 @@ const appRoutes: Routes = [ SessionPropertiesComponent, VarResultsComponent, VerificateurResultsComponent, - SectionDetailsEntryComponent + SectionDetailsEntryComponent, + SelectSectionDetailsComponent ], providers: [ // services ApplicationSetupService, diff --git a/src/app/components/generic-calculator/calculator.component.html b/src/app/components/generic-calculator/calculator.component.html index a61455db0..80581c365 100644 --- a/src/app/components/generic-calculator/calculator.component.html +++ b/src/app/components/generic-calculator/calculator.component.html @@ -200,6 +200,8 @@ {{ uitextGenerateRuSp }} </button> + <select-section-details id="generate-cr-sps" *ngIf="hasCourbeRemousResults" [points]="courbeRemousAbscissae"></select-section-details> + <button mat-raised-button color="accent" id="generate-par-simulation" *ngIf="isPAR" (click)="generatePARSimulation()" [disabled]="! generatePARSimulationEnabled" [title]="uitextGenerateParSimulationTitle"> diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index fc57d1653..500b329de 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -63,6 +63,8 @@ import { sprintf } from "sprintf-js"; import * as XLSX from "xlsx"; import { ServiceFactory } from "app/services/service-factory"; import { DefinedBoolean } from "app/definedvalue/definedboolean"; +import { FormulaireCourbeRemous } from "app/formulaire/definition/form-courbe-remous"; +import { RemousResults } from "app/results/remous-results"; @Component({ selector: "hydrocalc", @@ -710,6 +712,11 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe return this.is(CalculatorType.RegimeUniforme); } + // true if CourbeRemous results are present + public get hasCourbeRemousResults() { + return this.is(CalculatorType.CourbeRemous) && this.hasResults; + } + // true if current Nub is PAR public get isPAR() { return this.is(CalculatorType.Par); @@ -972,6 +979,20 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe this.router.navigate(["/calculator", f.uid]); } + /** + * @returns liste des abscisses du graphe de courbes de remous + */ + public get courbeRemousAbscissae(): number[] { + if (this.hasCourbeRemousResults) { + const crForm = this._formulaire as FormulaireCourbeRemous; + for (const r of crForm.results) { + if (r instanceof RemousResults) { + return r.abscissae; + } + } + } + } + public get generatePARSimulationEnabled(): boolean { const parCalage = (this._formulaire.currentNub as Par); return ( diff --git a/src/app/components/select-section-details/select-section-details.component.html b/src/app/components/select-section-details/select-section-details.component.html new file mode 100644 index 000000000..d8917f9e5 --- /dev/null +++ b/src/app/components/select-section-details/select-section-details.component.html @@ -0,0 +1,5 @@ +<mat-select [placeholder]="uitextPlaceholder"> + <mat-option *ngFor="let p of points"> + <section-details-entry [abscissa]=p></section-details-entry> + </mat-option> +</mat-select> \ No newline at end of file diff --git a/src/app/components/select-section-details/select-section-details.component.scss b/src/app/components/select-section-details/select-section-details.component.scss new file mode 100644 index 000000000..c62ffafb0 --- /dev/null +++ b/src/app/components/select-section-details/select-section-details.component.scss @@ -0,0 +1,3 @@ +mat-select { + border: 1px solid #4dbbe9; +} diff --git a/src/app/components/select-section-details/select-section-details.component.ts b/src/app/components/select-section-details/select-section-details.component.ts new file mode 100644 index 000000000..c27db1224 --- /dev/null +++ b/src/app/components/select-section-details/select-section-details.component.ts @@ -0,0 +1,33 @@ +import { Component, Input } from '@angular/core'; + +/** + * liste déroulante de boutons de génération de formulaire "section paramétrée" + */ + +@Component({ + selector: 'select-section-details', + templateUrl: './select-section-details.component.html', + styleUrls: ['./select-section-details.component.scss'] +}) +export class SelectSectionDetailsComponent { + private _points: number[]; + + /** + * abscisses auxquelles on peut créer un formulaire "section paramétrée" + */ + @Input() + public set points(ps: number[]) { + this._points = ps; + } + + public get points(): number[] { + return this._points; + } + + constructor( + ) { } + + public get uitextPlaceholder() { + return "Générer une section paramétrée pour..."; + } +} diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index abb20aa69..aebc15e0b 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -116,6 +116,15 @@ export class RemousResults extends CalculatorResults { this._xValues.setValues(abscissae); } + /* + * abscisses pour lesquelles on a des résultats + */ + public get abscissae(): number[] { + return this._result.resultElements.map((re) => { + return re.getValue("X"); + }); + } + public update() { this._hasFlu = false; this._hasTor = false; diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 90095e6df..22a2956fd 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -870,13 +870,15 @@ export class FormulaireService extends Observable { const serialisedSection = sn.section.serialise(); const sectionCopy = Session.getInstance().unserialiseSingleNub(serialisedSection, false).nub; const secParam = new SectionParametree(sectionCopy as acSection); - // copy value of calculated param - const cp: ParamDefinition = sn.calculatedParam; - const scp: ParamDefinition = secParam.section.getParameter(cp.symbol); - if (cp.hasMultipleValues) { - scp.setValues(sn.result.getCalculatedValues().map(v => round(v, this.appSetupService.displayPrecision))); - } else { - scp.singleValue = sn.result.vCalc; + if (sn instanceof RegimeUniforme) { + // copy value of calculated param + const cp: ParamDefinition = sn.calculatedParam; + const scp: ParamDefinition = secParam.section.getParameter(cp.symbol); + if (cp.hasMultipleValues) { + scp.setValues(sn.result.getCalculatedValues().map(v => round(v, this.appSetupService.displayPrecision))); + } else { + scp.singleValue = sn.result.vCalc; + } } Session.getInstance().registerNub(secParam); -- GitLab From 2290708ce2417e333a208b1185aef7d5516efaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 4 Nov 2022 10:14:56 +0100 Subject: [PATCH 05/12] feature: backwater curves: add Y to point list where a parametric section can be generated refs #496 --- .../calculator.component.html | 2 +- .../calculator.component.ts | 4 ++-- .../section-details-entry.component.ts | 12 ++++++---- .../select-section-details.component.html | 2 +- .../select-section-details.component.ts | 8 +++---- src/app/results/remous-results.ts | 24 +++++++++++++++---- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/app/components/generic-calculator/calculator.component.html b/src/app/components/generic-calculator/calculator.component.html index 80581c365..40cac6c06 100644 --- a/src/app/components/generic-calculator/calculator.component.html +++ b/src/app/components/generic-calculator/calculator.component.html @@ -200,7 +200,7 @@ {{ uitextGenerateRuSp }} </button> - <select-section-details id="generate-cr-sps" *ngIf="hasCourbeRemousResults" [points]="courbeRemousAbscissae"></select-section-details> + <select-section-details id="generate-cr-sps" *ngIf="hasCourbeRemousResults" [points]="courbeRemousPoints"></select-section-details> <button mat-raised-button color="accent" id="generate-par-simulation" *ngIf="isPAR" (click)="generatePARSimulation()" [disabled]="! generatePARSimulationEnabled" diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 500b329de..49e81d946 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -982,12 +982,12 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe /** * @returns liste des abscisses du graphe de courbes de remous */ - public get courbeRemousAbscissae(): number[] { + public get courbeRemousPoints(): any[] { if (this.hasCourbeRemousResults) { const crForm = this._formulaire as FormulaireCourbeRemous; for (const r of crForm.results) { if (r instanceof RemousResults) { - return r.abscissae; + return r.points; } } } diff --git a/src/app/components/section-details-entry/section-details-entry.component.ts b/src/app/components/section-details-entry/section-details-entry.component.ts index 6f5c77a06..715b2f1a7 100644 --- a/src/app/components/section-details-entry/section-details-entry.component.ts +++ b/src/app/components/section-details-entry/section-details-entry.component.ts @@ -3,6 +3,8 @@ import { Router } from '@angular/router'; import { FormulaireDefinition } from 'app/formulaire/definition/form-definition'; import { FormulaireService } from 'app/services/formulaire.service'; import { I18nService } from 'app/services/internationalisation.service'; +import { fv } from 'app/util'; +import { formattedValue } from 'jalhyd'; /** * Bouton d'ouverture des détails de section hydraulique pour chaque point du graphe de "courbes de remous". @@ -14,11 +16,11 @@ import { I18nService } from 'app/services/internationalisation.service'; styleUrls: ['./section-details-entry.component.scss'] }) export class SectionDetailsEntryComponent { - private _abscissa: number; + private _point: any; @Input() - private set abscissa(n: number) { - this._abscissa = n; + private set point(p: any) { + this._point = p; } constructor( @@ -28,10 +30,10 @@ export class SectionDetailsEntryComponent { ) { } public get label(): string { - if (this._abscissa === undefined) { + if (this._point === undefined) { return undefined; } - return "x : " + this._abscissa.toString(); + return "x : " + formattedValue(this._point.x, 1) + " y : " + fv(this._point.y); } public get uitextGenerateRuSp() { diff --git a/src/app/components/select-section-details/select-section-details.component.html b/src/app/components/select-section-details/select-section-details.component.html index d8917f9e5..bbb74ee25 100644 --- a/src/app/components/select-section-details/select-section-details.component.html +++ b/src/app/components/select-section-details/select-section-details.component.html @@ -1,5 +1,5 @@ <mat-select [placeholder]="uitextPlaceholder"> <mat-option *ngFor="let p of points"> - <section-details-entry [abscissa]=p></section-details-entry> + <section-details-entry [point]=p></section-details-entry> </mat-option> </mat-select> \ No newline at end of file diff --git a/src/app/components/select-section-details/select-section-details.component.ts b/src/app/components/select-section-details/select-section-details.component.ts index c27db1224..811e73291 100644 --- a/src/app/components/select-section-details/select-section-details.component.ts +++ b/src/app/components/select-section-details/select-section-details.component.ts @@ -10,17 +10,17 @@ import { Component, Input } from '@angular/core'; styleUrls: ['./select-section-details.component.scss'] }) export class SelectSectionDetailsComponent { - private _points: number[]; + private _points: any[]; /** - * abscisses auxquelles on peut créer un formulaire "section paramétrée" + * points auxquels on peut créer un formulaire "section paramétrée" */ @Input() - public set points(ps: number[]) { + public set points(ps: any[]) { this._points = ps; } - public get points(): number[] { + public get points(): any[] { return this._points; } diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index aebc15e0b..6b64caaf8 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -54,6 +54,11 @@ export class RemousResults extends CalculatorResults { /** pointer to form that instantiated this object */ protected _form: FormulaireDefinition; + /** + * liste des X,Y (fluvial ou torrentiel) + */ + private _points: any[]; + constructor(form?: FormulaireDefinition) { super(); this._form = form; @@ -114,15 +119,24 @@ export class RemousResults extends CalculatorResults { return re.getValue("X"); }); this._xValues.setValues(abscissae); + + this.updatePoints(); + } + + private updatePoints() { + this._points = this._result.resultElements.map((re) => { + let Y = re.getValue("flu"); + if (Y === undefined) + Y = re.getValue("tor"); + return { x: re.getValue("X"), y: Y }; + }); } /* - * abscisses pour lesquelles on a des résultats + * points pour lesquels on a des résultats */ - public get abscissae(): number[] { - return this._result.resultElements.map((re) => { - return re.getValue("X"); - }); + public get points(): any[] { + return this._points; } public update() { -- GitLab From 26d55b17d40dcf637b423bc253669fcd4b1b551c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 4 Nov 2022 10:22:13 +0100 Subject: [PATCH 06/12] feature: backwater curves: parametric section generation: link selected point Y value to generated calculator refs #496 --- .../section-details-entry.component.ts | 2 +- src/app/services/formulaire.service.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/components/section-details-entry/section-details-entry.component.ts b/src/app/components/section-details-entry/section-details-entry.component.ts index 715b2f1a7..477c7486f 100644 --- a/src/app/components/section-details-entry/section-details-entry.component.ts +++ b/src/app/components/section-details-entry/section-details-entry.component.ts @@ -44,7 +44,7 @@ export class SectionDetailsEntryComponent { * Génère une SectionParametree à partir du module en cours */ public async generateCrSp() { - const f: FormulaireDefinition = await this.formulaireService.generateParametricSectionForm(); + const f: FormulaireDefinition = await this.formulaireService.generateParametricSectionForm(this._point.y); // calculate form f.doCompute(); diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 22a2956fd..2bd8ee212 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -862,14 +862,17 @@ export class FormulaireService extends Observable { * Génère un formulaire SectionParametree à partir du module courant * s'il est du type régime uniforme ou courbe de remous */ - public async generateParametricSectionForm(): Promise<FormulaireDefinition> { + public async generateParametricSectionForm(Y?: number): Promise<FormulaireDefinition> { if (this.currentForm.currentNub instanceof SectionNub) { const sn: SectionNub = this.currentForm.currentNub; if (sn instanceof RegimeUniforme || sn instanceof CourbeRemous) { // copy section const serialisedSection = sn.section.serialise(); - const sectionCopy = Session.getInstance().unserialiseSingleNub(serialisedSection, false).nub; - const secParam = new SectionParametree(sectionCopy as acSection); + const sectionCopy: acSection = Session.getInstance().unserialiseSingleNub(serialisedSection, false).nub as acSection; + if (Y !== undefined) { + sectionCopy.prms.Y.singleValue = Y; + } + const secParam = new SectionParametree(sectionCopy); if (sn instanceof RegimeUniforme) { // copy value of calculated param const cp: ParamDefinition = sn.calculatedParam; -- GitLab From 95eff5263ff0df3396af7aed1543740fa005bb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Tue, 8 Nov 2022 14:58:05 +0100 Subject: [PATCH 07/12] fix: backwater curve: wrong Y value passed to generated parametric section, remove button in select entries refs #496 --- src/app/app.module.ts | 2 - .../section-details-entry.component.html | 6 -- .../section-details-entry.component.scss | 0 .../section-details-entry.component.ts | 55 ------------------- .../select-section-details.component.html | 6 +- .../select-section-details.component.ts | 24 ++++++++ src/app/results/remous-results.ts | 41 +++++++++++--- 7 files changed, 60 insertions(+), 74 deletions(-) delete mode 100644 src/app/components/section-details-entry/section-details-entry.component.html delete mode 100644 src/app/components/section-details-entry/section-details-entry.component.scss delete mode 100644 src/app/components/section-details-entry/section-details-entry.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 702dabc0e..43b3b0b91 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -123,7 +123,6 @@ import { DialogConfirmLoadSessionURLComponent } from "./components/dialog-confir import { StructureFieldsetContainerComponent } from "./components/structure-fieldset-container/structure-fieldset-container.component"; import { BasinFieldsetContainerComponent } from "./components/basin-fieldset-container/basin-fieldset-container.component"; import { PrebarrageService } from "./services/prebarrage.service"; -import { SectionDetailsEntryComponent } from "./components/section-details-entry/section-details-entry.component"; import { SelectSectionDetailsComponent } from "./components/select-section-details/select-section-details.component"; const appRoutes: Routes = [ @@ -260,7 +259,6 @@ const appRoutes: Routes = [ SessionPropertiesComponent, VarResultsComponent, VerificateurResultsComponent, - SectionDetailsEntryComponent, SelectSectionDetailsComponent ], providers: [ // services diff --git a/src/app/components/section-details-entry/section-details-entry.component.html b/src/app/components/section-details-entry/section-details-entry.component.html deleted file mode 100644 index 7ce439984..000000000 --- a/src/app/components/section-details-entry/section-details-entry.component.html +++ /dev/null @@ -1,6 +0,0 @@ -<div fxLayout="row wrap" fxLayoutGap="10px"> - <p>{{label}}</p> - <button mat-raised-button color="accent" id="generate-cr-sp" (click)="generateCrSp()"> - {{ uitextGenerateRuSp }} - </button> -</div> diff --git a/src/app/components/section-details-entry/section-details-entry.component.scss b/src/app/components/section-details-entry/section-details-entry.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/components/section-details-entry/section-details-entry.component.ts b/src/app/components/section-details-entry/section-details-entry.component.ts deleted file mode 100644 index 477c7486f..000000000 --- a/src/app/components/section-details-entry/section-details-entry.component.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { Router } from '@angular/router'; -import { FormulaireDefinition } from 'app/formulaire/definition/form-definition'; -import { FormulaireService } from 'app/services/formulaire.service'; -import { I18nService } from 'app/services/internationalisation.service'; -import { fv } from 'app/util'; -import { formattedValue } from 'jalhyd'; - -/** - * Bouton d'ouverture des détails de section hydraulique pour chaque point du graphe de "courbes de remous". - * Utilisé comme entrées d'un select. - */ -@Component({ - selector: 'section-details-entry', - templateUrl: './section-details-entry.component.html', - styleUrls: ['./section-details-entry.component.scss'] -}) -export class SectionDetailsEntryComponent { - private _point: any; - - @Input() - private set point(p: any) { - this._point = p; - } - - constructor( - private intlService: I18nService, - private formulaireService: FormulaireService, - private router: Router - ) { } - - public get label(): string { - if (this._point === undefined) { - return undefined; - } - return "x : " + formattedValue(this._point.x, 1) + " y : " + fv(this._point.y); - } - - public get uitextGenerateRuSp() { - return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_RU_SP"); - } - - /** - * Génère une SectionParametree à partir du module en cours - */ - public async generateCrSp() { - const f: FormulaireDefinition = await this.formulaireService.generateParametricSectionForm(this._point.y); - - // calculate form - f.doCompute(); - - // go to new form - this.router.navigate(["/calculator", f.uid]); - } -} diff --git a/src/app/components/select-section-details/select-section-details.component.html b/src/app/components/select-section-details/select-section-details.component.html index bbb74ee25..4b3a06f5c 100644 --- a/src/app/components/select-section-details/select-section-details.component.html +++ b/src/app/components/select-section-details/select-section-details.component.html @@ -1,5 +1,5 @@ -<mat-select [placeholder]="uitextPlaceholder"> - <mat-option *ngFor="let p of points"> - <section-details-entry [point]=p></section-details-entry> +<mat-select [placeholder]="uitextPlaceholder" (selectionChange)="generateCrSp($event.value)"> + <mat-option *ngFor="let p of points" [value]="p"> + {{ pointLabel(p) }} </mat-option> </mat-select> \ No newline at end of file diff --git a/src/app/components/select-section-details/select-section-details.component.ts b/src/app/components/select-section-details/select-section-details.component.ts index 811e73291..58516fc2d 100644 --- a/src/app/components/select-section-details/select-section-details.component.ts +++ b/src/app/components/select-section-details/select-section-details.component.ts @@ -1,4 +1,9 @@ import { Component, Input } from '@angular/core'; +import { Router } from '@angular/router'; +import { FormulaireDefinition } from 'app/formulaire/definition/form-definition'; +import { FormulaireService } from 'app/services/formulaire.service'; +import { fv } from 'app/util'; +import { formattedValue } from 'jalhyd'; /** * liste déroulante de boutons de génération de formulaire "section paramétrée" @@ -25,8 +30,27 @@ export class SelectSectionDetailsComponent { } constructor( + private formulaireService: FormulaireService, + private router: Router ) { } + public pointLabel(p: any): string { + return "x : " + formattedValue(p.x, 1) + " y : " + fv(p.z); + } + + /** + * Génère une SectionParametree à partir du module en cours + */ + public async generateCrSp(p: any) { + const f: FormulaireDefinition = await this.formulaireService.generateParametricSectionForm(p.y); + + // calculate form + f.doCompute(); + + // go to new form + this.router.navigate(["/calculator", f.uid]); + } + public get uitextPlaceholder() { return "Générer une section paramétrée pour..."; } diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index 6b64caaf8..20f412f13 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -15,6 +15,12 @@ export class RemousResults extends CalculatorResults { /** pas de discrétisation */ private _Dx: number; + /** cote de fond amont */ + private _ZF1: number; + + /** cote de fond aval */ + private _ZF2: number; + /** longueur du bief */ private _Long: number; @@ -80,17 +86,19 @@ export class RemousResults extends CalculatorResults { } public set parameters(p: CourbeRemousParams) { + const nub = p.parent as Nub; + // pente du fond - this._penteFond = (p.parent as Nub).getParameter("If").singleValue; + this._penteFond = nub.getParameter("If").singleValue; // hauteur de berge - this._hautBerge = (p.parent as Nub).getParameter("YB").singleValue; + this._hautBerge = nub.getParameter("YB").singleValue; // longueur du bief - this._Long = (p.parent as Nub).getParameter("Long").singleValue; + this._Long = nub.getParameter("Long").singleValue; // pas d'espace - this._Dx = (p.parent as Nub).getParameter("Dx").singleValue; + this._Dx = nub.getParameter("Dx").singleValue; // série de valeurs de X this._xValues = new ParamDefinition( @@ -98,6 +106,12 @@ export class RemousResults extends CalculatorResults { "ABSCISSE", ParamDomainValue.POS_NULL ); + + // cote de fond amont + this._ZF1 = nub.getParameter("ZF1").singleValue; + + // cote de fond aval + this._ZF2 = nub.getParameter("ZF2").singleValue; } public get log(): cLog { @@ -125,10 +139,21 @@ export class RemousResults extends CalculatorResults { private updatePoints() { this._points = this._result.resultElements.map((re) => { - let Y = re.getValue("flu"); - if (Y === undefined) - Y = re.getValue("tor"); - return { x: re.getValue("X"), y: Y }; + const X = re.getValue("X"); + + // cote de fond + const k = X / this._Long; + const Zf = (this._ZF2 - this._ZF1) * k + this._ZF1; + + // cote de l'eau + let Z = re.getValue("flu"); + if (Z === undefined) + Z = re.getValue("tor"); + + // tirant d'eau + const Y = Z - Zf; + + return { x: X, y: Y, z: Z }; }); } -- GitLab From 717a634090a528e9ac8542035d942a8265841552 Mon Sep 17 00:00:00 2001 From: toto <toto@tata> Date: Wed, 23 Nov 2022 13:45:23 +0100 Subject: [PATCH 08/12] fix: parametric section generation select: replace x,y by abscissa/water depth refs #496 --- .../select-section-details.component.ts | 8 ++++++-- src/locale/messages.en.json | 2 +- src/locale/messages.fr.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/components/select-section-details/select-section-details.component.ts b/src/app/components/select-section-details/select-section-details.component.ts index 58516fc2d..f315e94d1 100644 --- a/src/app/components/select-section-details/select-section-details.component.ts +++ b/src/app/components/select-section-details/select-section-details.component.ts @@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core'; import { Router } from '@angular/router'; import { FormulaireDefinition } from 'app/formulaire/definition/form-definition'; import { FormulaireService } from 'app/services/formulaire.service'; +import { I18nService } from 'app/services/internationalisation.service'; import { fv } from 'app/util'; import { formattedValue } from 'jalhyd'; @@ -31,11 +32,14 @@ export class SelectSectionDetailsComponent { constructor( private formulaireService: FormulaireService, - private router: Router + private router: Router, + private intlService: I18nService ) { } public pointLabel(p: any): string { - return "x : " + formattedValue(p.x, 1) + " y : " + fv(p.z); + const abs = this.intlService.localizeText("INFO_REMOUSRESULTS_ABSCISSE"); + const tirant = this.intlService.localizeText("INFO_REMOUSRESULTS_TIRANT"); + return abs + " : " + formattedValue(p.x, 1) + " - " + tirant + " : " + fv(p.z); } /** diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 5171fdefc..ce82a8a71 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -577,7 +577,7 @@ "INFO_REMOUSRESULTS_ABSCISSE": "Abscissa", "INFO_REMOUSRESULTS_BERGE": "Embankment", "INFO_REMOUSRESULTS_FOND": "Bottom", - "INFO_REMOUSRESULTS_TIRANT": "Water depth (m)", + "INFO_REMOUSRESULTS_TIRANT": "Water depth", "INFO_REMOUSRESULTS_TIRANTCRITIQUE": "Critical water level", "INFO_REMOUSRESULTS_TIRANTNORMAL": "Normal water level", "INFO_REPORT_BUG_BODY": "This is an issue report.\n\nPlease describe quickly the issue you encountered, and the steps you followed:\n\n\n\n\n--- Current session state - do not modify text below ---\n------------------------------------------------------------------------\n\n", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index d41d2edd4..618be937a 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -578,7 +578,7 @@ "INFO_REMOUSRESULTS_ABSCISSE": "Abscisse", "INFO_REMOUSRESULTS_BERGE": "Berge", "INFO_REMOUSRESULTS_FOND": "Fond", - "INFO_REMOUSRESULTS_TIRANT": "Tirant d'eau (m)", + "INFO_REMOUSRESULTS_TIRANT": "Tirant d'eau", "INFO_REMOUSRESULTS_TIRANTCRITIQUE": "Tirant d'eau critique", "INFO_REMOUSRESULTS_TIRANTNORMAL": "Tirant d'eau normal", "INFO_REPORT_BUG_BODY": "Ceci est un rapport d'erreur.\n\nMerci de décrire rapidement ci-dessous le problème rencontré, et les étapes qui vous y ont mené:\n\n\n\n\n--- État de la session en cours - ne pas modifier le texte ci-dessous ---\n--------------------------------------------------------------------------------------------\n\n", -- GitLab From 60b323ee568cc8ee14f37a7b1aa5c68a733a7936 Mon Sep 17 00:00:00 2001 From: toto <toto@tata> Date: Wed, 23 Nov 2022 13:49:00 +0100 Subject: [PATCH 09/12] fix: parametric section generation select: translate placeholder text refs #496 --- .../select-section-details/select-section-details.component.ts | 2 +- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/components/select-section-details/select-section-details.component.ts b/src/app/components/select-section-details/select-section-details.component.ts index f315e94d1..d42b1e86a 100644 --- a/src/app/components/select-section-details/select-section-details.component.ts +++ b/src/app/components/select-section-details/select-section-details.component.ts @@ -56,6 +56,6 @@ export class SelectSectionDetailsComponent { } public get uitextPlaceholder() { - return "Générer une section paramétrée pour..."; + return this.intlService.localizeText("INFO_REMOUSRESULTS_PARAM_SECTION_PLACEHOLDER"); } } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index ce82a8a71..b6eb8d07f 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -580,6 +580,7 @@ "INFO_REMOUSRESULTS_TIRANT": "Water depth", "INFO_REMOUSRESULTS_TIRANTCRITIQUE": "Critical water level", "INFO_REMOUSRESULTS_TIRANTNORMAL": "Normal water level", + "INFO_REMOUSRESULTS_PARAM_SECTION_PLACEHOLDER": "Generate a parametric section for...", "INFO_REPORT_BUG_BODY": "This is an issue report.\n\nPlease describe quickly the issue you encountered, and the steps you followed:\n\n\n\n\n--- Current session state - do not modify text below ---\n------------------------------------------------------------------------\n\n", "INFO_REPORT_BUG_SUBJECT": "Issue report", "INFO_REQUIRES": "requires", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 618be937a..36110f731 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -581,6 +581,7 @@ "INFO_REMOUSRESULTS_TIRANT": "Tirant d'eau", "INFO_REMOUSRESULTS_TIRANTCRITIQUE": "Tirant d'eau critique", "INFO_REMOUSRESULTS_TIRANTNORMAL": "Tirant d'eau normal", + "INFO_REMOUSRESULTS_PARAM_SECTION_PLACEHOLDER": "Générer une section paramétrée pour...", "INFO_REPORT_BUG_BODY": "Ceci est un rapport d'erreur.\n\nMerci de décrire rapidement ci-dessous le problème rencontré, et les étapes qui vous y ont mené:\n\n\n\n\n--- État de la session en cours - ne pas modifier le texte ci-dessous ---\n--------------------------------------------------------------------------------------------\n\n", "INFO_REPORT_BUG_SUBJECT": "Rapport d'erreur", "INFO_REQUIRES": "dépend de", -- GitLab From 7b0a518cc1ba51e25fdd3d3aefeafa2d7fddbb93 Mon Sep 17 00:00:00 2001 From: toto <toto@tata> Date: Wed, 23 Nov 2022 15:25:19 +0100 Subject: [PATCH 10/12] update jalhyd_branch to jalhyd#333 refs #496 --- jalhyd_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalhyd_branch b/jalhyd_branch index a210a99ef..3c757134f 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -329-un-parametre-lie-ne-change-pas-d-etat-apres-la-suppression-du-module-cible +333-remous-renommer-la-ligne-d-eau-en-z-et-fournir-le-tirant-d-eau-d-apres-celle-ci -- GitLab From afdd8d48a924166364434f7ee623bfedaf2cc6b4 Mon Sep 17 00:00:00 2001 From: toto <toto@tata> Date: Wed, 23 Nov 2022 15:25:43 +0100 Subject: [PATCH 11/12] feat : add water depth to backwater curves results refs #496 --- src/app/calculators/courberemous/en.json | 2 ++ src/app/calculators/courberemous/fr.json | 2 ++ .../pab-profile-chart/pab-profile-chart.component.ts | 2 +- src/app/results/remous-results.ts | 6 +++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/calculators/courberemous/en.json b/src/app/calculators/courberemous/en.json index c238adfb5..8e4ac96ad 100644 --- a/src/app/calculators/courberemous/en.json +++ b/src/app/calculators/courberemous/en.json @@ -26,6 +26,8 @@ "Z2": "Downstream water elevation", "ZF1": "Upstream bottom elevation", "ZF2": "Downstream bottom elevation", + "Y": "Water depth", + "ZW": "Water line (m)", "UNIT_FLU": "m", "UNIT_HS": "m", diff --git a/src/app/calculators/courberemous/fr.json b/src/app/calculators/courberemous/fr.json index 3c8408531..278c16ad4 100644 --- a/src/app/calculators/courberemous/fr.json +++ b/src/app/calculators/courberemous/fr.json @@ -26,6 +26,8 @@ "Z2": "Cote de l'eau à l'aval", "ZF1": "Cote du fond à l'amont", "ZF2": "Cote du fond à l'aval", + "Y" : "Tirant d'eau", + "ZW" : "Ligne d'eau (m)", "UNIT_FLU": "m", "UNIT_HS": "m", 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 35c943ea6..5bbc25c8f 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 @@ -444,7 +444,7 @@ export class PabProfileChartComponent extends ResultsComponentDirective implemen label: ( this._results.variatedParameters.length > 0 ? this.getLegendForSeries(n) : - this.intlService.localizeText("INFO_LIB_Y") // ligne d'eau + this.intlService.localizeText("INFO_LIB_ZW") // ligne d'eau ), color: palette[ n % palette.length ] }); diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index 20f412f13..647418012 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -179,6 +179,9 @@ export class RemousResults extends CalculatorResults { if (!this._hasExtra && re.getValue(this.extraParamSymbol)) { this._hasExtra = true; } + + if (this._hasFlu && this._hasTor && this._hasExtra ) + break; // micro optimisation : pas la peine de continuer à chercher } this._log.clear(); @@ -188,7 +191,8 @@ export class RemousResults extends CalculatorResults { this._varResults.variatedParameters = [ { param: this._xValues, values: this._xValues.paramValues } ]; this._varResults.result = this._result; const keys = []; - keys.push("Y"); // ligne d'eau + keys.push("ZW"); // ligne d'eau + keys.push("Y"); // tirant d'eau if (this._hasFlu) { keys.push("flu"); } -- GitLab From 70baf42f92a85d5316aa00f6aad4519a04dd093f Mon Sep 17 00:00:00 2001 From: toto <toto@tata> Date: Mon, 28 Nov 2022 14:17:57 +0100 Subject: [PATCH 12/12] fix: display water rather than water line depth in results select refs #496 --- .../select-section-details/select-section-details.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/select-section-details/select-section-details.component.ts b/src/app/components/select-section-details/select-section-details.component.ts index d42b1e86a..55c21b523 100644 --- a/src/app/components/select-section-details/select-section-details.component.ts +++ b/src/app/components/select-section-details/select-section-details.component.ts @@ -39,7 +39,7 @@ export class SelectSectionDetailsComponent { public pointLabel(p: any): string { const abs = this.intlService.localizeText("INFO_REMOUSRESULTS_ABSCISSE"); const tirant = this.intlService.localizeText("INFO_REMOUSRESULTS_TIRANT"); - return abs + " : " + formattedValue(p.x, 1) + " - " + tirant + " : " + fv(p.z); + return abs + " : " + formattedValue(p.x, 1) + " - " + tirant + " : " + fv(p.y); } /** -- GitLab