From ce170aaa4e4960c960e4d9896f2c4c50650cdab5 Mon Sep 17 00:00:00 2001 From: Mathias Chouet <mathias.chouet@irstea.fr> Date: Mon, 29 Jun 2020 11:15:41 +0200 Subject: [PATCH] Add default layout when creating new PreBarrage --- src/app/services/formulaire.service.ts | 35 +++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 281e2f6b8..ccd973610 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -14,7 +14,14 @@ import { Props, Cloisons, CloisonAval, - SPP + SPP, + PreBarrage, + PbBassin, + PbBassinParams, + LoiDebit, + PbCloison, + CreateStructure, + Structure } from "jalhyd"; import { ApplicationSetupService } from "./app-setup.service"; @@ -427,6 +434,32 @@ export class FormulaireService extends Observable { newDownWall.addChild(newDownwallDevice); f.pabNub.downWall = newDownWall; } + + // when creating a new PreBarrage, add one basin and two walls with one + // device each (when loading session, those items are already present) + if ( + f instanceof FormulairePrebarrage + && f.currentNub instanceof PreBarrage + && f.currentNub.children.length === 0 + ) { + // 1 basin + f.currentNub.addChild(new PbBassin(new PbBassinParams(13.80, 95))); + // 1st wall + f.currentNub.addChild(new PbCloison(undefined, f.currentNub.children[0] as PbBassin)); + const s1: Structure = CreateStructure(LoiDebit.WeirCunge80); + s1.prms.ZDV.singleValue = 95.30; + s1.getParameter("L").singleValue = 0.4; + s1.getParameter("CdGR").singleValue = 1.04; + f.currentNub.children[1].addChild(s1); + // 2nd wall + f.currentNub.addChild(new PbCloison(f.currentNub.children[0] as PbBassin, undefined)); + const s2: Structure = CreateStructure(LoiDebit.WeirCunge80); + s2.prms.ZDV.singleValue = 95.30; + s2.getParameter("L").singleValue = 0.4; + s2.getParameter("CdGR").singleValue = 1.04; + f.currentNub.children[2].addChild(s2); + } + this.notifyObservers({ "action": "createForm", "form": f -- GitLab