diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 9e3879d8ada618982c1343abe86977b6d6e587ef..3cb284a73316c3b3af529e91ea66439e084f72cb 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"; @@ -418,6 +425,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