diff --git a/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.html b/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.html index b379b1f095fac55e8ffc585487f1ef368c24d2f6..36c03aa08c323652eabee9fc15e619cd74927ef8 100644 --- a/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.html +++ b/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.html @@ -51,11 +51,21 @@ <div class="grid-row"> <mat-slide-toggle color="primary" - [formControl]="formGroup.controls?.cumulative" + [formControl]="formGroup.controls.cumulative" > Cumulative </mat-slide-toggle> </div> + + <!-- Weighted MFDs --> + <div class="grid-row"> + <mat-slide-toggle + color="primary" + [formControl]="formGroup.controls.weightedMfds" + > + Weighted MFDs + </mat-slide-toggle> + </div> </div> </div> diff --git a/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.ts b/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.ts index 0464b357210ffa9604786f5b0081f6d5a99914f8..1b97ea5b191448df36734bb60c7eb4a3dd663956 100644 --- a/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.ts +++ b/projects/nshmp-apps/src/app/source/mfd/components/control-panel/control-panel.component.ts @@ -113,6 +113,12 @@ export class ControlPanelComponent implements OnInit, OnDestroy { this.service.createPlots() ) ); + + this.subs.push( + controls.weightedMfds.valueChanges.subscribe(() => + this.service.createPlots() + ) + ); } ngOnDestroy(): void { diff --git a/projects/nshmp-apps/src/app/source/mfd/components/data/data.component.ts b/projects/nshmp-apps/src/app/source/mfd/components/data/data.component.ts index c7d0eb06b276b8f7913ce8c8cd803508f670d0bb..62ac752e48d93ac889284a595a1e969281d58150 100644 --- a/projects/nshmp-apps/src/app/source/mfd/components/data/data.component.ts +++ b/projects/nshmp-apps/src/app/source/mfd/components/data/data.component.ts @@ -123,6 +123,16 @@ export class DataComponent { th: 'Rate', }); + tableData.push({ + td: [branch.weight], + th: 'Branch Weight', + }); + + tableData.push({ + td: [mfdInfo.weight], + th: 'MFD Weight', + }); + Object.entries(mfdInfo.mfd.props).forEach( ([key, value]: [string, string]) => { tableData.push({ diff --git a/projects/nshmp-apps/src/app/source/mfd/models/control-form.model.ts b/projects/nshmp-apps/src/app/source/mfd/models/control-form.model.ts index 1a20f315612fb19e73c392de04918cd67a72430a..d770bc6673b60f8eafe54449f5ae200a962ceb33 100644 --- a/projects/nshmp-apps/src/app/source/mfd/models/control-form.model.ts +++ b/projects/nshmp-apps/src/app/source/mfd/models/control-form.model.ts @@ -33,6 +33,8 @@ export interface ControlForm { sourceAsString: string; /** Source tree id number */ sourceTree: number | null; + /** Whether to apply the weights to the MFDs */ + weightedMfds: boolean; } /** diff --git a/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts b/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts index a7dc09077edf806a202b4fa1f87775f83a23a861..5dea22443c336414a538ad514519d4daf84c1caf 100644 --- a/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts +++ b/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts @@ -75,6 +75,8 @@ export interface MfdQuery { sourceTree: string; /** Source type */ sourceType: SourceType; + /** Whether to apply weight */ + weightedMfds: string; } /** @@ -256,6 +258,7 @@ export class AppService source, sourceAsString: JSON.stringify(source), sourceTree: null, + weightedMfds: false, }; } @@ -594,12 +597,13 @@ export class AppService : null; const formValues: ControlForm = { - cumulative: queryParams.cumulative === 'true', + cumulative: queryParams?.cumulative === 'true', mfdType: defaultValues.mfdType, model, source, sourceAsString: JSON.stringify(source), sourceTree, + weightedMfds: queryParams?.weightedMfds === 'true', }; this.formGroup.patchValue(formValues); @@ -821,7 +825,9 @@ export class AppService let plotData: Partial<PlotData> = { name: name.length > 50 ? `${name.substring(0, 50)} ...` : name, x: xySequence.xs, - y: xySequence.ys.map(y => y * branch.weight * mfdInfo.weight), + y: form.weightedMfds + ? xySequence.ys.map(y => y * branch.weight * mfdInfo.weight) + : xySequence.ys, }; if (mfdInfo.mfd.props.type === MfdType.SINGLE) { @@ -894,6 +900,7 @@ export class AppService setting: source.tectonicSettings ?? null, sourceTree: values.sourceTree?.toString() ?? null, sourceType: source.sourceType ?? null, + weightedMfds: values.weightedMfds.toString(), }; this.router diff --git a/projects/nshmp-apps/src/app/source/model-maps/components/info-popup/info-popup.component.ts b/projects/nshmp-apps/src/app/source/model-maps/components/info-popup/info-popup.component.ts index ab2659c630619c780204388c6739a54b6617549f..a583b4def58bb4b64fb0ef279f2fbc057399c0f6 100644 --- a/projects/nshmp-apps/src/app/source/model-maps/components/info-popup/info-popup.component.ts +++ b/projects/nshmp-apps/src/app/source/model-maps/components/info-popup/info-popup.component.ts @@ -131,6 +131,7 @@ export class InfoPopupComponent { setting, sourceTree: treeInfo?.id.toString(), sourceType, + weightedMfds: false.toString(), }; return query;