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
3f52eaab
Commit
3f52eaab
authored
Nov 19, 2019
by
Mathias Chouet
🍝
Browse files
getDependingNubs() : add option to consider Solveur dependencies
parent
dcb8791d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/nub.ts
View file @
3f52eaab
import
{
CalculatorType
,
ComputeNode
}
from
"
./compute-node
"
;
import
{
Dichotomie
}
from
"
./dichotomie
"
;
import
{
acSection
,
MacrorugoCompound
,
Pab
,
ParamDefinition
,
ParamsEquation
,
Session
,
Structure
}
from
"
./index
"
;
Session
,
Solveur
,
Structure
}
from
"
./index
"
;
import
{
LinkedValue
}
from
"
./linked-value
"
;
import
{
ParamCalculability
,
ParamFamily
}
from
"
./param/param-definition
"
;
import
{
ParamValueMode
}
from
"
./param/param-value-mode
"
;
...
...
@@ -875,12 +875,15 @@ export abstract class Nub extends ComputeNode implements IObservable {
* if current Nub targets this symbol, it will be considered dependent
* @param includeValuesLinks if true, even if this Nub targets only non-calculated non-modified
* parameters, it will be considered dependent @see jalhyd#98
* @param includeSolveurDependencies if true and this Nub is a Solveur, also return
* true if ${uid} is either the X or the Ytarget's parent Nub of this Solveur
*/
public
resultDependsOnNub
(
uid
:
string
,
visited
:
string
[]
=
[],
symbol
?:
string
,
includeValuesLinks
:
boolean
=
false
includeValuesLinks
:
boolean
=
false
,
includeSolveurDependencies
:
boolean
=
false
):
boolean
{
if
(
uid
!==
this
.
uid
&&
!
visited
.
includes
(
this
.
uid
))
{
visited
.
push
(
this
.
uid
);
...
...
@@ -896,16 +899,23 @@ export abstract class Nub extends ComputeNode implements IObservable {
// does any of our parent's parameters depend on the target Nub ?
const
parent
=
this
.
getParent
();
if
(
parent
)
{
if
(
parent
.
resultDependsOnNub
(
uid
,
visited
,
symbol
,
includeValuesLinks
))
{
if
(
parent
.
resultDependsOnNub
(
uid
,
visited
,
symbol
,
includeValuesLinks
,
includeSolveurDependencies
))
{
return
true
;
}
}
// does any of our children' parameters depend on the target Nub ?
for
(
const
c
of
this
.
getChildren
())
{
if
(
c
.
resultDependsOnNub
(
uid
,
visited
,
symbol
,
includeValuesLinks
))
{
if
(
c
.
resultDependsOnNub
(
uid
,
visited
,
symbol
,
includeValuesLinks
,
includeSolveurDependencies
))
{
return
true
;
}
}
// is this a Solveur
if
(
includeSolveurDependencies
&&
(
this
instanceof
Solveur
))
{
return
(
(
this
.
searchedParameter
!==
undefined
&&
this
.
searchedParameter
.
nubUid
===
uid
)
||
(
this
.
nubToCalculate
!==
undefined
&&
this
.
nubToCalculate
.
uid
===
uid
)
);
}
}
return
false
;
}
...
...
src/session.ts
View file @
3f52eaab
...
...
@@ -634,11 +634,21 @@ export class Session {
* Nubs targetting this symbol will be considered dependent
* @param includeValuesLinks if true, even Nubs targetting non-calculated non-modified parameters
* will be considered dependent @see jalhyd#98
* @param includeSolveurDependencies if true, Solveur Nubs having given Nub either as X or as Ytarget's
* parent Nub, will be considered dependent
*/
public
getDependingNubs
(
uid
:
string
,
symbol
?:
string
,
includeValuesLinks
:
boolean
=
false
):
Nub
[]
{
public
getDependingNubs
(
uid
:
string
,
symbol
?:
string
,
includeValuesLinks
:
boolean
=
false
,
includeSolveurDependencies
:
boolean
=
false
):
Nub
[]
{
const
dependingNubs
:
Nub
[]
=
[];
for
(
const
n
of
this
.
_nubs
)
{
if
(
n
.
uid
!==
uid
&&
n
.
resultDependsOnNub
(
uid
,
[],
symbol
,
includeValuesLinks
))
{
if
(
n
.
uid
!==
uid
&&
n
.
resultDependsOnNub
(
uid
,
[],
symbol
,
includeValuesLinks
,
includeSolveurDependencies
)
)
{
dependingNubs
.
push
(
n
);
}
}
...
...
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