diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c5fd9324b2cd86c647d5ef126004b31df370845b..702dabc0ef9947f28672536888fe7ea722e6a48a 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 a61455db06fc8271a318e1955d57b18ba30bcfee..80581c365b0221ab8a4d00ed23d2b328b4d9b2b3 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 fc57d1653a54b9b69f994bf6ead3090235525c77..500b329def898af2ca7841d06e86ab5208857994 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 0000000000000000000000000000000000000000..d8917f9e5f0aff614978dd0cbcfd1f3757c44530 --- /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 0000000000000000000000000000000000000000..c62ffafb0b9baab4bdc6fc24730e83df0ec3b666 --- /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 0000000000000000000000000000000000000000..c27db12242809ec320684424e6594ceceefe042b --- /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 abb20aa69362c07f6dd26dd436b341d33190b0dc..aebc15e0b09e6524ca178fdd6140524c872ef440 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 90095e6df9d235bfb3585c3d206f93828fbb8d43..22a2956fd495d4ccf22466571f72c32fd42f2932 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);