diff --git a/src/app/components/section-results/section-results.component.html b/src/app/components/section-results/section-results.component.html index 77d384f656d8a962fa13fdd4c7abb491e64ba6f0..e9a103d4e780c34cea400353507f9b4762392762 100644 --- a/src/app/components/section-results/section-results.component.html +++ b/src/app/components/section-results/section-results.component.html @@ -9,13 +9,10 @@ <!-- tableau de valeurs --> <div class="row"> <div class="col mx-auto"> - <table style="width: 100%"> - <tr *ngFor="let r of sectionResults; let i=index" [class]="getResultClass(i)"> - <td class="result_label">{{r.label}}</td> - <td horizontal-result-element [result-element]=r.value class="result_value"> - </td> + <table style="width: 100%" cellpadding="15"> + <tr vertical-result-element [result-element]=resultElement> </tr> </table> </div> </div> -</div> \ No newline at end of file +</div> diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts index ea6daaae41a7af3c770e26ad684c1dceed25af32..0656b917ad31ae06cce6956c66e4734f40a2d57f 100644 --- a/src/app/components/section-results/section-results.component.ts +++ b/src/app/components/section-results/section-results.component.ts @@ -1,11 +1,12 @@ import { Component, ViewChild, DoCheck } from '@angular/core'; -import { acSection, Result } from 'jalhyd'; +import { acSection, Result, ResultElement } from 'jalhyd'; import { SectionCanvasComponent } from '../section-canvas/section-canvas.component'; import { SectionResults } from '../../results/section-results'; import { ApplicationSetupService } from '../../services/app-setup/app-setup.service'; import { CalculatorResults } from '../../results/calculator-results'; +import { InternationalisationService } from '../../services/internationalisation/internationalisation.service'; @Component({ selector: 'section-results', @@ -37,7 +38,12 @@ export class SectionResultsComponent implements DoCheck { */ private _results: SectionResults; - constructor(private appSetupService: ApplicationSetupService) { } + /** + * ResultElement mis en forme (symboles des variables traduits) + */ + private _resultElement: ResultElement; + + constructor(private appSetupService: ApplicationSetupService, private intlService: InternationalisationService) { } private static labelColors: { [key: string]: any; } = { "Hs": { r: 255, g: 0, b: 0 }, @@ -55,6 +61,8 @@ export class SectionResultsComponent implements DoCheck { private _sectionCanvas: SectionCanvasComponent; public set results(rs: CalculatorResults[]) { + this._resultElement = undefined; + this._results = undefined; if (rs != undefined) for (const r of rs) { @@ -82,18 +90,30 @@ export class SectionResultsComponent implements DoCheck { this._doUpdate = !this.updateResults(); } + private isSectionLevel(s: string) { + for (const k in SectionResultsComponent.labelColors) + if (k === s) + return true; + return false; + } + private updateResults() { - if (this._results != undefined && this._sectionCanvas != undefined) { + if (this._results && this._sectionCanvas) { const nDigits = this.appSetupService.displayDigits; - for (let r of this._results.results) { - const v: Result = r["value"]; - const l = r["label"]; + this._resultElement = new ResultElement(); - const drawLabel = r["drawLabel"]; - if (drawLabel != undefined && v.vCalc != undefined) - this._sectionCanvas.addLevel(v.vCalc, drawLabel + " = " + v.vCalc.toFixed(nDigits), SectionResultsComponent.labelColors[drawLabel]); + // traduction des symboles des variables calculées + for (const k in this._results.result.extraResults) { + const k2 = "INFO_GRANDEUR_" + k.toUpperCase(); + const lbl = this.intlService.localizeText(k2); + const er = this._results.result.getExtraResult(k); + this._resultElement.addExtraResult(lbl, er); + + if (this.isSectionLevel(k)) + this._sectionCanvas.addLevel(er, k + " = " + er.toFixed(nDigits), SectionResultsComponent.labelColors[k]); } + this._sectionCanvas.section = this._results.section; return true; } @@ -104,8 +124,8 @@ export class SectionResultsComponent implements DoCheck { return this._results != undefined && this._results.hasResults; } - private get sectionResults() { - return this._results.results; + private get resultElement() { + return this._resultElement; } private getResultClass(i: number) { diff --git a/src/app/formulaire/definition/form-compute-section-parametree.ts b/src/app/formulaire/definition/form-compute-section-parametree.ts index 3a05fe4340bc17fd381cc5030f8fa49ddb0c16f9..864d8b6e45b6dce05d4289827d983dd7d465147f 100644 --- a/src/app/formulaire/definition/form-compute-section-parametree.ts +++ b/src/app/formulaire/definition/form-compute-section-parametree.ts @@ -96,84 +96,15 @@ export class FormComputeSectionParametree extends FormCompute { return; } - var np: [ComputeNode, ParamsEquation] = this.getNubAndParameters(); - - let sect: acSection = np[0] as acSection; - let prms: ParamsEquation = np[1]; + const sectNub: SectionParametree = this.getCurrentNub() as SectionParametree; + const sect: acSection = sectNub.section; this._sectionResults.section = sect; - let computePrec: number = this._formBase.getParameterValue("Pr"); // précision de calcul - let nDigits = -Math.log10(computePrec); - - let Y = prms.map.Y.v; // tirant d'eau original (doit être fourni à acSection.Calc() sous peine d'être modifié par les appels successifs car c'est en même temps un paramètre et une variable temporaire) - - // charge spécifique - let Hs = sect.Calc("Hs", Y); - this._formSectionResult.addSectionFixedResult(Hs.resultElement, this.intlService.localizeText("INFO_GRANDEUR_HS"), "Hs"); - - // charge critique - let Hsc = sect.Calc("Hsc", Y); - this._formSectionResult.addSectionFixedResult(Hsc.resultElement, this.intlService.localizeText("INFO_GRANDEUR_HSC"), "Hsc"); - - // largeur au miroir - let B = sect.Calc("B", Y); - this._formSectionResult.addSectionFixedResult(B.resultElement, this.intlService.localizeText("INFO_GRANDEUR_B")); - - // périmètre hydraulique - let P = sect.Calc("P", Y); - this._formSectionResult.addSectionFixedResult(P.resultElement, this.intlService.localizeText("INFO_GRANDEUR_P")); - - // surface hydraulique - let S = sect.Calc("S", Y); - this._formSectionResult.addSectionFixedResult(S.resultElement, this.intlService.localizeText("INFO_GRANDEUR_S")); - - // rayon hydraulique - let R = sect.Calc("R", Y); - this._formSectionResult.addSectionFixedResult(R.resultElement, this.intlService.localizeText("INFO_GRANDEUR_R")); - - // vitesse moyenne - let V = sect.Calc("V", Y); - this._formSectionResult.addSectionFixedResult(V.resultElement, this.intlService.localizeText("INFO_GRANDEUR_V")); - - // nombre de Froude - let Fr = sect.Calc("Fr", Y); - this._formSectionResult.addSectionFixedResult(Fr.resultElement, this.intlService.localizeText("INFO_GRANDEUR_FR"), ); - - // tirant d'eau critique - let Yc = sect.Calc("Yc", Y); - this._formSectionResult.addSectionFixedResult(Yc.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YC"), "Yc"); - - // tirant d'eau normal - let Yn = sect.Calc("Yn", Y); - this._formSectionResult.addSectionFixedResult(Yn.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YN"), "Yn"); - - // tirant d'eau fluvial - let Yf = sect.Calc("Yf", Y); - this._formSectionResult.addSectionFixedResult(Yf.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YF"), "Yf"); - - // tirant d'eau torrentiel - let Yt = sect.Calc("Yt", Y); - this._formSectionResult.addSectionFixedResult(Yt.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YT"), "Yt"); - - // tirant d'eau conjugué - let Yco = sect.Calc("Yco", Y); - this._formSectionResult.addSectionFixedResult(Yco.resultElement, this.intlService.localizeText("INFO_GRANDEUR_YCO"), "Yco"); - - // perte de charge - let J = sect.Calc("J", Y); - this._formSectionResult.addSectionFixedResult(J.resultElement, this.intlService.localizeText("INFO_GRANDEUR_J")); - - // Variation linéaire de l'énergie spécifique - let IJ = sect.Calc("I-J", Y); - this._formSectionResult.addSectionFixedResult(IJ.resultElement, this.intlService.localizeText("INFO_GRANDEUR_I-J")); - - // impulsion hydraulique - let Imp = sect.Calc("Imp", Y); - this._formSectionResult.addSectionFixedResult(Imp.resultElement, this.intlService.localizeText("INFO_GRANDEUR_IMP")); - - // contrainte de cisaillement - let Tau0 = sect.Calc("Tau0", Y); - this._formSectionResult.addSectionFixedResult(Tau0.resultElement, this.intlService.localizeText("INFO_GRANDEUR_TAU0")); + const computePrec: number = this._formBase.getParameterValue("Pr"); // précision de calcul + this._sectionResults.result = sectNub.CalcSerie(computePrec, + undefined, // valeur initiale, non utilisée dans ce cas + undefined // variable à calculer, non utilisée + ); } } diff --git a/src/app/formulaire/definition/form-result-section.ts b/src/app/formulaire/definition/form-result-section.ts index 6742994376c7845fde18766858e9a1edae4528d8..14f07562c54d95a7a2e571383be5e2efbc04f02c 100644 --- a/src/app/formulaire/definition/form-result-section.ts +++ b/src/app/formulaire/definition/form-result-section.ts @@ -51,10 +51,6 @@ export class FormResultSection extends FormResult { this._sectionResults.reset(); } - public addSectionFixedResult(val: ResultElement, label: string, drawLabel: string = undefined) { - this._sectionResults.addResult(val, label, drawLabel); - } - public addSectionFixedParameters(displaySymbol: boolean) { for (let p of this._formBase.getDisplayedParamListFromState(ParamRadioConfig.FIX)) if (p.symbol !== "Pr") diff --git a/src/app/results/section-results.ts b/src/app/results/section-results.ts index 680b5b40cc6803df2d923c6e113b96c27542668a..8e3d3b88db248950581e9897ad0c6b4f4e9a33ba 100644 --- a/src/app/results/section-results.ts +++ b/src/app/results/section-results.ts @@ -4,7 +4,7 @@ import { CalculatorResults } from "./calculator-results"; import { NgParameter } from "../formulaire/ngparam"; export class SectionResults extends CalculatorResults { - private _results: Object[]; + private _result: Result; private _section: acSection; @@ -15,19 +15,15 @@ export class SectionResults extends CalculatorResults { public reset() { this._section = undefined; - this._results = []; + this._result = undefined; } - public addResult(v: ResultElement, l: string, drawLabel: string) { - this._results.push({ - "label": l, - "value": v, - "drawLabel": drawLabel - }); + public get result(): Result { + return this._result; } - public get results() { - return this._results; + public set result(r: Result) { + this._result = r; } public get section() { @@ -39,6 +35,6 @@ export class SectionResults extends CalculatorResults { } public get hasResults(): boolean { - return this._section != undefined && this._results.length > 0; + return this._section != undefined && this._result != undefined; } }