From f26d31e3973b776125048e164942c49b0d5b3c46 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 10 Apr 2019 15:35:21 +0200 Subject: [PATCH] Fix resetDefaultCalculatedParam for parallel structures --- src/nub.ts | 1 + src/param/param-definition.ts | 9 ++++----- src/structure/structure.ts | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/nub.ts b/src/nub.ts index af89bbc1..8e550220 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -124,6 +124,7 @@ export abstract class Nub extends ComputeNode implements IObservable { if ( p.calculability !== ParamCalculability.NONE && p.symbol !== "Pr" + && p.visible && p !== otherThan && p.valueMode === ParamValueMode.SINGLE ) { diff --git a/src/param/param-definition.ts b/src/param/param-definition.ts index 13a02356..7b1a9b8b 100644 --- a/src/param/param-definition.ts +++ b/src/param/param-definition.ts @@ -310,9 +310,8 @@ export class ParamDefinition implements INamedIterableValues, IObservable { * its parent Nub */ public get isCalculated(): boolean { - if (this.parentComputeNode && this.parentComputeNode instanceof Nub) { - // return (this.parentComputeNode.calculatedParam.symbol === this.symbol); - return (this.parentComputeNode.calculatedParam === this); // should be the same object + if (this.parentNub) { + return (this.parentNub.calculatedParam === this); // should be the same object } return false; } @@ -321,8 +320,8 @@ export class ParamDefinition implements INamedIterableValues, IObservable { * Sets this parameter as the one to be calculated */ public setCalculated() { - if (this.parentComputeNode && this.parentComputeNode instanceof Nub) { - this.parentComputeNode.calculatedParam = this; + if (this.parentNub) { + this.parentNub.calculatedParam = this; } } diff --git a/src/structure/structure.ts b/src/structure/structure.ts index af2ff99c..f811fbef 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -97,6 +97,17 @@ export abstract class Structure extends Nub { } } + /** + * Forwards to parent, that has vsibility over + * all the parameters, including the Structure ones + */ + public get calculatedParam(): ParamDefinition { + if (this.parent) { + return this.parent.calculatedParam; + } + return undefined; + } + /** * Forwards to parent, that has vsibility over * all the parameters, including the Structure ones @@ -107,6 +118,17 @@ export abstract class Structure extends Nub { } } + /** + * Forwards to parent, that has vsibility over + * all the parameters, including the Structure ones + */ + public findFirstSingleParameter(otherThan?: ParamDefinition) { + if (this.parent) { + return this.parent.findFirstSingleParameter(otherThan); + } + return undefined; + } + /** * Forwards to parent, that has visibility over * all the parameters, including the Structure ones -- GitLab