Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
cassiopee
jalhyd
Commits
27347745
Commit
27347745
authored
Oct 31, 2019
by
Mathias Chouet
🍝
Browse files
Nub.replaceChild() : copy values only for parameters present in both current child and new child
parent
16434765
Changes
2
Hide whitespace changes
Inline
Side-by-side
spec/structure/parallel_structure.spec.ts
View file @
27347745
...
...
@@ -5,6 +5,8 @@ import { SessionSettings } from "../../src/session_settings";
import
{
CreateStructure
}
from
"
../../src/structure/factory_structure
"
;
import
{
ParallelStructure
}
from
"
../../src/structure/parallel_structure
"
;
import
{
ParallelStructureParams
}
from
"
../../src/structure/parallel_structure_params
"
;
import
{
RectangularStructure
}
from
"
../../src/structure/rectangular_structure
"
;
import
{
RectangularStructureParams
}
from
"
../../src/structure/rectangular_structure_params
"
;
import
{
StructureKivi
}
from
"
../../src/structure/structure_kivi
"
;
import
{
StructureKiviParams
}
from
"
../../src/structure/structure_kivi_params
"
;
import
{
LoiDebit
}
from
"
../../src/structure/structure_props
"
;
...
...
@@ -218,3 +220,31 @@ describe("Class ParallelStructure: ", () => {
});
});
});
describe
(
"
switching between LoiDebit should load a new default Cd
"
,
()
=>
{
it
(
"
test 1
"
,
()
=>
{
const
ps
=
new
ParallelStructure
(
new
ParallelStructureParams
(
1
,
102
,
100
));
const
s
=
CreateStructure
(
LoiDebit
.
WeirSubmergedLarinier
,
ps
);
expect
((
s
.
prms
as
RectangularStructureParams
).
CdWSL
.
singleValue
).
toBe
(
0.65
);
ps
.
addChild
(
s
);
expect
((
ps
.
getChildren
()[
0
]
as
RectangularStructure
).
prms
.
CdWSL
.
singleValue
).
toBe
(
0.65
);
const
s2
=
CreateStructure
(
LoiDebit
.
WeirSubmerged
,
ps
);
expect
((
s2
.
prms
as
RectangularStructureParams
).
CdWS
.
singleValue
).
toBe
(
0.9
);
ps
.
replaceChildInplace
(
s
,
s2
);
expect
((
ps
.
getChildren
()[
0
]
as
RectangularStructure
).
prms
.
CdWS
.
singleValue
).
toBe
(
0.9
);
});
it
(
"
test 2
"
,
()
=>
{
const
ps
=
new
ParallelStructure
(
new
ParallelStructureParams
(
1
,
102
,
100
));
const
s
=
CreateStructure
(
LoiDebit
.
WeirSubmerged
,
ps
);
expect
((
s
.
prms
as
RectangularStructureParams
).
CdWS
.
singleValue
).
toBe
(
0.9
);
ps
.
addChild
(
s
);
expect
((
ps
.
getChildren
()[
0
]
as
RectangularStructure
).
prms
.
CdWS
.
singleValue
).
toBe
(
0.9
);
const
s2
=
CreateStructure
(
LoiDebit
.
WeirSubmergedLarinier
,
ps
);
expect
((
s2
.
prms
as
RectangularStructureParams
).
CdWSL
.
singleValue
).
toBe
(
0.65
);
ps
.
replaceChildInplace
(
s
,
s2
);
expect
((
ps
.
getChildren
()[
0
]
as
RectangularStructure
).
prms
.
CdWSL
.
singleValue
).
toBe
(
0.65
);
});
});
src/nub.ts
View file @
27347745
...
...
@@ -1138,7 +1138,11 @@ export abstract class Nub extends ComputeNode implements IObservable {
// store old parameters state
if
(
keepParametersState
&&
hasOldChild
)
{
for
(
const
p
of
this
.
_children
[
index
].
parameterIterator
)
{
parametersState
[
p
.
symbol
]
=
p
.
objectRepresentation
([]);
// if p is also present and visible in new Nub
const
cp
=
child
.
getParameter
(
p
.
symbol
);
if
(
cp
!==
undefined
&&
cp
.
visible
&&
p
.
visible
)
{
parametersState
[
p
.
symbol
]
=
p
.
objectRepresentation
([]);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment