Commit 145968a5 authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Bief: add buttons to generate up/downstream SectionParametree

Showing with 93 additions and 21 deletions
+93 -21
...@@ -104,6 +104,15 @@ ...@@ -104,6 +104,15 @@
{{ uitextGeneratePAB }} {{ uitextGeneratePAB }}
</button> </button>
<div *ngIf="isBief" class="multi-buttons-container">
<button mat-raised-button color="accent" id="generate-sp-amont" (click)="generateSPAmont()">
{{ uitextGenerateSPAmont }}
</button>
<button mat-raised-button color="accent" id="generate-sp-aval" (click)="generateSPAval()">
{{ uitextGenerateSPAval }}
</button>
</div>
<mat-card-content> <mat-card-content>
<calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results> <calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results>
</mat-card-content> </mat-card-content>
......
...@@ -66,6 +66,15 @@ mat-card { ...@@ -66,6 +66,15 @@ mat-card {
height: min-content; height: min-content;
} }
} }
.multi-buttons-container {
button:nth-of-type(even) {
margin-top: .5em;
}
button:nth-of-type(odd) {
margin-right: .5em;
}
}
} }
::ng-deep .mat-card-header-text { ::ng-deep .mat-card-header-text {
......
...@@ -2,7 +2,7 @@ import { Component, OnInit, DoCheck, OnDestroy, ViewChild, ViewChildren, ...@@ -2,7 +2,7 @@ import { Component, OnInit, DoCheck, OnDestroy, ViewChild, ViewChildren,
QueryList, AfterViewChecked, ElementRef, Inject, forwardRef } from "@angular/core"; QueryList, AfterViewChecked, ElementRef, Inject, forwardRef } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { Observer, Session, Cloisons, Pab, ParamValueMode, CalculatorType } from "jalhyd"; import { Observer, Session, Cloisons, Pab, ParamValueMode, CalculatorType, Bief, SectionParametree, acSection, round, SessionSettings } from "jalhyd";
import { AppComponent } from "../../app.component"; import { AppComponent } from "../../app.component";
import { FormulaireService } from "../../services/formulaire.service"; import { FormulaireService } from "../../services/formulaire.service";
...@@ -195,6 +195,14 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -195,6 +195,14 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_PAB"); return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_PAB");
} }
public get uitextGenerateSPAmont() {
return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT");
}
public get uitextGenerateSPAval() {
return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL");
}
public get uitextOpenHelp() { public get uitextOpenHelp() {
return this.intlService.localizeText("INFO_CALCULATOR_OPEN_HELP"); return this.intlService.localizeText("INFO_CALCULATOR_OPEN_HELP");
} }
...@@ -497,6 +505,15 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -497,6 +505,15 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
return this._formulaire && this._formulaire.helpLink; return this._formulaire && this._formulaire.helpLink;
} }
/** return true if current Nub type is ct */
public is(ct: CalculatorType): boolean {
return (
this._formulaire
&& this._formulaire.currentNub
&& this._formulaire.currentNub.calcType === ct
);
}
// for "one wide column" layout // for "one wide column" layout
public get isWide() { public get isWide() {
return (this.isPAB || this.isMRC); return (this.isPAB || this.isMRC);
...@@ -504,38 +521,27 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -504,38 +521,27 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
// true if current Nub is PAB // true if current Nub is PAB
public get isPAB() { public get isPAB() {
return ( return this.is(CalculatorType.Pab);
this._formulaire
&& this._formulaire.currentNub
&& this._formulaire.currentNub.calcType === CalculatorType.Pab
);
} }
// true if current Nub is MacroRugoCompound // true if current Nub is MacroRugoCompound
public get isMRC() { public get isMRC() {
return ( return this.is(CalculatorType.MacroRugoCompound);
this._formulaire
&& this._formulaire.currentNub
&& this._formulaire.currentNub.calcType === CalculatorType.MacroRugoCompound
);
} }
// true if current Nub is Jet // true if current Nub is Jet
public get isJet() { public get isJet() {
return ( return this.is(CalculatorType.Jet);
this._formulaire
&& this._formulaire.currentNub
&& this._formulaire.currentNub.calcType === CalculatorType.Jet
);
} }
// for "generate PAB" button // for "generate PAB" button
public get isPABCloisons() { public get isPABCloisons() {
return ( return this.is(CalculatorType.Cloisons);
this._formulaire }
&& this._formulaire.currentNub
&& this._formulaire.currentNub.calcType === CalculatorType.Cloisons // true if current Nub is Bief
); public get isBief() {
return this.is(CalculatorType.Bief);
} }
/** /**
...@@ -611,6 +617,50 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe ...@@ -611,6 +617,50 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
}); });
} }
/**
* Génère une SectionParametree à partir des cotes amont du module Bief en cours
*/
public generateSPAmont() {
const bief = (this._formulaire.currentNub as Bief);
this.generateSP(round(bief.prms.Z1.singleValue - bief.prms.ZF1.singleValue, 3));
}
/**
* Génère une SectionParametree à partir des cotes aval du module Bief en cours
*/
public generateSPAval() {
const bief = (this._formulaire.currentNub as Bief);
this.generateSP(round(bief.prms.Z2.singleValue - bief.prms.ZF2.singleValue, 3));
}
/**
* Génère une SectionParametree à partir du module Bief en cours
* @param Y tirant d'eau
*/
private generateSP(Y: number) {
const bief = (this._formulaire.currentNub as Bief);
const pente = round(
(bief.prms.ZF1.singleValue - bief.prms.ZF2.singleValue) / bief.prms.Long.singleValue,
5 // ça ou autre chose…
);
const serialisedSection = bief.section.serialise();
const sectionCopy = Session.getInstance().unserialiseSingleNub(serialisedSection, false).nub;
const secParam = new SectionParametree(sectionCopy as acSection);
Session.getInstance().registerNub(secParam);
this.formulaireService.createFormulaire(CalculatorType.SectionParametree, secParam)
.then((f: FormulaireDefinition) => {
const sp = (f.currentNub as SectionParametree);
sp.section.prms.Y.singleValue = Y;
sp.section.prms.If.singleValue = pente;
// calculate
f.doCompute();
// go to new SP
this.router.navigate(["/calculator", f.uid]).then();
}
);
}
public saveCalculator() { public saveCalculator() {
this.formulaireService.saveForm(this._formulaire); this.formulaireService.saveForm(this._formulaire);
} }
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
"INFO_CALCULATOR_OPEN_HELP": "Help", "INFO_CALCULATOR_OPEN_HELP": "Help",
"INFO_CALCULATOR_PARAMFIXES": "Fixed parameters", "INFO_CALCULATOR_PARAMFIXES": "Fixed parameters",
"INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Generate a fish ladder", "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Generate a fish ladder",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT": "Hydraulic details of upstream section",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Hydraulic details of downstream section",
"INFO_CALCULATOR_RESULTS_TITLE": "Results", "INFO_CALCULATOR_RESULTS_TITLE": "Results",
"INFO_CALCULATOR_SAVE": "Save", "INFO_CALCULATOR_SAVE": "Save",
"INFO_CALCULATOR_USED_BY": "Used by", "INFO_CALCULATOR_USED_BY": "Used by",
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
"INFO_CALCULATOR_OPEN_HELP": "Aide", "INFO_CALCULATOR_OPEN_HELP": "Aide",
"INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés", "INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés",
"INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassins", "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassins",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT": "Détails hydrauliques de la section amont",
"INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Détails hydrauliques de la section aval",
"INFO_CALCULATOR_RESULTS_TITLE": "Résultats", "INFO_CALCULATOR_RESULTS_TITLE": "Résultats",
"INFO_CALCULATOR_SAVE": "Enregistrer", "INFO_CALCULATOR_SAVE": "Enregistrer",
"INFO_CALCULATOR_USED_BY": "Utilisé par", "INFO_CALCULATOR_USED_BY": "Utilisé par",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment