diff --git a/README.md b/README.md index b2537cfd8face0b7ba6bb84f90fa93a218dcb4d5..626235967a262a4f68e2109baecbb7a11311f2b4 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,8 @@ Custom Material SVG Icons will only show up when the application is deployed on 5. **Si une nouvelle classe a été créée à l'étape 2**, dans la méthode _FormulaireService.newFormulaire()_, compléter le _switch_ pour fournir la classe à instancier. +6. Dans `config.json`, ajouter si nécessaire le numéro de CalculatorType à un ou plusieurs thèmes afin de classer le module sur la page de liste; dans le cas contraire le nouveau module apparaîtra dans une section "Autres" + # Create PDF from documentation ```sh diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json new file mode 100644 index 0000000000000000000000000000000000000000..6a05f9cc338251e6f60fdd4eac090ff5c2d063c6 --- /dev/null +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json @@ -0,0 +1,44 @@ +[ + { + "id": "fs_hydraulique", + "type": "fieldset", + "fields": [ + "Z1", + "DH" + ] + }, + { + "id": "fs_pass", + "type": "fieldset", + "fields": [ + "If", + "Ks", + "C" + ] + }, + { + "id": "fs_bloc", + "type": "fieldset", + "fields": [ + "PBD", + "PBH", + "Cd0" + ] + }, + { + "id": "fs_pass_type", + "type": "fieldset", + "fields": [ + { + "id": "select_pass_type", + "type": "select", + "source": "mrc_pass_type" + } + ] + }, + { + "type": "options", + "idCal": "Q", + "help": "pam/macrorugo-compound" + } +] \ No newline at end of file diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json new file mode 100644 index 0000000000000000000000000000000000000000..dd0ba5be3fb865ac9b8f7014bbf03fdedaa3bb51 --- /dev/null +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json @@ -0,0 +1,17 @@ +{ + "fs_hydraulique": "Hydraulic parameters", + "fs_pass": "Fish pass parameters", + "fs_bloc": "Blocks parameters", + "fs_pass_type": "Pass type", + + "select_pass_type": "Pass type", + "If": "Slope", + "Ks": "Bottom roughness", + "C": "Block concentration", + "PBD": "Diameter", + "PBH": "Height", + "Cd0": "Shape (1 for round, 2 for square)", + + "select_pass_type_0": "Multiple aprons", + "select_pass_type_1": "Inclined apron" +} \ No newline at end of file diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json new file mode 100644 index 0000000000000000000000000000000000000000..dc9c6c7f33835002d0a9e5dfccb05bacceb620f0 --- /dev/null +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json @@ -0,0 +1,16 @@ +{ + "fs_hydraulique": "Paramètres hydrauliques", + "fs_pass": "Paramètres de la passe", + "fs_bloc": "Paramètres des blocs", + "fs_pass_type": "Type de passe", + "select_pass_type": "Type de passe", + "If": "Pente", + "Ks": "Rugosité de fond", + "C": "Concentration de blocs", + "PBD": "Diamètre", + "PBH": "Hauteur", + "Cd0": "Forme (1 pour rond, 2 pour carré)", + + "select_pass_type_0": "Radiers multiples", + "select_pass_type_1": "Radier incliné" +} \ No newline at end of file diff --git a/src/app/components/calculator-list/calculator-list.component.ts b/src/app/components/calculator-list/calculator-list.component.ts index d58d2758e6b4c99f450a63ce4b63589e60513537..a33f00de6ee2716581e5e3eaae2c27561194f73e 100644 --- a/src/app/components/calculator-list/calculator-list.component.ts +++ b/src/app/components/calculator-list/calculator-list.component.ts @@ -119,6 +119,15 @@ export class CalculatorListComponent implements OnInit { } } } + // @TODO on ajoute un ouvrage après l'ouverture du module de calcul "passe à macrorugosités complexe" + /* if (f instanceof FormulaireMacrorugoCompound) { + for (const e of f.allFormElements) { + if (e instanceof FieldsetContainer) { + e.addFromTemplate(0); + break; + } + } + } */ }); } diff --git a/src/app/config.json b/src/app/config.json index 5160a729c5b169892b9d6c0eacebdbbdaf6e813e..1d9710c5dc8238e6c8d8fef278364e75eeecbd59 100644 --- a/src/app/config.json +++ b/src/app/config.json @@ -24,7 +24,7 @@ "title": "Passe à poisson sur le petit Buech, seuil de Chiala ou des Savoillons", "credits": "Catherine Tailleux / Irstea" }, - "calculators": [ 11 ] + "calculators": [ 11, 17 ] }, { "name": "HYDRAULIQUE_A_SURFACE_LIBRE", diff --git a/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts b/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a9404d8f931a5244849576152dfef93b95d923b --- /dev/null +++ b/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts @@ -0,0 +1,27 @@ +// import { Pab } from "jalhyd"; + +import { FormulaireBase } from "./form-base"; +import { FormResultFixedVar } from "../form-result-fixedvar"; +import { FormComputeFixedVar } from "../form-compute-fixedvar"; + +/** + * Formulaire pour les passes à macrorugosités complexes + */ +export class FormulaireMacrorugoCompound extends FormulaireBase { + + constructor() { + super(); + this._formResult = new FormResultFixedVar(this); + + // default properties + this._props["inclinedApron"] = "1"; + + // remove obsolete observer set by super() + this.removeObserver(this._formCompute); + this._formCompute = new FormComputeFixedVar(this, (this._formResult as FormResultFixedVar)); + } + + /* public get pabNub(): Pab { + return this.currentNub as Pab; + } */ +} diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index fcfbb4e889530fccac16df11fbac2264a71bf89b..ac30f3e420ed4510e7e65bec8918d7667b202bf9 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -227,6 +227,9 @@ export class FieldSet extends FormulaireElement implements Observer { this.setSelectValueFromProperty("select_target", "varCalc"); break; + case "fs_pass_type": // macro-rugo complexe + this.setSelectValueFromProperty("select_pass_type", "inclinedApron"); + break; } } @@ -243,6 +246,7 @@ export class FieldSet extends FormulaireElement implements Observer { } const selectElement = selectField.getSelectedEntryFromValue(propVal); try { + console.log(`setting propval ${propVal} (propKey ${propertyKey}) on select ${selectId}`, selectElement, selectField); selectField.setValue(selectElement); } catch (e) { console.error(`setSelectValueFromProperty: cannot set value ${propVal} on <select> ${selectId}`); @@ -358,6 +362,9 @@ export class FieldSet extends FormulaireElement implements Observer { case "select_target": // courbes de remous, variable à calculer this.setPropValue("varCalc", data.value.value); break; + case "select_pass_type": // macro-rugo complexe + this.setPropValue("inclinedApron", data.value.value); + break; } break; } diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts index 7e87dd83baadfeced8ca68e00c3b8d79b6723022..a4ad51902b1b669d24775581995246bee8b412b3 100644 --- a/src/app/formulaire/select-field.ts +++ b/src/app/formulaire/select-field.ts @@ -157,6 +157,11 @@ export class SelectField extends Field { this.addEntry(e); } break; + + case "mrc_pass_type": // macrorugo complexe: type de radier + this.addEntry(new SelectEntry(this._entriesBaseId + "0", "0")); + this.addEntry(new SelectEntry(this._entriesBaseId + "1", "1")); + break; } } } diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index c88c9681a90d317e2c765f912688c241a0dedd4b..31708213d2568bbdc5652f90906768d98e6fb121 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -35,6 +35,7 @@ import { FieldsetContainer } from "../..//formulaire/fieldset-container"; import { ApplicationSetupService } from "../app-setup/app-setup.service"; import { NotificationsService } from "../notifications/notifications.service"; import { FormulairePab } from "../../formulaire/definition/concrete/form-pab"; +import { FormulaireMacrorugoCompound } from "../../formulaire/definition/concrete/form-macrorugo-compound"; @Injectable() export class FormulaireService extends Observable { @@ -75,6 +76,7 @@ export class FormulaireService extends Observable { this.calculatorPaths[CalculatorType.Cloisons] = "cloisons"; this.calculatorPaths[CalculatorType.MacroRugo] = "macrorugo"; this.calculatorPaths[CalculatorType.Pab] = "pab"; + this.calculatorPaths[CalculatorType.MacroRugoCompound] = "macrorugo-compound"; } private get _intlService(): I18nService { @@ -299,6 +301,10 @@ export class FormulaireService extends Observable { f = new FormulairePab(); break; + case CalculatorType.MacroRugoCompound: + f = new FormulaireMacrorugoCompound(); + break; + default: f = new FormulaireBase(); } @@ -394,6 +400,18 @@ export class FormulaireService extends Observable { f.pabNub.downWall = newDownWall; } + // @TODO add aprons for existing Aprons if needed + // (when loading session only) + /* if (f.currentNub instanceof MacrorugoCompound) { + for (const struct of f.currentNub.structures) { + for (const e of f.allFormElements) { + if (e instanceof FieldsetContainer) { // @TODO manage many containers one day ? + e.addFromTemplate(0, undefined, struct); + } + } + } + } */ + return f; }).then(fi => { diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 08c4f88647b1887523977625fd2337dab092ed5a..c3c892a834c1cd082bc2085efb66d81de481c61b 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -261,6 +261,8 @@ "INFO_LOIDEBIT_WeirVillemonte": "Notch (Villemonte 1957)", "INFO_MACRORUGO_TITRE_COURT": "Rock-ramp", "INFO_MACRORUGO_TITRE": "Rock-ramp fishpasses (beta)", + "INFO_MACRORUGOCOMPOUND_TITRE": "Compound rock-ramp fishpasses (beta)", + "INFO_MACRORUGOCOMPOUND_TITRE_COURT": "Compound RR", "INFO_MENU_EMPTY_SESSION_TITLE": "New session", "INFO_MENU_HELP_TITLE": "Help", "INFO_MENU_LOAD_SESSION_TITLE": "Load session", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index de9d932ff3245b7da61fe157b704906b91aeb4ca..a35a29bd2cacbb5b3230404509b84c8efd9c0d3d 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -260,6 +260,8 @@ "INFO_LOIDEBIT_WeirVillemonte": "Échancrure (Villemonte 1957)", "INFO_MACRORUGO_TITRE_COURT": "Macro-rugo.", "INFO_MACRORUGO_TITRE": "Passe à macro-rugosités (beta)", + "INFO_MACRORUGOCOMPOUND_TITRE": "Passe à macro-rugosités complexe (beta)", + "INFO_MACRORUGOCOMPOUND_TITRE_COURT": "M-Rugo complexe", "INFO_MENU_EMPTY_SESSION_TITLE": "Nouvelle session", "INFO_MENU_HELP_TITLE": "Aide", "INFO_MENU_LOAD_SESSION_TITLE": "Charger une session",