Skip to content
Snippets Groups Projects
Commit 8231e75a authored by Mathias Chouet's avatar Mathias Chouet
Browse files

ParamDefinition: add method to copies values from another parameter

parent 8e9f1063
No related branches found
Tags nghyd_4.10.4
No related merge requests found
......@@ -493,6 +493,34 @@ export class ParamDefinition implements INamedIterableValues, IObservable {
return this.paramValues.valuesIterator.count();
}
/**
* Copies values of p into the current parameter, whatever the valueMode is; if
* p has linked values, the target values will be copied and the links won't be kept
* @param p a reference ParamDefinition or ParamValues to copy values from
*/
public copyValuesFrom(p: ParamDefinition | ParamValues) {
this.valueMode = p.valueMode;
switch (p.valueMode) {
case ParamValueMode.MINMAX:
this.min = p.min;
this.max = p.max;
this.step = p.step;
break;
case ParamValueMode.LISTE:
this.valueList = p.valueList;
break;
case ParamValueMode.LINK:
if (p instanceof ParamDefinition) {
this.copyValuesFrom(p.referencedValue.getParamValues());
}
break;
case ParamValueMode.CALCUL:
case ParamValueMode.SINGLE:
default:
this.singleValue = p.singleValue;
}
}
// for INumberiterator interface
public get currentValue(): number {
// magically follows links
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment